Using Function Calls in Functions and Programs
- Updated2026-04-22
- 1 minute(s) read
Using Function Calls in Functions and Programs
You can call functions within the program and within functions.
The syntax corresponds to the function description without specifying the data types. Specify all other characters and keywords (for example, ref and [ , ]) with the data type.
Call functions without return values, with one return value, or with multiple return values.
Without Return Values
Example
program
section globals
//definition of global variables
text Message_Error
endsection
sendMessage(Message_Error)
endprogram
// Declaration of functions
function sendMessage(text t)
sys:logInfo(sys:ui, "%s", t)
endfunction
One Return Value
Example
program
section globals
int32 value
int32 absValue
endsection
absValue = myAbs(value)
endprogram
function int32 result = myAbs(int32 a)
if a < 0 then
result = a * -1
else
result = a
endif
endfunction
Multiple Return Values, Multiple Parameters
Example
program
section globals
int32 myState, myMode
real64 resultVariable, input1
endsection
[myState, resultVariable] = myAbs(input1, myMode)
endprogram
function [int32 state, real64 result] = myAbs(int32 mode, real64 var)
if var:isValid then
state = -1
result = 0.0
else
state = 1
switch mode
case 1
if var < 0 then
result = -1 * var
else
result = var
endif
case 2
result = abs(var)
default
result = var
endswitch
endif
endfunction