If you group the repetitive values into an array list inside the command, then they would be easier to access.


PARM KWD(VARIABLE) TYPE(VARTYPE1) MAX(20) PROMPT('Change variable/value')

VARTYPE1: ELEM TYPE(*CHAR) LEN(10) MIN(1) EXPR(*YES) CASE(*MIXED) INLPMTLEN(10) PROMPT('Variable')
ELEM TYPE(*CHAR) LEN(50) MIN(1) EXPR(*YES) CASE(*MIXED) INLPMTLEN(50) PROMPT('Value')


Then to use them in the command:
CMDNAME VARIABLE((x xx) (y yy))



Then you can code the input as an array.

//Count Groups, Offset to Each Element, Count fields passed in Element, Element
// 2+ 2*20 + 20 * (2+ 10 +50) = 1282
Dcl-Ds VarParam Len(1282) TEMPLATE QUALIFIED;
Count Int(5) INZ;
Offset Int(5) DIM(20);
End-Ds;

Dcl-Ds input_Variable TEMPLATE QUALIFIED;
Count Int(5) inz;
Var Char(10) INZ;
VarVal Char(50) INZ;
End-Ds;

Dcl-S EntVarCount LIKE(VarParam.COUNT) INZ(0);
Dcl-S ptr_Entvar Pointer;
Dcl-Ds P#Entvars LIKEDS(input _Variable) BASED(ptr_Entvar);

Dcl-s LoadedCount Int(10) inz(0);
Dcl-Ds loadedVars LIKEDS(input _Variable) Dim(20);

Dcl-Pi *N;
EntVars LIKEDS(VarParam) OPTIONS(*VARSIZE);
End-Pi;

IF %PARMS >= %PARMNUM(EntVars);
EntVarCount = Entvars.Count;
For idx = 1 to EntVarCount;
ptr_Entvar = %ADDR(EntVars) + Entvars.Offset(idx);
LoadedCount += 1;
loadedVars(LoadedCount) = P#Entvars;
Endfor;
Endif;





You might also be able to get away with this definition.
However, from what I recall the array elements may be presented in reverse order in memory.
So using the pointer and address to access them would return them in the expected order.
Dcl-Ds VarParam Len(1282) TEMPLATE QUALIFIED;
Count Int(5) INZ;
Offset Int(5) DIM(20);
var Likeds(input_Variable) Dim(20);
End-Ds;

Chris Hiebert
Senior Programmer/Analyst
Disclaimer: Any views or opinions presented are solely those of the author and do not necessarily represent those of the company.


-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Roger Harman
Sent: Thursday, March 5, 2020 4:32 PM
To: RPG programming on the IBM i (AS/400 and iSeries) <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Redefining input parms into an array

I have a command processing program I'm writing in RPG.  I have 3 fixed parms and then a recurring pair of parms (20 pair).

I'm having problems getting a redefine to work on the PR/PI.

dcl-ds dsParms_T template;
ParmIn char(10);
ParmOut char(50);
end-ds;

dcl-pr (or pi)har(1);
  ReqdParm1 char(1);
  ReqdParm2 char(2);
  ReqdParm3 char(4);
OptionalParm01_1 char(10);
OptionalParm01_2 char(50);
// repeat...
OptionalParm20_1 char(10);
OptionalParm20_2 char(50);
dsParms likeds(dsParms_T) dim(20) pos(8); end-pr (or pi)

I'm getting RNF3748 - Keyword not allowed on the dsParms. Does not like the POS() keyword.

I need to specify the individual parms as I'm using CEETSTA to determine which were passed.

Any suggestions? I guess I could change the command to pass blanks or something if unspecified.

Thanks.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.