6-103
6 Programming
NJ-series CPU Unit Software User’s Manual (W501)
6-5 Programming Languages
6
6-5-3 Structured Text Language
Omitting Parameters
When you call a function block, you can omit parameters that are not required. The following table
shows when you can omit parameters.
OK: Possible (initial used), ---: A building error will occur.
Function Calls
Overview:
This statement calls a function.
Reserved Words: None
Statement Structure:
Give the output parameter to which the return value is assigned on the left side of the assignment
keyword (:=). On the right side, give the argument specifications (to pass the values of the specified
variables to the input variables of the called function) inside the parenthesis after the function name.
There are two methods of writing this statement, as shown in (1) and (2) below.
We recommend method (1) for program readability.
Notation Method 1:
IF (x0=TRUE) THEN
y1 := MyFUN(A:=x1, B:=x2, C=>y2);
END_IF;
• Ladder Diagram Expression
MyFUN: Function name
x0: Specifies whether to call the function.
A and B: Input variable names of the called function
x1 and x2: Input parameters of the called function
C: Output variable name of the called function
y1: Storage location for the return value from the called function
y2: Output parameters of the called function
• You can give the arguments in any order.
POU type
Variables for
the called
POU
Notation pattern
Omission
Parameters included Examples
FB Given (notation
method 1)
All parameters given instance(x:=a,y:=b,z:=c); OK
More than one parameter given instance(x:=a,y:=b);
One parameter given instance(y:=b);
No parameters given instance(x:=); ---
Given (notation
method 2)
All parameters given instance(a,b,c); OK
All parameters not given instance();
Only the first parameter given instance(a); ---
One parameter given instance(a, , );
More than one parameter given instance(a,b);
MyFUN
BC
A
EN ENO
x2
x1
y2
y1
x0