Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
MOVE Opcode in Free Format
has no ratings.
Published: 02 Nov 2012
Revised: 23 Jan 2013 - 4082 days ago
Last viewed on: 28 Mar 2024 (4744 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.

MOVE Opcode in Free Format Published by: Bob Cozzi on 02 Nov 2012 view comments

Here's a routine I wrote a couple years ago that mimics the MOVE opcode for character fields. Remember that free format has the EVALR opcode which works similar to this, except it clears the target/results unless %SUBST is used on that target/result variable.

 

D CEEGSI          PR                  extproc('CEEGSI')      
D  nParmNum                     10I 0 Const                  
D  nParmDataType                10I 0                        
D  nParmCurLen                  10I 0                        
D  nParmMaxLen                  10I 0                        
D  szParmError                  12A   OPTIONS(*OMIT)         
                                                             
D moveR           PR                  OPDESC                 
D  target                    32767A   OPTIONS(*VARSIZE)      
D  source                    32767A   OPTIONS(*VARSIZE) Const

P moveR           B                                                
D moveR           PI                  OPDESC                       
D  target                    32767A   OPTIONS(*VARSIZE)            
D  source                    32767A   OPTIONS(*VARSIZE) Const      
D tLen            S             10I 0                              
D tDataType       S             10I 0                              
D tMaxLen         S             10I 0                              
D sLen            S             10I 0                              
D sDataType       S             10I 0                              
D sMaxLen         S             10I 0                              
 /free                                                             
    ceegsi(1 : tdataType : tLen : tMaxLen : *OMIT);                
    ceegsi(2 : sdataType : sLen : sMaxLen : *OMIT);                
      if (sLen > tLen);                                            
         EVALR %subst(target:1:tLen) = %subst(source:1:tLen);      
      else;                                                        
         %subst(target:tLen-(sLen-1):sLen) = %subst(source:1:sLen);
      endif;                                                       
 /end-free                                                         
P moveR           E                                                

 

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

COMMENTS