[Info-vax] COBOL example $MGBLSC

Jan-Erik Söderholm jan-erik.soderholm at telia.com
Sat Sep 9 09:29:13 EDT 2023


Den 2023-09-09 kl. 15:15, skrev bill:
> On 9/8/2023 6:59 PM, Chris Townley wrote:
>> On 08/09/2023 23:50, bill wrote:
>>> On 9/8/2023 4:40 PM, Arne Vajhøj wrote:
>>>> 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?
>>>
>>> Can you point me at a copy of the VMS COBOL Reference Manual?
>>> This is something VMS specific.  I tried a couple sites.  One
>>> of them returned XML errors and sector7 pointed me at localhost.
>>> If I can grab a quick look at the manual I can probably provide
>>> a fairly clean way to do it.  I may even try to figure out how
>>> to get to EISNER after the port change and then I will actually
>>> test what I write.
>>>
>>
>> Try https://docs.vmssoftware.com/vsi-cobol-for-openvms-reference-guide
>> There is also a User guide
>>
> 
> 
> Afraid I will have to take a pass on this one.  Too much VMS
> specific stuff that makes no sense to me in COBOL.
> An example:
> ------------------------------
> LINKAGE SECTION.
> 
>     01 GLOBAL-SECTION.
> 
> -----------------------
> 
> PROCEDURE DIVISION USING GLOBAL_SECTION.
> 
> -----------------------------
> 
> Note that the names don't match.  And, GLOBAL is a reserved word.
> 
> And I thought IBM COBOL was convoluted.
> 
> bill
> 

As that same manual says in section "1.2.1.1. User-Defined Words":

"Throughout this manual, and except where specific rules apply, the
hyphen (-) and the underline (_) are treated as the same character
in a user-defined word."

So the two symbols "GLOBAL-SECTION" and "GLOBAL_SECTION" are the same.
Could had been clearer to if that had been avoided...

There are some other special cases, search the manual for "underline".



More information about the Info-vax mailing list