Author Topic: Help with this part of code  (Read 2221 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Help with this part of code
« 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 )))

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help with this part of code
« Reply #1 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
« Last Edit: July 21, 2014, 10:20:30 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Help with this part of code
« Reply #2 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"
""

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help with this part of code
« Reply #3 on: July 21, 2014, 09:24:16 AM »
Sorry i update code again, try that.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help with this part of code
« Reply #4 on: July 21, 2014, 09:30:07 AM »
Also I question the placement of strcase? what is your intent?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Help with this part of code
« Reply #5 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))

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help with this part of code
« Reply #6 on: July 21, 2014, 10:21:03 AM »
OK in that case I updated the code again.
Is it working for you?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Help with this part of code
« Reply #7 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...

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Help with this part of code
« Reply #8 on: July 22, 2014, 05:45:14 AM »
Thanks CAB
Thnaks LEE
both working perfect

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Help with this part of code
« Reply #9 on: July 22, 2014, 01:22:06 PM »
You're welcome Hasan  :-)