Re: COBOL is dynamic (depends)



"Frank Swarbrick" <Frank.Swarbrick@xxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:4qctegFmeh26U1@xxxxxxxxxxxxxxxxx
Ah! I was wondering if it perhaps was not "standard" COBOL. Just forgot
to
mention it. But even though it isn't, perhaps it should be? Seems pretty
useful. I'm sure there are dangers in that you could code it incorrectly
and get some fairly bizarre results, but isn't that always the case? :-)

Frank
Frank,
a standard2002 soulution similar to Yours is possible, using BASED items and
pointers; something like:

WORKING-STORAGE SECTION.
77 LEN-1 PIC S9(3) PACKED-DECIMAL.
01 WRK-PTR USAGE POINTER.
01 DATA-IN.
05 A PIC X(4).
05 B PIC X(2).
05 C-LG-IND PIC X.
05 REST PIC X(102).
LINKAGE SECTION.
01 C BASED.
05 PIC X OCCURS 0 TO 49
DEPENDING ON LEN-1.
01 D-E BASED.
05 D PIC 9(4).
05 E.
10 PIC X OCCURS 0 TO 49
DEPENDING ON D.
01 F BASED.
05 PIC X.
PROCEDURE DIVISION.

*> removed length computations from PROCESS-VC
*> extended/modified GET-VC
*> other unchanged snipped here

GET-VC.
MOVE LOW-VALUES TO DATA-IN
ACCEPT DATA-IN
IF DATA-IN NOT = LOW-VALUES
EVALUATE C-LG-IND
WHEN 'T'
MOVE 49 TO LEN-1
WHEN 'U'
MOVE 33 TO LEN-1
WHEN OTHER
MOVE 16 TO LEN-1
END-EVALUATE
*> make parts C, D-E, F addressable within area DATA-IN
SET WRK-PTR TO ADDRESS OF C-LG-IND
SET ADDRESS OF C TO WRK-PTR
SET WRK-PTR UP BY LEN-1
SET ADDRESS OF D-E TO WRK-PTR
SET WRK-PTR UP BY FUNCTION BYTE-LENGTH(D-E)
SET ADDRESS OF F TO WRK-PTR
END-IF.

This has a shortcoming compared to the original solution: data A ...F can
not be accessed as a group like VC in the original solution

Karl Kiesel
Fujitsu Siemens Computers, München



.