home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / cad / jul93.zip / ADDXDAT.LSP next >
Lisp/Scheme  |  1993-06-21  |  2KB  |  54 lines

  1. ; ADDXDAT.LSP   copyright 1993, Anthony Hotchkiss
  2.  
  3. ;;; ADDXDAT --  A function to create an xdata list
  4. (defun addxdat (/ appname xdat more xdname xdtype xdval item)   
  5.    (setq appname (getstring "\nApplication ID name: "))
  6.    (setq xdat (list (cons 1002 "{")))
  7. ;;;  The major segment of the function is a while loop, which tests
  8. ;;;  that you want to add 'more' xdata, so we set 'more' to 't':
  9.    (setq more t)
  10.    (while more
  11. ;;;  The xdata is defined as an item name, an item type, and value:
  12.       (setq xdname (getstring "\nItem name <exit>: "))
  13. ;;;  If the default 'exit' is used, the function bypasses the 'if' statement
  14.       (if (/= xdname "")
  15.          (progn
  16. ;;;  The 'item name' is added to the 'xdat' list with the correct
  17. ;;;  dxf code '1000'
  18.             (setq xdname (cons 1000 xdname))
  19.             (setq xdat (append xdat (list xdname)))
  20. ;;;  The 'item type' is forced to be String, Distance, Integer, or Real:
  21.             (initget "String Distance Integer Real")
  22.             (setq xdtype (getkword 
  23.                "\nItem type String/Distance/Integer/Real: "))
  24. ;;;  The user now enters the 'item value.'
  25.             (setq xdval (getstring "\nItem value: "))
  26. ;;;  The dotted pair of the dxf code and the item value is formed
  27. ;;;  depending on the item type using the (cond) function
  28.             (setq item
  29.                (cond
  30.                   ((= xdtype "String") (cons 1000 xdval))
  31.                   ((= xdtype "Distance") (cons 1041 (atof xdval)))
  32.                   ((= xdtype "Integer") (cons 1070 (atoi xdval)))
  33.                   ((= xdtype "Real") (cons 1040 (atof xdval)))
  34.                   (t nil)
  35.                ); cond
  36.             ); setq
  37. ;;;  The dotted pair is now added to the list of 'xdat'
  38.             (setq xdat (append xdat (list item)))
  39. ;;;  If an item name was given, we set 'more' to 't'
  40.             (setq more t)
  41.          ); progn
  42. ;;;  Or else, we set 'more' to nil, and the 'if' statement is completed
  43.          (setq more nil)
  44.       ); if
  45. ;;;  That also ends the 'while' loop:
  46.    ); while
  47. ;;;  Finally, we add the closing "}" to the end of  'xdat,'
  48.    (setq xdat (append xdat (list (cons 1002 "}"))))
  49. ;;;  and we add the (-3  ("application-name"..  to the front of 'xdat':
  50.    (setq xdat (list -3 (cons appname xdat)))
  51. ); end of defun
  52.  
  53.  
  54.