home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 v2.4 Fix / W95-v2.4fix.iso / ACADWIN / ASE / SAMPLE / ASESMP.LSP < prev    next >
Encoding:
Lisp/Scheme  |  1995-02-08  |  23.1 KB  |  717 lines

  1. ;;;
  2. ;;;    asesmp.lsp
  3. ;;;    
  4. ;;;    Copyright (C) 1990, 1992, 1994 by Autodesk, Inc.
  5. ;;;    
  6. ;;;    Permission to use, copy, modify, and distribute this software 
  7. ;;;    for any purpose and without fee is hereby granted, provided
  8. ;;;    that the above copyright notice appears in all copies and 
  9. ;;;    that both that copyright notice and the limited warranty and 
  10. ;;;    restricted rights notice below appear in all supporting 
  11. ;;;    documentation.
  12. ;;;    
  13. ;;;    AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.  
  14. ;;;    AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF 
  15. ;;;    MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC. 
  16. ;;;    DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE 
  17. ;;;    UNINTERRUPTED OR ERROR FREE.
  18. ;;;    
  19. ;;;    Use, duplication, or disclosure by the U.S. Government is suject to 
  20. ;;;    restrictions set forth in FAR 52.227-19 (Commercial Computer 
  21. ;;;    Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) 
  22. ;;;    (Rights in Technical Data and Computer Software), as applicable. 
  23. ;;;
  24. ;;; DESCRIPTION
  25. ;;;
  26. ;;;    This module contains the following functions:
  27. ;;;        (asesmpdo)
  28. ;;;        (asesmplpn)
  29. ;;;        (asesmplink)
  30. ;;;        (asesmpsel)
  31. ;;;        (asesmperr)
  32. ;;;
  33. ;;;    1. (asesmpdo) - Database Object Reference statistic
  34. ;;;                    This command demostrates how to get the
  35. ;;;                    information by the given Database Object Reference.
  36. ;;;
  37. ;;;        Command: (asesmpdo)
  38. ;;;        Enter DO path:
  39. ;;;          
  40. ;;;            This function prints the information, related to specified DO:
  41. ;;;                - DO path code
  42. ;;;                - all of the contained names
  43. ;;;                - status information
  44. ;;;                - updatability
  45. ;;;                - related Link Path Names
  46. ;;;                - subordinate DO names
  47. ;;;                - quantity of the related links
  48. ;;;                - quantity of the related entities
  49. ;;;
  50. ;;;    2. (asesmplpn) - Creating, Erasing, Renaming of LPN(s)
  51. ;;;
  52. ;;;        Command: (asesmplpn)
  53. ;;;        View/Erase/Rename/Create/<eXit>:
  54. ;;;            View    - displays Table path and key column names of LPN
  55. ;;;            Erase   - erases LPN
  56. ;;;            Rename  - renames LPN
  57. ;;;            Create  - creates a new LPN
  58. ;;;            eXit    - terminates function
  59. ;;;
  60. ;;;    3. (asesmplink) - Creating, Erasing, Updating of links
  61. ;;;
  62. ;;;        Command: (asesmplink)
  63. ;;;        View/Erase/Update/Create/<eXit>:
  64. ;;;            View    - displays link
  65. ;;;            Erase   - erases link
  66. ;;;            Update  - updates link
  67. ;;;            Create  - creates a new link
  68. ;;;            eXit    - terminates function
  69. ;;;
  70. ;;;    4. (asesmpsel) - Links Statistic
  71. ;;;                     This command demonstrates how to get
  72. ;;;                     the link information
  73. ;;;                     for the selected drawing objects.
  74. ;;;
  75. ;;;        Command: (asesmpsel)
  76. ;;;        Select objects:
  77. ;;;
  78. ;;;            This command asks for the drawing objects selecting and
  79. ;;;            prints the statistic for the link information,
  80. ;;;            related with the selected entities :
  81. ;;;                - total links quantity
  82. ;;;                - total links quantity per each LPN
  83. ;;;                - Entity Links quantity per each LPN
  84. ;;;                - DA links quantity per each LPN
  85. ;;;
  86. ;;;    5. (asesmperr) - prints ASE error stack
  87. ;;;
  88. ;;;        Command: (asesmperr)
  89. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  90. (defun *error* (msg / i n)
  91.    (terpri)
  92.    (princ msg)
  93.    (setq n (ase_errqty))
  94.    (setq i 0)
  95.    (while (< i n)
  96.        (progn
  97.            (terpri)
  98.            (princ i)
  99.            (princ ": ")
  100.            (princ (ase_errmsg i))
  101.            (princ " dsc=")
  102.            (princ (ase_errdsc i))
  103.            (princ " code=")
  104.            (princ (ase_errcode i))
  105.            (setq i (+ i 1))
  106.        )
  107.    )
  108. )
  109. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  110. (defun print_status (status) 
  111.     (terpri)
  112.     (princ "Status: ")
  113.     (princ (if (= 0 status) "undefined " ""))
  114.     (princ (if (/= 0 (Boole 1 status 1)) "current " ""))
  115.     (princ (if (/= 0 (Boole 1 status 2)) "registered " ""))
  116.     (princ (if (/= 0 (Boole 1 status 4)) "accessible " ""))
  117.     (princ (if (/= 0 (Boole 1 status 8)) "connected " ""))
  118.     (princ (if (/= 0 (Boole 1 status 16)) "? " ""))
  119.     (terpri)
  120. )
  121. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  122. (defun getdo (prompt)
  123.    (getstring prompt)
  124. )
  125. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  126. (defun getlpn (prompt / lpn lst)
  127.    (setq lpn "?")
  128.    (while (equal lpn "?")
  129.        (progn
  130.            (setq lpn (getstring prompt))
  131.            (if (equal lpn "?")
  132.                (if (setq lst (ase_lplist))
  133.                    (princ lst)
  134.                    (*error* "Empty list")
  135.                )
  136.            )
  137.        )
  138.    )
  139.    (if (equal lpn "")
  140.        (setq lpn nil)
  141.        (setq lpn lpn)
  142.    )
  143. )
  144. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  145. (defun getkey (/ lst col)
  146.    (setq lst nil)
  147.    (setq col "")
  148.    (while col
  149.        (progn
  150.            (setq col (getstring "\nEnter key column name: "))
  151.            (if (equal col "")
  152.                (setq col nil)
  153.                (setq lst (cons col lst))
  154.            )
  155.        )
  156.    )
  157.    (setq lst (reverse lst))
  158. )
  159. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  160. (defun getlinkid ()
  161.    (initget 4)
  162.    (getreal "\nEnter ID of existing link: ")
  163. )
  164. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  165. (defun printlink (link / i flag item)
  166.    (setq i 0)
  167.    (while (setq flag (nth i link))
  168.        (progn
  169.            (setq i (+ i 1))
  170.            (if (setq item (nth i link))
  171.                (progn
  172.                    (terpri)
  173.                    (if (= flag 1)
  174.                        (progn
  175.                            (princ "ID: ")
  176.                            (princ item)
  177.                        )
  178.                    )
  179.                    (if (= flag 2)
  180.                        (progn
  181.                            (princ "Type: ")
  182.                            (if (= item 2)
  183.                                (princ "DA")
  184.                                (princ "Entity")
  185.                            )
  186.                        )
  187.                    )
  188.                    (if (= flag 3)
  189.                        (progn
  190.                            (princ "Status: ")
  191.                            (princ item)
  192.                        )
  193.                    )
  194.                    (if (= flag 4)
  195.                        (progn
  196.                            (princ "Entity name: ")
  197.                            (princ item)
  198.                        )
  199.                    )
  200.                    (if (= flag 5)
  201.                        (progn
  202.                            (princ "LPN: ")
  203.                            (princ item)
  204.                        )
  205.                    )
  206.                    (if (= flag 6)
  207.                        (progn
  208.                            (princ "Key values: ")
  209.                            (print item)
  210.                        )
  211.                    )
  212.                    (if (= flag 7)
  213.                        (progn
  214.                            (princ "DA column names: ")
  215.                            (princ item)
  216.                        )
  217.                    )
  218.                    (if (= flag 9)
  219.                        (progn
  220.                            (princ "DA column values: ")
  221.                            (print item)
  222.                        )
  223.                    )
  224.                    (if (= flag 10)
  225.                        (progn
  226.                            (princ "Xref/Block: ")
  227.                            (princ item)
  228.                        )
  229.                    )
  230.                    (if (= flag 11)
  231.                        (progn
  232.                            (princ "Reserved attribute: ")
  233.                            (princ item)
  234.                        )
  235.                    )
  236.                    (setq i (+ i 1))
  237.                )
  238.            )
  239.        )
  240.    )
  241. )
  242. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  243. (defun getentity (/ lst ent )
  244.    (setq lst (entsel "\nSelect object: "))
  245.    (if lst
  246.        (setq ent (car lst))
  247.        (setq ent nil)
  248.    )
  249. )
  250. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  251. (defun getkeyval (/ cond kword lst val)
  252.    (terpri)
  253.    (princ "Enter key column values")
  254.    (setq lst nil)
  255.    (setq cond t)
  256.    (while cond
  257.        (progn
  258.            (setq val nil)
  259.            (initget 0 "Real Integer String eXit")
  260.            (setq kword (getkword "\nReal/Integer/String/<eXit>: "))
  261.            (if (not kword)
  262.                (setq cond nil)
  263.            )
  264.            (if (equal kword "eXit")
  265.                (setq cond nil)
  266.            )
  267.            (if (equal kword "Real")
  268.                (setq val (getreal "\nEnter real: "))
  269.            )
  270.            (if (equal kword "Integer")
  271.                (setq val (getint "\nEnter integer: "))
  272.            )
  273.            (if (equal kword "String")
  274.                (setq val (getstring "\nEnter string: "))
  275.            )
  276.  
  277.            (if val
  278.                (setq lst (cons val lst))
  279.            )
  280.        )
  281.    )
  282.    (setq lst (reverse lst))
  283. )
  284. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  285. ;; This function prints number of links in the link selection and returns 
  286. ;; this number
  287. ;;
  288. (defun print_lsqty ( lsel / qty )
  289.  
  290.    ; initial set
  291.    (setq qty 0.)
  292.  
  293.    (if (or (eq lsel nil)                        ;; bad parameter
  294.        (eq 0 (setq qty (ase_lsqty lsel))))      ;; actual number of links
  295.  
  296.        (princ "\nNo linked entity selected.")
  297.        (princ (strcat "\nTotal links: " (rtos qty)))
  298.    )
  299.  
  300.    ; return value
  301.    (setq qty qty)     
  302. )
  303. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  304. ;; This function filters links to the LPN 'lpn' from link selection 'lsel'
  305. ;; and prints information of each type of links among them
  306. ;;
  307. (defun print_lpn_ls_info (lpn lsel / ls)
  308.  
  309.    ;; make copy of the current link selection
  310.    (if (setq ls (ase_lscopy lsel))
  311.  
  312.        (progn 
  313.  
  314.            ;; filter links to the specified lpn
  315.            (ase_lsintersectfilter ls 5 lpn)
  316.  
  317.            ;; print total links info
  318.            (print_lpn_ls_type_info lpn ls 0)
  319.  
  320.            ;; print entity links info
  321.            (print_lpn_ls_type_info lpn ls 1)
  322.  
  323.            ;; print DA links info
  324.            (print_lpn_ls_type_info lpn ls 2)
  325.  
  326.            ;; remove copy 
  327.            (ase_lsfree ls)
  328.  
  329.        )
  330.  
  331.        ;; error
  332.        (*error* "Can't copy link selection")
  333.    )
  334. )
  335. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  336. ;; This function prints information about links of type 'type'
  337. ;; among link selection 'lsel', associated with the LPN 'lpn'
  338. ;;
  339. (defun print_lpn_ls_type_info (lpn lsel type / ls qty ss)
  340.  
  341.    ;; make copy of the current link selection
  342.    (if (setq ls (ase_lscopy lsel))
  343.  
  344.        (progn
  345.  
  346.            ;; filter ls by link type
  347.            (ase_lsintersectfilter ls 2 type)
  348.  
  349.            ;; print message
  350.            (cond
  351.                ((= type 1) ; entity link
  352.                    (princ (strcat "\nEntity Links Statistic for DOR [" lpn "]:"))
  353.                )
  354.                ((= type 2) ; DA link
  355.                    (princ (strcat "\nDA Links Statistic for DOR [" lpn "]:"))
  356.                )
  357.                ((= type 0) ; All links
  358.                    (princ (strcat "\nLink Statistic for DOR [" lpn "]:"))     
  359.                )
  360.            )
  361.  
  362.            ;;  print number of links of the specified type        
  363.            (if (= 0. (setq qty (ase_lsqty ls)))
  364.                (princ "\nNo Links of the specified type") 
  365.                (princ (strcat "\nLinks #" (rtos qty)))
  366.            )
  367.  
  368.            ;; get selection set, associated with ls and print its length
  369.            (if (setq ss (ase_lsentsel ls))
  370.                (princ (strcat "\nEntities #" (rtos (sslength ss))))
  371.                (princ "\nCan't get the entity selection for link selection")
  372.            )
  373.  
  374.            ;; free ls
  375.            (ase_lsfree ls)
  376.        )
  377.  
  378.        ;; error 
  379.        (*error* "Can't copy link selection") 
  380.    )
  381. )
  382. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  383. ; asesmpdo - Database Object Reference statistic
  384. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  385. (defun asesmpdo (/ do_name subordinate_do ss ls dolist name do_name_list name_code level status i lpn)
  386.  
  387.    (if (setq do_name (getdo "\nEnter DO path: "))
  388.        (progn
  389.  
  390.            (setq do_name_list (list "Unknown" "Environment" "Catalog" "Schema" "Table" "LPN" "Full Path" "DO Path" "SQL Table Path"))
  391.  
  392.            (if (not (setq level (ase_dopathcode do_name)))            
  393.                (progn
  394.                    (*error* "Wrong DO name")
  395.                    (exit)
  396.                )
  397.            )     
  398.  
  399.            (terpri)
  400.            (setq status (ase_dostatus do_name))
  401.            (princ (nth level do_name_list))
  402.            (princ "- ")
  403.            (princ do_name)
  404.            (print_status status)
  405.     
  406.            (if (setq lpn (ase_dopathname do_name 5))
  407.                (progn 
  408.                    (terpri)
  409.                    (princ "LPN '")
  410.                    (princ lpn)
  411.                    (princ "': ")
  412.                    (princ (if (ase_lpisupdatable lpn) "is updatable" "isn't updatable"))
  413.                    (terpri)
  414.                )
  415.            )
  416.  
  417.            (if (< level 4)
  418.                (progn 
  419.                    (setq dolist (ase_dolist do_name))
  420.                    (princ "Subordinate DO objects (")
  421.                    (princ (nth (1+ level) do_name_list))
  422.                    (princ "):")
  423.                    (terpri)
  424.                    (setq i 0)
  425.                    (while (setq subordinate_do (nth i dolist))
  426.                        (progn            
  427.                            (princ (ase_dopathname subordinate_do (+ 1 level)))
  428.                            (terpri)
  429.                            (setq i (1+ i))
  430.                        )
  431.                    )
  432.                )
  433.            )
  434.     
  435.            (if (/= 0 (Boole 1 status 2))
  436.                (progn 
  437.                    (setq ls (ase_lscreate -3 do_name))
  438.                    (terpri)
  439.                    (princ "Number of the links: ")
  440.                    (princ (ase_lsqty ls))
  441.                    (terpri)
  442.                    (setq ss (ase_lsentsel ls))
  443.                    (princ "Number of the linked objects: ")
  444.                    (princ (sslength ss))
  445.                    (ase_lsfree ls)
  446.                )
  447.            )
  448.  
  449. ;          (setq i 0)
  450. ;          (while (and dolist (setq subordinate_do (nth i dolist)))
  451. ;              (progn 
  452. ;                  (asesmpdo subordinate_do)
  453. ;                  (setq i (1+ i))
  454. ;              )
  455. ;          )
  456.        )
  457.    )
  458.  
  459.    (terpri)
  460. )
  461. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  462. ; asesmplpn - Creating, Erasing, Renaming of LPN(s)
  463. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  464. (defun asesmplpn(/ cond kword lpn lpn1 path lst)
  465.  
  466.    (setq cond t)
  467.  
  468. ;  Main loop
  469.    (while cond
  470.  
  471.        (progn
  472. ;          Get user's key word
  473.            (initget 0 "View Erase Rename Create eXit")
  474.            (setq kword (getkword "\nView/Erase/Rename/Create/<eXit>: "))
  475.  
  476.            (if (not kword)
  477. ;              Exit
  478.                (setq cond nil)
  479.            )
  480.  
  481.            (if (equal kword "eXit")
  482. ;              Exit
  483.                (setq cond nil)
  484.            )
  485.  
  486.            (if (equal kword "View")
  487. ;              View LPN
  488.                (if (setq lpn (getlpn "\nEnter existing LPN or ? for list: "))
  489.                    (progn
  490. ;                      Get DO path for LPN
  491.                        (if (not (setq path (ase_lppath lpn)))
  492.                            (*error* "Can't get DO path")
  493.                            (progn
  494.                                (terpri)
  495.                                (princ "DO path: ")
  496.                                (princ path)
  497.                            )
  498.                        )
  499. ;                      Get key column names for LPN
  500.                        (if (not (setq lst (ase_lpkey lpn)))
  501.                            (*error* "Can't get key column names")
  502.                            (progn
  503.                                (terpri)
  504.                                (princ "Key column names: ")
  505.                                (princ lst)
  506.                            )
  507.                        )
  508.                    )
  509.                )
  510.            )
  511.  
  512.            (if (equal kword "Erase")
  513. ;              Erase LPN
  514.                (if (setq lpn (getlpn "\nEnter existing LPN or ? for list: "))
  515.                    (if (ase_lperase lpn)
  516.                        (progn
  517.                            (terpri)
  518.                            (princ "OK")
  519.                        )
  520.                        (*error* "Can't erase LPN")
  521.                    )
  522.                )
  523.            )
  524.  
  525.            (if (equal kword "Rename")
  526. ;              Rename LPN
  527.                (if (setq lpn (getlpn "\nEnter existing LPN or ? for list: "))
  528.                    (if (setq lpn1 (getlpn "\nEnter new LPN or ? for list: "))
  529.                        (if (ase_lprename lpn lpn1)
  530.                            (progn
  531.                                (terpri)
  532.                                (princ "OK")
  533.                            )
  534.                            (*error* "Can't rename LPN")
  535.                        )
  536.                    )
  537.                )
  538.            )
  539.  
  540.            (if (equal kword "Create")
  541. ;              Create new LPN
  542.                (if (setq path (getdo "\nEnter table path: "))
  543.                    (if (setq lpn (getlpn "\nEnter new LPN or ? for list: "))
  544.                        (if (setq lst (getkey))
  545.                            (if (ase_lpcreate path lpn lst)
  546.                                (progn
  547.                                    (terpri)
  548.                                    (princ "OK")
  549.                                )
  550.                                (*error* "Can't create LPN")
  551.                            )
  552.                        )
  553.                    )
  554.                )
  555.            )
  556.        )
  557.    )
  558.    (terpri)
  559. )
  560. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  561. ; asesmplink - Creating, Erasing, Updating of links
  562. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  563. (defun asesmplink(/ cond kword id lst ent lpn path lst)
  564.  
  565.    (setq cond t)
  566.  
  567. ;  Main loop
  568.    (while cond
  569.  
  570.        (progn
  571. ;          Get user's key word
  572.            (initget 0 "View Erase Update Create eXit")
  573.            (setq kword (getkword "\nView/Erase/Update/Create/<eXit>: "))
  574.  
  575.            (if (not kword)
  576. ;              Exit
  577.                (setq cond nil)
  578.            )
  579.  
  580.            (if (equal kword "eXit")
  581. ;              Exit
  582.                (setq cond nil)
  583.            )
  584.  
  585.            (if (equal kword "View")
  586. ;              View link
  587.                (if (setq id (getlinkid))
  588.                    (if (setq lst (ase_linkget id))
  589.                        (printlink lst)
  590.                        (*error* "Can't get link")
  591.                    )
  592.                )
  593.            )
  594.  
  595.            (if (equal kword "Erase")
  596. ;              Erase link
  597.                (if (setq id (getlinkid))
  598.                    (if (ase_linkremove id)
  599.                        (princ "OK")
  600.                        (*error* "Can't erase link")
  601.                    )
  602.                )
  603.            )
  604.  
  605.            (if (equal kword "Update")
  606. ;              Update link
  607.                (if (setq id (getlinkid))
  608.                    (progn
  609.  
  610.                        (initget 0 "Entity Lpn Key")
  611.                        (setq kword (getkword "\nEntity/Lpn/Key: "))
  612.  
  613. ;                      Change entity
  614.                        (if (equal kword "Entity")
  615.                            (if (setq ent (getentity))
  616.                                (if (ase_linkupdate 1 id 4 ent)
  617.                                    (princ "OK")
  618.                                    (*error* "Can't update link")
  619.                                )
  620.                            )
  621.                        )
  622.  
  623. ;                      Change LPN and Key Values
  624.                        (if (equal kword "Lpn")
  625.                            (if (setq lpn (getlpn "\nEnter existing LPN or ? for list: "))
  626.                                (if (setq lst (getkeyval))
  627.                                    (if (ase_linkupdate 1 id 5 lpn 6 lst)
  628.                                        (princ "OK")
  629.                                        (*error* "Can't update link")
  630.                                    )
  631.                                )
  632.                            )
  633.                        )
  634.  
  635. ;                      Change Key Values
  636.                        (if (equal kword "Key")
  637.                            (if (setq lst (getkeyval))
  638.                                (if (ase_linkupdate 1 id 6 lst)
  639.                                    (princ "OK")
  640.                                    (*error* "Can't update link")
  641.                                )
  642.                            )
  643.                        )
  644.                    )
  645.                )
  646.            )
  647.  
  648.            (if (equal kword "Create")
  649. ;              Create new link
  650. ;              This sample can't create DA (only Entity link)
  651.                (if (setq ent (getentity))
  652.                    (if (setq lpn (getlpn "\nEnter existing LPN or ? for list: "))
  653.                        (if (setq lst (getkeyval))
  654.                            (if (setq id (ase_linkcreate 2 1 4 ent 5 lpn 6 lst))
  655.                                (progn
  656.                                    (princ "ID of new link: ")
  657.                                    (princ id)
  658.                                )
  659.                                (*error* "Can't create link")
  660.                            )
  661.                        )
  662.                    )
  663.                )
  664.            )
  665.        )
  666.    )
  667.    (terpri)
  668. )
  669. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  670. ; asesmpsel - Links Statistic
  671. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  672. (defun asesmpsel ( / ss do lsel lpn_list lpn i)
  673.  
  674.    ;;  select objects
  675.    (if (setq ss (ssget))
  676.        (progn
  677.            
  678.            ;; create link selection  
  679.            (setq lsel (ase_lscreate -2 ss))
  680.  
  681.            ;; print total number of links in the link selection
  682.            (if (< 0. (print_lsqty lsel))
  683.                (progn
  684.                 
  685.                    // get the list of lpn, associated with link selection     
  686.                    (if (setq lpn_list (ase_lslpnames lsel)) 
  687.                        (progn 
  688.                            (setq i 0)     
  689.                            (while (setq lpn (nth i lpn_list))
  690.                                (progn  
  691.                                    (print_lpn_ls_info lpn lsel)
  692.                                    (princ "\n")      
  693.                                    (setq i (+ 1 i))
  694.                                ) 
  695.                            )
  696.                        )
  697.                        
  698.                        ;; error
  699.                        (*error* "Can't get list of LPNs, associated with link selection")
  700.                    )
  701.  
  702.                    ;; free link selection          
  703.                    (ase_lsfree lsel)
  704.                ) 
  705.            )               
  706.        )
  707.    )
  708.  
  709.    (terpri)
  710. )
  711. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  712. ; asesmperr - prints ASE error stack
  713. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  714. (defun asesmperr()
  715.    (*error* "ASE error stack:")
  716. )
  717.