|
发表于 2022-7-5 19:56:26
|
显示全部楼层
I forgot to post a subroutine I have built into this lisp. It is as follows:
;* USTR: User interface string
;* If BIT=1 no null "" input allowed, 0 for none, BIT ignored if DEF present.
;* MSG is the prompt string, to which a default string is added as (nil
;* or "" is for none), and a : is added. If SPFLAG T, spaces are allowed in string.
(defun ustr (bit msg def spflag / inp nval)
(if (and def (/= def ""))
(setq msg (strcat "\n" msg ": ")
inp (getstring spflag msg)
inp (if (= inp "") def inp)
);setq
(progn
(if (= " " (substr msg (strlen msg) 1))
(setq msg (strcat "\n" (substr msg 1 (1- (strlen msg))) ": "))
(setq msg (strcat "\n" msg ": " ))
);if
(if (= bit 1)
(while (= "" (setq inp (getstring spflag msg)))
(prompt "\nInvalid string.")
)
(setq inp (getstring spflag msg))
) );progn&if
);if
inp
);defun
;*
Again, any help would be appreciated. |
|