Difference between revisions of "User Defined Function"

Jump to navigation Jump to search
284 bytes added ,  06:19, 15 July 2014
note about let and eval
imported>Odessa
m
imported>Odessa
(note about let and eval)
Line 4: Line 4:
UDFs may optionally return a single value of any type, using the [[SetFunctionValue]] command within them. They may optionally accept one or more arguments of any type, which are defined within curly braces:
UDFs may optionally return a single value of any type, using the [[SetFunctionValue]] command within them. They may optionally accept one or more arguments of any type, which are defined within curly braces:
<pre>
<pre>
scn SomeUDF
int arg1 ; * args are optional
int arg1 ; * args are optional
ref arg2
ref arg2
Line 9: Line 11:


Begin Function { arg1, arg2, arg3... }
Begin Function { arg1, arg2, arg3... }
     ; * body
     ; * do whatever like any other script
End  
End  
</pre>
</pre>
and called in a similar way to regular functions:
and called in a similar way to regular functions:
<pre>
<pre>
Call SomeUDF arg1, arg2, arg3...
scn SomeOtherScript
...
call SomeUDF arg1, arg2, arg3...
</pre>


let SomeVariable := Call SomeOtherUDF arg1
However, to assign the return to a variable, [[Let]] must be used rather than <b>set .. to ..</b>, and to use in a conditional, [[Eval|if eval]] rather than simply <b>if</b>:
<pre>
let SomeVariable := call SomeOtherUDF arg1


if eval (call SomeSuitableUDF)
if eval (call SomeSuitableUDF)
Line 79: Line 86:
*[[Eval]]
*[[Eval]]
*[[Let]]
*[[Let]]
*[[Script Compiler Override]]
==External Links==
==External Links==
*[http://fallout.bethsoft.com/eng/links/privacyredirect.php?site=http://www.loverslab.com/topic/26802-tutorial-nvse4-part-2-user-defined-functions-udfs/ Tutorial on User Defined Functions in NVSE 4]
*[http://fallout.bethsoft.com/eng/links/privacyredirect.php?site=http://www.loverslab.com/topic/26802-tutorial-nvse4-part-2-user-defined-functions-udfs/ Tutorial on User Defined Functions in NVSE 4]
[[Category:NVSE]]
[[Category:NVSE]]
Anonymous user

Navigation menu