2-331
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Data Movement Instructions
2
Exchange
Exchange
The Exchange instruction exchanges the values of two variables.
The Exchange instruction exchanges the values of data to exchange InOut1 and InOut2. You can spec-
ify enumerations, structures, or structure members for InOut1 and InOut2.
The following figure shows a programming example. The values in variables abc and def are
exchanged.
Instruction Name FB/FUN Graphic expression ST expression
Exchange Data Exchange FUN Exchange(InOut1, InOut2);
Variables
Name Meaning I/O Description Valid range Unit Default
InOut1 and
InOut2
Data to
exchange
In-out Data to exchange Depends on data type.
--- ---
Out Return
value
Output Always TRUE TRUE only --- ---
Boolean
Bit strings Integers
Real
numbers
Times, durations,
dates, and text strings
BOOL
BYTE
WORD
DWORD
LWORD
USINT
UINT
UDINT
ULINT
SINT
INT
DINT
LINT
REAL
LREAL
TIME
DATE
TOD
DT
STRING
InOut1
OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK
An enumeration, structure, or structure member can also be specified.
InOut2 Must be same data type as InOut1.
Out OK
Function
(@)Exchange
EN ENO
InOut1
InOut2
Out
Exchange(abc, def);
LD ST
abc abc
def
def
Exchange
EN ENO
InOut1
InOut2
Out