[Info-vax] Calling $CREPRC in COBOL

Arne Vajhøj arne at vajhoej.dk
Fri Jun 10 20:18:55 EDT 2022


On 6/10/2022 1:39 PM, VAXman- at SendSpamHere.ORG wrote:
>    10  ENQ-TYPE      PIC X(1)  VALUE EXTERNAL PQL$_ENQLM.
> ..............^
> %COBOL-E-EXTREFVAL, VALUE EXTERNAL clause ignored - valid only on COMP
> data-item
> 
> How do you put PQL$ items in to a COBOL "byte"?

Disclaimer: I don't do Cobol.

As I read the fine manual then VMS Cobol only have
16, 32 and 64 bit binary integers.

So one has to cheat.

Here is my suggestion for cheating:

$ type pack.cob
identification division.
program-id.pack.
*
data division.
working-storage section.
01 packrec.
    03 b1 pic x.
    03 lw1 pic s9(9) comp.
    03 b2 pic x.
    03 lw2 pic s9(9) comp.
*
procedure division.
main-paragraph.
     move function char(11 + 1) to b1
     move 22 to lw1
     move function char (33 + 1) to b2
     move 44 to lw2
     call "dump" using
         by reference packrec
         by value 10
     end-call
     stop run.
$ type packsup.c
#include <stdio.h>

void dump(char *b, int len)
{
     int i;
     for(i = 0; i < len; i++)
     {
         printf(" %d", b[i]);
     }
     printf("\n");
}

$ cob pack
$ cc packsup
$ link pack + packsup
$ run pack
  11 22 0 0 0 33 44 0 0 0

The code should be pretty self explanatory.

And you will of course need to move from one variable
with external to the single byte text variable.

Arne





More information about the Info-vax mailing list