Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
In i5/OS at V5.1 and later, RPG IV supports the /FREE specification. The /free spec does not support several traditional operation codes. Many are deprecated; being replaced by equivalent or near equivalent built-in functions, as follows:
OpCode | /Free Equivalent |
---|---|
ALLOC | %ALLOC() |
BITOFF | %BITAND() |
BITON | %BITOR() |
CHECK | %CHECK |
CHECKR | %CHECKR |
DO | FOR |
LOOKUP | %LOOKUPxx |
MHHZ, MHLZ, MLHZ, MLLZ | N/A |
MOVE | EVALR with %SUBST() |
MOVEL | EVAL with %SUBST() |
OCCUR | %OCCUR() |
REALLOC | %REALLOC() |
SCAN | %SCAN() |
SQRT | %SQRT() |
TIME | %TIMESTAMP |
XLATE | %XLATE |
Z-ADD, Z-SUB | EVAL |
This might be helpful.
Example using EVAL/EVALR instead of Move/MoveL
D FLD1 S 30A D FLD2 S 10A D FLD3 S 35A C MOVEL FLD1 FLD3 C MOVE FLD2 FLD3 // Semi - Equivalent Free Code: /FREE FLD3 = FLD1; EVALR %SUBST( FLD3 :%LEN(FLD3)-%LEN(FLD2)+1) = Fld2; /END-FREE
why statement
C MOVEL FLD1 FLD3
Why are worse than :
/FREE
EVALR %SUBST( FLD3 :%LEN(FLD3)-%LEN(FLD2)+1) = Fld2;
/END-FREE
?
Statement
EVALR %SUBST( FLD3 :%LEN(FLD3)-%LEN(FLD2)+1) = Fld2;
very ugly
At first I looked at the sample and thought why not just use:
FLD3 = FLD1 + FLD2;
But then I noticed that FLD3 is only 35A, while FLD1 is 30A and FLD2 is 10A, so to replicate the result of the 2 moves in fixed you could instead use:
FLD3 = %subst(FLD1:1:25) + FLD2;