TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: HasanCAD on July 21, 2014, 09:03:26 AM

Title: Help with this part of code
Post by: HasanCAD on July 21, 2014, 09:03:26 AM
I am createing, this part gives correct answer at first time but second time gives blank
Code: [Select]
(setq *str (cond ( (getstring (strcase (strcat "\nWhat is Stirrup Dia And repeatation? <" (setq *str (cond ( *str ) ( "T10@200" ))) ">: ")))) ( *str )))
Title: Re: Help with this part of code
Post by: CAB on July 21, 2014, 09:12:06 AM
I would do it this way.
Code: [Select]
(setq *str (cond (*str) ("T10@200")))
(setq *str (if (= "" (setq tmp (strcase (getstring (strcat "\nWhat is Stirrup Dia And repeatation? <" *str  ">: ")))))
             *str tmp)
            )

Edit:
Found the problem.
getstring returns "" on ENTER and not nil
Title: Re: Help with this part of code
Post by: HasanCAD on July 21, 2014, 09:19:36 AM
The same
Code: [Select]
(setq *str nil)
(setq *str (cond (*str) ("T10@200")))
(setq *str (cond ((getstring (strcat "\nWhat is Stirrup Dia And repeatation? <" *str  ">: ")))))
when press Enter (without typing any data) the result is
Code: [Select]
nil
"T10@200"
""
Title: Re: Help with this part of code
Post by: CAB on July 21, 2014, 09:24:16 AM
Sorry i update code again, try that.
Title: Re: Help with this part of code
Post by: CAB on July 21, 2014, 09:30:07 AM
Also I question the placement of strcase? what is your intent?
Title: Re: Help with this part of code
Post by: HasanCAD on July 21, 2014, 09:55:56 AM
Also I question the placement of strcase? what is your intent?
in case of the user types small letter and all letters should be ib capital
oopps I belive that it should be like this
Code: [Select]
(setq *str (if (= "" (setq tmp (strcase (getstring (strcat "\nWhat is Stirrup Dia And repeatation? <" *str  ">: "))))) *str tmp))
Title: Re: Help with this part of code
Post by: CAB on July 21, 2014, 10:21:03 AM
OK in that case I updated the code again.
Is it working for you?
Title: Re: Help with this part of code
Post by: Lee Mac on July 21, 2014, 12:21:53 PM
Here is how I would approach it:
Code - Auto/Visual Lisp: [Select]
  1. (if (null *str)
  2.     (setq *str "T10@200")
  3. )
  4. (if (/= "" (setq tmp (strcase (getstring (strcat "\nWhat is Stirrup Dia And repeatation? <" *str ">: ")))))
  5.     (setq *str tmp)
  6. )

Not dissimilar to those already posted...
Title: Re: Help with this part of code
Post by: HasanCAD on July 22, 2014, 05:45:14 AM
Thanks CAB
Thnaks LEE
both working perfect
Title: Re: Help with this part of code
Post by: Lee Mac on July 22, 2014, 01:22:06 PM
You're welcome Hasan  :-)