STRCAT to Create a LIST name

Discussion in 'AutoCAD' started by jonesr, Jan 22, 2004.

  1. jonesr

    jonesr Guest

    I am defining a list and then trying to reference it by building it's name
    using STRCAT. STRCAT returns "lst-id-1" which obviously is not the same as
    the LIST name lst-id-1.

    Depending on the Current Tab the user is on the list will be different (they
    are all predefined in my full body of code.

    (defun C:VPLAY ()
    (setq lst-ID-1 '("A-BASE-CLNG"
    "A-BASE-CLNG-MAINS"
    "A-BASE-DIMS"
    "A-BASE-EQPM"
    )
    )
    (foreach layr (strcat "lst-" (getvar "CTab"));;; <<==============
    PROBLEM
    (if (tblsearch "Layer" layr)
    (command "VPlayer" "F" layr "" "")
    nil
    ) ;_ end of if
    ) ;_ end of foreach
    ) ;_end of defun

    How can I overcome this problem?
     
    jonesr, Jan 22, 2004
    #1
  2. jonesr

    jonesr Guest

    Yes exactly. There are prededined lists in my code for tab ID-1, ID-2, ID-3,
    etc. I'm trying to "foreach" using the return from the STRCAT line but it
    fails. Basically, how can I "build" the name of the (valid) list I want to
    submit to the FOREACH function?
     
    jonesr, Jan 22, 2004
    #2
  3. jonesr

    jonesr Guest

    BINGO! Exactly what I wan trying to do - convert the string into a symbol.
    Help was not much help in this instance.
    Thanks.
     
    jonesr, Jan 22, 2004
    #3
  4. (strcat) just returns a concatenated string.

    You need to convert that into a symbol, and then
    evaluate it.

    Try this:

    (foreach layr (eval (read (strcat "lst-" (getvar "ctab"))))
    ; blah blah
    )
     
    Tony Tanzillo, Jan 22, 2004
    #4
  5. jonesr

    Jeff Mishler Guest

    OK, now I get it! So, what Tony said is what you are looking for....
    (eval (read (strcat .....

    Jeff
     
    Jeff Mishler, Jan 22, 2004
    #5
  6. jonesr

    Adesu Guest

    Hi ECCAD,I correction your code if not false

    _$ (setq lst-ID-1 (list ("A-BASE-CLNG" "A-BASE-CLNG-MAINS" "A-BASE-DIMS"
    "A-BASE-EQPM")))
    ; error: bad function: "A-BASE-CLNG"

    _$ (setq lst-ID-1 (list "A-BASE-CLNG" "A-BASE-CLNG-MAINS" "A-BASE-DIMS"
    "A-BASE-EQPM"))
    ("A-BASE-CLNG" "A-BASE-CLNG-MAINS" "A-BASE-DIMS" "A-BASE-EQPM")
     
    Adesu, Oct 22, 2004
    #6
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.