Type Conversions; Value Pass-Along & Reference Pass-Along - Omron SCARA YRCX Series Programming Manual

Robot controller
Hide thumbs Also See for SCARA YRCX Series:
Table of Contents

Advertisement

7

Type Conversions

1
2
3
4
8
Value Pass-Along & Reference Pass-Along
5
6
3-6
Chapter 3 Variables
When different-type values are assigned to variables, the data type is converted as described below.
• When a real number is assigned to an integer type:
The decimal value is rounded off to the nearest whole number.
• When an integer is assigned to a real type:
The integer is assigned as it is, and is handled as a real number.
• When a numeric value is assigned to a character string type:
The numeric value is automatically converted to a character string.
• When a character string is assigned to numeric type:
This assignment is not possible,and an error will occur at the program is execution. Use the "VAL"
command to convert the character string to a numeric value, and that value is then assigned.
A variable can be passed along when a sub-procedure is called by a CALL statement. This pass-
along can occur in either of two ways: as a value pass-along, or as a reference pass-along.
Value pass-along
With this method, the variable's value is passed along to the sub-procedure. Even if this value is
changed within the sub-procedure, the content of the call source variable is not changed.
A value pass-along occurs when the CALL statement's actual argument specifies a constant, an
expression, a variable, or an array element (array name followed by (subscript)).
Reference pass-along
With this method, the variable's reference (address in memory) is passed along to the sub-
procedure. If this value is changed within the sub-procedure, the content of the call source variable
is also changed.
A reference pass-along occurs when the CALL statement's actual argument specifies an entire array
(an array named followed by parenthetical content), or when the actual argument is preceded by
"REF".
Value pass-along & reference pass-along
  
Value pass-along
X%=5
CALL *TEST( X% )
PRINT X%
HALT
' SUB ROUTINE
SUB *TEST( A% )
A%=A%*10
END SUB
The X% value remains as "5".
Execution result:
Reference pass-along
X%=5
CALL *TEST( REF X% )
PRINT X%
HALT
' SUB ROUTINE
SUB *TEST( A% )
A%=A%*10
END SUB
The X% value becomes "50".
Execution result:
33302-R7-00

Advertisement

Table of Contents
loading

Table of Contents