Die folgenden Themen werden behandelt:
Beispiel 2 — DEFINE DATA LOCAL (Array-Definition/Initialisierung)
Beispiel 3 — DEFINE DATA (View-Definition, Array-Redefinition)
Beispiel 4 — DEFINE DATA (Global, Parameter und Local Data Areas)
** Example 'DDAEX1': DEFINE DATA ************************************************************************ DEFINE DATA LOCAL 1 #VAR1 (A15) 1 #VAR2 2 #VAR2A (N4.1) INIT <1111> 2 #VAR2B (N6.2) INIT <222222> 1 REDEFINE #VAR2 2 #VAR2C (A2) 2 #VAR2D (A2) 2 #VAR2E (A6) END-DEFINE * WRITE NOTITLE '=' #VAR2A / '=' #VAR2B / '=' #VAR2C / '=' #VAR2D / '=' #VAR2E * END
Ausgabe des Programms DDAEX1
:
#VAR2A: 1111.0 #VAR2B: 222222.00 #VAR2C: 11 #VAR2D: 11 #VAR2E: 022222
** EXAMPLE 'DDAEX2': DEFINE DATA (array definition/initialization) ************************************************************************ DEFINE DATA LOCAL **============================================= 1 #A01 (A5/1:4) INIT <'A','B',,'D'> 1 #A02 (A5/1:4) INIT (V) <'A','B'> (4) <'D'> 1 #A03 (A5/1:4) INIT (*) <'A'> 1 #A04 (A5/1:4) INIT (2) <'B'> (3) <'C'> 1 #A05 (A5/1:4) INIT (2:3) <'X'> (4) <'D'> 1 #A06 (A5/1:4) INIT (*) <'X'> (3) <'C'> **--------------------------------------------- 1 #A10 (A5/1:4) INIT FULL LENGTH <'X'> 1 #A11 (A5/1:4) INIT FULL LENGTH <,'B',,'D'> 1 #A12 (A5/1:4) INIT (V) FULL LENGTH <'A','B'> 1 #A13 (A5/1:4) INIT (2) FULL LENGTH <'B'> 1 #A14 (A5/1:4) INIT (*) FULL LENGTH <'X'> **--------------------------------------------- 1 #A20 (A5/1:4) INIT LENGTH 2 <'A'> 1 #A21 (A5/1:4) INIT (2) LENGTH 2 <'B'> (3) LENGTH 3 <'C'> 1 #A22 (A5/1:4) INIT (3:4) LENGTH 2 <'X'> 1 #A23 (A5/1:4) INIT (V) LENGTH 2 <,'B',,'D'> **--------------------------------------------- 1 #A30 (A5/1:4) INIT ALL <'Z'> 1 #A31 (A5/1:4) INIT ALL FULL LENGTH <'Z'> 1 #A32 (A5/1:4) INIT ALL LENGTH 2 <'Z'> **============================================= 1 #B01 (A5/1:2,1:4) INIT (2,V) <'A','B',,'D'> 1 #B02 (A5/1:2,1:4) INIT (1,*) <'X'> (1,2) <'B'> (2,3) <'F'> 1 #B03 (A5/1:2,1:4) INIT (1,1:2) <'X'> (1,4) <'Y'> 1 #B04 (A5/1:2,1:4) INIT (V,1) <'A1','A2'> 1 #B05 (A5/1:2,1:4) INIT (V,*) <'X','Y'> **--------------------------------------------- 1 #B10 (A5/1:2,1:4) INIT ALL <'Z'> 1 #B11 (A5/1:2,1:4) INIT (1,*) FULL LENGTH <'Z'> 1 #B12 (A5/1:2,1:4) INIT (*,*) FULL LENGTH <'Z'> 1 #B13 (A5/1:2,1:4) INIT (1,*) LENGTH 2 <'Z'> 1 #B14 (A5/1:2,1:4) INIT (1,V) FULL LENGTH <'A',,'C'> (2,V) FULL LENGTH <'E','F'> 1 #B15 (A5/1:2,1:4) INIT (1,*) FULL LENGTH <'X'> (2,*) FULL LENGTH <'Y'> (2,4) FULL LENGTH <'Z'> * END-DEFINE **============================================= WRITE 7X '(1) (2) (3) (4)' WRITE (AD=V) '=' #A01(*) WRITE (AD=V) '=' #A02(*) WRITE (AD=V) '=' #A03(*) WRITE (AD=V) '=' #A04(*) WRITE (AD=V) '=' #A05(*) WRITE (AD=V) '=' #A06(*) SKIP 1 WRITE (AD=V) '=' #A10(*) WRITE (AD=V) '=' #A11(*) WRITE (AD=V) '=' #A12(*) WRITE (AD=V) '=' #A13(*) WRITE (AD=V) '=' #A14(*) SKIP 1 WRITE (AD=V) '=' #A20(*) WRITE (AD=V) '=' #A21(*) WRITE (AD=V) '=' #A22(*) WRITE (AD=V) '=' #A23(*) SKIP 1 WRITE (AD=V) '=' #A30(*) WRITE (AD=V) '=' #A31(*) WRITE (AD=V) '=' #A32(*) SKIP 1 **============================================= WRITE 6X '(1,1) (1,2) (1,3) (1,4) (2,1) (2,2) (2,3) (2,4)' WRITE (AD=V) '=' #B01(1,*) 2X #B01(2,*) WRITE (AD=V) '=' #B02(1,*) 2X #B02(2,*) WRITE (AD=V) '=' #B03(1,*) 2X #B03(2,*) WRITE (AD=V) '=' #B04(1,*) 2X #B04(2,*) WRITE (AD=V) '=' #B05(1,*) 2X #B05(2,*) SKIP 1 WRITE (AD=V) '=' #B10(1,*) 2X #B10(2,*) WRITE (AD=V) '=' #B11(1,*) 2X #B11(2,*) WRITE (AD=V) '=' #B12(1,*) 2X #B12(2,*) WRITE (AD=V) '=' #B13(1,*) 2X #B13(2,*) WRITE (AD=V) '=' #B14(1,*) 2X #B14(2,*) WRITE (AD=V) '=' #B15(1,*) 2X #B15(2,*) **============================================= END
** Example 'DDAEX3': DEFINE DATA (view definition, array redefinition) ************************************************************************ DEFINE DATA LOCAL 1 EMPLOY-VIEW VIEW OF EMPLOYEES 2 NAME 2 ADDRESS-LINE (A20/2) 2 PHONE * 1 #ARRAY (A75/1:4) 1 REDEFINE #ARRAY 2 #ALINE (A25/1:4,1:3) 1 #X (N2) INIT <1> 1 #Y (N2) INIT <1> END-DEFINE * FORMAT PS=20 LIMIT 5 FIND EMPLOY-VIEW WITH NAME = 'SMITH' MOVE NAME TO #ALINE (#X,#Y) MOVE ADDRESS-LINE(1) TO #ALINE (#X+1,#Y) MOVE ADDRESS-LINE(2) TO #ALINE (#X+2,#Y) MOVE PHONE TO #ALINE (#X+3,#Y) IF #Y = 3 RESET INITIAL #Y PERFORM PRINT ELSE ADD 1 TO #Y END-IF AT END OF DATA PERFORM PRINT END-ENDDATA END-FIND * DEFINE SUBROUTINE PRINT WRITE NOTITLE (AD=OI) #ARRAY(*) RESET #ARRAY(*) SKIP 1 END-SUBROUTINE * END
Ausgabe des Programms DDAEX3
:
SMITH SMITH SMITH ENGLANDSVEJ 222 3152 SHETLAND ROAD 14100 ESWORTHY RD. MILWAUKEE MONTERREY 554349 877-4563 994-2260 SMITH SMITH 5 HAWTHORN 13002 NEW ARDEN COUR OAK BROOK SILVER SPRING 150-9351 639-8963
** Example 'DDAEX4': DEFINE DATA (global and local data area definition) ************************************************************************ DEFINE DATA GLOBAL USING DDAEX4G LOCAL 1 #FIELD1 (A10) 1 #FIELD2 (N5) END-DEFINE * MOVE 'HELLO' TO #FIELD1 MOVE 123 TO #FIELD2 * CALLNAT 'DDAEX4N' #FIELD1 #FIELD2 * END
Vom Programm DDAEX4
benutzte Global Data Area
DDAEX4G
:
1 GLOBAL-FIELD A 10
Vom Programm DDAEX4
aufgerufenes Subprogramm
DDAEX4N
:
** Example 'DDAEX4N': DEFINE DATA PARAMETER (called by DDAEX4) ************************************************************************ DEFINE DATA PARAMETER 1 #FIELDA (A10) 1 #FIELDB (N5) END-DEFINE * WRITE '=' #FIELDA '=' #FIELDB END
Ausgabe des Programms DDAEX4
:
Page 1 05-01-12 08:55:53 #FIELDA: HELLO #FIELDB: 123
** Example 'DDAEX5': DEFINE DATA (initialization) ************************************************************************ DEFINE DATA LOCAL 1 #START-DATE (D) INIT <*DATX> 1 #UNDERLINE (A50) INIT FULL LENGTH <'_'> 1 #SCALE (A65) INIT LENGTH 65 <'....+..../'> END-DEFINE * WRITE NOTITLE #START-DATE (DF=L) / #UNDERLINE / #SCALE END
Ausgabe des Programms DDAEX5
:
2005-01-12 __________________________________________________ ....+..../....+..../....+..../....+..../....+..../....+..../....+
** Example 'DDAEX6': DEFINE DATA (variable array with (1:V)) ************************************************************************ DEFINE DATA LOCAL 1 #ARRAY (A1/1:10) 1 #MAX-ARR (P3) END-DEFINE * #ARRAY (1) := 'R' #ARRAY (2) := 'E' #ARRAY (3) := 'D' #MAX-ARR := 4 * WRITE #ARRAY(*) * CALLNAT 'DDAEX6N' #ARRAY(1:4) #MAX-ARR * WRITE #ARRAY(*) * * #MAX-ARR := 5 * CALLNAT 'DDAEX6N' #ARRAY(1:5) #MAX-ARR * WRITE #ARRAY(*) * END
Vom Programm DDAEX6
aufgerufenes Subprogramm
DDAEX6N
:
** Example 'DDAEX6N': DEFINE DATA (variable array with (1:V)) ************************************************************************ DEFINE DATA PARAMETER 1 #STRING (A1/1:V) 1 #MAX (P3) END-DEFINE * IF #MAX = 4 MOVE 'B' TO #STRING (1) MOVE 'L' TO #STRING (2) MOVE 'U' TO #STRING (3) MOVE 'E' TO #STRING (4) END-IF * IF #MAX = 5 MOVE 'W' TO #STRING (1) MOVE 'H' TO #STRING (2) MOVE 'I' TO #STRING (3) MOVE 'T' TO #STRING (4) MOVE 'E' TO #STRING (5) END-IF END
Ausgabe des Programms DDAEX4
:
Page 1 05-01-12 09:06:43 R E D B L U E W H I T E