Swap the values of two similarly-defined variables without a temporary holding variable
Page 1 of 1
Swap the values of two similarly-defined variables without a temporary holding variable
THIS CAN BE ACHIEVED BY USING %BITXOR BIF
This code fragment illustrates that technique.
D Var1 s 8a
D Var2 s 8a
/free
Var1 = 'PMS INFO';
Var2 = 'INFO PMS';
Var1 = %bitxor(Var1: Var2);
Var2 = %bitxor(Var1: Var2);
Var1 = %bitxor(Var1: Var2);
after this code runs, Var1 has the value "INFO PMS" and Var2 has the value "PMS INFO"
This code fragment illustrates that technique.
D Var1 s 8a
D Var2 s 8a
/free
Var1 = 'PMS INFO';
Var2 = 'INFO PMS';
Var1 = %bitxor(Var1: Var2);
Var2 = %bitxor(Var1: Var2);
Var1 = %bitxor(Var1: Var2);
after this code runs, Var1 has the value "INFO PMS" and Var2 has the value "PMS INFO"
Similar topics
» Is this possible to use the long field name in RPG that is defined with ALIAS keyword in DDS?
» How to write Data to Variable File using RPG ?
» Program Temporary Fix
» Remove Program Temporary Fix
» Comparison of DDS and SQL-Defined Files
» How to write Data to Variable File using RPG ?
» Program Temporary Fix
» Remove Program Temporary Fix
» Comparison of DDS and SQL-Defined Files
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|