Scripting in StreamServe > Function files > User created script functions with arguments

User created script functions with arguments
You can create script functions that need arguments in the input. In the script function, you use #1 to retrieve the first argument in the input, #2 to retrieve the second argument, and so on.
You can also declare arguments to a function as local variable names. See Using local variable names as arguments to a function.
Example 34
Function
func FileNameString ()
{
$namestring = #1 + "_" + #2;
return $namestring;
}
In this example, the script function FileNameString uses two input arguments to create the string “customer name_invoice number”.
Function call
$nameAndNumber = FileNameString (&yourReference, &invoiceNumber);
Result
If &yourReference is Mike Jones, and &invoiceNumber is 1020, the value of $nameAndNumber is “Mike Jones_1020”.
 
Example 35
Function
func ChangeDateFormat ()
{
$month = #1(1,2); //Character 1 and 2 in input string
$day = #1(4,2); //Character 4 and 5 in input string
$year = #1(7,4); //Character 7 to 10 in input string
$newformat = $year + "-" + $month + "-" + $day;
return $newformat;
}
In this example, the script function ChangeDateFormat changes the date format mm/dd/yyyy to yyyy-mm-dd.
Function call
$dateFormatSWE = ChangeDateFormat (&invoiceDate);
Result
If &invoiceDate is 05/21/2008, the value of $dateFormatSWE is 2008-05-21.
 
OpenText StreamServe 5.6 Updated: 2013-03-01