Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| user_defined_functions [2016/09/22 02:36] – external edit 127.0.0.1 | user_defined_functions [2020/05/10 03:08] (current) – removed admin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== User Defined Function ===== | ||
| - | User Defined Functions can improve the re-usability of your mscripts. User defined functions are first declared in // | ||
| - | |||
| - | Below is an example of a user function: | ||
| - | |||
| - | {{http:// | ||
| - | |||
| - | ---- | ||
| - | |||
| - | ==== Declare User Defined Function ==== | ||
| - | |||
| - | You can create as many user defined functions as you want. Each user defined function is declared with //func// tag that has a //name// attribute . | ||
| - | < | ||
| - | <log msg=" | ||
| - | <action code=" | ||
| - | </ | ||
| - | |||
| - | User defined function can take 0 or any number of parameters. Parameters are specified as key=value pairs. Multiple parameters are passed in separately, e.g. | ||
| - | |||
| - | $callFunc(' | ||
| - | |||
| - | Within the //func// tag, you add any mscript tags and methods. You can access the parameters passed into the function with mscript method // | ||
| - | |||
| - | ---- | ||
| - | ==== Return Value ==== | ||
| - | Optionally you can return a value. You can do so with mscript method // | ||
| - | |||
| - | Below is an example of a user defined function that returns a full name: | ||
| - | |||
| - | < | ||
| - | <action code=" | ||
| - | </ | ||
| - | |||
| - | |||
| - | ---- | ||
| - | ==== Call User Defined Function ==== | ||
| - | To call this user defined function, use mscript method // | ||
| - | |||
| - | < | ||
| - | |||
| - | |||
| - | ---- | ||
| - | ==== Accessing Parameters==== | ||
| - | Inside the user function, you can access the input parameters with $getFuncParam(' | ||
| - | |||
| - | |||
| - | User function may call another user function with // | ||
| - | |||
| - | |||
| - | |||
| - | |||