Author Topic: Can Spaces be used in "GETSTRING"?  (Read 5827 times)

0 Members and 1 Guest are viewing this topic.

A_LOTA_NOTA

  • Guest
Can Spaces be used in "GETSTRING"?
« on: August 03, 2007, 01:29:12 PM »
Can flags be set to let the user enter spaces when promted by "GETSTRING"? Is so how?

(setq DwgName (getstring "\nEnter Drawing Name: "))

I want the user to be able to enter this "9513C A"

Thanks

Guest

  • Guest
Re: Can Spaces be used in "GETSTRING"?
« Reply #1 on: August 03, 2007, 01:31:56 PM »
Yup!

(setq s (getstring T "What's your full name? "))

A_LOTA_NOTA

  • Guest
Having a problem with leading spaces.
« Reply #2 on: August 03, 2007, 01:34:44 PM »
I have tried that but it doesn't work if the user adds a leading space by mistake. Not on my machine anyway.....
« Last Edit: August 03, 2007, 02:35:25 PM by A_LOTA_NOTA »

CADaver

  • Guest
Re: Can Spaces be used in "GETSTRING"?
« Reply #3 on: August 03, 2007, 02:41:57 PM »
Works fine on mine.  did you add the "T"??

A_LOTA_NOTA

  • Guest
Re: Can Spaces be used in "GETSTRING"?
« Reply #4 on: August 03, 2007, 02:46:58 PM »
Yes... I even tried the example he posted.

(setq s (getstring T "What's your full name? "))

Gets hosed if I add a leading space.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Can Spaces be used in "GETSTRING"?
« Reply #5 on: August 03, 2007, 02:52:38 PM »
Gets hosed if I add a leading space.

(vl-string-trim " \t\n\r"
    (getstring t "Enter stuff: ")
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Guest

  • Guest
Re: Can Spaces be used in "GETSTRING"?
« Reply #6 on: August 03, 2007, 02:53:36 PM »
Yes... I even tried the example he posted.

(setq s (getstring T "What's your full name? "))

Gets hosed if I add a leading space.

No it doesn't...

Code: [Select]
(defun C:GetGString ( / )
   (setq s (getstring T "What's your full name? "))
   (alert s)
   (princ)
)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Can Spaces be used in "GETSTRING"?
« Reply #7 on: August 03, 2007, 03:14:24 PM »
Try this at the command line:

Code: [Select]
!T

If it returns nil, then you have redefined T somewhere in some code .. I had a novice programmer do that some years ago and it took me a while to figure it out.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

A_LOTA_NOTA

  • Guest
Re: Can Spaces be used in "GETSTRING"?
« Reply #8 on: August 03, 2007, 03:19:04 PM »


No it doesn't...

Code: [Select]
(defun C:GetGString ( / )
   (setq s (getstring T "What's your full name? "))
   (alert s)
   (princ)
)
[/quote]

If I put a leading space then a letter ("  A9513C A") it works fine. But if I do a space then a number ("  9513C A") it doesn't work.

Guest

  • Guest
Re: Can Spaces be used in "GETSTRING"?
« Reply #9 on: August 03, 2007, 03:21:42 PM »
First it was a leading space.
Now it's a leading space AND then an integer.


Either way, it still works.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Can Spaces be used in "GETSTRING"?
« Reply #10 on: August 03, 2007, 03:24:29 PM »
I don't know why it doesn't work for you, but it works for me.  Here is a copy from the command line.
Quote
Command: (getstring T "\n Testing: ")

 Testing:  567
" 567"

Command: (getstring T "\n Testing: ")

 Testing:  happy
" happy"

You can see that both have a leading space.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

A_LOTA_NOTA

  • Guest
Re: Can Spaces be used in "GETSTRING"?
« Reply #11 on: August 03, 2007, 03:28:42 PM »
First it was a leading space.
Now it's a leading space AND then an integer.


Either way, it still works.

Well I didn't know about the integer until doing some tests. Guess it is just my machine! Thanks for the help.

A_LOTA_NOTA

  • Guest
Re: Can Spaces be used in "GETSTRING"?
« Reply #12 on: August 03, 2007, 03:33:57 PM »
I don't know why it doesn't work for you, but it works for me.  Here is a copy from the command line.
Quote
Command: (getstring T "\n Testing: ")

 Testing:  567
" 567"

Command: (getstring T "\n Testing: ")

 Testing:  happy
" happy"

You can see that both have a leading space.

If I type this at the command prompt as you have done I get the same result as you. But if I run example posted by Matt. This is what I get.

Command: !S
" "

CADaver

  • Guest
Re: Can Spaces be used in "GETSTRING"?
« Reply #13 on: August 03, 2007, 03:40:59 PM »
I don't know why it doesn't work for you, but it works for me.  Here is a copy from the command line.
Quote
Command: (getstring T "\n Testing: ")

 Testing:  567
" 567"

Command: (getstring T "\n Testing: ")

 Testing:  happy
" happy"

You can see that both have a leading space.

If I type this at the command prompt as you have done I get the same result as you. But if I run example posted by Matt. This is what I get.

Command: !S
" "


Texteval??  Nah, works for me either way.
« Last Edit: August 03, 2007, 03:43:28 PM by CADaver »

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Can Spaces be used in "GETSTRING"?
« Reply #14 on: August 03, 2007, 03:42:44 PM »
What happens if you press !T at the command line?

I suspect you are not doing something correctly as AutoCAD always interprets the space as a string if you are using the T in the getstring command.

It works perfectly for me here ... perhaps you are making your variable S local to some code ... it is really hard to guess what could be wrong without a little help from you, other than "it don't work". ... maybe a copyclip from the command line, the code you are trying to put it in, a screen shot, something ... anything ... will be better than nothing.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie