How to Pass parm to PRO*CoBOL program in UNIX environment 
Author Message
 How to Pass parm to PRO*CoBOL program in UNIX environment

I'm converting programs from Open VMS to UNIX Compaq Tru64.  I am
having trouble figuring out how to pass parms to the programs, and
read them in the Pro*CoBOL program.

The symbols used in VMS don't work here, and I'm guessing it has to be
changed quite a bit.  I simply want to pass one, two or 3 parms to a
program. For instance I want to pass a year parm, 1984, to a variable
in Cobol, then use it in the 'select' statement in the program.

Here is what I would do in VMS:

* FIRST PARM IS THE Fiscal Year.
    MOVE 'P1'                       TO SYMBOL-NAME.
    CALL 'LIB$GET_SYMBOL'
         USING BY DESCRIPTOR  SYMBOL-NAME
               BY DESCRIPTOR  SYMBOL-EQUIVALENT
               BY REFERENCE   SYMBOL-LENGTH
               GIVING SYMBOL-RETURN-STATUS.
    IF SS$_NORMAL
        MOVE SYMBOL-EQUIVALENT                 TO PARM-DATA-AREA
        MOVE INCOMING-PARM1                    TO CLASS-TYPE-PARM
    ELSE
        DISPLAY 'SERIOUS ERROR GETTING FIRST SYMBOL'
        STOP RUN.
-And the 'SYMBOL-'  variables are defined in the Working-Storage as 01
levels.

Can someone give an example on what the cobol code would look like to
be compatible with UNIX, and how I'd run this in UNIX from the prompt?



Mon, 20 Sep 2004 00:34:49 GMT  
 How to Pass parm to PRO*CoBOL program in UNIX environment

Quote:

> I'm converting programs from Open VMS to UNIX Compaq Tru64.  I am
> having trouble figuring out how to pass parms to the programs, and
> read them in the Pro*CoBOL program.

> The symbols used in VMS don't work here, and I'm guessing it has to be
> changed quite a bit.  I simply want to pass one, two or 3 parms to a
> program. For instance I want to pass a year parm, 1984, to a variable
> in Cobol, then use it in the 'select' statement in the program.

> Here is what I would do in VMS:

> * FIRST PARM IS THE Fiscal Year.
>     MOVE 'P1'                       TO SYMBOL-NAME.
>     CALL 'LIB$GET_SYMBOL'
>          USING BY DESCRIPTOR  SYMBOL-NAME
>                BY DESCRIPTOR  SYMBOL-EQUIVALENT
>                BY REFERENCE   SYMBOL-LENGTH
>                GIVING SYMBOL-RETURN-STATUS.
>     IF SS$_NORMAL
>         MOVE SYMBOL-EQUIVALENT                 TO PARM-DATA-AREA
>         MOVE INCOMING-PARM1                    TO CLASS-TYPE-PARM
>     ELSE
>         DISPLAY 'SERIOUS ERROR GETTING FIRST SYMBOL'
>         STOP RUN.
> -And the 'SYMBOL-'  variables are defined in the Working-Storage as
> 01 levels.

> Can someone give an example on what the cobol code would look like
> to be compatible with UNIX, and how I'd run this in UNIX from the
> prompt?

I dunno Pro*CoBOL, but Compaq COBOL for Tru64 has both environment and
command line argument passing. Check the Special-Names paragraph in
your Pro*CoBOL documentation.

A different way to read environmental variables is to use the Tru64
getenv(3) routine. I assume that unix COBOLs have a way to deal with
string pointers returned from system calls. Getenv(3) returns a pointer
to the requested variable if it exists.

Assuming that Pro*CoBOL supports ARGUMENT-NUMBER, ARGUMENT-VALUE,
or ENVIRONMENT-NAME, ENVIRONMENT-VALUE you can get the command line
with the ARG* mechanism or use the ENV* mechanism to get the values
of environment variables.

[...]
environment division.
configuration section.
special-names.
    environment-name  is symbol-name
    environment-value is symbol-value
    .

[...]
working-storage section.
01  PARM-DATA-AREA    pic x(4).

procedure division.

    display "year-param-name" upon symbol-name

    accept PARM-DATA-AREA from symbol-value
        on exception
           display "'year-param-name' not defined in environment'"
           stop run
    end-accept

[...]

The command line argument passing would look something like this

[...]
environment division.
configuration section.
special-names.
    argument-number is arg-count
    argument-value  is arg-value
    .
[...]
working-storage section.
01  counter        pic 9(9) comp.
01  cur-arg-num    pic zzz9.
01  dest-item      pic x(80).
01  num-of-args    pic 9(9) comp.

procedure division.

    accept num-of-args from arg-count end-accept

    perform varying counter from 1 by 1 until counter > num-of-args
        accept dest-item from arg-value
           on exception
              move counter to cur-arg-num
              display "Exception reading command line arguement" space
cur-arg-num

           not on exception
              move dest-item to where-ever-it-goes

        end-accept
    end-perform
[...]

From the shell prompt you would enter something like:  "./myprog arg1
arg2 arg3"

Jeff Campbell



Mon, 20 Sep 2004 05:37:48 GMT  
 How to Pass parm to PRO*CoBOL program in UNIX environment

Quote:


> > I'm converting programs from Open VMS to UNIX Compaq Tru64.  I am
> > having trouble figuring out how to pass parms to the programs, and
> > read them in the Pro*CoBOL program.
> ...
> I dunno Pro*CoBOL, but Compaq COBOL for Tru64 has both environment and
> command line argument passing. Check the Special-Names paragraph in
> your Pro*CoBOL documentation.

I don't have a reference to the Pro*COBOL documentation, but here is
the Compaq COBOL documentation reference for these features:

  http://www.openvms.compaq.com/doc/73final/cobol/cobum_003.htm#com_li_...

- Don Braffitt
  Compaq COBOL and SORT project leader (OpenVMS and Tru64 UNIX)



Fri, 15 Oct 2004 19:36:50 GMT  
 How to Pass parm to PRO*CoBOL program in UNIX environment
Thanks all. I used a variation of what Jeff has written earlier.


Tue, 19 Oct 2004 01:39:52 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Passing parm hex parm to STCKCONV

2. HELP!! Micro Focus COBOL Parm Passing

3. sample makefile to compile Microfocus COBOL and Pro*Cobol programs

4. Graphing program, parm program, etc.

5. App to App parm passing in 2.003

6. Passing (Python) COM Object as Method Parm

7. Pro*Fortrran Program (ORACLE, UNIX, SUN, SOLARIS, SPARCFORTRAN)

8. MicroFocus COBOL in Unix Environment

9. oberon-like programming environment for Unix/X

10. Unix programming environment?

11. UNIX parameters passed thru cobol linkage

12. PASSING PARAMETERS TO A COBOL PROGRAM

 

 
Powered by phpBB® Forum Software