| Run Time Array in RPG AS400 |
Introduction to Run-Time Array
Run Time Array will be loaded during the run time i.e. program execution time and the values will be dynamic in nature.
Code Example of Run-Time Array in RPG
RPG Code in Fixed format for Run Time Array in AS400
*Header Specification
HDebug(*Yes)
HOption(*NoDebugio)
* program variables
D Array S 10A DIM(10)
*
D Index S 10i 0
*
C EVAL Index = 1
C DOW Index <=10
C EVAL Array(Index) = 'TEST' +
C %Trim(%Char(Index))
C Array(Index) DSPLY
C EVAL Index = Index + 1
C ENDDO
C EVAL *INLR = *ON
RPG Code in /Free format for Run Time Array in AS400
*Header Specification
HDebug(*Yes)
HOption(*NoDebugio)
* program variables
D Array S 10A DIM(10)
*
D Index S 10i 0
*
/Free
// Begin program
Index = 1;
Dow (Index <=10);
Array(Index) = 'TEST' + %Trim(%Char(Index));
DSPLY Array(Index);
Index = Index + 1;
EndDo;
//Set Last Record Indicator ON
*Inlr = *ON;
/End-Free
RPG Code in fully Free format for Run Time Array in AS400
**FREE
ctl-opt debug(*yes);
ctl-opt Option(*NoDebugio);
dcl-s Array char(10) DIM(10);
dcl-s Index int(10);
// Begin program
Index = 1;
Dow (Index <=10);
Array(Index) = 'TEST' + %Trim(%Char(Index));
DSPLY Array(Index);
Index = Index + 1;
EndDo;
//Set Last Record Indicator ON
*Inlr = *ON;
Program Output
DSPLY TEST1 DSPLY TEST2 DSPLY TEST3 DSPLY TEST4 DSPLY TEST5 DSPLY TEST6 DSPLY TEST7 DSPLY TEST8 DSPLY TEST9 DSPLY TEST10
Related Post
Read also :
- Array and Types of Array in RPG AS400
- Compile Time Array in RPG AS400
- Using PERRCD keyword in compile Time Array in RPG AS400
- Pre-Run Time Array in RPG AS400
- Lookup an Array element in RPGLE AS400
- Sorting Array (SORTA) opcode for ARRAY in RPG AS400
- XFOOT opcode for ARRAY in RPG AS400
- Using keywords QUALIFIED, LIKEDS, and DIM with data structures
- Array Data Structures in RPG AS400