TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: whdjr on December 23, 2004, 11:03:29 AM

Title: List trouble
Post by: whdjr on December 23, 2004, 11:03:29 AM
Can someone tell why this doesn't work?
It is supposed to strip the "%%U" from the 1st string in the second llist in each of the 5 larger lists.
Code: [Select]
(defun c:test (/ lst this)
  (setq lst '(((("338" . "A231")("%%UEQUIPMENT STORAGE" . "A232")("EXTG CERAMIC TILE" . "A233")) "A230")
    ((("305" . "886D")("%%UTOILET" . "886E")("NEW CONC." . "886F")) "886C")
    ((("319" . "885E")("%%UCOACH" . "885F")("EXTG CONC." . "8860")) "885D")
    ((("317" . "5E37")("%%U9TH GRADE DRESSING" . "5E38")("EXTG QUARRY TILE" . "5E39")) "5E36")
    ((("301" . "1E1A")("%%UCOVERED WALK" . "1E1B")("EXTG CONC" . "1E1D")) "1E19")
   )
  )
  (if (wcmatch (strcase (car (setq this (cadaar lst)))) "%%U*")
    (setq lst (subst (cons (substr (car this) 4) (cdr this))
    this
    lst
     )
    )
    lst
  )
  (print lst)
)
Title: List trouble
Post by: Jeff_M on December 23, 2004, 11:44:55 AM
Hi Will, give this a try:
Code: [Select]

(defun c:test (/ lst this)
  (setq   biglst '(((("338" . "A231")("%%UEQUIPMENT STORAGE" . "A232")("EXTG CERAMIC TILE" . "A233")) "A230")
        ((("305" . "886D")("%%UTOILET" . "886E")("NEW CONC." . "886F")) "886C")
        ((("319" . "885E")("%%UCOACH" . "885F")("EXTG CONC." . "8860")) "885D")
        ((("317" . "5E37")("%%U9TH GRADE DRESSING" . "5E38")("EXTG QUARRY TILE" . "5E39")) "5E36")
        ((("301" . "1E1A")("%%UCOVERED WALK" . "1E1B")("EXTG CONC" . "1E1D")) "1E19")
       )
  )
  (foreach lst biglst
    (if (wcmatch (strcase (car (setq this (cadar lst)))) "%%U*")
      (setq newlst (cons (subst (cons (substr (car this) 4) (cdr this)) this (car lst)) (cdr lst))
   biglst (subst newlst lst biglst))
      )
    )
  (print biglst)
)
Title: List trouble
Post by: whdjr on December 23, 2004, 01:29:28 PM
That works Jeff. Thanks.