Got a weird problem with this. I think it has something to do with the initget bitcode, but I'm not sure what's up. It seems to work fine (except the wcmatch that I haven't fixed yet) as long as you enter the kword string correctly. It works the first time you enter a wrong option, but then doesn't accept anything after that, giving the error "Invalid option keyword".
Would someone mind taking a look?
Code:
(defun c:foo ()
(vl-load-com)
;| BEGIN SUBFUNCTIONS |;
;; Join list items into string with delimiter string
(defun _implode (data delim / str n)
(if (and (= (type data) 'LIST)
(= (type delim) 'STR)
(> (strlen delim) 0)
)
(foreach n data
(if str
(setq str (strcat str delim n))
(setq str n)
)
)
)
)
;| END SUBFUNCTIONS |;
;| BEGIN MAIN ROUTINE |;
; SET UP OPTIONS FOR ITEM TYPE
(if
(= *TypLst nil)
(setq *TypLst (list
"PNL"
"CAB"
"DSK"
"CLT"
"TFS"
"STD"
"SGN"
"DOR"
"CLG"
"FAS"
"PST"
"SUP"
"MIS"
)
)
)
; BREAK THE LIST UP INTO A STRING WITH SPACES
(setq TypStr (_implode *TypLst " "))
; ON FIRST RUN, SET DEFAULT OPTION
(if (not *Typ) (setq *Typ (car *TypLst)))
; GET TYPE FROM USER
(initget 128 TypStr)
(while
(not
(and
(setq
str (strcase (getkword
(strcat "\nChoose [" ; hangs right here when retrying an incorrect keyword
(vl-string-translate " " "/" TypStr)
"] <"
*Typ
">: "
)
)
)
)
(= (strlen str) 3)
)
)
(prompt "\nNothing entered, or too many characters --")
(setq str nil)
)
(setq *Typ str)
; ADD IT TO THE OPTION LIST IF NOT ALREADY PRESENT
(if
(not (wcmatch TypStr *Typ))
(setq *TypLst (cons *Typ *TypLst))
)
(princ *Typ)
(setq str nil)
(setq *typ nil)
(setq *typlst nil)
(setq typstr nil)
;| END MAIN ROUTINE |;
(princ)
)