Author Topic: Can Spaces be used in "GETSTRING"?  (Read 5774 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

A_LOTA_NOTA

  • Guest
Re: Can Spaces be used in "GETSTRING"?
« Reply #15 on: August 03, 2007, 03:43:47 PM »
Texteval??

set to "0"
« Last Edit: August 03, 2007, 03:45:03 PM by A_LOTA_NOTA »

A_LOTA_NOTA

  • Guest
Re: Can Spaces be used in "GETSTRING"?
« Reply #16 on: August 03, 2007, 03:51:13 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.

I it enter "!T" it returns "T".

I pasted the code that Matt posted in to Visual LISP. I ran the code and when I enter " 1234" when promted the "Alert Box" is blank. But if I enter " A1234" it works fine.
« Last Edit: August 03, 2007, 03:58:12 PM by A_LOTA_NOTA »

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Can Spaces be used in "GETSTRING"?
« Reply #17 on: August 03, 2007, 04:12:21 PM »
Ok .. now we are getting somewhere ... I think ...

on the command line, enter !getstring .. paste the results
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 #18 on: August 03, 2007, 04:13:32 PM »
Ok .. now we are getting somewhere ... I think ...

on the command line, enter !getstring .. paste the results

Command: !GETSTRING
#<SUBR @05fbf658 GETSTRING>

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Can Spaces be used in "GETSTRING"?
« Reply #19 on: August 03, 2007, 04:19:57 PM »
Ok, lets look at what we know:
getstring is the default AutoCAD, i.e. not overwritten by a custom routine
T is indeed True
getstring returns correctly when value is not a number
getstring interprets spaces correctly
code is NOT part of a larger project (or is it)
S is not a global variable to another program (or is it)

Everything tells me that this should be operating as it is supposed to, and my gut instinct tells me that there is something amis, if you can indeed type the code at the command line and it works fine, but cannot load it through the IDE and have it work properly.

All sources of error have been eliminated so far as I can tell, so we must look at the other aspects, i.e. such as YOUR copy of the code you are trying to get to work from the IDE.
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 #20 on: August 03, 2007, 04:24:29 PM »
This is the code I have in the IDE....

(defun C:test ( / )
   (setq s (getstring T "What's your full name? "))
   (alert s)
   (princ)
)

I can copy the "getstring" line & past it at the command line & it works good. If I run it as posted above it will freeze ACAD for a few seconds.

What is the purpose of the ( / ) when no variables are listed?
« Last Edit: August 03, 2007, 04:31:33 PM by A_LOTA_NOTA »

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Can Spaces be used in "GETSTRING"?
« Reply #21 on: August 03, 2007, 04:32:31 PM »
strange, it seems to work fine for me either way
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 #22 on: August 03, 2007, 04:54:05 PM »
strange, it seems to work fine for me either way

Thanks for the help. I would never intentionally put a leading space, but just wanted to make sure the program would handle if it is needed. That is the only reason I noticed the problem to begin with.
« Last Edit: August 03, 2007, 05:08:28 PM by A_LOTA_NOTA »

CADaver

  • Guest
Re: Can Spaces be used in "GETSTRING"?
« Reply #23 on: August 03, 2007, 05:52:08 PM »
strange, it seems to work fine for me either way
and me

hmspe

  • Bull Frog
  • Posts: 362
Re: Can Spaces be used in "GETSTRING"?
« Reply #24 on: August 04, 2007, 11:20:19 AM »
Maybe the next question should be, "What version of Autocad are you running?"  Then, "Do you have more than one computer with Autocad loaded?"  If so, "Does the code work on the other computers?"

FWIW, the code in the 12:24:29pm post works perfectly for me under R2004.

Martin
"Science is the belief in the ignorance of experts." - Richard Feynman

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Can Spaces be used in "GETSTRING"?
« Reply #25 on: August 04, 2007, 02:03:57 PM »
I tried the code on R2000 and R2007, both work perfectly
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 #26 on: August 06, 2007, 01:21:42 PM »
Maybe the next question should be, "What version of Autocad are you running?"  Then, "Do you have more than one computer with Autocad loaded?"  If so, "Does the code work on the other computers?"

FWIW, the code in the 12:24:29pm post works perfectly for me under R2004.

Martin

I tried it on another computer & it worked fine. But on this one it has problems.