PDA

View Full Version : CLLE parameter checking like %Parms in RPGLE



Guest.Visitor
01-01-1995, 02:00 AM
Hello, Does the CLLE have an equivalent code like %PARMS of RPG IV in checking the number of parameters received? I'm using CEETSTA API and it works fine but I'm just kind of curious if there's an alternative. Thanks, Giovanni :-)

Guest.Visitor
10-10-2000, 05:54 AM
You can monitor for MCH3601 to check for unpassed parameter.

Guest.Visitor
10-10-2000, 06:43 AM
Gene, that's not reliable. There's no guarantee that you will get a MCH3601 if the parameter isn't passed; there may occasionally be a valid pointer where the CLLE program/procedure is looking for the parameter. If you use that "parameter"'s value, your program won't run properly, and if you change that "parameter", you will corrupt some storage, who knows where (possibly different every time, depending on what calls were made before the CLLE was called ). When you corrupt storage, if you're lucky you'll get a nice noisy exception; if you're unlucky you'll corrupt more storage, and possibly your database will get corrupted. Barbara Morris, IBM Toronto Lab, RPG Compiler Development

D.Handy
10-10-2000, 07:03 AM
Barbara, <font color=blue>"There's no guarantee that you will get a MCH3601 if the parameter isn't passed; there may occasionally be a valid pointer ... (and) you will corrupt some storage, who knows where"</font> I see what you are saying, but this is troubling to me. I was always taught that when you create a RTVxxx type command with multiple optional keywords, like RTVJOBA permits, that your CPP can use MCH3601 to determine which parameters to return. Or put another way, you just try to set all the return values, and ignore MCH3601 exceptions for unpassed arguments. Would using a command interface make the stack such that this technique is in fact reliable? I've not yet encountered any (known) problems in doing it this way. Should I be changing all of these commands to use CEESTA instead? Doug

Guest.Visitor
10-10-2000, 08:30 AM
Thank you all for your responses and hearing from the experts I would say that I'm on the right track. Regards, Giovanni Ps. Is it safe to assume that MCH3601 can only be applied to CLP since there's no workaround with it?

Guest.Visitor
10-10-2000, 06:13 PM
Doug, for commands with RTNVAL parms, you can rely on MCH3601. For RTNVAL parms that aren't coded on the command, you get passed a null pointer, so nothing is left up to chance. Barbara

D.Handy
10-10-2000, 07:09 PM
Barbara, <font color=blue>"for commands with RTNVAL parms, you can rely on MCH3601</font> Thanks; it has always (apparently) worked for my RTVxxx type toolbox commands. The way you worded the warning caused a knee-jerk reaction as I thought about all the places I used that technique in CPP's for optional return values. Doug

Guest.Visitor
10-10-2000, 07:32 PM
Sorry to scare you, Doug. (Too bad it isn't closer to Halloween ... ) But you might be better off writing that type of CPP in RPG IV, or any other language that allows you to test the address of a parameter. Not because of any possible inaccuracy, but to avoid the overhead of the exception handling. (%parms will always give the same (maximum) answer for a command, even one with RTNVAL parameters.) Barbara

Guest.Visitor
10-11-2000, 08:38 AM
<font color=blue>Is it safe to assume that MCH3601 can only be applied to CLP since there's no workaround with it?</font> OPM CL makes fixed-length entry parameter lists (no need for %Parms), however, the REXX program below can modify the entry parameter list in an observable OPM program into variable-length. For example if you create CL program X to accept 4 parameters, then "SETMINPARM PGM(X) MIN(0)" will let you call X with no parameters. X should then monitor for parameter-not-passed errors. <pre> /************************************************** ****************************/ /* COMMAND - SETMINPARM */ /* FUNCTION - Set Minimum Number of Parameters in OPM Program */ /* AUTHOR - Gene Gaunt */ /************************************************** ****************************/ CMD PROMPT('Set Minimum Number of Parms') PARM KWD(PGM) TYPE(Q1) MIN(1) PROMPT('Program') Q1: QUAL TYPE(*NAME) MIN(1) QUAL TYPE(*NAME) MIN(1) PROMPT('Library') PARM KWD(MIN) TYPE(*INT2) MIN(1) PROMPT('Minimum number') /************************************************** ****************************/ /* PROGRAM - SETMINPARM */ /* FUNCTION - Set Minimum Number of Parameters in OPM Program */ /* LANGUAGE - REXX */ /* AUTHOR - Gene Gaunt */ /************************************************** ****************************/ Arg "PGM(" Library "/" Program ") MIN(" Minimum ")" "DLTF FILE(QTEMP/STDIN)" "DLTF FILE(QTEMP/STDOUT)" "RMVMSG CLEAR(*NEW)" Signal On Error "CHKOBJ OBJ(QSCMATPG) OBJTYPE(*PGM) AUT(*USE)" "CHKOBJ OBJ(QSCCRTPG) OBJTYPE(*PGM) AUT(*USE)" "CRTPF FILE(QTEMP/STDIN) RCDLEN(80) SIZE(*NOMAX) LVLCHK(*NO)" "OVRDBF FILE(STDIN) TOFILE(QTEMP/STDIN)" "CALL PGM(QSCMATPG) PARM(&Program &Library STDIN QTEMP STDIN '*REPLACE')" /* read in the program template */ Data = '' Do Count = 0 By 80 Parse Linein Record If Record == '' Then Leave Data = Insert( Record, Data, Count, 80 ) End Count /* change the external parameter list */ ODV = Int4( 133 ) + 17 OES = Int4( 137 ) + 17 Do X = ODV + 4 By 4 For Int4( ODV ) / 4 - 1 Type = Bitand( 'F0'x, Substr( Data, X, 1 )) If Type = 'F0'x Then Y = OES + Int3( X + 1 ) Else Y = X If Substr( Data, Y, 1 ) = '5B'x Then Do Data = Overlay( Bitand( '7F'x, Substr( Data, Y + 1, 1 )), Data, Y + 1 ) If Type = 'F0'x Then Y = Y + 2 Else Y = OES + Int2( Y + 2 ) Data = Overlay( D2C( Minimum, 2 ), Data, Y + 3 ) Leave End End X /* re-encapsulate the program */ "CRTPF FILE(QTEMP/STDOUT) RCDLEN(80) SIZE(*NOMAX) LVLCHK(*NO)" "OVRDBF FILE(STDOUT) TOFILE(QTEMP/STDOUT)" Do X = 1 To Count By 80 Say Substr( Data, X, 80 ) End X "DLTPGM PGM("Strip( Library )"/"Strip( Program )")" "CALL PGM(QSCCRTPG) PARM(&Program &Library STDOUT QTEMP STDOUT)" "SNDPGMMSG MSG('Done.')" Return Int2: Return C2D( Substr( Data, Arg( 1 ), 2 ), 2 ) Int3: Return C2D( Substr( Data, Arg( 1 ), 3 ), 3 ) Int4: Return C2D( Substr( Data, Arg( 1 ), 4 ), 4 ) Error: 'SNDPGMMSG MSG(''Error' RC 'occured. See job log for details.'')' </pre>