AIV Variables

Your confusion reflects why Natural was changed to introduce the Global Data Area.

The AIV needs to have a definition before the program can be compiled. So, if you don’t want to put the definition in “SUBPROG”, then you have to do something to define the AIV before you can compile SUBPROG - such as running a program that already has the AIV defined. That puts the AIVs in the program in the AIV area in the workspace (try edit +V to see them). When you compile SUBPROG with reference to an AIV that is already in the AIV area, the definition is added to the compiled object.

Another approach was to always include the definition of the AIVs in the programs that were going to use them. The danger of this approach was that the definitions were not always compatible or correct, resulting in run time errors or data loss. So the alternative Graeme mentions became the best practice - always have a single module that does nothing but define the AIVs, catalog it and run it before compiling any programs. No format/length definitions should then be included in the programs/subprograms/etc.

Like all “global data”, AIVs are inherently non-modular and non-object oriented. Operations in one module can have side effects in other modules when global data (AIVs) is used.

I did not start another post, but I am having a problem with +AIV variables and putting them on the map.

How can I assign an +AIV variable as display only in a map when the AIV variable was populated in a different program?

Thanks for your help in advance…Michele :?:

Hi Michele,

You would add an AIV to a map the same way you define local variables:

Ob M Ob D CLS ATT DEL CLS ATT DEL
. . T D Blnk T I ?
. . A D _ A I )
. . A N ¬ M D &
. . M I : O D +
. . O I (
. .
008 --010—±—±—±–030—±—±—±–050—±—±—±–070—±—
ERROR-REPLY-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
DATA-REPLY-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
DATA-REQUEST-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
TRANS-REPLY-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
TRANS-REQUEST-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ERROR-REPLY-HOBJ (9999999999
LE ID (XX
NATPROC (XXXXXXXX

Edit the field with .E to provide your AIV name and format/length and AD attribute for display-only:

Fld +LE-NATPROC Fmt A8

AD= OIL_______ ZP= SG= HE= _____________________ Rls 0
AL= _____ CD= __ CV= ________________________________ Mod User
PM= __ DF= DY= ______________________________
EM= __________________________ SB= ________________________________

008 --010—±—±—±–030—±—±—±–050—±—±—±–070—±—
ERROR-REPLY-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
DATA-REPLY-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
DATA-REQUEST-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
TRANS-REPLY-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
TRANS-REQUEST-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ERROR-REPLY-HOBJ (9999999999
LE ID (XX
NATPROC .EXXXXXXX

Try your map with a sample program:

                                    	> 	+  	Program     	TESTPGM  	Lib 	DBALIB   

All …+…1…+…2…+…3…+…4…+…5…+.Mode Structured.
0010 INPUT USING MAP ‘TESTMAP’
0020 END
0030
0040
0050

This will work, displaying the given values of your AIV, even if defined previously.

Douglas Kelly mentioned that you can use “Edit +V” to see the AIVs.
Another (shorter) command, to do the same thing, is “AIV” :slight_smile: