Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing A Variable Parameter

Status
Not open for further replies.

EMSS

Programmer
Jan 14, 2003
4
US
Real stuck on this one.

Please help..... If I can get a parm into the program and execute a simple calc spec, I wil be able to figure out the rest.

Or, does anyone know of an RPG ILE forum that has a good knowledge pool? (not trying to insult anyone)

Have been able to get this code to complile, but not execute past mainline entry (using Debug). Need to pass variable length Parms into a Program.

I use the following to call the program:
CALL PGM(TST05R) PARM('a' 'b')


H DFTACTGRP(*NO) ACTGRP(*NEW)
* Prototype for procedure
D Tst05r PR
D Parm1 72A varying Const
D Parm2 72A varying Const
D Parm3 100A Options(*nopass) Const
D Parm4 100A Options(*nopass) Const
P Tst05r B
* Procedure Inteface to Entry Parms
D Tst05r PI
D Parm1 72A varying Const
D Parm2 72A varying Const
D Parm3 100A Options(*nopass) Const
D Parm4 100A Options(*nopass) Const

D x s 100A
D*
C Eval x = Parm1
C Return
C eval *inlr = *on
P e

 
Silly question, but if you are doing a CALL to a program with a couple of parameters, doesn't the program need some code like
Code:
C   *ENTRY    PARM
C             PARM         Parm1
C             PARM         Parm2
in order to let it know what parameters to expect? I'm not sure about the varying length bit - I've never used varying length for program entry parameters.
 
Other silly question. I thought that

D Tst05r PR
D Parm1 72A varying Const

meant that you were passing a varying length constant with a maximum length of 72 characters? If I've got that right, what's the point of passing a CONSTANT parameter to a procedure?

Do you need to change the value of this variable length parameter? If not, then
Code:
D Proc1        PR             LIKE(*IN)
D  Parameter             72A  VALUE
lets you call the procedure from a program without checking that the parameter lengths match, so you can do
Code:
D SomeField10  S         10A
D SomeField72  S         72A

C      CallP     Proc1('some bit of literal text')
C      CallP     Proc1(SomeField10)
C      If        Proc1(SomeField72) = *OFF
and the compiler would be happy with all of these examples. If you do need it to be varying, wouldn't it work if you did
Code:
D SomeField72  S         72A
C        Eval    SomeField72 = %SUBST(Parameter:1:
C                                %LEN(Parameter))
then referred to the internal field in your calcs?
 
Try this, instead of

D Parm1 72A varying Const

try
D Parm1 72A Const Options(*VarSize)

on all of your varying size parms in you PR specs. Then, if you're call a procedure, use the CALLP instead of CALL



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top