|
The Raven Magician
Joined: 13 Oct 2000 Posts: 463
|
Posted: Tue Nov 14, 2006 3:57 am
Named Parameters in User Functions |
How do named parameters to user defined functions work? As a test, I defined a simple variable for use as a function. It merely returns a '1' if you pass it the text 'yes', and a 0 otherwise.
#VAR TestFunc {%if(%1="yes",1,0)}
In the GUI, I gave it a named parameter, 'input', and tried altering it like this:
#VAR TestFunc {%if($input="yes",1,0)}
That results in a syntax error, no such variable. How are named parameters used in variable functions?
(please note, my alterations were done via the GUI, the illustrations here are for easy copying).
Also, how is the named parameter 'list' separated? Spaces? Commas? Pipes? There is no helpfile that I can find that covers this. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Nov 14, 2006 5:23 am |
The syntax is this:
#func TestFunc($param1,$param2) {%if($param1,$param2)}
or whatever. For your example, you just need to define the variable after the function name - it's the same as aliases. You should also be using the #function command to create functions on the command line. If you're creating them in the GUI, just drop the names of the paramers (without the $) into the "params" field at the bottom of the editor, under the vartype menu. They're separated by commas. Copy the command above for an example.
At the moment, user functions are bugged, though, as noted here and here. |
|
|
|
|
|
|
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
|
|