transfering a tekststing to an variable
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
transfering a tekststing to an variable

 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
Marcel Janmaat
Guest





Posted: Tue Jan 04, 2005 7:44 pm    Post subject: transfering a tekststing to an variable Reply with quote

Hello there,

Maby I 'm being foolish here, but...

If I have

(setq a '("variable" "1" "This is a variable"))

How can I transfer "variable" to variable like

(setq variable ; meaning (car a) transferd to variable
(cadr a)
)

Regards M

Back to top
Tom Smith
Guest





Posted: Tue Jan 04, 2005 7:58 pm    Post subject: Re: transfering a tekststing to an variable Reply with quote

(set (read (car a)) (cadr a))
Back to top
Marcel Janmaat
Guest





Posted: Tue Jan 04, 2005 8:53 pm    Post subject: Re: transfering a tekststing to an variable Reply with quote

Thanx! That was easy! Never had to use read before.

"Tom Smith" <nospam> schreef in bericht news:41daaec5_3@newsprd01...
Quote:
(set (read (car a)) (cadr a))



Back to top
Tom Smith
Guest





Posted: Tue Jan 04, 2005 9:45 pm    Post subject: Re: transfering a tekststing to an variable Reply with quote

read is useful when you need to create a symbol name, as in a case like
this.

Also note the set instead of setq. Setq is a contraction of "set quote"
where the first argument is ro be taken literally (quoted) as in (setq
variable 1) which is the same as (set (quote variable) 1) or (set 'variable
1).

But in your case the first argument was something that needed to be
evaluated -- (read (car a)) -- so you don't want to suppress evaluation by
quoting it.
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Contact Us
Powered by phpBB