+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Super Member Bill Tillman's Avatar
    Using
    AutoCAD 2018
    Join Date
    Oct 2008
    Location
    Miami, FL
    Posts
    1,299

    Default What's With QUOTE in the Array

    Registered forum members do not see this ad.

    Some other developers here are sending some variables with values into the project I'm working on from C#.NET code. It looks simple but something I did not expect is happening.

    Code:
    (setq the_array '('(1 "R" 0 1) '(1 "L" 0 1) '(0 "L" 0 1) '(0 "R" 0 1) '(1 "R" 1 1) '(1 "L" 1 1)))
    If I examine the value of this variable called the_array it will show this:
    ((QUOTE (1 "R" 0 1)) (QUOTE (1 "L" 0 1)) (QUOTE (0 "L" 0 1)) (QUOTE (0 "R" 0 1)) (QUOTE (1 "R" 1 1)) (QUOTE (1 "L" 1 1)))
    I wasn't expecting the word "QUOTE" to show up in the array. I'm going to parse this text to do some drawing tasks so just deleting this text from the string I think I can handle. I'd like to know why it shows up in the first place. I think this guy's attempt to form a list of lists is not quite right.

    By removing the leading apostrophes I able to get the "QUOTE" text out of the value, but I have to admit I wasn't expecting this to happen. Nor were the other developers. And to be honest, I don't really need the " " around the text items in this either. So I'm going to change their input slightly to make it easier to parse this list of lists.
    It's deja vu, all over again.

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,591

    Default

    Registered forum members do not see this ad.

    The apostrophe or single quote is a shorthand equivalent for the AutoLISP quote function, therefore, by quoting a list which contains single quotes, you will see the AutoLISP quote function appear as the quoted list is a literal expression and hence is not evaluated. This is no different to quoting a list containing any other AutoLISP function or symbol. Since the entire list is already quoted as a literal expression, the quotes within the list are redundant - see here for more information.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

Similar Threads

  1. Tutorial: The Apostrophe and the Quote Function
    By Lee Mac in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 2nd Dec 2013, 01:28 pm
  2. Quote request
    By joey_hv in forum AutoCAD Drawing Management & Output
    Replies: 0
    Last Post: 16th Jul 2007, 08:25 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts