[Info-vax] COBOL example $MGBLSC

Arne Vajhøj arne at vajhoej.dk
Fri Sep 8 16:40:27 EDT 2023


On 9/8/2023 1:55 PM, bill wrote:
> On 9/8/2023 1:13 PM, Arne Vajhøj wrote:
>> On 9/8/2023 12:45 PM, Brian Schenkenberger wrote:
>>> I have the SYS$MGBLSC working... at least, in the debugger.  I 
>>> defined a test global section with two longwords.
>>>
>>> 1,-1
>>> 2,-2
>>> 3,-3
>>> etc.,-etc.
>>> 0,0
>>>
>>> I have the following for the global section's element definition:
>>>
>>> LINKAGE SECTION.
>>>
>>> 01 GLOBAL-SECTION.
>>>   02 ELEMENT OCCURS 2000 TIMES.
>>>     03 A        PIC S9(9) COMP.
>>>     03 B        PIC S9(9) COMP.
>>>
>>> and the procedure...
>>>
>>> PROCEDURE DIVISION USING GLOBAL_SECTION.
>>> PARAGRAPH-MAIN.
>>>     PERFORM PARAGRAPH-ENTER THRU PARAGRAPH-EXIT
>>>             VARYING I FROM 1 BY 1 UNTIL A(I) = 0 AND B(I) = 0.
>>> PARAGRAPH-ENTER.
>>>     DISPLAY "First[" I "]: " A(I) "  Second[" I "]: " B(I).
>>> PARAGRAPH-EXIT.
>>>     EXIT.
>>> END PROGRAM GBLSEC.
>>>
>>> In the debugger, A(I) and B(I) show me the values but DISPLAY pukes 
>>> on them. It'd be great too if there was a way to DISPLAY them in HEX 
>>> but just getting it to DISPLAY without regurgitaing garbage would be 
>>> great.
>>
>> Add a couple of temporary variables:
>>
>> WORKING-STORAGE SECTION.
>> 01 AI PIC 9(4) DISPLAY.
>> 01 BI PIC 9(4) DISPLAY.
>>
>> and do:
>>
>> MOVE A(I) TO AI
>> MOVE B(I) TO BI
>> DISPLAY "First[" I "]: " AI "  Second[" I "]: " BI.
>>
>> If anyone that actually knows Cobol has a better solution then
>> I am also interested!
> 
> I really don't have that much experience with VMS COBOL and have no idea
> what $MGBLSC means,

SYS$MGLBSC is the VMS system service to map a global section.

>                      but, if it is merely a display problem how about a
> REDEFINES from COMP to DISPLAY instead of another variable and the MOVE?

How would that look like?

> Is this unique to x86-64 or could I play with the examples on EISNER?

Not x86-64 specific. In fact I am pretty sure that Brian is not
running it on x86-64. You could run it on VAX!

Arne





More information about the Info-vax mailing list