| View previous topic :: View next topic |
| Author |
Message |
F-3000
Joined: 06 Dec 2010 Posts: 63 Location: Next to polarbear
|
Posted: Sun Mar 13, 2011 12:57 pm Post subject: %1 also contains %2 within function |
|
|
Inside function:
| Code: | | #showme (you used call %1 with value %2); |
Alias that calls the function:
| Code: | | #alias {.prefs} {@prefs{%0}} |
I trigger the alias...
Output:
| Code: | | (you used call where 30 with value 30) |
Here's the whole function:
| Code: | #function {prefs}
{
#showme ;
#if {"%0" == "show"}
{
#showme Preferences;
#foreach {$prefs[]} {tmp}
{
#showme $tmp = $prefs[$tmp];
};
};
#elseif {"$prefs[%1]" != ""}
{
#if {"$prefs[%1]" == "off"} {#var prefs[%1] on};
#elseif {"$prefs[%1]" == "on"} {#var prefs[%1] off};
#elseif {%2 != ""} {#var prefs[$%1] {%2}};
#showme Preference %1 is now $prefs[%1].;
};
#else
{
#showme (you used call %1 with value %2);
#showme Preferences -- help;
#showme ;
#showme syntax:;
#showme .prefs argument [value - if not on/off];
#showme ;
#showme arguments:;
#showme show Show all prefs and their values;
#showme [pref] Toggles on/off preference, other type is set to default;
#showme [pref] <value> Toggles on/off, other type is set to <value>;
#showme ;
};
#var {result} {#nop};
} |
This bug does not limit to this example. Same bug is in 2.00.4 and 2.00.6 as I updated to check if newer would have fixed that. (also, the function is unfinished (regarding feature mentioned in the "help"), so no need to mention about that) |
|
| Back to top |
|
 |
Scandum Site Admin
Joined: 03 Dec 2004 Posts: 3274
|
Posted: Sun Mar 13, 2011 9:04 pm Post subject: |
|
|
You call the function with one argument, so %2 is invalid, though it probably holds the value that was assigned to it by the alias.
If you want two arguments you could use:
#alias {.prefs} {@prefs{%1;%2}
I'm not sure why you're calling a function though, an alias is basically a function that doesn't return a value. |
|
| Back to top |
|
 |
F-3000
Joined: 06 Dec 2010 Posts: 63 Location: Next to polarbear
|
Posted: Mon Mar 14, 2011 6:36 am Post subject: |
|
|
So, the %2 is more the bug than the %1?
I'm just too used to functions (from PHP). Maybe I should rebuild the alias to include the content of the function...
Thanks for the hint.  |
|
| Back to top |
|
 |
|