朽木大师 发表于 2012-8-26 16:47:43

帮看一下or 函数

(defun c:test()
(setq input (getstring "\n请输入已认正码:"))
(setq oneinput "oneinput")
(setq twoinput "twoinput")
(setq threeinput "threeinput")
(if (or (not input)
      (/= input oneinput)
                                (/= input twoinput)
                                (/= input threeinput)
                                )
                (progn
                (princ "no"))
                (progn
                (princ "OK")
                )
                )
                (princ)
                )
这个程序运行,总是结果是no
当将or 里面        (/= input twoinput)
                                (/= input threeinput) 取消 就可以

Andyhon 发表于 2012-8-26 17:13:01

本帖最后由 Andyhon 于 2012-8-27 08:10 编辑

(defun c:test ()
(setq input (getstring "\n请输入已认正码:"))    ; Enter ==> ""
(setq oneinput "oneinput")
(setq twoinput "twoinput")
(setq threeinput "threeinput")
(cond
    ((= input "") (princ "no"))
    ((or
       (= input oneinput)
       (= input twoinput)
       (= input threeinput)
   )
   (princ "OK")
    )
)
(princ)
)

ZZXXQQ 发表于 2012-8-26 23:35:39


(defun c:test ()
(setq input (getstring "\n请输入已认正码:"))
(setq oneinput "oneinput")
(setq twoinput "twoinput")
(setq threeinput "threeinput")
(if (or (/= input "") (member input (list oneinput twoinput threeinput)))
(princ "OK")
(princ "no")
)
(princ)
)

朽木大师 发表于 2012-8-27 08:46:23

ZZXXQQ 发表于 2012-8-26 23:35 static/image/common/back.gif


感谢,感谢,还是这个好
页: [1]
查看完整版本: 帮看一下or 函数