Multiple Initget / getkword Within a function

Multiple Initget / getkword Within a function

alex.dickmann
Explorer Explorer
517 Views
6 Replies
Message 1 of 7

Multiple Initget / getkword Within a function

alex.dickmann
Explorer
Explorer

Hi,

 

I am very new to lisp and am a bit confused. I am trying to use two separate instances of initget and getkwords.

Basically I want to ask the user two separate questions, each of which have 2 different answers. Can anyone shed some light on what I might be doing wrong here?

 

Generic Example:

 

(initget 1 "A B")

(setq ans (getkword "\nChoose [A/B]: "))

 

(initget 1 "C D")

(setq ans1 (getkword "\nChoose [C/D]: "))

 

END OF EXAMPLE

 

I would eventually use thier choices to these two questions later on in my actual function.

 

When I do this though, it doesnt seem to recognize C & D and keywords.

 

Not sure how to work around this. I learn best from simple examples.

 

Thank you in advance!

0 Likes
Accepted solutions (1)
518 Views
6 Replies
Replies (6)
Message 2 of 7

paullimapa
Mentor
Mentor
Message 3 of 7

Sea-Haven
Mentor
Mentor

Try this look inside code for more examples. A replacement for initget.

(if (not AH:Butts)(load "Multi radio buttons.lsp")) ; loads the program if not loaded already
(setq ans1 (ah:butts 1 "V"   '("Please choose A B " "A" "B"))) 	; ans holds the button picked value as a string
(setq ans2 (ah:butts 1 "V"   '("Please choose C D " "C" "D" ))) 	; ans holds the button picked value as a string

SeaHaven_0-1701916180871.png

 

 

 

0 Likes
Message 4 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

There is nothing wrong with your generic example. It works flawlessly.

 

 

(defun c:test ()
  
  (initget 1 "A B")
  (setq ans (getkword "\nChoose [A/B]: "))
  
  (initget 1 "C D")
  (setq ans1 (getkword "\nChoose [C/D]: "))
  
  (princ "\nFirst choice: ")
  (princ ans)
  (princ "\nSecond choice: ")
  (princ ans1)
  
  (princ)
  )
Message 5 of 7

john.uhden
Mentor
Mentor

@ВeekeeCZ ,

Works for me too.

His/her problem is probably subsequent to those inputs.

John F. Uhden

Message 6 of 7

alex.dickmann
Explorer
Explorer

Thanks for the help all.  It must be something I goofed up somewhere else like John mentioned.

 

Thanks again @ВeekeeCZ 

0 Likes
Message 7 of 7

paullimapa
Mentor
Mentor

no you didn't goof up...read my previous reply again where I provided the thread explaining the reason for what you've encountered. 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos