STRCAT to Create a LIST name

jonesr

Usenet Archive
Joined
Jun 27, 2003
Messages
93
Reaction score
0
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?
 
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?
 
BINGO! Exactly what I wan trying to do - convert the string into a symbol. Help was not much help in this instance.
Thanks.
 
(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 )
 
OK, now I get it! So, what Tony said is what you are looking for....
(eval (read (strcat .....

Jeff
 
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")
 

Latest threads

Back
Top