× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Chaps,

I have been following this discussion with great interest. To satisfy my own curiosity I created a test program (below is the code). This performs a series of calls to a couple of procedures, each with a selection of 10-alpha parameters defined. The procedures call CEEDOD for each parameter, to see what is actually passed. A comparison of these values to the values declared in the prototype are listed in a summary table below the code:

(Apologies if this doesn't format correctly)
**********************************************************************************************
d proc1           pr                  opdesc
d  parm1                        10a   const options(*varsize)
d  parm2                        10a   const
d  parm3                        10a   options(*varsize)
d  parm4                        10a   const options(*varsize) varying
d  parm5                        10a   const                   varying
d  parm6                        10a   options(*varsize)       varying

d proc2           pr                  opdesc
d  parm1                        10a   const options(*varsize) varying
d  parm2                        10a   const                   varying
d  parm3                        10a   const options(*varsize)
d  parm4                        10a   const

d CEEDOD          pr
d posn                          10i 0 const
d desctype                      10i 0
d datatype                      10i 0
d descinf1                      10i 0

d descinf2                      10i 0
d datalen                       10i 0
d feedback                      12a   options(*omit)
**********************************************************************************************

d  parmvalue1     s              1a   inz('1')
d  parmvalue10    s             10a   inz('1234567890')
d  parmvalue100   s            100a   inz('1234567890>>>')

d  parmvalue1v    s              1a   inz('1')               varying
d  parmvalue10v   s             10a   inz('1234567890')      varying
d  parmvalue100v  s            100a   inz('1234567890>>>')   varying

d desc            s             10i 0
d data            s             10i 0
d inf1            s             10i 0
d inf2            s             10i 0
d len             s             10i 0
**********************************************************************************************
/free

 // Procedure proc1 is called with 6 parameters:
 // The first three are fixed length strings.
 // The next three are varying length strings.

 // In all cases, the parameters are passed using the following prototype:
 //   10a  const options(*varsize)
 //   10a  const
 //   10a  options(*varsize)
 //   10a  const options(*varsize) varying
 //   10a  const                   varying
 //   10a  options(*varsize)       varying

 // Pass 1-alpha strings...
 dsply (' ');
 dsply ('Proc1 called with 1-alpha strings');
 proc1(parmvalue1 :parmvalue1 :parmvalue1
      :parmvalue1v :parmvalue1v :parmvalue1v);

 // Pass 10-alpha strings...
 dsply (' ');
 dsply ('Proc1 called with 10-alpha strings');
 proc1(parmvalue10 :parmvalue10 :parmvalue10
      :parmvalue10v :parmvalue10v :parmvalue10v);

 // Pass 100-alpha strings...
 dsply (' ');
 dsply ('Proc1 called with 100-alpha strings');
 proc1(parmvalue100 :parmvalue100 :parmvalue100
      :parmvalue100v :parmvalue100v :parmvalue100v);

 // Procedure proc2 is called with 4 parameters:
 // The first two are varying length strings.
 // The next two are fixed length strings.

 // In all cases, the parameters are passed using the following prototype:
 //   10a  const options(*varsize) varying
 //   10a  const                   varying
 //   10a  const options(*varsize)
 //   10a  const

 // Pass 1-alpha strings...
 dsply (' ');
 dsply ('Proc2 called with 1-alpha strings');
 proc2(parmvalue1 :parmvalue1 :parmvalue1v :parmvalue1v);

 // Pass 10-alpha strings...
 dsply (' ');
 dsply ('Proc2 called with 10-alpha strings');
 proc2(parmvalue10 :parmvalue10 :parmvalue10v :parmvalue10v);

 // Pass 100-alpha strings...
 dsply (' ');
 dsply ('Proc2 called with 100-alpha strings');
 proc2(parmvalue100 :parmvalue100 :parmvalue100v :parmvalue100v);

 *inLR = *on;
 return;

/end-free
**********************************************************************************************
p proc1           b
**********************************************************************************************
d proc1           pi                  opdesc
d  parm1                        10a   const options(*varsize)
d  parm2                        10a   const
d  parm3                        10a   options(*varsize)
d  parm4                        10a   const options(*varsize) varying
d  parm5                        10a   const                   varying
d  parm6                        10a   options(*varsize)       varying
**********************************************************************************************
/free

 monitor;

 CEEDOD(1 :desc :data :inf1 :inf2 :len :*OMIT);
 dsply ('variable 1 value = ' + parm1);
 dsply ('variable 1 length = ' + %char(len));

 CEEDOD(2 :desc :data :inf1 :inf2 :len :*OMIT);
 dsply ('variable 2 value = ' + parm2);
 dsply ('variable 2 length = ' + %char(len));

 CEEDOD(3 :desc :data :inf1 :inf2 :len :*OMIT);
 dsply ('variable 3 value = ' + parm3);
 dsply ('variable 3 length = ' + %char(len));

 CEEDOD(4 :desc :data :inf1 :inf2 :len :*OMIT);
 dsply ('variable 4 value = ' + parm4);
 dsply ('variable 4 length = ' + %char(len));

 CEEDOD(5 :desc :data :inf1 :inf2 :len :*OMIT);
 dsply ('variable 5 value = ' + parm5);
 dsply ('variable 5 length = ' + %char(len));

 CEEDOD(6 :desc :data :inf1 :inf2 :len :*OMIT);
 dsply ('variable 6 value = ' + parm6);
 dsply ('variable 6 length = ' + %char(len));

 on-error *program;
 dsply ('parameter error calling proc1');
 endmon;

 return;

/end-free
**********************************************************************************************
p proc1           e
**********************************************************************************************

**********************************************************************************************
p proc2           b
**********************************************************************************************
d proc2           pi                  opdesc
d  parm1                        10a   const options(*varsize) varying
d  parm2                        10a   const                   varying
d  parm3                        10a   const options(*varsize)
d  parm4                        10a   const
**********************************************************************************************
/free

 monitor;

 CEEDOD(1 :desc :data :inf1 :inf2 :len :*OMIT);
 dsply ('variable 1 value = ' + parm1);
 dsply ('variable 1 length = ' + %char(len));

 CEEDOD(2 :desc :data :inf1 :inf2 :len :*OMIT);
 dsply ('variable 2 value = ' + parm2);
 dsply ('variable 2 length = ' + %char(len));

 CEEDOD(3 :desc :data :inf1 :inf2 :len :*OMIT);
 dsply ('variable 3 value = ' + parm3);
 dsply ('variable 3 length = ' + %char(len));

 CEEDOD(4 :desc :data :inf1 :inf2 :len :*OMIT);
 dsply ('variable 4 value = ' + parm4);
 dsply ('variable 4 length = ' + %char(len));

 on-error *program;
 dsply ('parameter error calling proc2');
 endmon;

 return;

/end-free
**********************************************************************************************
p proc2           e
**********************************************************************************************


Results:

Prototype definition                    Passed variable Op Desc parameter type 
and length
10a   const options(*varsize)           1a                      1a
10a   const                             1a                      10a
10a   options(*varsize)                 1a                      1a
10a   const options(*varsize) varying   1a varying              1a varying
10a   const varying                     1a varying              10a varying
10a   options(*varsize) varying 1a varying              1a varying
10a   const options(*varsize) varying   1a                      1a varying
10a   const varying                     1a                      10a varying
10a   const options(*varsize)           1a varying              1a
10a   const                             1a varying              10a

10a   const options(*varsize)           10a                     10a
10a   const                             10a                     10a
10a   options(*varsize)                 10a                     10a
10a   const options(*varsize) varying   10a varying             10a varying
10a   const varying                     10a varying             10a varying
10a   options(*varsize) varying 10a varying             10a varying
10a   const options(*varsize) varying   10a                     10a varying
10a   const varying                     10a                     10a varying
10a   const options(*varsize)           10a varying             10a
10a   const                             10a varying             10a

10a   const options(*varsize)           100a                    10a
10a   const                             100a                    10a
10a   options(*varsize)                 100a                    100a
10a   const options(*varsize) varying   100a varying            10a varying
10a   const varying                     100a varying            10a varying
10a   options(*varsize) varying 100a varying            100a varying ***
10a   const options(*varsize) varying   100a                    10a varying
10a   const varying                     100a                    10a varying
10a   const options(*varsize)           100a varying            10a
10a   const                             100a varying            10a

Notes:
1) When const is specified the received variable has a length which never exceeds the length set on the prototype definition. 2) When using const and not options(*varsize), if the passed fixed-length parameter is smaller than that defined on the prototype, it is padded with blanks. 3) When using const and options(*varsize), if the passed fixed-length parameter is smaller than that defined on the prototype, it is not padded with blanks. 4) In cases 2) and 3) for received varying-length variables the length portion is set appropriately - padding is not required. 5) When options(*varsize) is specified the received variable has a length equal to that passed by the caller - this can cause problems with varying-length variables. See 6) below. 6) When varying is specified, with options(*varsize) and without const, referencing the variable will cause a runtime error if the actual length passed exceeds the prototype definition. 7) When passing a fixed-length string using a varying-length prototype definition the following must be considered: i) You MUST use const - otherwise a parameter mismatch will be thrown and the module will not compile. ii) Because of the requirement to use const, even when specifying options(*varsize), any strings passed which are longer than the prototype definition will be truncated to the length set by the prototype definition. iii) For passed strings with a length exceeding the prototype definition, the length portion of the received variable will be set to the truncated length. 8) When passing a varying-length string using a fixed-length ptototype definition the following must be considered: i) You MUST use const - otherwise a parameter mismatch will be thrown and the module will not compile. ii) Because of the requirement to use const, even when specifying options(*varsize), any strings passed which are longer than the prototype definition will be truncated to the length set by the prototype definition.

** In all cases any reference to parameter length is the length retrieved from CEEDOD, not the declared prototype length.

*** Any reference to the variable causes runtime error. This is due to it having an invalid length portion.


Of course, this does not directly address the question of temporary variable use, but it may give an indication of scenarios where temporary variables would likely get used. These resulta, or my conclusions may be incorrect, I will happily have them corrected for the benefit of the archive.


Cheers

Larry Ducie



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.