[Info-vax] COBOL example $MGBLSC

Hein RMS van den Heuvel heinvandenheuvel at gmail.com
Fri Sep 8 21:02:56 EDT 2023


On Friday, September 8, 2023 at 12:45:07 PM UTC-4, Brian Schenkenberger wrote:

> I have the SYS$MGBLSC working... at least, in the debugger.:
:
> 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.

Good, that creates a subroutine expecting a pointer to a structure, which may be in a global section previously mapped.
But before we go there, what exactly are the customer requirements? 
There is also something called 'EXTERNAL DATA', essentially named Psects/common blocks.

> 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. 

Ask yourself AITA for expecting a compiler NOT to do exactly what I ask? Garbage in, Garbage out - as requested.

You are TA for being an ancient hack (much like myself) who can only think bits and bytes when he can just do text!
Load your global with ascii "+001" and "-001" or "AAAB" and similar and call it is PIC X(4) or PIC 9(4) USAGE DISPLAY and all will be well :-).

Or... DISPLAY WITH CONVERSION  !

Or, RTFM ... "5. Numeric items do not require the CONVERSION phrase to be displayed correctly with conversion if you specify /DISPLAY_FORMATTED (on OpenVMS Alpha")

Or, as Arne suggests, move (= convert) them into a display helper variable and use that.
This may be best for many cases because (if I recall correctly) any use of "WITH CONVERSION" activates some bonus screen handling you may not care for

(I hope I do not have to litter this with smiley's to indicate these are all friendly pokes, do I?)

> 
> I also can't figure out how to define GLOBA:L-SECTION ELEMENT OCCURS * 
> TIMES. The number of the elements in the global section could be quite 
> variable.

With the linkage section it's all just virtual right? take a thousand, take a million, it matters none I suspect -- haven't tried i a while.

Ah... is this a peephole into the actual user requirements?
Are the elements fixed length?
Anyways, could you not make the linkage section just for one 'element'  and do pointer math on the outside to provide the right element?
Or provide a second lower level function with just the 1 element also passed as linkage and called from the one you have?
Remember these are functions 'giving', but they can only 'give' an R0 return value. Per Reference Guide: "The identifier must refer to an elementary integer numeric data
item with COMP, COMP-1, or COMP-2 usage and no scaling positions."

Greetings my friend! I'll re-poke some folks for I64 access as we (or rather they! have a mutual shared goal. 

Hein.



More information about the Info-vax mailing list