Hi,
I am custom to making menu slevtions in Autolisp ussing the following method
(setq MYCHOICE (strcase(getstring (strcat "\nWelkom " (getvar "loginname") ". Kies een menu-optie: [<Item 1>/<Item 2>/<Item 3>/<Item 4>]: ")))) (if (or (equal MYCHOICE "ITEM 1"))(SUBCOMMAND1)) (if (or (equal MYCHOICE "ITEM 2"))(SUBCOMMAND2)) (if (or (equal MYCHOICE "ITEM 3"))(SUBCOMMAND3)) (if (or (equal MYCHOICE "ITEM 4"))(SUBCOMMAND4)).....
Nice but this only works if I type out the menu choice in full if I click I get "I", which is a right royal pain seeing as the options all start with "I
how do I overcome this?
Can you omit the word "Item" and the space in each, and just use the numbers? Put Item into the prompt wording, and let the options be <1/2/3/4>. That would also eliminate the need for the (strcase) function.
You can use (initget) and (getkword) instead of (getstring) to limit the User's input, so that it will ask again if they don't give a valid option. And you can use (cond) instead of a series of (if) functions, so that it will stop looking as soon as it finds the chosen option.
[By the way, those (or) functions are not doing anything for you. And in the case of a text string, you can use the shorter (=) instead of (equal).]
I may not have the re-wording right, since I don't know the language, but....
(initget "1 2 3 4")
(setq MYCHOICE (getkword (strcat "\nWelkom " (getvar "loginname") ". Kies een menu-optie Item: [<1/2/3/4>]: ")))
(cond
((= MYCHOICE "1") (SUBCOMMAND1))
((= MYCHOICE "2") (SUBCOMMAND2))
((= MYCHOICE "3") (SUBCOMMAND3))
....
); cond