Crystal syntax custom functions are expression oriented, like Crystal syntax formulas. You can use either syntax formats listed below.
Function ([argList])
expressions
Function ([argList])
(
expressions
)
argList syntax
Optional. A list of variables representing arguments that are passed into the function when it is called. Multiple variables are separated by commas. An empty argList is allowed; however, the parentheses surrounding argList are not optional and must be used even when argList is empty.
[Optional] simpleType [Range] [Array] varName [:=defaultValue]
Optional
Optional. Indicates if the argument can be omitted when the custom function is called. If an argument is optional, all subsequent arguments must be optional as well. If you supply a value for an optional argument when calling the function, then you must supply values for each preceding argument.
simpleType
Required. You can use one of:
Range
Optional. Specifies if the argument is a range variable.
Note: You cannot use Boolean Ranges.
Array
Optional. Specifies if the argument is an array variable.
varName
Required. The name of the variable representing the argument.
:=defaultValue
Required for optional arguments. defaultValue is a constant or constant expression; that is, it's an expression involving no variables that can be simplified at compile time to a constant value. If an optional argument is omitted when calling a custom function, then the default value for the argument will be used.
expressions
Required. The value returned by the Crystal syntax custom function is the value of the last expression evaluated in the expression sequence. The syntax is the same as that in Crystal syntax formulas.
Scope
Variable declarations within a custom function are local scope by default. This contrasts with variable declarations in Crystal syntax formulas, where global scope is the default.