INSPECT works by sweeping through the "EFABDBCGABEFGG" text one position at a time. At each position, it checks each of the "FOR" conditions. When a condition is satisfied, it increments the counter for that condition, the remaining conditions are skipped for that position, and the position pointer is advanced by the length of the match. So, in the present case: Position 1 is "EF..", so we have a match for LEADING "EF". COUNT-2 is incremented to 1, and the pointer updated to position 3. Position...
INSPECT example from ISO: bad COUNT-4; corrupt REPLACING
INSPECT example from ISO calculates incorrect COUNT-4
EVALUATE [...] WHEN - ]...] crashes GC3.2
Simon, and @vcoen, I have found this discussion to be extremely useful, and I appreciate it very much. I believe that the GC documentation surrounding DEPENDING ON should be expanded. It basically covers rule 7). The behavior covered by 8a) and 8b) needs to be covered. I would hope that the expansion would be written in language plain enough -- maybe even with examples -- in an effort to be understandable the first time through, rather than the third or fifth time. I have just tested these three...
Simon, and @vcoen, I have found this discussion to be extremely useful, and I appreciate it very much. I believe that the GC documentation surrounding DEPENDING ON should be expanded. It basically covers rule 7). The behavior covered by 8a) and 8b) needs to be covered. I would hope that the expansion would be written in language plain enough -- maybe even with examples -- in an effort to be understandable the first time through, rather than the third or fifth time. I have just tested these three...
A light begins to dawn. Unfortunately, so far it is just illuminating my confusion. In the example I posted, the data structure is 01 PLINE. 03 PLINE-LEN PIC S9(4) COMP-5. 03 PLINE-TEXT. 04 FILLER PIC X(1) OCCURS 1 TO 80 DEPENDING ON PLINE-LEN. The instructions are MOVE 5 TO PLINE-LEN MOVE 'the first part in' TO PLINE-TEXT Just so I am sure: When MOVEing something to PLINE-TEXT, the DEPENDING ON variable is PLINE-LEN, which is not subordinate to PLINE-TEXT, so rule 8a) applies, and the MOVE is limited...
A light begins to dawn. Unfortunately, so far it is just illuminating my confusion. In the example I posted, the data structure is 01 PLINE. 03 PLINE-LEN PIC S9(4) COMP-5. 03 PLINE-TEXT. 04 FILLER PIC X(1) OCCURS 1 TO 80 DEPENDING ON PLINE-LEN. The instructions are MOVE 5 TO PLINE-LEN MOVE 'the first part in' TO PLINE-TEXT Just so I am sure: When MOVEing something to PLINE-TEXT, the DEPENDING ON variable is PLINE-LEN, which is not subordinate to PLINE-TEXT, so rule 8a) applies, and the MOVE is limited...