This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

parsing variables

Old posts that have not been replied to for several years.
Locked
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

parsing variables

Post by Ofloo »

Code: Select all

return [join [lrange [string map {%NAME% $var(name)} $arg] 0 end]]
how could i make the variable pars .. cause it shows the var name not the value of the var...

oh could make a difference its reading this from a html file then parses the variables like a template .. suggestions ..
XplaiN but think of me as stupid
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: parsing variables

Post by user »

Code: Select all

[list %NAME% $var(name)]
instead of

Code: Select all

{%NAME% $var(name)}
Or instead of setting 'var(name)' you could make the element name the same as the text to be replaced by its value... 'var(%NAME%)' then use 'string map [array get var] ...' to do the mapping.

http://tcl.tk/man/tcl8.5/TclCmd/Tcl.htm#M10 - "No substitutions are performed on the characters between the braces except for backslash-newline substitutions"
http://tcl.tk/man/tcl8.5/TclCmd/string.htm#M34 - "charMap is a list ..."
Have you ever read "The Manual"?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

ok sounds logic altho i don't competly get it

what about if u do

set var {
%VAR% $variable
%VAR2% $variable2
}

and use

foreach and import it


global var
foreach data [split [join [lrange $var 0 end]] \n] {
set data [string map [list [lindex $data 0] [join [lrange $arg 1 end]]] $data]
}

for some reason that won't parse .. either ive tryed various ways tryed adding list in the before i split after i split .... and so on ive tryed list $var doesn't seem to be working either for some reason it won't parse.. i know its probably a logic reason but i don't understand why all i got from the manual was that that once u open it u should close it i know i know i haveing bit trouble with technical english langue .. sorry hehe
XplaiN but think of me as stupid
Locked