
- ;;;[say-提示 key-关键字列表 def-缺省关键字 control-为T时不能空退出(没def时)]
- (defun getkword:(say key def control / a b c how is return)
- (if(listp key)(setq key(mapcar 'strcase key))(setq key(list(strcase key))))
- (prompt say)
- (setq how t return nil)
- (while(and how(setq is(grread)))
- (setq a(car is) b(cadr is))
- (cond((and(= a 2)(member(setq c(strcase(chr b)))key))(setq return c how nil))
- ((member is '((2 13)(2 32)(11 0)))
- (if def(setq return(strcase def) how nil) ;;有缺省就可以退出了
- (if control(princ(strcat"\n不能为空,重新输入!"say)) ;;没缺省,看能不能退出
- (setq how nil)
- )
- )
- )
- (t (princ(strcat"\n重输!"say))) ;;这行可以不要
- ))return
- )
- ;;;example:
- ;;;(getkword: "\nA??,B!!,C$$[A]: " '("a""b""c") "A" nil) ;;有缺省时,control随便
- ;;;(getkword: "\nA??:" "a" "A" nil) ;;单个
- ;;;(getkword: "\nA??,B!!,C$$(回车退出):" '("a""b""c") nil nil) ;;回车返回nil
- ;;;(getkword: "\nA??,B!!,C$$: " '("a""b""c") nil t) ;;回车要求重输
|