我不知道如何将默认值添加到while循环。下面是我正在使用的代码(这是我从Tim Spangler那里获得并修改过的代码):
(
- if (= defstyle nil) (setq defstyle "Square"))
- (initget 6 "Square s S Round r R")
- (setq DuctStyle (getkword (strcat "\n Enter duct style (Square/Round)<"defstyle">: ")))
- (if (= DuctStyle nil) (setq DuctStyle defstyle) (setq defstyle DuctStyle))
下面是我还想添加默认值的while循环:
- ;; Get duct width
- (if(= (strcase DuctStyle) "SQUARE")
- (while(null(setq DuctWidth (getint "\n Enter duct width: ")))
- (princ "\n Enter duct width: ")
- )
-
- (while(null(setq DuctWidth (getint "\n Enter duct diameter: ")))
- (princ "\n Enter duct diameter:: ")
- )
- )
- ;; Get duct height
- (if(= (strcase DuctStyle) "SQUARE")
- (while(null(setq DuctHeight (getint "\n Enter duct height: ")))
- (princ "\n Enter duct height: ")
- )
- (setq DuctHeight DuctWidth)
- )
我还附上了完整的程序。
顺便说一句,让例程像filet命令一样“运行”要困难多少?因此,在任何后续运行中,它会自动使用最后的输入,并且只为usre提供更改输入的选项。这样,如果例程再次运行且所有输入都相同,则只需发出例程并按enter键。
我对LISP编程的世界还很陌生——在这里和那里尽可能多地学习。
谢谢非常感谢您的帮助。
RWB-管道。LSP |