Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
RPG IV Deprecated OpCodes in Free Format
has no ratings.
Published: 27 Dec 2011
Revised: 23 Jan 2013 - 1580 days ago
Last viewed on: 22 May 2017 (8137 views) 

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.

RPG IV Deprecated Operation Codes Published by: Bob Cozzi on 27 Dec 2011 view comments(3)

Deprecated Opcodes in /Free RPGIV

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

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: ChrisHiebert
Premium member *
Comment on: RPG IV Deprecated OpCodes in Free Format
Posted: 5 years 2 months 1 days 16 hours 23 minutes ago
Edited: Thu, 22 Mar, 2012 at 18:19:16 (1887 days ago)

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

 

Posted by: leumit39
Premium member *
Comment on: RPG IV Deprecated OpCodes in Free Format
Posted: 5 years 2 months 1 days 7 hours 28 minutes ago

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

Posted by: neilrh
Premium member *
Jackson, MI
Comment on: RPG IV Deprecated OpCodes in Free Format
Posted: 5 years 2 months 19 hours 1 minutes ago

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;