带参数的函数定义
www.dimcax.com
带参数的函数定义我在定义一个函数test后,怎么实现在命令中输入test -p后,提示用户输入一个字符串,输入test则直接引用用户上一次输入的字符
d
楼主说的是函数还是命令行的操作,没看明白
d
;;一楼的问题我也看不懂,大概是这样的意思吧?我自己猜的
;;;;不用带参数的
(defun c:tt ()
(if str str (setq str ""))
(setq str (getstring (strcat "\n请输入一个字符串<" str ">:")))
(princ)
)
d
我是想在命令行实现这样的操作,怎么去定义这个函数
d
不用非输入-p吧?下面程序在提示输入字串时空回车默认前次输入字串。
(defun c:test ()
(setq str1 (getstring (strcat "\nenter a string " (if (/= str "") (strcat "<" str "> :") ":"))))
(setq str (if (/= str1 "") str1 str))
(princ str)
(princ)
)
踅摸
d
定义一个全局变量
每次执行程序就把这个变量作为默认提示
回车就认为是这个变量值
(if (not (numberp scale))(setq scale 0.5))
(setq temp (getreal "缩放比例"))
(if (not temp)(setq temp scale)(setq scale temp))