Tanzillo's LSort & double-quotes

Discussion in 'AutoCAD' started by chris villanueva, Jan 25, 2005.

  1. If the string has a double-quote, I get a "Error: malformed string on input"
    If I take out the double-quote, it works fine.

    Here's my list to sort (notice the double-quote on the line 1'-0\"=1'):
    (setq lresult_sorted
    '(
    ("1" "privbig" "LTR1:Z" "FSHT1:E-10")
    ("1" "PRIVSML" "LTR:BB" "FSHT:E-10")
    ("1" "PRIVSML2" "LTR:C" "FSHT:E-10")
    ("4" "SYML5" "VALUE:R" "DESCRIPTION:")
    ("1" "circid2" "GRAPHIC:20")
    ("1" "circid4" "GRAPHIC:00")
    ("1" "sqid1""GRAPHIC:00")
    ("1" "sqid2" "GRAPHIC:00")
    ("1" "hexid1" "GRAPHIC:00")
    ("1" "hexid2" "GRAPHIC:00")
    ("1" "hexdbl1" "TYPEID:" "NUMBER:")
    ("1" "triid1" "GRAPHIC:00")
    ("1" "diamid1" "GRAPHIC:00")
    ("1" "diamid2" "GRAPHIC:00")
    ("1" "SYML5" "VALUE:J" "DESCRIPTION:")
    ("1" "syml1" "VALUE:J" "DESCRIPTION:J-BOX, CEIL. MTD.")
    ("1" "switch1a" "LEFTXT:b" "RIGHTXT:3")
    ("1" "switch1a" "LEFTXT:" "RIGHTXT:2")
    ("2" "switch1a" "LEFTXT:3" "RIGHTXT:a")
    ("5" "F_NAME0" "FILE_NAME:Z:\\ACAD\\PROJECTS\\1001\\_TEST_R16 XREFS:
    _TEST12 XREF2 XREF1")
    ("1" "LASTEDIT" "LAST_EDIT:LAST SAVE: 01/07/05 @ 08:58:57 BY: CV PLOT SC
    1'-0\"=1'")
    ("1" "PRIVSML" "LTR:BB" "FSHT:x")
    ("2" "privbig" "LTR1:B" "FSHT1:E-10")
    )
    )

    (setq Col3_width
    (apply 'max
    (mapcar
    '(lambda (record)
    (strlen (caddr record))
    )
    lresult_sorted
    )
    )
    )
    (defun by-qty+tag (item)
    (strcat (car item) (ljust (cadr item) Col3_width))
    )

    (setq lresult_sorted (LSort lresult 'by-qty+tag))

    This is the LSort I have:

    (defun lsort (input fun / i)
    (setq i -1)
    (mapcar
    '(lambda (rec)
    (nth (cdr (read (strcat "(" rec ")" ))) input)
    )
    (acad_strlsort
    (mapcar
    '(lambda (rec / input)
    (strcat "\""
    (apply fun (list rec))
    "\" . "
    (itoa (setq i (1+ i)))
    )
    )
    input
    )
    )
    )
    )

    Tony, do you have a revised version?

    Thanks,
    Chris Villanueva
     
    chris villanueva, Jan 25, 2005
    #1
  2. The LSORT you're using is ancient, and has problems.

    Unless you're still running R13 or R14 without Visual LISP,
    there's no need to use that function.

    Why not just use VL-SORT ?
     
    Tony Tanzillo, Jan 25, 2005
    #2
  3. Found your version of vl-sort.
    Switched to that.
    All fine, now.

    Thanks.
     
    chris villanueva, Jan 27, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.