Author Topic: List trouble  (Read 2082 times)

0 Members and 1 Guest are viewing this topic.

whdjr

  • Guest
List trouble
« 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)
)

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
List trouble
« Reply #1 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)
)

whdjr

  • Guest
List trouble
« Reply #2 on: December 23, 2004, 01:29:28 PM »
That works Jeff. Thanks.