I have a system that can have up to 200 AIV fields. It works but is bulky. I’ve tried in a small test program creating an AIV array of five entries. This would greatly reduce the amount of code, making it much nicer to work with. Here are my two test programs:
Program MDH0451
0010 DEFINE DATA
0020 LOCAL
0030 1 #A (N5)
0040 INDEPENDENT
0050 1 +AIV-ARRAY (A20/5)
0060 END-DEFINE
0070 *
0080 +AIV-ARRAY (1) := ‘#FIELD1’
0090 +AIV-ARRAY (2) := ‘#FIELD2’
0100 +AIV-ARRAY (3) := ‘#FIELD3’
0110 +AIV-ARRAY (4) := ‘#NO-FIELD’
0120 +AIV-ARRAY (5) := ‘#NO-FIELD’
0130 RUN ‘MDH0451P’
0140 *
0150 END
Program MDH0451P
0010 DEFINE DATA
0020 LOCAL
0030 1 #A (N2)
0040 1 #FIELD-A (A5)
0050 1 #FIELD1 (A5) INIT<‘AAA’>
0060 1 #FIELD2 (A5) INIT<‘BBB’>
0070 1 #FIELD3 (A5) INIT<‘CCC’>
0080 1 #NO-FIELD (A5)
0090 END-DEFINE
0100 *
0110 WRITE ‘BEFORE’
0120 FOR #A 1 TO 5
0130 IF +AIV-ARRAY (#A) = ’ ’ THEN
0140 ESCAPE TOP
0150 END-IF
0160 WRITE ‘=’ +AIV-ARRAY (#A)
0170 END-FOR
0180 *
0190 WRITE / ‘AFTER’
0200 FOR #A 1 TO 5
0210 IF +AIV-ARRAY (#A) = ’ ’ THEN
0220 ESCAPE TOP
0230 END-IF
0240 #FIELD-A := &AIV-ARRAY (#A)
0250 WRITE ‘=’ #FIELD-A
0260 END-FOR
0270 *
0280 END
If I comment out my “RUN” statement and execute the first program, my AIV array is created. When I type AIV on the command line I see:
C Variable F Length
__ +AIV-ARRAY A 20 (5)
However, when I put my RUN statement back in and execute the first program I get the following error:
“NAT0280 Index entry incorrectly specified for field.” marking 0240 #FIELD-A := &AIV-ARRAY (#A).
My question is, how numeric field do I need to use to reference the AIV array? My #A (N2) doesn’t work. I’ve tried (I2) and (I4).
Thanks for the help.
Mike