I thought, "Hey, why not write code to replace the underscores with hyphens and then convert it back." Nope. That won't work because some of the visibility parameters have both underscores and hyphens.
(setq MyKeyWords (list "Abc" "Def" "X_y" "X_y-z"))
(setq ModList (RemoveUnderScore MyKeyWords)) ; returns ("Abc" "Def" "X-y" "X-y-z")
(initget (ADDSpaces ModList))
(setq Answer (getkword (strcat "\nType ["(ADDSpaces ModList)"]")))
(setq ParameterType (nth (vl-position Answer ModList) MyKeyWords))
By using mapcar and lambda the code will be a lot smaller.That's usually the major reason for using them. Smaller code means less possibility for errors thus makes it easier to get something working properly.
By using mapcar and lambda the code will be a lot smaller.That's usually the major reason for using them. Smaller code means less possibility for errors thus makes it easier to get something working properly.
Not to mention concision *usually* results in greater efficiency...Well it's definitely more efficient to write the code! Less to type :)
Command: (getkword+ "Testing" '("Yes" "No") nil)
Testing [YES/NO]:
nil
Command: (getkword+ "Testing" '("Yes" "No") nil)
Testing [YES/NO]: y
"Yes"
Command: (getkword+ "Testing" '("Yes" "No") nil)
Testing [YES/NO]: n
"No"
Command: (getkword+ "Testing" '("Yes" "No") "Yes")
Testing [YES/NO] <YES>:
"Yes"
Command: (getkword+ "Testing" '("Yes" "No") "Yes")
Testing [YES/NO] <YES>:
"Yes"
Command: (getkword+ "Testing" '("Yes" "No") "Yes")
Testing [YES/NO] <YES>: n
"No"
It works with the pick a keyword also. It would allow for spaces in the keywords as well.
Thank you for sharing your knowledge.Pleasure! Glad I could help someone. Though my code is not much more than an amalgamation of all the ideas in this thread.