On 3/28/2012 11:54 AM, Phil Smith wrote:
Steve Comstock wrote:
On 3/23/2012 2:57 PM, Phil Smith wrote:
Now for the next question: this allows us to implement variable
parameterlists in C, by declaring the functions thus:
int SOMEFUNCTION(char *someparm, ...); >
Is there an equivalent way to do this in PL/I?

In the declare of the subroutine, specify the word LIST in the last
argument descriptor, for example:

dcl avgyx entry (fixed bin(31),
  fixed decimal(7,2) optional,
  char (8),
  list byaddr)
  options(asm);

This indicates there are zero or more arguments from the point
of the LIST

Then, in the invocation, pass at least as many arguments as
arguments before the word LIST and any others you want:

call avgyx (test_no,
           weight,
           test_name,
           rand_var,
           score_low,
           score_high);

Hm. This isn't quite working:

Declare THEFN  External('THEFN') Entry(
          Char(*) byaddr,
          Char(*) byaddr,
          Fixed Bin(31) byaddr,
          Char(*) byaddr,
          Fixed Bin(31) byaddr,
          Char(*) byaddr
         )
         returns( byvalue Fixed Bin(31) )
         options ( nodescriptor );

Where's the word 'list'? That wasn't a variable name,
it's a required operand to get a variable number of
parameters. It's hard to say from your fragment, but
maybe something like:

Declare THEFN  External('THEFN') Entry(
         Char(*) byaddr,
         Char(*) byaddr,
         Fixed Bin(31) byaddr,
         Char(*) byaddr,
         Fixed Bin(31) byaddr,
         Char(*) byaddr list
        )
        returns( byvalue Fixed Bin(31) )
        options ( nodescriptor );


On compile, this gets RC=4 and:
IBM1214I W      35.0    A dummy argument will be created for argument number
                         4 in entry reference VSHPROT.

Then it linkedits OK but gets a ABENDU4038 on run. This differs from your
recommendation by being an EXTERNAL function; I had to use NODESCRIPTOR because
ASM isn't supported for functions, apparently.

Yes; there is some more information, from the PL/I language reference:

  When the LIST attribute is specified, no descriptors are
  allowed, and OPTIONS(NODESCRIPTOR) must be specified on
  its PROCEDURE statement and on its corresponding ENTRY
  declaration.

  The address of the first of these additional parameters may
  be obtained via the VARGLIST built-in function. This address
  may be used to obtain the addresses of any additional parameters as follows:

  * if the additional parameters to this procedure were passed BYVALUE,
    successively incrementing this initial address by the value returned
    by the VARGSIZE built-in function will return the addresses of any
    additional parameters

  * if the additional parameters to this procedure were passed byaddr,
    successively incrementing this initial address by the size of a
    pointer will return the addresses of any additional parameters


Ideas?
--
...phsiii

Phil Smith III
p...@voltage.com
Voltage Security, Inc.
www.voltage.com
(703) 476-4511 (home office)
(703) 568-6662 (cell)

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: INFO IBM-MAIN



--

Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-355-2752
http://www.trainersfriend.com

* To get a good Return on your Investment, first make an investment!
  + Training your people is an excellent investment

* Try our tool for calculating your Return On Investment
    for training dollars at
  http://www.trainersfriend.com/ROI/roi.html

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: INFO IBM-MAIN

Reply via email to