|
gmueller Apprentice
Joined: 06 Apr 2004 Posts: 173
|
Posted: Fri Aug 18, 2006 11:53 pm
hrm |
I want to have variables in the string that %expandlist expands, but expandlist wants to evaluate them before outputting them... if there is a way to inhibit the expansion of a string that would be great to know.
EXAMPLE1
how do you get around this:
#VAR stringlist {}
#ADDITEM stringlist "@"
#ADDITEM stringlist "bob"
#ALIAS aliastest {<%expandlist(@stringlist,"")>}
---------------------------------------
output
#ALIAS aliaslist {@|bob}
it puts in a pipe symbol.
EXAMPLE2
#var stringlist = "#IF (@bob = 0) {kill bob}"
#ALIAS aliastest {<%expandlist(@stringlist,"")>}
---------------------------
output
#ALIAS aliastest {#IF (0 = 0) {kill bob}}
----------------------------
any suggestions?
any alternative structures that can get this same effect?
the example in ex 2. is closest to what I'm trying to do. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Aug 19, 2006 3:42 am |
I think maybe you should start with a description of what you want to do, or what you are trying to do. You have described how your trying to do something. Obviously that HOW isn't working, but if we understood what that SOMETHING was we could suggest another way.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
gmueller Apprentice
Joined: 06 Apr 2004 Posts: 173
|
Posted: Sat Aug 19, 2006 7:27 am dynamic aliases |
this is what I want to do:
list = "a|b|c"
#ALIAS newalias {<%expandlist(@list,"")>}
and have the result be:
#ALIAS newalias {abc}
where a, b, c potentially contain variables or lists of commands...
such as:
list = "#IF (@class = syssin) {hypnotise @tar}|; |#IF (@balance = 1) {seal @tar 10}"
obviously this wont work, because expandlist evalutates the variables during expansion, but, im suprised that it puts a pipe in (see EX1) even when the expansion character is a "". I was trying to fool expandlist by putting @ in as a seperate list element. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Aug 19, 2006 2:28 pm |
What you are looking for is controlled expansion.
#EXEC {%concat("#ALIAS newalias {",%replace(%expand(@list,1),"|",""),"}")} |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
scudfly Newbie
Joined: 19 Aug 2006 Posts: 2 Location: China
|
Posted: Sat Aug 19, 2006 2:29 pm |
Hi,
You could do the following:
#FUNC list "#IF (@class = syssin) {hypnotise @tar}|#IF (@balance = 1) {seal @tar 10}"
#ALIAS newalias {<%expandlist(@list,";")>}
I guess the output is what you expect;-)
Brs, Qi Fei |
|
|
|
gmueller Apprentice
Joined: 06 Apr 2004 Posts: 173
|
Posted: Sat Aug 19, 2006 9:25 pm |
scudfly your #FU should be a #VAR I believe... and the output would have similar problems as those I discussed.
------------------
ahhhh yes Vijilante that is perfect... can you explain why the %expand is inside of the replace? it would seem that this would be the same as:
#EXEC {%concat("#ALIAS newalias {", %replace(@list,"|",""), "}")}
because the %expand version of list would be input into the replace command... |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Sun Aug 20, 2006 2:56 am |
No, #FUNC is a function.
It exports as #var for some unknown reason.
Think of func as a var with code. |
|
|
|
scudfly Newbie
Joined: 19 Aug 2006 Posts: 2 Location: China
|
Posted: Sun Aug 20, 2006 3:51 am |
#FUNC is not like #VAR, it will NOT expand variables,
so the output is correct.
I've wrote some useful script with the help of #FUNC for years,
you could just try and see the output. |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Sun Aug 20, 2006 6:42 pm |
Slight Derail ahead
#FUNC name {code here} is the same as #VAR name "code here" but not the same as #VAR name {code here}, the differance has to do with the use of "" (to not expand/evaluate on creation) and {} (to expand on creation}
A function is just a variable that is not expanded when it is created. The problem with exporting scripts with funcs is that they get exported as #VAR name {code here} instead of #VAR name "code here" and when they are imported they get expanded. |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Sun Aug 20, 2006 7:29 pm |
yeah, that's what i said......kinda...
|
|
|
|
|
|