Charles Mills wrote:
Trying to figure out this subject.

The C/C++ Language Reference on p. 207 says "Under z/OS batch . argv[0]
Returns the program name in uppercase argv[1 to n] Returns the arguments as
you enter them." Not the most useful documentation - I don't think "as you
enter them" is terribly clear as it pertains to z/OS batch.

Well, you normally get an integer which contains the number of
subsequent arguments:

void main(int argc, char *argv[]);

'argc' is the traditional name used for a variable to hold
the first value, and argv the traditional name for the
second value; the second value is an array of words, each
word presented as a separate element in the array, in the
case you entered it on the PARM= parameter on the EXEC
statement. Actually, each argument is a pointer to the
corresponding word. As you noted, argv[0] contains the
program name.

A 'word' is delimited by blanks; leading and trailing spaces
are stripped off. In this list of words, each is terminated
by a null (x'00).


The C/C++ User's Guide on p. 70 says "When NOARGPARSE is in effect,
arguments on the invocation line are not parsed, argc has a value of 2, and
argv contains a pointer to the string."


Right. argv[0] is still the program name; argv[1] is the unparsed
parm string as entered on the EXEC statement.


Question: Does anyone know if a NOARGPARSE C++ program called via LINK or
ATTACH would receive parm 2 - the second word pointed to by R1 - anywhere?
Is there a recommended way to do this?

Well, I don't do C++, but some notes for C below:

What I'd like to end up with is a C program that "did me no favors" - if
invoked from JCL EXEC, then argv[1] would point to the PARM= string if any
("as is") and if called via LINK or ATTACH would get the vector pointed to
by the caller's R1 as argv[1, 2, 3 .].

Since C programs are LE-based, why not use the LE callable service CEE3PRM?

         _VSTRING p_mess;
         char char_work [88];
         char * p_ptr;
         ...
         CEE3PRM(char_work, &fc);
         strcpy(p_mess.string, "Parm = ");
         p_ptr = strcat(p_mess.string,char_work);
         p_mess.length = 87;
         CEEMOUT(&p_mess, &dest, &fc);


(well, one reason is that CEE3PRM is restricted to 80 characters;
 but if that's not a problem, this is a good way to go)



Anyone know the answer to this?

Not sure if this will get you going or not. Good luck.


--

Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-393-8716
http://www.trainersfriend.com

  z/OS Application development made easier
    * Our classes include
       + How things work
       + Programming examples with realistic applications
       + Starter / skeleton code
       + Complete working programs
       + Useful utilities and subroutines
       + Tips and techniques

==> Ask about being added to our opt-in list:              <==
==>   * Early announcement of new courses                  <==
==>   * Early announcement of new techincal papers         <==
==>   * Early announcement of new promotions               <==

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to