Subject: (dsssl) access variable value with a string From: hoenicka_markus <hoenicka_markus@xxxxxxxxxxxxxx> Date: Fri, 16 Mar 2001 02:41:05 -0500 |
Hi, I need to access the value of a variable. The tricky part is that I construct the name of the variable as a string at runtime. I found some helpful hints on this problem in the archive (see http://www.biglist.com/lists/dssslist/archives/199712/msg00081.html), but that didn't quite work out for me. It is apparently not possible to directly access the variable via a string, but using an association list should do the trick. I tried to adapt the example code in the above mentioned message but this utterly fails for me. I have something like: (define foo "none") (define bar "none") (define styleparams (list (cons 'foo foo) (cons 'bar bar))) (define (symbol-value varname) (let ((a (assoc (string->symbol varname) styleparams))) (if a (cadr a) #f))) Then I try to get the value of say foo with: (symbol-value var) where var is the string "foo". Jade says: openjade:E: 1st argument for primitive "list-ref" of wrong type: "(foo . "none")" not a list Could anyone enlighten me how I get this straight? Thanks Markus DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: (dsssl) Japanese and OpenJade, Adam Di Carlo | Thread | Re: (dsssl) access variable value w, Brandon Ibach |
Re: (dsssl) Japanese and OpenJade, jany . quintard | Date | Re: (dsssl) access variable value w, Brandon Ibach |
Month |