Dieses Dokument enthält zusätzliche Beispielprogramme, die in der
Natural Statements- und in der Systemvariablen-Dokumentation) referenziert
werden. Es handelt sich dabei hauptsächlich um Beispiele für den Reporting
Mode. Alle diese Beispiele sind in der Library SYSEXSYN
enthalten.
Anmerkung:
Grundsätzlich sind die in den Statement-Beschreibungen gezeigten
Beispielprogramme im Structured Mode geschrieben. Bei Statements, bei denen die
Syntax im Reporting Mode stark von der Syntax im Structured Mode abweicht,
finden Sie außerdem Verweise auf äquivalente Reporting Mode-Beispiele. Die im
folgenden abgebildeten Beispielprogramme sind auch online in Sourcecode-Form
verfügbar, und zwar in der Natural-Library SYSEXSYN
. Weitere
Beispielprogramme zur Benutzung der Natural-Statements sind im
Leitfaden zur Programmierung dokumentiert. Diese
Beispielprogramme stehen online in der Natural-Library SYSEXPG
zur
Verfügung. Näheres zur Verfügbarkeit dieser Libraries in Ihrem Unternehmen
erfahren Sie von Ihrem Natural-Administrator. Die Beispielprogramme verwenden
Daten aus der Datei EMPLOYEES
(Angestelltendaten), die die
Software AG zu Demonstrationszwecken ausliefert.
Auf die hier aufgeführten Beispielprogramme wird in den Beschreibungen der folgenden Statements bzw. Systemvariablen Bezug genommen:
Das folgende Beispiel wird in der ASSIGN
/COMPUTE
-Statement-Beschreibung
referenziert.
** Beispiel 'ASGEX1R': ASSIGN (reporting mode) ************************************************************************ RESET #A (N3) #B (A6) #C (N0.3) #D (N0.5) #E (N1.3) #F (N5) #G (A25) #H (A3/1:3) * #A = 5 WRITE NOTITLE '=' #A #B = 'ABC' WRITE '=' #B #C = .45 WRITE '=' #C #D = #E = -0.12345 WRITE '=' #D / '=' #E ASSIGN ROUNDED #F = 199.999 WRITE '=' #F #G = 'HELLO' WRITE '=' #G * #H (1) = 'UVW' #H (3) = 'XYZ' WRITE '=' #H (1:3) * END
Ausgabe des Programms AEDEX1R
:
#A: 5 #B: ABC #C: .450 #D: -.12345 #E: -0.123 #F: 200 #G: HELLO #H: UVW XYZ
Die folgenden Beispiele werden in der AT BREAK
-Statement-Beschreibung
referenziert.
** Beispiel 'ATBEX1R': AT BREAK (reporting mode) ************************************************************************ * LIMIT 10 READ EMPLOYEES BY CITY AT BREAK OF CITY DO SKIP 1 DOEND /* DISPLAY NOTITLE CITY (IS=ON) COUNTRY (IS=ON) NAME LOOP END
Ausgabe des Programms ATBEX1R
:
CITY COUNTRY NAME -------------------- ------- -------------------- AIKEN USA SENKO AIX EN OTHE F GODEFROY AJACCIO CANALE ALBERTSLUND DK PLOUG ALBUQUERQUE USA HAMMOND ROLLING FREEMAN LINCOLN ALFRETON UK GOLDBERG ALICANTE E GOMEZ
** Beispiel 'ATBEX5R': AT BREAK (multiple break levels) (reporting mode) ************************************************************************ RESET LEAVE-DUE-L (N4) * LIMIT 5 FIND EMPLOYEES WITH CITY = 'PHILADELPHIA' OR = 'PITTSBURGH' SORTED BY CITY DEPT MOVE LEAVE-DUE TO LEAVE-DUE-L DISPLAY CITY (IS=ON) DEPT (IS=ON) NAME LEAVE-DUE-L AT BREAK OF DEPT WRITE NOTITLE / T*DEPT OLD(DEPT) T*LEAVE-DUE-L SUM(LEAVE-DUE-L) / AT BREAK OF CITY WRITE NOTITLE T*CITY OLD(CITY) T*LEAVE-DUE-L SUM(LEAVE-DUE-L) // LOOP * END
Ausgabe des Programms ATBEX5R
:
CITY DEPARTMENT NAME LEAVE-DUE-L CODE -------------------- ---------- -------------------- ----------- PHILADELPHIA MGMT30 WOLF-TERROINE 11 MACKARNESS 27 MGMT30 38 TECH10 BUSH 39 NETTLEFOLDS 24 TECH10 63 PHILADELPHIA 101 PITTSBURGH MGMT10 FLETCHER 34 MGMT10 34 PITTSBURGH 34
Das folgende Beispiel wird in der AT
END OF DATA
-Statement-Beschreibung referenziert.
** Beispiel 'AEDEX1R': AT END OF DATA (reporting mode) ************************************************************************ LIMIT 5 EMP. FIND EMPLOYEES WITH CITY = 'STUTTGART' IF NO RECORDS FOUND ENTER DISPLAY PERSONNEL-ID NAME FIRST-NAME SALARY (1) CURR-CODE (1) /* AT END OF DATA DO IF *COUNTER (EMP.) = 0 DO WRITE 'NO RECORDS FOUND' ESCAPE BOTTOM DOEND WRITE NOTITLE / 'SALARY STATISTICS:' / 7X 'MAXIMUM:' MAX(SALARY(1)) CURR-CODE (1) / 7X 'MINIMUM:' MIN(SALARY(1)) CURR-CODE (1) / 7X 'AVERAGE:' AVER(SALARY(1)) CURR-CODE (1) DOEND LOOP END
Ausgabe des Programms AEDEX1R
:
PERSONNEL NAME FIRST-NAME ANNUAL CURRENCY ID SALARY CODE --------- -------------------- -------------------- ---------- -------- 11100328 BERGHAUS ROSE 70800 DM 11100329 BARTHEL PETER 42000 DM 11300313 AECKERLE SUSANNE 55200 DM 11300316 KANTE GABRIELE 61200 DM 11500304 KLUGE ELKE 49200 DM SALARY STATISTICS: MAXIMUM: 70800 DM MINIMUM: 42000 DM AVERAGE: 55680 DM
Das folgende Beispiel wird in der AT
END OF PAGE
-Statement-Beschreibung referenziert.
** Beispiel 'AEPEX1R': AT END OF PAGE (reporting mode) ************************************************************************ FORMAT PS=10 LIMIT 10 READ EMPLOYEES BY PERSONNEL-ID FROM '20017000' DISPLAY NOTITLE GIVE SYSTEM FUNCTIONS NAME JOB-TITLE 'SALARY' SALARY(1) CURR-CODE (1) /* AT END OF PAGE DO WRITE / 28T 'AVERAGE SALARY: ...' AVER(SALARY(1)) CURR-CODE (1) DOEND /* LOOP END
Ausgabe des Programms AEPEX1R
:
NAME CURRENT SALARY CURRENCY POSITION CODE -------------------- ------------------------- ---------- -------- CREMER ANALYST 34000 USD MARKUSH TRAINEE 22000 USD GEE MANAGER 39500 USD KUNEY DBA 40200 USD NEEDHAM PROGRAMMER 32500 USD JACKSON PROGRAMMER 33000 USD AVERAGE SALARY: ... 33533 USD
Das folgende Beispiel wird in der AT
START OF DATA
-Statement-Beschreibung referenziert.
** Beispiel 'ASDEX1R': AT START OF DATA (reporting mode) *********************************************************************** RESET #CITY (A20) #CNTL (A1) * REPEAT INPUT 'ENTER VALUE FOR CITY' #CITY /* IF #CITY = ' ' OR= 'END' DO STOP DOEND FIND EMPLOYEES WITH CITY = #CITY IF NO RECORDS FOUND DO WRITE NOTITLE NOHDR 'NO RECORDS FOUND' ESCAPE DOEND /* AT START OF DATA DO INPUT (AD=O) 'RECORDS FOUND' *NUMBER // 'ENTER ''D'' TO DISPLAY RECORDS' #CNTL (AD=A) IF #CNTL NE 'D' DO ESCAPE BOTTOM DOEND DOEND /* DISPLAY NAME FIRST-NAME LOOP LOOP END
Ausgabe des Programms ASDEX1R
:
ENTER VALUE FOR CITY PARIS
Nach Eingabe und Bestätigung des Namens der Stadt:
RECORDS FOUND 26 ENTER 'D' TO DISPLAY RECORDS D
Nach Eingabe und Bestätigung von D
:
NAME FIRST-NAME -------------------- -------------------- MAIZIERE ELISABETH MARX JEAN-MARIE REIGNARD JACQUELINE RENAUD MICHEL REMOUE GERMAINE LAVENDA SALOMON BROUSSE GUY GIORDA LOUIS SIECA FRANCOIS CENSIER BERNARD DUC JEAN-PAUL CAHN RAYMOND MAZUY ROBERT FAURIE HENRI VALLY ALAIN BRETON JEAN-MARIE GIGLEUX JACQUES KORAB-BRZOZOWSKI BOGDAN XOLIN CHRISTIAN LEGRIS ROGER VVVV
Das folgende Beispiel wird in der AT
TOP OF PAGE
-Statement-Beschreibung referenziert.
** Beispiel 'ATPEX1R': AT TOP OF PAGE (reporting mode) ************************************************************************ * FORMAT PS=15 LIMIT 15 * READ EMPLOYEES BY NAME STARTING FROM 'L' DISPLAY 2X NAME 4X FIRST-NAME CITY DEPT WRITE TITLE UNDERLINED 'EMPLOYEE REPORT' WRITE TRAILER '-' (78) /* AT TOP OF PAGE DO WRITE 'BEGINNING NAME:' NAME DOEND /* AT END OF PAGE DO SKIP 1 WRITE 'ENDING NAME: ' NAME DOEND LOOP END
Das folgende Beispiel wird in der DEFINE
SUBROUTINE
-Statement-Beschreibung referenziert.
** Beispiel 'DSREX1R': DEFINE SUBROUTINE (reporting mode) ************************************************************************ RESET #ARRAY-ALL (A300) #X (N2) #Y (N2) REDEFINE #ARRAY-ALL (#ARRAY (A75/1:4)) #ARRAY-ALL (#ALINE (A25/1:4,1:3)) * FORMAT PS=20 LIMIT 5 * MOVE 1 TO #X #Y * FIND EMPLOYEES WITH NAME = 'SMITH' OBTAIN ADDRESS-LINE (1:2) /* 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 DO MOVE 1 TO #Y PERFORM PRINT DOEND ELSE DO ADD 1 TO #Y DOEND AT END OF DATA DO PERFORM PRINT DOEND LOOP * DEFINE SUBROUTINE PRINT WRITE NOTITLE (AD=OI) #ARRAY(*) RESET #ARRAY(*) SKIP 1 RETURN * END
Ausgabe des Programms AEDEX1R
:
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
Die folgenden Beispiele werden in der FIND
-Statement-Beschreibung
referenziert.
** Beispiel 'FNDFIR': FIND FIRST ************************************************************************ * FIND FIRST EMPLOYEES WITH CITY = 'DERBY' * WRITE NOTITLE 'TOTAL RECORDS SELECTED:' *NUMBER SKIP 2 WRITE '***FIRST PERSON SELECTED***' // 'NAME: ' NAME / 'DEPARTMENT:' DEPT / 'JOB TITLE: ' JOB-TITLE * END
Ausgabe des Programms FNDFIR
:
TOTAL RECORDS SELECTED: 141 ***FIRST PERSON SELECTED*** NAME: DEAKIN DEPARTMENT: SALE01 JOB TITLE: SALES ACCOUNTANT
** Beispiel 'FNDNUM': FIND NUMBER ************************************************************************ RESET #BIRTH (D) * MOVE EDITED '19500101' TO #BIRTH (EM=YYYYMMDD) * FIND NUMBER EMPLOYEES WITH CITY = 'MADRID' WHERE BIRTH LT #BIRTH * WRITE NOTITLE 'TOTAL RECORDS SELECTED: ' *NUMBER / 'TOTAL BORN BEFORE 1 JAN 1950: ' *COUNTER * END
Ausgabe des Programms FNDNUM
:
TOTAL RECORDS SELECTED: 41 TOTAL BORN BEFORE 1 JAN 1950: 16
** Beispiel 'FNDUNQ': FIND UNIQUE ************************************************************************ RESET #NAME (A20) * * INPUT 'ENTER EMPLOYEE NAME: ' #NAME IF #NAME = ' ' STOP * FIND UNIQUE EMPLOYEES WITH NAME = #NAME * DISPLAY NOTITLE NAME FIRST-NAME JOB-TITLE * ON ERROR DO WRITE 'NAME EITHER NOT UNIQUE OR DOES NOT EXIST' FETCH 'FNDUNQ' DOEND * END
Ausgabe des Programms FNDUNQ
:
ENTER EMPLOYEE NAME: HEURTEBISE
Nach Eingabe und Bestätigung des Namens HEURTEBISE
:
NAME FIRST-NAME CURRENT POSITION -------------------- -------------------- ------------------------- HEURTEBISE MICHEL CONTROLEUR DE GESTION
Das folgende Beispiel wird in der FOR
-Statement-Beschreibung
referenziert.
** Beispiel 'FOREX1R': FOR (reporting mode) ************************************************************************ RESET #INDEX (I1) #ROOT (N2.7) * FOR #INDEX 1 TO 5 COMPUTE #ROOT = SQRT (#INDEX) WRITE NOTITLE '=' #INDEX 3X '=' #ROOT LOOP * SKIP 1 FOR #INDEX 1 TO 5 STEP 2 COMPUTE #ROOT = SQRT (#INDEX) WRITE '=' #INDEX 3X '=' #ROOT LOOP * END
Ausgabe des Programms FOREX1R
:
#INDEX: 1 #ROOT: 1.0000000 #INDEX: 2 #ROOT: 1.4142135 #INDEX: 3 #ROOT: 1.7320508 #INDEX: 4 #ROOT: 2.0000000 #INDEX: 5 #ROOT: 2.2360679 #INDEX: 1 #ROOT: 1.0000000 #INDEX: 3 #ROOT: 1.7320508 #INDEX: 5 #ROOT: 2.2360679
Das folgende Beispiel wird in der HISTOGRAM
-Statement-Beschreibung
referenziert.
** Beispiel 'HSTEX1R': HISTOGRAM (reporting mode) ************************************************************************ * LIMIT 8 HISTOGRAM EMPLOYEES CITY STARTING FROM 'M' DISPLAY NOTITLE CITY 'NUMBER OF/PERSONS' *NUMBER *COUNTER LOOP * END
Ausgabe des Programms HSTEX1R
:
CITY NUMBER OF CNT PERSONS -------------------- ----------- ----------- MADISON 3 1 MADRID 41 2 MAILLY LE CAMP 1 3 MAMERS 1 4 MANSFIELD 4 5 MARSEILLE 2 6 MATLOCK 1 7 MELBOURNE 2 8
Das folgende Beispiel wird in der IF
-Statement-Beschreibung
referenziert.
** Beispiel 'IFEX1R': IF (reporting mode) ************************************************************************ RESET #BIRTH (D) * MOVE EDITED '19450101' TO #BIRTH (EM=YYYYMMDD) SUSPEND IDENTICAL SUPPRESS LIMIT 20 * FND. FIND EMPLOYEES WITH CITY = 'FRANKFURT' SORTED BY NAME BIRTH IF SALARY (1) LT 40000 WRITE NOTITLE '*****' NAME 30X 'SALARY LT 40000' ELSE DO IF BIRTH GT #BIRTH DO FIND VEHICLES WITH PERSONNEL-ID = PERSONNEL-ID (FND.) DISPLAY (IS=ON) NAME BIRTH (EM=YYYY-MM-DD) SALARY (1) MAKE (AL=8) LOOP DOEND DOEND LOOP END
Ausgabe des Programms IFEX1R
:
NAME DATE ANNUAL MAKE OF SALARY BIRTH -------------------- ---------- ---------- -------- BAECKER 1956-01-05 74400 BMW ***** BECKER SALARY LT 40000 BLOEMER 1979-11-07 45200 FIAT FALTER 1954-05-23 70800 FORD ***** FALTER SALARY LT 40000 ***** GROTHE SALARY LT 40000 ***** HEILBROCK SALARY LT 40000 ***** HESCHMANN SALARY LT 40000 HUCH 1952-09-12 67200 MERCEDES ***** KICKSTEIN SALARY LT 40000 ***** KLEENE SALARY LT 40000 ***** KRAMER SALARY LT 40000
Das folgende Beispiel wird in der PERFORM BREAK
PROCESSING
-Statement-Beschreibung referenziert.
** Beispiel 'PBPEX1R': PERFORM BREAK PROCESSING (reporting mode) ************************************************************************ RESET #LINE (N2) #INDEX (N2) * MOVE 1 TO #LINE FOR #INDEX 1 TO 18 PERFORM BREAK PROCESSING /* AT BREAK OF #INDEX /1/ DO WRITE NOTITLE / 'PLEASE COMPLETE LINES 1-9 ABOVE' / MOVE 1 TO #LINE DOEND /* WRITE NOTITLE '_' (64) '=' #LINE ADD 1 TO #LINE LOOP END
Ausgabe des Programms PBPEX1R
:
________________________________________________________________ #LINE: 1 ________________________________________________________________ #LINE: 2 ________________________________________________________________ #LINE: 3 ________________________________________________________________ #LINE: 4 ________________________________________________________________ #LINE: 5 ________________________________________________________________ #LINE: 6 ________________________________________________________________ #LINE: 7 ________________________________________________________________ #LINE: 8 ________________________________________________________________ #LINE: 9 PLEASE COMPLETE LINES 1-9 ABOVE ________________________________________________________________ #LINE: 1 ________________________________________________________________ #LINE: 2 ________________________________________________________________ #LINE: 3 ________________________________________________________________ #LINE: 4 ________________________________________________________________ #LINE: 5 ________________________________________________________________ #LINE: 6 ________________________________________________________________ #LINE: 7 ________________________________________________________________ #LINE: 8 ________________________________________________________________ #LINE: 9 PLEASE COMPLETE LINES 1-9 ABOVE
Das folgende Beispiel wird in der READ
-Statement-Beschreibung
referenziert.
** Beispiel 'REAEX1R': READ (reporting mode) ************************************************************************ LIMIT 3 * WRITE 'READ IN PHYSICAL SEQUENCE' READ EMPLOYEES IN PHYSICAL SEQUENCE DISPLAY NOTITLE PERSONNEL-ID NAME *ISN *COUNTER LOOP * WRITE / 'READ IN ISN SEQUENCE' READ EMPLOYEES BY ISN STARTING FROM 1 ENDING AT 3 DISPLAY PERSONNEL-ID NAME *ISN *COUNTER LOOP * WRITE / 'READ IN NAME SEQUENCE' READ EMPLOYEES BY NAME DISPLAY PERSONNEL-ID NAME *ISN *COUNTER LOOP * WRITE / 'READ IN NAME SEQUENCE STARTING FROM ''M''' READ EMPLOYEES BY NAME STARTING FROM 'M' DISPLAY PERSONNEL-ID NAME *ISN *COUNTER LOOP * END
Ausgabe des Programms REAEX1R
:
PERSONNEL NAME ISN CNT ID --------- -------------------- ----------- ----------- READ IN PHYSICAL SEQUENCE 50005800 ADAM 1 1 50005600 MORENO 2 2 50005500 BLOND 3 3 READ IN ISN SEQUENCE 50005800 ADAM 1 1 50005600 MORENO 2 2 50005500 BLOND 3 3 READ IN NAME SEQUENCE 60008339 ABELLAN 478 1 30000231 ACHIESON 878 2 50005800 ADAM 1 3 READ IN NAME SEQUENCE STARTING FROM 'M' 30008125 MACDONALD 923 1 20028700 MACKARNESS 765 2 40000045 MADSEN 508 3
Die folgenden Beispiele werden in der REPEAT
-Statement-Beschreibung
referenziert.
** Beispiel 'RPTEX1R': REPEAT (reporting mode) ************************************************************************ RESET #PERS-NR (A8) * REPEAT INPUT 'ENTER A PERSONNEL NUMBER:' #PERS-NR IF #PERS-NR = ' ' ESCAPE BOTTOM FIND EMPLOYEES WITH PERSONNEL-ID = #PERS-NR IF NO RECORD FOUND REINPUT 'NO RECORD FOUND' DISPLAY NOTITLE NAME LOOP LOOP * END
Ausgabe des Programms RPTEX1R
:
ENTER A PERSONNEL NUMBER:
** Beispiel 'RPTEX2R': REPEAT (with WHILE and UNTIL option) ************************************************************************ RESET #X (I1) #Y (I1) * * REPEAT WHILE #X <= 5 ADD 1 TO #X WRITE NOTITLE '=' #X LOOP * SKIP 3 REPEAT ADD 1 TO #Y WRITE '=' #Y UNTIL #Y = 6 LOOP * END
Ausgabe des Programms RPTEX2R
:
#X: 1 #X: 2 #X: 3 #X: 4 #X: 5 #X: 6 #Y: 1 #Y: 2 #Y: 3 #Y: 4 #Y: 5 #Y: 6
Das folgende Beispiel wird in der SORT
-Statement-Beschreibung
referenziert.
** Beispiel 'SRTEX1R': SORT (reporting mode) ************************************************************************ RESET #AVG (P11) #TOTAL-TOTAL (P11) #TOTAL-SALARY (P11) #AVER-PERCENT (N3.2) * LIMIT 3 FIND EMPLOYEES WITH CITY = 'BOSTON' OBTAIN SALARY(1:2) COMPUTE #TOTAL-SALARY = SALARY (1) + SALARY (2) ACCEPT IF #TOTAL-SALARY GT 0 /* SORT BY PERSONNEL-ID USING #TOTAL-SALARY SALARY(*) CURR-CODE GIVE AVER(#TOTAL-SALARY) /* AT START OF DATA DO WRITE NOTITLE '*' (40) 'AVG CUMULATIVE SALARY:' *AVER (#TOTAL-SALARY) / MOVE *AVER (#TOTAL-SALARY) TO #AVG DOEND COMPUTE ROUNDED #AVER-PERCENT = #TOTAL-SALARY / #AVG * 100 ADD #TOTAL-SALARY TO #TOTAL-TOTAL /* DISPLAY NOTITLE PERSONNEL-ID SALARY (1) SALARY (2) #TOTAL-SALARY CURR-CODE (1) 'PERCENT/OF/AVER' #AVER-PERCENT AT END OF DATA WRITE / '*' (40) 'TOTAL SALARIES PAID: ' #TOTAL-TOTAL LOOP * END
Ausgabe des Programms SRTEX1R
:
PERSONNEL ANNUAL ANNUAL #TOTAL-SALARY CURRENCY PERCENT ID SALARY SALARY CODE OF AVER --------- ---------- ---------- ------------- -------- ------- **************************************** AVG CUMULATIVE SALARY: 44633 20000100 31000 29400 60400 USD 135.30 20019200 18000 17100 35100 USD 78.60 20020400 20000 18400 38400 USD 86.00 **************************************** TOTAL SALARIES PAID: 133900
Das folgende Beispiel wird in der STORE
-Statement-Beschreibung
referenziert.
** Beispiel 'STOEX1R': STORE (reporting mode) ** ** CAUTION: Executing this example will modify the database records! ************************************************************************ RESET #PERSONNEL-ID (A8) #NAME (A20) #FIRST-NAME (A15) #BIRTH-D (D) #MAR-STAT (A1) #BIRTH (A8) #CITY (A20) #COUNTRY (A3) #CONF (A1) * REPEAT INPUT 'ENTER A PERSONNEL ID AND NAME (OR ''END'' TO END)' // 'PERSONNEL-ID : ' #PERSONNEL-ID // 'NAME : ' #NAME / 'FIRST-NAME : ' #FIRST-NAME /* /* VALIDATE ENTERED DATA /* IF #PERSONNEL-ID = 'END' OR #NAME = 'END' STOP IF #NAME = ' ' REINPUT WITH TEXT 'ENTER A LAST-NAME' MARK 2 AND SOUND ALARM IF #FIRST-NAME = ' ' REINPUT WITH TEXT 'ENTER A FIRST-NAME' MARK 3 AND SOUND ALARM /* /* ENSURE PERSON IS NOT ALREADY ON FILE /* FIND NUMBER EMPLOYEES WITH PERSONNEL-ID = #PERSONNEL-ID IF *NUMBER > 0 REINPUT 'PERSON WITH SAME PERSONNEL-ID ALREADY EXISTS' MARK 1 AND SOUND ALARM MOVE 'N' TO #CONF /* /* GET FURTHER INFORMATION /* INPUT 'ADDITIONAL PERSONNEL DATA' //// 'PERSONNEL-ID :' #PERSONNEL-ID (AD=IO) / 'NAME :' #NAME (AD=IO) / 'FIRST-NAME :' #FIRST-NAME (AD=IO) /// 'MARITAL STATUS :' #MAR-STAT / 'DATE OF BIRTH (YYYYMMDD) :' #BIRTH / 'CITY :' #CITY / 'COUNTRY (3 CHARACTERS) :' #COUNTRY // 'ADD THIS RECORD (Y/N) :' #CONF (AD=M) /* /* ENSURE REQUIRED FIELDS CONTAIN VALID DATA /* IF NOT (#MAR-STAT = 'S' OR = 'M' OR = 'D' OR = 'W') REINPUT TEXT 'ENTER VALID MARITAL STATUS S=SINGLE ' - 'M=MARRIED D=DIVORCED W=WIDOWED' MARK 1 IF NOT (#BIRTH = MASK(YYYYMMDD) AND #BIRTH = MASK(1582-2699)) REINPUT TEXT 'ENTER CORRECT DATE' MARK 2 IF #CITY = ' ' REINPUT TEXT 'ENTER A CITY NAME' MARK 3 IF #COUNTRY = ' ' REINPUT TEXT 'ENTER A COUNTRY CODE' MARK 4 IF NOT (#CONF = 'N' OR= 'Y') REINPUT TEXT 'ENTER Y (YES) OR N (NO)' MARK 5 IF #CONF = 'N' ESCAPE TOP /* /* ADD THE RECORD /* MOVE EDITED #BIRTH TO #BIRTH-D (EM=YYYYMMDD) /* STORE RECORD IN EMPLOYEES WITH PERSONNEL-ID = #PERSONNEL-ID NAME = #NAME FIRST-NAME = #FIRST-NAME MAR-STAT = #MAR-STAT BIRTH = #BIRTH-D CITY = #CITY COUNTRY = #COUNTRY END OF TRANSACTION /* WRITE NOTITLE 'RECORD HAS BEEN ADDED' /* LOOP END
Das folgende Beispiel wird in der UPDATE
-Statement-Beschreibung
referenziert.
** Beispiel 'UPDEX1R': UPDATE (reporting mode) ** ** CAUTION: Executing this example will modify the database records! ************************************************************************ RESET #NAME (A20) * INPUT 'ENTER A NAME:' #NAME (AD=M) IF #NAME = ' ' STOP * FIND EMPLOYEES WITH NAME = #NAME IF NO RECORDS FOUND REINPUT WITH 'NO RECORDS FOUND' MARK 1 /* INPUT 'NAME: ' NAME (AD=O) / 'FIRST NAME:' FIRST-NAME (AD=M) / 'CITY: ' CITY (AD=M) /* UPDATE USING SAME RECORD /* END TRANSACTION /* LOOP * END
Ausgabe des Programms UPDEX1R
:
ENTER A NAME:
Die folgenden Beispiele werden in der
*OCCURRENCE
-Systemvariablen-Beschreibung
referenziert:
** Beispiel 'OCC1P': *OCCURRENCE ************************************************************************ DEFINE DATA LOCAL 1 #N1 (N7/1:10) 1 #N2 (N7/1:10,1:10) 1 #N3 (N7/1:10,1:10,1:10) END-DEFINE * CALLNAT 'OCC1N' #N1(*) #N2(1:2,1:4) #N3(1:6,1:7,1:8) * END
Vom Programm OCC1P
aufgerufenes Subprogramm
OCC1N
:
** Beispiel 'OCC1N': *OCCURRENCE (called by OCC1P) ********************************************************************** DEFINE DATA PARAMETER 1 PARM1 (N7/1:V) 1 PARM2 (N7/1:V,1:V) 1 PARM3 (N7/1:V,1:V,1:V) LOCAL 1 #OCC2 (I4/1:2) 1 #OCC3 (I4/1:3) 1 #OCC1 (I4) END-DEFINE * MOVE *OCC(PARM1) TO #OCC1 MOVE *OCC(PARM2,*) TO #OCC2(*) MOVE *OCC(PARM3,*) TO #OCC3(*) * DISPLAY #OCC1 #OCC2(*) #OCC3(*) DISPLAY *OCC(PARM1,*) *OCC(PARM2,*) *OCC(PARM3,*) * NEWPAGE * WRITE NOHDR 'Occurrences of 1. parameter:' *OCC(PARM1) / 'Occurrences of 1. parameter:' *OCC(PARM1,1) / 'Occurrences of 1. parameter:' *OCC(PARM1,*) / 'Occurrences of 2. parameter:' *OCC(PARM2,1) *OCC(PARM2,2) / 'Occurrences of 2. parameter:' *OCC(PARM2,*) / 'Occurrences of 3. parameter:' *OCC(PARM3,1) *OCC(PARM3,2) *OCC(PARM3,3) / 'Occurrences of 3. parameter:' *OCC(PARM3,*) * END
Ausgabe des Programms OCC1P
- Seite 1:
Page 1 05-01-18 10:21:30 #OCC1 #OCC2 #OCC3 ----------- ----------- ----------- 10 2 6 4 7 8 10 2 6 4 7 8
Ausgabe des Programms OCC1P
- Seite 2:
Page 2 05-01-18 10:21:30 Occurrences of 1. parameter: 10 Occurrences of 1. parameter: 10 Occurrences of 1. parameter: 10 Occurrences of 2. parameter: 2 4 Occurrences of 2. parameter: 2 4 Occurrences of 3. parameter: 6 7 8 Occurrences of 3. parameter: 6 7 8
** Beispiel 'OCC2P': *OCCURRENCE ************************************************************************ DEFINE DATA LOCAL 1 #N (N7/1:10) 1 #I (I4) END-DEFINE * FOR #I=1 TO 10 MOVE #I TO #N(#I) END-FOR * WRITE 'Passing ocurrences 1:5' CALLNAT 'OCC2N' #N(1:5) * WRITE 'Passing ocurrences 5:10' CALLNAT 'OCC2N' #N(5:10) * END
Vom Programm OCC2P
aufgerufenes Subprogramm
OCC2N
:
** Beispiel 'OCC2N': *OCCURRENCE (called by OCC2P) ********************************************************************** DEFINE DATA PARAMETER 1 #ARR (N7/1:V) LOCAL 1 I (N7) END-DEFINE * FOR I=1 TO *OCC(#ARR) DISPLAY #ARR(I) END-FOR * END
Ausgabe des Programms OCC2P
:
Page 1 05-01-18 10:33:03 Passing ocurrences 1:5 1 2 3 4 5 Passing ocurrences 5:10 5 6 7 8 9 10