- UID
- 41992
- 积分
- 958
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-4-10
- 最后登录
- 1970-1-1
|
发表于 2013-6-17 08:17:25
|
显示全部楼层
本帖最后由 xshrimp 于 2013-6-17 08:20 编辑
不过这个好像不是最新版的.最新的作者加了.
October 19, 2004 added function chkkwds (see description at end of file)
- ;*
- ;;;This function alerts the user when keywords containing invalid characters are used and it will
- ;;;identify and disable the offending keywords leaving the remaining keywords enabled.
- (DEFUN chkkwds (kwd /)
- (SETQ invalidcharlst (LIST "_" "!" "@" "$" "%" "^" "&" "`" "(" ")" "*" "+" "=" "<" ">"))
- (IF (OR (WCMATCH kwd "*_*")
- (WCMATCH kwd "*`!*")
- (WCMATCH kwd "*`@*")
- (WCMATCH kwd "*`$*")
- (WCMATCH kwd "*`%*")
- (WCMATCH kwd "*`^*")
- (WCMATCH kwd "*`&*")
- (WCMATCH kwd "*`**")
- (WCMATCH kwd "*(*")
- (WCMATCH kwd "*)*")
- (WCMATCH kwd "*+*")
- (WCMATCH kwd "*=*")
- (WCMATCH kwd "*<*")
- (WCMATCH kwd "*>*")
- ) ;_ end of OR
- (PROGN (PRINC "\nInvalid characters in keyword specification!")
- (PRINC "\nAttempting to disable invalid keywords.")
- (PRINC)
- (SETQ stripkwd kwd
- kwdcnt 1
- charposlst NIL
- ) ;_ end of setq
- (WHILE (AND stripkwd (<= kwdcnt (STRLEN kwd)))
- (IF (MEMBER (SUBSTR stripkwd kwdcnt 1) invalidcharlst)
- (IF charposlst
- (SETQ charposlst (APPEND charposlst (LIST kwdcnt)))
- (SETQ charposlst (LIST kwdcnt))
- ) ;_ end of if
- ) ;_ end of if
- (SETQ kwdcnt (1+ kwdcnt))
- ) ;_ end of while
- (FOREACH n charposlst
- (COND ((OR (WCMATCH (SUBSTR kwd 1 n) "* *") (WCMATCH (SUBSTR kwd n) "* *"))
- (SETQ inicnt n)
- (WHILE (/= (SUBSTR kwd (1- inicnt) 1) " ") (SETQ inicnt (1- inicnt)))
- (SETQ endcnt inicnt)
- (WHILE (AND (/= endcnt (1- (STRLEN kwd))) (/= (SUBSTR kwd (1+ endcnt) 1) " "))
- (SETQ endcnt (1+ endcnt))
- ) ;_ end of WHILE
- (SETQ remcnt inicnt
- remend endcnt
- ) ;_ end of SETQ
- (WHILE (<= inicnt endcnt)
- (SETQ kwd (STRCAT (SUBSTR kwd 1 (1- inicnt)) " " (SUBSTR kwd (1+ inicnt))))
- (SETQ inicnt (1+ inicnt))
- ) ;_ end of WHILE
- (PRINC (STRCAT "\nKeyword " (SUBSTR stripkwd remcnt (- endcnt remcnt -1)) " is disabled! "))
- (PRINC)
- )
- ) ;_ end of COND
- ) ;_ end of FOREACH
- (PRINC "\nOmit invalid keyword characters at source to enable these keywords. ")
- (PRINC)
- ) ;_ end of PROGN
- ) ;_ end of IF
- )
- ;;;---------------------------------------------------------
- ;;;U系列函数.格式化输入.
- ;;;October 19, 2004 added function chkkwds (see description at end of file)
- ;* UANGLE User interface angle function
- ;* BIT (1 for no null, 0 for none) and KWD key word ("" for none) are same as
- ;* for INITGET. MSG is the prompt string, to which a default real in rads is
- ;* added as <DEF> (nil for none), and a : is added. BPT is base point (nil
- ;* for none).
- ;*
- ;(defun ui-get-input (str default) ;;/*{{{*/
- ; (cond
- ; ((getint (strcat str "<" (itoa default) "> " )))
- ; (default)
- ; )
- ;)
- (defun uangle (bit kwd msg def bpt / inp)
- (chkkwds kwd)
- (if def
- (setq msg (strcat "\n" msg " <" (if(eq(type def)'STR) def (angtos def)) ">: ")
- bit (* 2 (fix (/ bit 2)))
- )
- (setq msg (strcat "\n" msg ": "))
- )
- (initget bit kwd)
- (setq inp
- (if bpt
- (getangle msg bpt)
- (getangle msg)
- ) )
- (if inp inp def)
- )
- ;*
- ;* UDIST User interface function
- ;* BIT (0 for none) and KWD key word ("" for none) are same as for INITGET.
- ;* MSG is the prompt string, to which a default real is added as <DEF> (nil
- ;* for none), and a : is added. BPT is base point (nil for none).
- ;*
- (defun udist (bit kwd msg def bpt / inp)
- (chkkwds kwd)
- (if def
- (setq msg (strcat "\n" msg " <" (rtos def) ">: ")
- bit (* 2 (fix (/ bit 2)))
- );setq
- (setq msg (strcat "\n" msg ": "))
- );if
- (initget bit kwd)
- (setq inp
- (if bpt
- (getdist msg bpt)
- (getdist msg)
- ) );setq&if
- (if inp inp def)
- )
- ;*
- ;* UINT User interface function
- ;* BIT (0 for none) and KWD key word ("" for none) are same as for INITGET.
- ;* MSG is the prompt string, to which a default real is added as <DEF> (nil
- ;* for none), and a : is added.
- ;*
- (defun uint (bit kwd msg def / inp)
- (if def
- (setq msg (strcat "\n" msg " <" (if (eq (type def) 'REAL) (rtos def 2 0)(if (eq (type def) 'INT) (itoa def) def)) ">: ")
- bit (* 2 (fix (/ bit 2)))
- )
- (setq msg (strcat "\n" msg ": "))
- );if
- (initget bit kwd)
- (setq inp (getint msg))
- (if inp inp def)
- )
- ;*
- ;;;* UKWORD User key word. DEF, if any, must match one of the KWD strings
- ;;;* BIT (1 for no null, 0 for none) and KWD key word ("" for none) are same as
- ;;;* for INITGET. MSG is the prompt string, to which a default string is added
- ;;;* as <DEF> (nil or "" for none), and a : is added.
- ;;;*
- (DEFUN ukword (bit kwd msg def / inp)
- (chkkwds kwd)
- (IF (AND def (/= def ""))
- (SETQ msg (STRCAT "\n" msg " <" def ">: ")
- bit (* 2 (FIX (/ bit 2)))
- );setq
- );if
- (INITGET bit kwd)
- (SETQ inp (GETKWORD msg))
- (IF inp
- inp
- def
- ) ;_ end of if
- )
- ;*
- ;* UPOINT User interface point function
- ;* BIT (1 for no null, 0 for none) and KWD key word ("" for none) are same as
- ;* for INITGET. MSG is the prompt string, to which a default point variable
- ;* is added as <DEF> (nil for none), and a : is added. BPT is base point
- ;* (nil for none).
- ;*
- (defun upoint (bit kwd msg def bpt / inp)
- (if def
- (if (eq (type def) 'STR)
- (setq msg (strcat "\n" msg " <" def ">:")
- bit (* 2 (fix (/ bit 2)))
- )
- (progn
- (setq pts (strcat
- (rtos (car def)) "," (rtos (cadr def))
- (if
- (and (caddr def) (= 0 (getvar "FLATLAND")))
- (strcat "," (rtos (caddr def)))
- ""
- ) );if&strcat
- msg (strcat "\n" msg " <" pts ">: ")
- bit (* 2 (fix (/ bit 2)))
- )
- )
- )
- (setq msg (strcat "\n" msg ": "))
- );if a default was supplied
- (initget bit kwd)
- (setq inp
- (if bpt
- (getpoint msg bpt)
- (getpoint msg)
- ) );setq&if
- (if inp inp def)
- )
- ;* UREAL User interface real function
- ;* BIT (0 for none) and KWD key word ("" for none) are same as for INITGET.
- ;* MSG is the prompt string, to which a default real is added as <DEF> (nil
- ;* for none), and a : is added.
- ;*
- (defun ureal (bit kwd msg def / inp)
- (if def
- (setq msg (strcat "\n" msg " <" (if (eq (type def) 'REAL)(rtos def 2)(if (eq (type def) 'INT)(itoa def)def)) ">: ")
- bit (* 2 (fix (/ bit 2)))
- )
- (setq msg (strcat "\n" msg ": "))
- );if
- (initget bit kwd)
- (setq inp (getreal msg))
- (if inp inp def)
- )
- ;;; 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 <DEF> (nil or "" for none), and a : is added. If SPFLAG T, spaces
- ;;; are allowed in
- ;;; string.
- ;;;
- ;;;> Author: Henry C. Francis
- ;;;> 425 N. Ashe St.
- ;;;> Southern Pines, NC 28387
- ;;;> [url]http://paracadd.com[/url]
- ;;;> All rights reserved.
- ;;;
- ;;;> COPYRIGHT: 1-14-98
- ;;;> EDITED: 03-02-2001
- ;;;
- (DEFUN ustr (bit msg def spflag / inp nval)
- (IF (AND def (/= def ""))
- (SETQ msg (STRCAT "\n" msg " <" def ">: ")
- inp (GETSTRING msg spflag)
- inp (IF (= inp "")
- def
- inp
- ) ;_ end of if
- ) ;_ end of setq
- (PROGN
- (SETQ msg (STRCAT "\n" msg ": "))
- (IF (= bit 1)
- (WHILE (= "" (SETQ inp (GETSTRING msg spflag))))
- (SETQ inp (GETSTRING msg spflag))
- ) ;_ end of if
- ) ;_ end of progn
- ) ;_ end of if
- inp
- )
|
|