バージョン 6.3.3
 —  プログラミングガイド  —

参照プログラム例

このドキュメントでは、『プログラミングガイド』で参照されている追加のプログラム例を示します。

次のトピックについて説明します。


READ ステートメント

次の例は、「データベースアクセスのためのステートメント」セクションで参照されています。

READX03 - READ ステートメント(LOGICAL 節を含む)

** Example 'READX03': READ (with LOGICAL clause)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 NAME
  2 PERSONNEL-ID
  2 JOB-TITLE
END-DEFINE
*
LIMIT 8
READ EMPLOY-VIEW LOGICAL BY PERSONNEL-ID
  DISPLAY NOTITLE  *ISN      NAME
                  'PERS-NO'  PERSONNEL-ID
                  'POSITION' JOB-TITLE
END-READ
END

プログラム READX03 の出力:

   ISN              NAME         PERS-NO          POSITION         
----------- -------------------- -------- -------------------------
                                                                   
        204 SCHINDLER            11100102 PROGRAMMIERER            
        205 SCHIRM               11100105 SYSTEMPROGRAMMIERER      
        206 SCHMITT              11100106 OPERATOR                 
        207 SCHMIDT              11100107 SEKRETAERIN              
        208 SCHNEIDER            11100108 SACHBEARBEITER           
        209 SCHNEIDER            11100109 SEKRETAERIN              
        210 BUNGERT              11100110 SYSTEMPROGRAMMIERER      
        211 THIELE               11100111 SEKRETAERIN

Top of page

FIND ステートメント

次の例は、「データベースアクセスのためのステートメント」セクションで参照されています。

FINDX07 - FIND ステートメント(複数節を含む)

** Example 'FINDX07': FIND  (with several clauses)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 NAME
  2 FIRST-NAME
  2 CITY
  2 SALARY    (1)
  2 CURR-CODE (1)
END-DEFINE
*
FIND EMPLOY-VIEW WITH  PHONETIC-NAME = 'JONES' OR = 'BECKR'
                 AND   CITY          = 'BOSTON' THRU 'NEW YORK'
                 BUT NOT               'CHAPEL HILL'
                 SORTED BY NAME
                 WHERE SALARY (1)    < 28000
  DISPLAY NOTITLE NAME FIRST-NAME CITY SALARY (1)
END-FIND
END

プログラム FINDX07 の出力:

        NAME              FIRST-NAME              CITY           ANNUAL  
                                                                 SALARY  
-------------------- -------------------- -------------------- ----------
                                                                         
BAKER                PAULINE              DERBY                      4450
JONES                MARTHA               KALAMAZOO                 21000
JONES                KEVIN                DERBY                      7000

FINDX08 - FIND ステートメント(LIMIT を含む)

** Example 'FINDX08': FIND (with LIMIT)                                 
**                    Demonstrates FIND statement with LIMIT option to  
**                    terminate program with an error message if the    
**                    number of records selected exceeds a specified    
**                    limit (no output).                                
************************************************************************
DEFINE DATA LOCAL                                                       
1 EMPLOY-VIEW VIEW OF EMPLOYEES                                         
  2 NAME                                                                
  2 JOB-TITLE                                                           
END-DEFINE                                                              
*                                                                       
FIND EMPLOY-VIEW WITH LIMIT (5) JOB-TITLE = 'SALES PERSON'              
  DISPLAY NAME JOB-TITLE                                                
END-FIND                                                                
END

プログラム FINDX08 によって発生するランタイムエラー:

NAT1005 検索制限の指定より多くのレコードが見つかりました。

FINDX09 - FIND ステートメント(*NUMBER、*COUNTER、*ISN を使用)

** Example 'FINDX09': FIND (using *NUMBER, *COUNTER, *ISN)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 DEPT
  2 NAME
END-DEFINE
*
FIND EMPLOY-VIEW WITH CITY  = 'BOSTON'
                 WHERE DEPT = 'TECH00' THRU 'TECH10'
  DISPLAY NOTITLE
          'COUNTER' *COUNTER NAME DEPT 'ISN' *ISN
  AT START OF DATA
    WRITE '(TOTAL NUMBER IN BOSTON:' *NUMBER ')' /
  END-START
END-FIND
END

プログラム FINDX09 の出力:

  COUNTER           NAME         DEPARTMENT     ISN    
                                    CODE               
----------- -------------------- ---------- -----------
                                                       
(TOTAL NUMBER IN BOSTON:           7 )                 
                                                       
          1 STANWOOD             TECH10             782
          2 PERREAULT            TECH10             842

FINDX10 - FIND ステートメント(READ との組み合わせ)

** Example 'FINDX10': FIND (combined with READ)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 NAME
  2 FIRST-NAME
1 VEHIC-VIEW VIEW OF VEHICLES
  2 PERSONNEL-ID
  2 MAKE
END-DEFINE
*
LIMIT 15
*
EMP. READ EMPLOY-VIEW BY NAME STARTING FROM 'JONES'
  VEH. FIND VEHIC-VIEW WITH PERSONNEL-ID = PERSONNEL-ID (EMP.)
    IF NO RECORDS FOUND
      MOVE '*** NO CAR ***' TO MAKE
    END-NOREC
    DISPLAY NOTITLE
            NAME (EMP.) (IS=ON)
            FIRST-NAME (EMP.) (IS=ON)
            MAKE (VEH.)
  END-FIND
END-READ
END

プログラム FINDX10 の出力:

        NAME              FIRST-NAME              MAKE        
-------------------- -------------------- --------------------
                                                              
JONES                VIRGINIA             CHRYSLER            
                     MARSHA               CHRYSLER            
                                          CHRYSLER            
                     ROBERT               GENERAL MOTORS      
                     LILLY                FORD                
                                          MG                  
                     EDWARD               GENERAL MOTORS      
                     MARTHA               GENERAL MOTORS      
                     LAUREL               GENERAL MOTORS      
                     KEVIN                DATSUN              
                     GREGORY              FORD                
JOPER                MANFRED              *** NO CAR ***      
JOUSSELIN            DANIEL               RENAULT             
JUBE                 GABRIEL              *** NO CAR ***      
JUNG                 ERNST                *** NO CAR ***      
JUNKIN               JEREMY               *** NO CAR ***      
KAISER               REINER               *** NO CAR ***     

FINDX11 - FIND NUMBER ステートメント(*NUMBER を含む)

** Example 'FINDX11': FIND NUMBER (with *NUMBER)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 FIRST-NAME
  2 NAME
  2 CITY
  2 JOB-TITLE
  2 SALARY        (1)
*
1 #PERCENT        (N.2)
1 REDEFINE #PERCENT
  2 #WHOLE-NBR    (N2)
1 #ALL-BOST       (N3.2)
1 #SECR-ONLY      (N3.2)
1 #BOST-NBR       (N3)
1 #SECR-NBR       (N3)
END-DEFINE
*
F1. FIND NUMBER EMPLOY-VIEW WITH CITY = 'BOSTON'
F2. FIND NUMBER EMPLOY-VIEW WITH CITY = 'BOSTON'
                            AND JOB-TITLE = 'SECRETARY'
*
MOVE *NUMBER(F1.) TO #ALL-BOST  #BOST-NBR
MOVE *NUMBER(F2.) TO #SECR-ONLY #SECR-NBR
DIVIDE #ALL-BOST INTO #SECR-ONLY GIVING #PERCENT
*
WRITE TITLE LEFT JUSTIFIED UNDERLINED
  'There are' #BOST-NBR 'employees in the Boston offices.' /
  #SECR-NBR '(=' #WHOLE-NBR (EM=99%')') 'are secretaries.'
*
SKIP 1
FIND EMPLOY-VIEW WITH CITY      = 'BOSTON'
                 AND  JOB-TITLE = 'SECRETARY'
  DISPLAY NAME FIRST-NAME JOB-TITLE SALARY (1)
END-FIND
END

プログラム FINDX11 の出力:

There are    7 employees in the Boston offices.                                
   3 (= 42%) are secretaries.                                                  
-------------------------------------------------------------------------------
                                                                               
        NAME              FIRST-NAME               CURRENT            ANNUAL   
                                                  POSITION            SALARY   
-------------------- -------------------- ------------------------- ---------- 
                                                                               
SHAW                 LESLIE               SECRETARY                      18000 
CREMER               WALT                 SECRETARY                      20000 
COHEN                JOHN                 SECRETARY                      16000

Top of page

READ および FIND ステートメントのネスト

次の例は、「データベース処理ループ」セクションで参照されています。

READX04 - READ ステートメント(FIND およびシステム変数 *NUMBER と *COUNTER との組み合わせ)

** Example 'READX04': READ (in combination with FIND and the system
**                    variables *NUMBER and *COUNTER)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 NAME
  2 FIRST-NAME
1 VEHIC-VIEW VIEW OF VEHICLES
  2 PERSONNEL-ID
  2 MAKE
END-DEFINE
*
LIMIT 10
RD. READ EMPLOY-VIEW BY NAME STARTING FROM 'JONES'
  FD. FIND VEHIC-VIEW WITH PERSONNEL-ID = PERSONNEL-ID (RD.)
    IF NO RECORDS FOUND
      ENTER
    END-NOREC
    /*
    DISPLAY NOTITLE
            *COUNTER (RD.)(NL=8) NAME         (AL=15) FIRST-NAME (AL=10)
            *NUMBER  (FD.)(NL=8) *COUNTER (FD.)(NL=8) MAKE
  END-FIND
END-READ
END

プログラム READX04 の出力:

  CNT          NAME       FIRST-NAME   NMBR      CNT             MAKE        
--------- --------------- ---------- --------- --------- --------------------
                                                                             
        1 JONES           VIRGINIA           1         1 CHRYSLER            
        2 JONES           MARSHA             2         1 CHRYSLER            
        2 JONES           MARSHA             2         2 CHRYSLER            
        3 JONES           ROBERT             1         1 GENERAL MOTORS      
        4 JONES           LILLY              2         1 FORD                
        4 JONES           LILLY              2         2 MG                  
        5 JONES           EDWARD             1         1 GENERAL MOTORS      
        6 JONES           MARTHA             1         1 GENERAL MOTORS      
        7 JONES           LAUREL             1         1 GENERAL MOTORS      
        8 JONES           KEVIN              1         1 DATSUN              
        9 JONES           GREGORY            1         1 FORD                
       10 JOPER           MANFRED            0         0                    

LIMITX01 - LIMIT ステートメント(READ、FIND ループ処理)

** Example 'LIMITX01': LIMIT  (for READ, FIND loop processing)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 FIRST-NAME
  2 NAME
1 VEH-VIEW VIEW OF VEHICLES
  2 PERSONNEL-ID
  2 MAKE
END-DEFINE
*
LIMIT 4
*
READ EMPLOY-VIEW BY NAME STARTING FROM 'A'
  FIND VEH-VIEW WITH PERSONNEL-ID = EMPLOY-VIEW.PERSONNEL-ID
    IF NO RECORDS FOUND
      MOVE 'NO CAR' TO MAKE
    END-NOREC
    DISPLAY PERSONNEL-ID NAME FIRST-NAME MAKE
  END-FIND
END-READ
END

プログラム LIMITX01 の出力:

Page      1                                                  04-12-13  14:01:57
                                                                               
PERSONNEL-ID         NAME              FIRST-NAME              MAKE            
------------ -------------------- -------------------- --------------------    
                                                                               
             ABELLAN              KEPA                 NO CAR                  
30000231     ACHIESON             ROBERT               FORD                    
             ADAM                 SIMONE               NO CAR                  
20008800     ADKINSON             JEFF                 GENERAL MOTORS         

Top of page

ACCEPT および REJECT ステートメント

次の例は、「ACCEPT/REJECT を使用したレコードの選択」セクションで参照されています。

ACCEPX04 - ACCEPT IF ... LESS THAN ... ステートメント

** Example 'ACCEPX04': ACCEPT IF ... LES THAN ...
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 NAME
  2 JOB-TITLE
  2 SALARY (1)
END-DEFINE
*
LIMIT 20
READ EMPLOY-VIEW BY PERSONNEL-ID = '20017000'
  ACCEPT IF SALARY (1) LESS THAN 38000
  DISPLAY NOTITLE PERSONNEL-ID NAME JOB-TITLE SALARY (1) 
END-READ 
END

プログラム ACCEPX04 の出力:

PERSONNEL         NAME                  CURRENT            ANNUAL  
   ID                                  POSITION            SALARY  
--------- -------------------- ------------------------- ----------
                                                                   
20017000  CREMER               ANALYST                        34000
20017100  MARKUSH              TRAINEE                        22000
20017400  NEEDHAM              PROGRAMMER                     32500
20017500  JACKSON              PROGRAMMER                     33000
20017600  PIETSCH              SECRETARY                      22000
20017700  PAUL                 SECRETARY                      23000
20018000  FARRIS               PROGRAMMER                     30500
20018100  EVANS                PROGRAMMER                     31000
20018200  HERZOG               PROGRAMMER                     31500
20018300  LORIE                SALES PERSON                   28000
20018400  HALL                 SALES PERSON                   30000
20018500  JACKSON              MANAGER                        36000
20018800  SMITH                SECRETARY                      24000
20018900  LOWRY                SECRETARY                      25000

ACCEPX05 - ACCEPT IF ... AND ... ステートメント

** Example 'ACCEPX05': ACCEPT IF ... AND ...
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 NAME
  2 CITY
  2 JOB-TITLE
  2 SALARY (1:2)
END-DEFINE
*
LIMIT 6
READ EMPLOY-VIEW PHYSICAL WHERE SALARY(2) > 0
  ACCEPT IF  SALARY(1) > 10000
         AND SALARY(1) < 50000
  DISPLAY (AL=15) 'SALARY I' SALARY (1) 'SALARY II'  SALARY (2)
                   NAME JOB-TITLE  CITY
END-READ
END

プログラム ACCEPX05 の出力:

Page      1                                                  04-12-13  14:05:28
                                                                               
 SALARY I  SALARY II       NAME           CURRENT          CITY                
                                         POSITION                              
---------- ---------- --------------- --------------- ---------------          
                                                                               
     48000      46000 SPENGLER        SACHBEARBEITER  DARMSTADT                
     45000      40000 SPECK           SACHBEARBEITER  DARMSTADT                
     48000      46000 SCHINDLER       PROGRAMMIERER   HEPPENHEIM               
     36000      32000 SCHMIDT         SEKRETAERIN     HEPPENHEIM              

ACCEPX06 - REJECT IF ... OR ... ステートメント

** Example 'ACCEPX06': REJECT IF ... OR ...
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 SALARY (1)
  2 JOB-TITLE
  2 CITY
  2 NAME
END-DEFINE
*
LIMIT 20
READ EMPLOY-VIEW LOGICAL BY PERSONNEL-ID = '20017000'
  REJECT IF SALARY (1) < 20000
         OR SALARY (1) > 26000
  DISPLAY NOTITLE SALARY (1) NAME JOB-TITLE CITY
END-READ
END

プログラム ACCEPX06 の出力:

  ANNUAL           NAME                  CURRENT                  CITY        
  SALARY                                POSITION                              
---------- -------------------- ------------------------- --------------------
                                                                              
     22000 MARKUSH              TRAINEE                   LOS ANGELES         
     22000 PIETSCH              SECRETARY                 VISTA               
     23000 PAUL                 SECRETARY                 NORFOLK             
     24000 SMITH                SECRETARY                 SILVER SPRING       
     25000 LOWRY                SECRETARY                 LEXINGTON          

Top of page

AT START OF DATA および AT END OF DATA ステートメント

次の例は、「AT START/END OF DATA ステートメント」セクションで参照されています。

ATENDX01 - AT END OF DATA ステートメント

** Example 'ATENDX01': AT END OF DATA
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 NAME
  2 JOB-TITLE
END-DEFINE
*
READ (6) EMPLOY-VIEW BY PERSONNEL-ID FROM '20017000'
  DISPLAY NOTITLE NAME JOB-TITLE
  AT END OF DATA
    WRITE / 'LAST PERSON SELECTED:' OLD(NAME)
  END-ENDDATA
END-READ
END

プログラム ATENDX01 の出力:

        NAME                  CURRENT         
                             POSITION         
-------------------- -------------------------
                                              
CREMER               ANALYST                  
MARKUSH              TRAINEE                  
GEE                  MANAGER                  
KUNEY                DBA                      
NEEDHAM              PROGRAMMER               
JACKSON              PROGRAMMER               
                                              
LAST PERSON SELECTED: JACKSON                

ATSTAX02 - AT START OF DATA ステートメント

** Example 'ATSTAX02': AT START OF DATA
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 FIRST-NAME
  2 NAME
  2 SALARY    (1)
  2 CURR-CODE (1)
  2 BONUS     (1,1)
END-DEFINE
*
LIMIT 3
FIND EMPLOY-VIEW WITH CITY = 'MADRID'
  DISPLAY NAME FIRST-NAME SALARY(1) BONUS(1,1) CURR-CODE (1)
  /*
  AT START OF DATA
    WRITE NOTITLE *DAT4E /
  END-START
END-FIND
END

プログラム ATSTAX02 の出力:

        NAME              FIRST-NAME        ANNUAL     BONUS    CURRENCY
                                            SALARY                CODE  
-------------------- -------------------- ---------- ---------- --------
                                                                        
13/12/2004                                                              
                                                                        
DE JUAN              JAVIER                  1988000          0 PTA     
DE LA MADRID         ANSELMO                 3120000          0 PTA     
PINERO               PAULA                   1756000          0 PTA    

WRITEX09 - WRITE ステートメント(AT END OF DATA との組み合わせ)

** Example 'WRITEX09': WRITE (in combination with AT END OF DATA )
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 CITY
  2 NAME
  2 BIRTH
  2 JOB-TITLE
  2 DEPT
END-DEFINE
*
READ (3) EMPLOY-VIEW BY CITY
  DISPLAY NOTITLE NAME BIRTH (EM=YYYY-MM-DD) JOB-TITLE
  WRITE 38T 'DEPT CODE:' DEPT
  /*
  AT END OF DATA
    WRITE / 'LAST PERSON SELECTED:' OLD(NAME)
  END-ENDDATA
  SKIP 1
END-READ
END

プログラム WRITEX09 の出力:

        NAME            DATE             CURRENT         
                         OF             POSITION         
                       BIRTH                             
-------------------- ---------- -------------------------
                                                         
SENKO                1971-09-11 PROGRAMMER               
                                     DEPT CODE: TECH10   
                                                         
GODEFROY             1949-01-09 COMPTABLE                
                                     DEPT CODE: COMP02   
                                                         
CANALE               1942-01-01 CONSULTANT               
                                     DEPT CODE: TECH03   
                                                         
                                                         
LAST PERSON SELECTED: CANALE                            

Top of page

DISPLAY および WRITE ステートメント

次の例は、「DISPLAY および WRITE ステートメント」セクションで参照されています。

DISPLX13 - DISPLAY ステートメント(WRITE を使用する WRITEX08 と比較)

** Example 'DISPLX13': DISPLAY (compare with WRITEX08 using WRITE)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 FIRST-NAME
  2 NAME
  2 SALARY (2)
  2 BONUS  (1,1)
  2 CITY
END-DEFINE
*
LIMIT 2
READ EMPLOY-VIEW WITH CITY = 'CHAPEL HILL' WHERE BONUS(1,1) NE 0
  /*
  DISPLAY 'PERS/ID' PERSONNEL-ID  NAME / FIRST-NAME
          '**' '=' SALARY(1:2) 'BONUS' BONUS(1,1) CITY (AL=15)
  /*
  SKIP 1
END-READ
END

プログラム DISPLX13 の出力:

Page      1                                                  04-12-13  14:11:28
                                                                               
  PERS           NAME            ANNUAL       BONUS         CITY               
   ID         FIRST-NAME         SALARY                                        
-------- -------------------- ------------- ---------- ---------------         
                                                                               
20027000 CUMMINGS             **      41000       1500 CHAPEL HILL             
         PUALA                        38900                                    
                                                                               
20000200 WOOLSEY              **      26000       3000 CHAPEL HILL             
         LOUISE                       24700                                   

WRITEX08 - WRITE ステートメント(DISPLAY を使用する DISPLX13 と比較)

** Example 'WRITEX08': WRITE  (compare with DISPLX13 using DISPLAY)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 FIRST-NAME
  2 NAME
  2 SALARY (2)
  2 BONUS  (1,1)
  2 CITY
END-DEFINE
*
LIMIT 2
READ EMPLOY-VIEW WITH CITY = 'CHAPEL HILL' WHERE BONUS(1,1) NE 0
  /*
  WRITE 'PERS/ID' PERSONNEL-ID  NAME / FIRST-NAME
        '**' '=' SALARY(1:2) 'BONUS' BONUS(1,1) CITY (AL=15)
  /*
  SKIP 1
END-READ
END

プログラム WRITEX08 の出力:

Page      1                                                  04-12-13  14:12:43
                                                                               
PERS/ID 20027000 CUMMINGS                                                      
PUALA                ** ANNUAL SALARY:      41000      38900 BONUS       1500  
CHAPEL HILL                                                                    
                                                                               
PERS/ID 20000200 WOOLSEY                                                       
LOUISE               ** ANNUAL SALARY:      26000      24700 BONUS       3000  
CHAPEL HILL                                                                   

DISPLX14 - DISPLAY ステートメント(AL、SF、nX を含む)

** Example 'DISPLX14': DISPLAY  (with AL, SF and nX)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 FIRST-NAME
  2 NAME
  2 ADDRESS-LINE (1)
  2 TELEPHONE
    3 AREA-CODE
    3 PHONE
  2 CITY
END-DEFINE
*
READ (3) EMPLOY-VIEW BY NAME STARTING FROM 'W'
  DISPLAY (AL=15 SF=5) NAME CITY / ADDRESS-LINE(1) 2X TELEPHONE
  SKIP 1
END-READ
END

プログラム DISPLX14 の出力:

Page      1                                                  04-12-13  14:14:00
                                                                               
     NAME                CITY                     TELEPHONE                    
                        ADDRESS                                                
                                          AREA              TELEPHONE          
                                          CODE                                 
---------------     ---------------  ---------------     ---------------       
                                                                               
WABER               HEIDELBERG       06221               456452                
                    ERBACHERSTR. 78                                            
                                                                               
WADSWORTH           DERBY            0332                515365                
                    56 PINECROFT CO                                            
                                                                               
WAGENBACH           FRANKFURT        069                 983218                
                    BECKERSTR. 4                                              

WRITEX09 - WRITE ステートメント(AT END OF DATA との組み合わせ)

** Example 'WRITEX09': WRITE (in combination with AT END OF DATA )
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 CITY
  2 NAME
  2 BIRTH
  2 JOB-TITLE
  2 DEPT
END-DEFINE
*
READ (3) EMPLOY-VIEW BY CITY
  DISPLAY NOTITLE NAME BIRTH (EM=YYYY-MM-DD) JOB-TITLE
  WRITE 38T 'DEPT CODE:' DEPT
  /*
  AT END OF DATA
    WRITE / 'LAST PERSON SELECTED:' OLD(NAME)
  END-ENDDATA
  SKIP 1
END-READ
END

プログラム WRITEX09 の出力:

        NAME            DATE             CURRENT         
                         OF             POSITION         
                       BIRTH                             
-------------------- ---------- -------------------------
                                                         
SENKO                1971-09-11 PROGRAMMER               
                                     DEPT CODE: TECH10   
                                                         
GODEFROY             1949-01-09 COMPTABLE                
                                     DEPT CODE: COMP02   
                                                         
CANALE               1942-01-01 CONSULTANT               
                                     DEPT CODE: TECH03   
                                                         
                                                         
LAST PERSON SELECTED: CANALE                            

Top of page

DISPLAY ステートメント

次の例は、「ページタイトル、改ページ、空行」セクションで参照されています。

DISPLX21 DISPLAY ステートメント(スラッシュ '/' を含む。WRITE と比較)

** Example 'DISPLX21': DISPLAY (usage of slash '/' in DISPLAY and WRITE)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 CITY
  2 NAME
  2 FIRST-NAME
  2 ADDRESS-LINE (1)
END-DEFINE
*
WRITE TITLE LEFT JUSTIFIED UNDERLINED
       *TIME
   5X  'PEOPLE LIVING IN SALT LAKE CITY'
   21X 'PAGE:' *PAGE-NUMBER /
   15X 'AS OF' *DAT4E //
*
WRITE TRAILER UNDERLINED 'REGISTER OF' / 'SALT LAKE CITY'
*
READ (2) EMPLOY-VIEW WITH CITY = 'SALT LAKE CITY'
  DISPLAY  NAME /
           FIRST-NAME
           'HOME/CITY' CITY
           'STREET/OR BOX NO.' ADDRESS-LINE (1)
  SKIP 1
END-READ
END

プログラム DISPLX21 の出力:

14:15:50.1     PEOPLE LIVING IN SALT LAKE CITY                     PAGE:      1
               AS OF 13/12/2004                                                
                                                                               
                                                                               
-------------------------------------------------------------------------------
        NAME                 HOME                STREET                        
     FIRST-NAME              CITY              OR BOX NO.                      
-------------------- -------------------- --------------------                 
                                                                               
ANDERSON             SALT LAKE CITY       3701 S. GEORGE MASON                 
JENNY                                                                          
                                                                               
SAMUELSON            SALT LAKE CITY       7610 W. 86TH STREET                  
MARTIN                                                                         
                                                                               
                                  REGISTER OF                                  
                                SALT LAKE CITY                                 
-------------------------------------------------------------------------------

Top of page

列ヘッダー

次の例は、「列ヘッダー」セクションで参照されています。

DISPLX15 - DISPLAY ステートメント(FC、UC を含む)

** Example 'DISPLX15': DISPLAY  (with FC, UC)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 FIRST-NAME
  2 NAME
  2 ADDRESS-LINE (1)
  2 CITY
  2 TELEPHONE
    3 AREA-CODE
    3 PHONE
END-DEFINE
*
FORMAT AL=12 GC== UC=%
*
READ (3) EMPLOY-VIEW BY NAME STARTING FROM 'R'
  DISPLAY NOTITLE (FC=*)
          NAME FIRST-NAME CITY  (FC=- UC=-) /
          ADDRESS-LINE(1) TELEPHONE
  SKIP 1
END-READ
END

プログラム DISPLX15 の出力:

****NAME**** *FIRST-NAME* ----CITY---- ========TELEPHONE========
                          **ADDRESS***                          
                                       ****AREA**** *TELEPHONE**
                                       ****CODE****             
%%%%%%%%%%%% %%%%%%%%%%%% ------------ %%%%%%%%%%%% %%%%%%%%%%%%
                                                                
RACKMANN     MARIAN       FRANKFURT    069          375849      
                          FINKENSTR. 1                          
                                                                
RAMAMOORTHY  TY           SEPULVEDA    209          175-1885    
                          12018 BROOKS                          
                                                                
RAMAMOORTHY  TIMMIE       SEATTLE      206          151-4673    
                          921-178TH PL                         

DISPLX16 - DISPLAY ステートメント('/'、'text'、'text/text' を含む)

** Example 'DISPLX16': DISPLAY  (with '/', 'text', 'text/text')
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 FIRST-NAME
  2 NAME
  2 ADDRESS-LINE (1)
  2 CITY
  2 TELEPHONE
    3 AREA-CODE
    3 PHONE
END-DEFINE
*
READ (5) EMPLOY-VIEW BY NAME STARTING FROM 'E'
  DISPLAY NOTITLE
    '/'          NAME       (AL=12) /* suppressed header
    'FIRST/NAME' FIRST-NAME (AL=10) /* two-line user-defined header
    'ADDRESS'    CITY /             /* user-defined header
    ' '          ADDRESS-LINE(1)    /* 'blank' header
                 TELEPHONE (HC=L)   /* default header
  SKIP 1
END-READ
END

プログラム DISPLX16 の出力:

               FIRST          ADDRESS        TELEPHONE             
                NAME                                               
                                             AREA   TELEPHONE      
                                             CODE                  
             ---------- -------------------- ------ ---------------
                                                                   
EAVES        TREVOR     DERBY                0332   657623         
                        17 HARTON ROAD                             
                                                                   
ECKERT       KARL       OBERRAMSTADT         06154  99722          
                        FORSTWEG 22                                
                                                                   
ECKHARDT     RICHARD    DARMSTADT                                  
                        BRESLAUERPL. 4                             
                                                                   
EDMUNDSON    LES        TULSA                918    945-4916       
                        2415 ALSOP CT.                             
                                                                   
EGGERT       HERMANN    STUTTGART            0711   981237         
                        RABENGASSE 8                              

Top of page

フィールド出力関連パラメータ

次の例は、「フィールドの出力に影響を与えるパラメータ」セクションで参照されています。

これらの例は、LCICTCALNLISZPES の各パラメータ、および SUSPEND IDENTICAL SUPPRESS ステートメントの使用法を示すために提供されています。

DISPLX17 - DISPLAY ステートメント(NL、AL、IC、LC、TC を含む)

** Example 'DISPLX17': DISPLAY (with NL, AL, IC, LC, TC)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 FIRST-NAME
  2 NAME
  2 SALARY (1)
  2 BONUS  (1,1)
END-DEFINE
*
READ (3) EMPLOY-VIEW BY NAME STARTING FROM 'JONES'
  DISPLAY NOTITLE (IS=ON NL=15)
                    NAME
    '-' '='         FIRST-NAME (AL=12)
    'ANNUAL SALARY' SALARY(1)  (LC=USD   TC=.00)   /
    '+ BONUSES'     BONUS(1,1) (IC='+  ' TC=.00)
  SKIP 1
END-READ
END

プログラム DISPLX17 の出力:

        NAME           FIRST-NAME       ANNUAL SALARY     
                                          + BONUSES       
-------------------- -------------- ----------------------
                                                          
JONES                - VIRGINIA     USD           46000.00
                                                +  9000.00
                                                          
                     - MARSHA       USD           50000.00
                                                   +  0.00
                                                          
                     - ROBERT       USD           31000.00
                                                   +  0.00

DISPLX18 - DISPLAY ステートメント(SF、AL、UC、LC、IC、TC のデフォルト設定を使用。DISPLX19 と比較)

** Example 'DISPLX18': DISPLAY  (using default settings for SF, AL, UC,
**                     LC, IC, TC and compare with DISPLX19)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 NAME
  2 FIRST-NAME
  2 CITY
  2 SALARY    (1)
  2 BONUS     (1,1)
END-DEFINE
*
FIND (6) EMPLOY-VIEW WITH CITY = 'CHAPEL HILL'
  DISPLAY NAME FIRST-NAME SALARY(1) BONUS(1,1)
END-FIND
END

プログラム DISPLX18 の出力:

Page      1                                                  04-12-13  14:20:48
                                                                               
        NAME              FIRST-NAME        ANNUAL     BONUS                   
                                            SALARY                             
-------------------- -------------------- ---------- ----------                
                                                                               
KESSLER              CLARE                     41000          0                
ADKINSON             DAVID                     24000          0                
GEE                  TOMMIE                    39500          0                
HERZOG               JOHN                      31500          0                
QUILLION             TIMOTHY                   30500          0                
CUMMINGS             PUALA                     41000       1500               

DISPLX19 - DISPLAY ステートメント(SF、AL、LC、IC、TC を含む。DISPLX18 と比較)

** Example 'DISPLX19': DISPLAY  (with SF, AL, LC, IC, TC and compare
**                     with DISPLX19)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 NAME
  2 FIRST-NAME
  2 CITY
  2 SALARY (1)
  2 BONUS  (1,1)
END-DEFINE
*
FORMAT SF=3 AL=15 UC==
*
FIND (6) EMPLOY-VIEW WITH CITY = 'CHAPEL HILL'
  DISPLAY (NL=10)
    NAME
    FIRST-NAME  (LC='- ' UC=-)
    SALARY (1)  (LC=USD)
    BONUS (1,1) (IC='*** ' TC=' ***')
END-FIND
END

プログラム DISPLX19 の出力:

Page      1                                                  04-12-13  14:21:57
                                                                               
     NAME            FIRST-NAME           ANNUAL              BONUS            
                                          SALARY                               
===============   -----------------   ==============   ===================     
                                                                               
KESSLER           - CLARE             USD      41000             *** 0 ***     
ADKINSON          - DAVID             USD      24000             *** 0 ***     
GEE               - TOMMIE            USD      39500             *** 0 ***     
HERZOG            - JOHN              USD      31500             *** 0 ***     
QUILLION          - TIMOTHY           USD      30500             *** 0 ***     
CUMMINGS          - PUALA             USD      41000          *** 1500 ***    

SUSPEX01 - SUSPEND IDENTICAL SUPPRESS ステートメント(DISPLAY のパラメータ IS、ES、ZP との組み合わせ)

** Example 'SUSPEX01': SUSPEND IDENTICAL SUPPRESS (in conjunction with
**                     parameters IS, ES, ZP in DISPLAY)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 FIRST-NAME
  2 NAME
  2 CITY
1 VEH-VIEW VIEW OF VEHICLES
  2 PERSONNEL-ID
  2 MAKE
END-DEFINE
*
LIMIT 15
RD. READ EMPLOY-VIEW BY NAME STARTING FROM 'JONES'
  SUSPEND IDENTICAL SUPPRESS
  FD. FIND VEH-VIEW WITH PERSONNEL-ID = PERSONNEL-ID (RD.)
    IF NO RECORDS FOUND
      MOVE '******' TO MAKE
    END-NOREC
    DISPLAY NOTITLE (ES=OFF IS=ON ZP=ON AL=15)
            NAME       (RD.)
            FIRST-NAME (RD.)
            MAKE       (FD.) (IS=OFF)
  END-FIND
END-READ
END

プログラム SUSPEX01 の出力:

     NAME         FIRST-NAME         MAKE      
--------------- --------------- ---------------
                                               
JONES           VIRGINIA        CHRYSLER       
JONES           MARSHA          CHRYSLER       
                                CHRYSLER       
JONES           ROBERT          GENERAL MOTORS 
JONES           LILLY           FORD           
                                MG             
JONES           EDWARD          GENERAL MOTORS 
JONES           MARTHA          GENERAL MOTORS 
JONES           LAUREL          GENERAL MOTORS 
JONES           KEVIN           DATSUN         
JONES           GREGORY         FORD           
JOPER           MANFRED         ******         
JOUSSELIN       DANIEL          RENAULT        
JUBE            GABRIEL         ******         
JUNG            ERNST           ******         
JUNKIN          JEREMY          ******         
KAISER          REINER          ******        

SUSPEX02 - SUSPEND IDENTICAL SUPPRESS ステートメント(DISPLAY のパラメータ IS、ES、ZP との組み合わせ)IS=OFF である以外は SUSPEX01 と同じ

** Example 'SUSPEX02': SUSPEND IDENTICAL SUPPRESS (in conjunction with
**                     parameters IS, ES, ZP in DISPLAY)
**                     Identical to SUSPEX01, but with IS=OFF.
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 FIRST-NAME
  2 NAME
  2 CITY
1 VEH-VIEW VIEW OF VEHICLES
  2 PERSONNEL-ID
  2 MAKE
END-DEFINE
*
LIMIT 15
RD. READ EMPLOY-VIEW BY NAME STARTING FROM 'JONES'
  SUSPEND IDENTICAL SUPPRESS
  FD. FIND VEH-VIEW WITH PERSONNEL-ID = PERSONNEL-ID (RD.)
    IF NO RECORDS FOUND
      MOVE '******' TO MAKE
    END-NOREC
    DISPLAY NOTITLE (ES=OFF IS=OFF ZP=ON AL=15)
            NAME       (RD.)
            FIRST-NAME (RD.)
            MAKE       (FD.) (IS=OFF)
  END-FIND
END-READ
END

プログラム SUSPEX02 の出力:

     NAME         FIRST-NAME         MAKE      
--------------- --------------- ---------------
                                               
JONES           VIRGINIA        CHRYSLER       
JONES           MARSHA          CHRYSLER       
JONES           MARSHA          CHRYSLER       
JONES           ROBERT          GENERAL MOTORS 
JONES           LILLY           FORD           
JONES           LILLY           MG             
JONES           EDWARD          GENERAL MOTORS 
JONES           MARTHA          GENERAL MOTORS 
JONES           LAUREL          GENERAL MOTORS 
JONES           KEVIN           DATSUN         
JONES           GREGORY         FORD           
JOPER           MANFRED         ******         
JOUSSELIN       DANIEL          RENAULT        
JUBE            GABRIEL         ******         
JUNG            ERNST           ******         
JUNKIN          JEREMY          ******         
KAISER          REINER          ******        

COMPRX03 - COMPRESS ステートメント

** Example 'COMPRX03': COMPRESS (using parameters LC and TC)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 CITY
  2 SALARY     (1)
  2 CURR-CODE  (1)
  2 LEAVE-DUE
  2 NAME
  2 FIRST-NAME
  2 JOB-TITLE
*
1 #SALARY      (N9)
1 #FULL-SALARY (A25)
1 #VACATION    (A11)
END-DEFINE
*
READ (3) EMPLOY-VIEW WITH CITY = 'BOSTON'
  MOVE SALARY(1) TO #SALARY
  COMPRESS 'SALARY  :' CURR-CODE(1) #SALARY INTO #FULL-SALARY
  COMPRESS 'VACATION:' LEAVE-DUE            INTO #VACATION
  /*
  DISPLAY NOTITLE NAME FIRST-NAME
           'JOB DESCRIPTION' JOB-TITLE  (LC='JOB     : ')  /
           '/'               #FULL-SALARY                  /
           '/'               #VACATION  (TC='DAYS')
  SKIP 1
END-READ
END

プログラム COMPRX03 の出力:

        NAME              FIRST-NAME                JOB DESCRIPTION          
-------------------- -------------------- -----------------------------------
                                                                             
SHAW                 LESLIE               JOB     : SECRETARY                
                                          SALARY  : USD 18000                
                                          VACATION: 2DAYS                    
                                                                             
STANWOOD             VERNON               JOB     : PROGRAMMER               
                                          SALARY  : USD 31000                
                                          VACATION: 1DAYS                    
                                                                             
CREMER               WALT                 JOB     : SECRETARY                
                                          SALARY  : USD 20000                
                                          VACATION: 3DAYS                   

Top of page

編集マスク

次の例は、「編集マスク - EM パラメータ」セクションで参照されています。

EDITMX03 - 編集マスク(英数字フィールドの異なる EM)

** Example 'EDITMX03': Edit mask (different EM for alpha-numeric fields)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 FIRST-NAME
  2 NAME
  2 CITY
  2 SALARY(1)
END-DEFINE
*
LIMIT 3
READ EMPLOY-VIEW BY PERSONNEL-ID FROM '20018000'
                 WHERE SALARY(1) = 28000 THRU 30000
  DISPLAY 'N A M E'  NAME       (EM=X^^X^^X^^X^^X^^X^^X^^X^^X^^X^^X) /
          'NAME HEX' NAME       (EM=H^H^H^H^H^H^H^H^H^H^H)
                     FIRST-NAME (EM=' - 'X(15)*)
                     CITY       (EM=X..X(10))
  SKIP 1
END-READ
END

プログラム EDITMX03 の出力:

Page      1                                                  04-12-13  14:26:57
                                                                               
            N A M E                  FIRST-NAME         CITY                   
            NAME HEX                                                           
-------------------------------- ------------------ -------------              
                                                                               
L  O  R  I  E                    - JEAN-PAUL      * C..LEVELAND                
D3 D6 D9 C9 C5 40 40 40 40 40 40                                               
                                                                               
H  A  L  L                       - ARTHUR         * A..NN ARBER                
C8 C1 D3 D3 40 40 40 40 40 40 40                                               
                                                                               
V  A  S  W  A  N  I              - TOMMIE         * M..ONTERREY                
E5 C1 E2 E6 C1 D5 C9 40 40 40 40                                              

EDITMX04 - 編集マスク(数値フィールドの異なる EM)

** Example 'EDITMX04': Edit mask (different EM for numeric fields)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 FIRST-NAME
  2 NAME
  2 SALARY (1)
  2 BONUS  (1,1)
  2 LEAVE-DUE
END-DEFINE
*
LIMIT 2
READ EMPLOY-VIEW BY PERSONNEL-ID = '20018000'
                 WHERE SALARY(1) = 28000 THRU 30000
  DISPLAY (SF=4)
          'N A M E'    NAME
          'SALARY'     SALARY(1)  (EM=*USD^ZZZ,999)
          'BONUS (ZZ)' BONUS(1,1) (EM=S*ZZZ,999) /
          'BONUS (Z9)' BONUS(1,1) (EM=SZ99,999+) /
          '->' '='     BONUS(1,1) (EM=-999,999)
          'VAC/DUE'    LEAVE-DUE  (EM=+999)
  SKIP 1
END-READ
END

プログラム EDITMX04 の出力:

Page      1                                                  04-12-13  14:27:43
                                                                               
      N A M E             SALARY       BONUS (ZZ)     VAC                      
                                       BONUS (Z9)     DUE                      
                                          BONUS                                
--------------------    -----------    -----------    ---                      
                                                                               
LORIE                   USD *28,000    +**4,000       +13                      
                                       + 04,000+                               
                                       ->  004,000                             
                                                                               
HALL                    USD *30,000    +**5,000       +14                      
                                       + 05,000+                               
                                       ->  005,000                            

EDITMX05 - 編集マスク(日付および時刻システム変数の EM)

** Example 'EDITMX05': Edit mask (EM for date and time system variables)
************************************************************************
WRITE NOTITLE //
  'DATE INTERNAL :' *DATX (DF=L) /
  '              :' *DATX (EM=N(9)' 'ZW.'WEEK 'YYYY)  /
  '              :' *DATX (EM=ZZJ'.DAY 'YYYY)        /
  '     ROMAN    :' *DATX (EM=R)  /
  '     AMERICAN :' *DATX (EM=MM/DD/YYYY)      12X 'OR  ' *DAT4U /
  '     JULIAN   :' *DATX (EM=YYYYJJJ)         15X 'OR  ' *DAT4J /
  '     GREGORIAN:' *DATX (EM=ZD.''L(10)''YYYY) 5X 'OR  ' *DATG ///
  'TIME INTERNAL :' *TIMX                      14X 'OR  ' *TIME /
  '              :' *TIMX (EM=HH.II.SS.T) /
  '              :' *TIMX (EM=HH.II.SS' 'AP) /
  '              :' *TIMX (EM=HH)
END

プログラム EDITMX05 の出力:

                                                          
                                                          
DATE INTERNAL : 2004-12-13                                
              : Monday 51.WEEK 2004                       
              : 348.DAY 2004                              
     ROMAN    : MMIV                                      
     AMERICAN : 12/13/2004            OR   12/13/2004     
     JULIAN   : 2004348               OR   2004348        
     GREGORIAN: 13.December2004       OR   13December 2004
                                                          
                                                          
TIME INTERNAL : 14:28:49              OR   14:28:49.1     
              : 14.28.49.1                                
              : 02.28.49 PM                               
              : 14                                       

Top of page

WRITE ステートメントを含む DISPLAY VERT

WRITEX10 - WRITE ステートメント(nT、T*field、P*field を含む)

** Example 'WRITEX10': WRITE (with nT, T*field and P*field)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 JOB-TITLE
  2 NAME
  2 SALARY (1)
  2 BONUS  (1,1)
END-DEFINE
*
READ (3) EMPLOY-VIEW WITH JOB-TITLE FROM 'SALES PERSON'
  DISPLAY NOTITLE NAME 30T JOB-TITLE
          VERT AS 'SALARY/BONUS' SALARY(1) BONUS(1,1)
  AT BREAK OF JOB-TITLE
    WRITE 20T 'AVERAGE' T*JOB-TITLE OLD(JOB-TITLE) (AL=15)
              '(SAL)'   P*SALARY AVER(SALARY(1))  /
          46T '(BON)'   P*BONUS  AVER(BONUS(1,1)) /
  END-BREAK
  SKIP 1
END-READ
END

プログラム WRITEX10 の出力:

        NAME                          CURRENT            SALARY  
                                     POSITION            BONUS   
--------------------         ------------------------- ----------
                                                                 
SAMUELSON                    SALES PERSON                   32000
                                                             6000
                                                                 
PAPAYANOPOULOS               SALES PERSON                   34000
                                                             7000
                                                                 
HELL                         SALES PERSON                   38000
                                                             9000
                                                                 
                   AVERAGE   SALES PERSON    (SAL)          34666
                                             (BON)           7333

Top of page

AT BREAK ステートメント

次の例は、「コントロールブレイク」セクションで参照されています。

ATBREX06 - AT BREAK OF ステートメント(NMIN、NAVER、NCOUNT を MIN、AVER、COUNT と比較)

** Example 'ATBREX06': AT BREAK OF (comparing NMIN, NAVER, NCOUNT with
**                     MIN, AVER, COUNT)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 CITY
  2 SALARY (1:2)
END-DEFINE
*
WRITE TITLE '-- SALARY STATISTICS BY CITY --' /
*
READ (2) EMPLOY-VIEW WITH CITY = 'NEW YORK'
  DISPLAY CITY  'SALARY (1)' SALARY(1) 15X 'SALARY (2)' SALARY(2)
  AT BREAK OF CITY
    WRITE /
      14T 'S A L A R Y   (1)'         39T 'S A L A R Y  (2)'          /
      13T '-   MIN:' MIN(SALARY(1))   38T '-   MIN:' MIN(SALARY(2))   /
      13T '-  AVER:' AVER(SALARY(1))  38T '-  AVER:' AVER(SALARY(2))  /
      16T COUNT(SALARY(1)) 'RECORDS'  41T COUNT(SALARY(2)) 'RECORDS'  //
      13T '-  NMIN:' NMIN(SALARY(1))  38T '-  NMIN:' NMIN(SALARY(2))  /
      13T '- NAVER:' NAVER(SALARY(1)) 38T '- NAVER:' NAVER(SALARY(2)) /
      16T NCOUNT(SALARY(1)) 'RECORDS' 41T NCOUNT(SALARY(2)) 'RECORDS'
  END-BREAK
END-READ
END

プログラム ATBREX06 の出力:

                        -- SALARY STATISTICS BY CITY -- 
                                                        
        CITY         SALARY (1)               SALARY (2)
-------------------- ----------               ----------
                                                        
NEW YORK                  17000                    16100
NEW YORK                  38000                    34900
                                                        
             S A L A R Y   (1)        S A L A R Y  (2)  
            -   MIN:      17000      -   MIN:      16100
            -  AVER:      27500      -  AVER:      25500
                      2 RECORDS                2 RECORDS
                                                        
            -  NMIN:      17000      -  NMIN:      16100
            - NAVER:      27500      - NAVER:      25500
                      2 RECORDS                2 RECORDS

Top of page

COMPUTE、MOVE、および COMPRESS ステートメント

次の例は、「データ計算」セクションで参照されています。

WRITEX11 - WRITE ステートメント(nX、n/n、および COMPRESS を含む)

** Example 'WRITEX11': WRITE (with nX, n/n and COMPRESS)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 SALARY       (1)
  2 FIRST-NAME
  2 NAME
  2 CITY
  2 ZIP
  2 CURR-CODE    (1)
  2 JOB-TITLE
  2 LEAVE-DUE
  2 ADDRESS-LINE (1)
*
1 #SALARY        (A8)
1 #FULL-NAME     (A25)
1 #FULL-CITY     (A25)
1 #FULL-SALARY   (A25)
1 #VACATION      (A16)
END-DEFINE
*
READ (3) EMPLOY-VIEW LOGICAL BY PERSONNEL-ID = '2001800'
  MOVE SALARY(1) TO  #SALARY
  COMPRESS FIRST-NAME NAME                    INTO #FULL-NAME
  COMPRESS ZIP        CITY                    INTO #FULL-CITY
  COMPRESS 'SALARY  :'  CURR-CODE(1)  #SALARY INTO #FULL-SALARY
  COMPRESS 'VACATION:'  LEAVE-DUE    'DAYS'   INTO #VACATION
  /*
  DISPLAY NOTITLE 'NAME AND ADDRESS' NAME
               5X 'PERS-NO.'         PERSONNEL-ID
               3X 'JOB TITLE'        JOB-TITLE (LC='JOB     : ')
  WRITE   1/5 #FULL-NAME        1/37  #FULL-SALARY
          2/5 ADDRESS-LINE(1)   2/37  #VACATION
          3/5 #FULL-CITY
  SKIP 1
END-READ
END

プログラム WRITEX11 の出力:

  NAME AND ADDRESS       PERS-NO.                JOB TITLE             
--------------------     --------   -----------------------------------
                                                                       
FARRIS                   20018000   JOB     : PROGRAMMER               
    JACKIE FARRIS                   SALARY  : USD 30500                
    918 ELM STREET                  VACATION: 10 DAY                   
    32306 TALLAHASSEE                                                  
                                                                       
EVANS                    20018100   JOB     : PROGRAMMER               
    JO EVANS                        SALARY  : USD 31000                
    1058 REDSTONE LANE              VACATION: 11 DAY                   
    68508 LINCOLN                                                      
                                                                       
HERZOG                   20018200   JOB     : PROGRAMMER               
    JOHN HERZOG                     SALARY  : USD 31500                
    255 ZANG STREET #253            VACATION: 12 DAY                   
    27514 CHAPEL HILL                                                 

IFX03 - IF ステートメント

** Example 'IFX03': IF
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 NAME
  2 CITY
  2 BONUS  (1,1)
  2 SALARY (1)
*
1 #INCOME  (N9)
1 #TEXT    (A26)
END-DEFINE
*
WRITE TITLE '-- DISTRIBUTION OF CATALOGS I AND II --' /
*
READ (3) EMPLOY-VIEW BY CITY = 'SAN FRANSISCO'
  COMPUTE #INCOME = BONUS(1,1) + SALARY(1)
  /*
  IF #INCOME > 40000
    MOVE 'CATALOGS I AND II' TO #TEXT
  ELSE
    MOVE 'CATALOG I'         TO #TEXT
  END-IF
  /*
  DISPLAY NAME 5X 'SALARY' SALARY(1) / BONUS(1,1)
  WRITE T*SALARY '-'(10) /
        16X 'INCOME:' T*SALARY #INCOME 3X #TEXT /
        16X '='(19)
  SKIP 1
END-READ
END

プログラム IFX03 の出力:

                    -- DISTRIBUTION OF CATALOGS I AND II --
                                                           
        NAME               SALARY                          
                           BONUS                           
--------------------     ----------                        
                                                           
COLVILLE JR                   56000                        
                                  0                        
                         ----------                        
                INCOME:       56000   CATALOGS I AND II    
                ===================                        
                                                           
RICHMOND                       9150                        
                                  0                        
                         ----------                        
                INCOME:        9150   CATALOG I            
                ===================                        
                                                           
MONKTON                       13500                        
                                600                        
                         ----------                        
                INCOME:       14100   CATALOG I            
                ===================                       

COMPRX03 - COMPRESS ステートメント(パラメータ LC および TC を使用)

** Example 'COMPRX03': COMPRESS (using parameters LC and TC)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 CITY
  2 SALARY     (1)
  2 CURR-CODE  (1)
  2 LEAVE-DUE
  2 NAME
  2 FIRST-NAME
  2 JOB-TITLE
*
1 #SALARY      (N9)
1 #FULL-SALARY (A25)
1 #VACATION    (A11)
END-DEFINE
*
READ (3) EMPLOY-VIEW WITH CITY = 'BOSTON'
  MOVE SALARY(1) TO #SALARY
  COMPRESS 'SALARY  :' CURR-CODE(1) #SALARY INTO #FULL-SALARY
  COMPRESS 'VACATION:' LEAVE-DUE            INTO #VACATION
  /*
  DISPLAY NOTITLE NAME FIRST-NAME
           'JOB DESCRIPTION' JOB-TITLE  (LC='JOB     : ')  /
           '/'               #FULL-SALARY                  /
           '/'               #VACATION  (TC='DAYS')
  SKIP 1
END-READ
END

プログラム COMPRX03 の出力:

        NAME              FIRST-NAME                JOB DESCRIPTION          
-------------------- -------------------- -----------------------------------
                                                                             
SHAW                 LESLIE               JOB     : SECRETARY                
                                          SALARY  : USD 18000                
                                          VACATION: 2DAYS                    
                                                                             
STANWOOD             VERNON               JOB     : PROGRAMMER               
                                          SALARY  : USD 31000                
                                          VACATION: 1DAYS                    
                                                                             
CREMER               WALT                 JOB     : SECRETARY                
                                          SALARY  : USD 20000                
                                          VACATION: 3DAYS                   

Top of page

システム変数

次の例は、「システム変数とシステム関数」で参照されているものです。

EDITMX05 - 編集マスク(日付および時刻システム変数の EM)

** Example 'EDITMX05': Edit mask (EM for date and time system variables)
************************************************************************
WRITE NOTITLE //
  'DATE INTERNAL :' *DATX (DF=L) /
  '              :' *DATX (EM=N(9)' 'ZW.'WEEK 'YYYY)  /
  '              :' *DATX (EM=ZZJ'.DAY 'YYYY)        /
  '     ROMAN    :' *DATX (EM=R)  /
  '     AMERICAN :' *DATX (EM=MM/DD/YYYY)      12X 'OR  ' *DAT4U /
  '     JULIAN   :' *DATX (EM=YYYYJJJ)         15X 'OR  ' *DAT4J /
  '     GREGORIAN:' *DATX (EM=ZD.''L(10)''YYYY) 5X 'OR  ' *DATG ///
  'TIME INTERNAL :' *TIMX                      14X 'OR  ' *TIME /
  '              :' *TIMX (EM=HH.II.SS.T) /
  '              :' *TIMX (EM=HH.II.SS' 'AP) /
  '              :' *TIMX (EM=HH)
END

プログラム EDITMX05 の出力:

                                                          
                                                          
DATE INTERNAL : 2004-12-13                                
              : Monday 51.WEEK 2004                       
              : 348.DAY 2004                              
     ROMAN    : MMIV                                      
     AMERICAN : 12/13/2004            OR   12/13/2004     
     JULIAN   : 2004348               OR   2004348        
     GREGORIAN: 13.December2004       OR   13December 2004
                                                          
                                                          
TIME INTERNAL : 14:36:58              OR   14:36:58.8     
              : 14.36.58.8                                
              : 02.36.58 PM                               
              : 14                                       

READX04 - READ ステートメント(FIND およびシステム変数 *NUMBER と *COUNTER との組み合わせ)

** Example 'READX04': READ (in combination with FIND and the system
**                    variables *NUMBER and *COUNTER)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 NAME
  2 FIRST-NAME
1 VEHIC-VIEW VIEW OF VEHICLES
  2 PERSONNEL-ID
  2 MAKE
END-DEFINE
*
LIMIT 10
RD. READ EMPLOY-VIEW BY NAME STARTING FROM 'JONES'
  FD. FIND VEHIC-VIEW WITH PERSONNEL-ID = PERSONNEL-ID (RD.)
    IF NO RECORDS FOUND
      ENTER
    END-NOREC
    /*
    DISPLAY NOTITLE
            *COUNTER (RD.)(NL=8) NAME         (AL=15) FIRST-NAME (AL=10)
            *NUMBER  (FD.)(NL=8) *COUNTER (FD.)(NL=8) MAKE
  END-FIND
END-READ
END

プログラム READX04 の出力:

  CNT          NAME       FIRST-NAME   NMBR      CNT             MAKE        
--------- --------------- ---------- --------- --------- --------------------
                                                                             
        1 JONES           VIRGINIA           1         1 CHRYSLER            
        2 JONES           MARSHA             2         1 CHRYSLER            
        2 JONES           MARSHA             2         2 CHRYSLER            
        3 JONES           ROBERT             1         1 GENERAL MOTORS      
        4 JONES           LILLY              2         1 FORD                
        4 JONES           LILLY              2         2 MG                  
        5 JONES           EDWARD             1         1 GENERAL MOTORS      
        6 JONES           MARTHA             1         1 GENERAL MOTORS      
        7 JONES           LAUREL             1         1 GENERAL MOTORS      
        8 JONES           KEVIN              1         1 DATSUN              
        9 JONES           GREGORY            1         1 FORD                
       10 JOPER           MANFRED            0         0                    

WTITLX01 - WRITE TITLE ステートメント(*PAGE-NUMBER を含む)

** Example 'WTITLX01': WRITE TITLE (with *PAGE-NUMBER)
************************************************************************
DEFINE DATA LOCAL
1 VEHIC-VIEW VIEW OF VEHICLES
  2 MAKE
  2 YEAR
  2 MAINT-COST (1)
END-DEFINE
*
LIMIT 5
*
READ VEHIC-VIEW
END-ALL
SORT BY YEAR USING MAKE MAINT-COST (1)
  DISPLAY NOTITLE YEAR MAKE MAINT-COST (1)
  AT BREAK OF YEAR
    MOVE 1 TO *PAGE-NUMBER
    NEWPAGE
  END-BREAK
  /*
  WRITE TITLE LEFT JUSTIFIED
        'YEAR:' YEAR 15X 'PAGE' *PAGE-NUMBER
END-SORT
END

プログラム WTITLX01 の出力:

YEAR:  1980               PAGE      1
YEAR          MAKE         MAINT-COST
----- -------------------- ----------
                                     
 1980 RENAULT                 20000  
 1980 RENAULT                 20000  
 1980 PEUGEOT                 20000 

Top of page

システム関数

次の例は、「システム変数とシステム関数」で参照されているものです。

ATBREX06 - AT BREAK OF ステートメント(NMIN、NAVER、NCOUNT を MIN、AVER、COUNT と比較)

** Example 'ATBREX06': AT BREAK OF (comparing NMIN, NAVER, NCOUNT with
**                     MIN, AVER, COUNT)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 CITY
  2 SALARY (1:2)
END-DEFINE
*
WRITE TITLE '-- SALARY STATISTICS BY CITY --' /
*
READ (2) EMPLOY-VIEW WITH CITY = 'NEW YORK'
  DISPLAY CITY  'SALARY (1)' SALARY(1) 15X 'SALARY (2)' SALARY(2)
  AT BREAK OF CITY
    WRITE /
      14T 'S A L A R Y   (1)'         39T 'S A L A R Y  (2)'          /
      13T '-   MIN:' MIN(SALARY(1))   38T '-   MIN:' MIN(SALARY(2))   /
      13T '-  AVER:' AVER(SALARY(1))  38T '-  AVER:' AVER(SALARY(2))  /
      16T COUNT(SALARY(1)) 'RECORDS'  41T COUNT(SALARY(2)) 'RECORDS'  //
      13T '-  NMIN:' NMIN(SALARY(1))  38T '-  NMIN:' NMIN(SALARY(2))  /
      13T '- NAVER:' NAVER(SALARY(1)) 38T '- NAVER:' NAVER(SALARY(2)) /
      16T NCOUNT(SALARY(1)) 'RECORDS' 41T NCOUNT(SALARY(2)) 'RECORDS'
  END-BREAK
END-READ
END

プログラム ATBREX06 の出力:

                        -- SALARY STATISTICS BY CITY -- 
                                                        
        CITY         SALARY (1)               SALARY (2)
-------------------- ----------               ----------
                                                        
NEW YORK                  17000                    16100
NEW YORK                  38000                    34900
                                                        
             S A L A R Y   (1)        S A L A R Y  (2)  
            -   MIN:      17000      -   MIN:      16100
            -  AVER:      27500      -  AVER:      25500
                      2 RECORDS                2 RECORDS
                                                        
            -  NMIN:      17000      -  NMIN:      16100
            - NAVER:      27500      - NAVER:      25500
                      2 RECORDS                2 RECORDS

ATENPX01 - AT END OF PAGE ステートメント(DISPLAY の GIVE SYSTEM FUNCTIONS 経由で使用可能なシステム関数を含む)

** Example 'ATENPX01': AT END OF PAGE (with system function available
**                     via GIVE SYSTEM FUNCTIONS in DISPLAY)
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
  2 PERSONNEL-ID
  2 NAME
  2 JOB-TITLE
  2 SALARY (1)
END-DEFINE
*
READ (10) EMPLOY-VIEW BY PERSONNEL-ID = '20017000'
  DISPLAY NOTITLE GIVE SYSTEM FUNCTIONS
          NAME JOB-TITLE 'SALARY' SALARY(1)
  /*
  AT END OF PAGE
    WRITE / 24T 'AVERAGE SALARY: ...' AVER(SALARY(1))
  END-ENDPAGE
END-READ
END

プログラム ATENPX01 の出力:

        NAME                  CURRENT            SALARY  
                             POSITION                    
-------------------- ------------------------- ----------
                                                         
CREMER               ANALYST                        34000
MARKUSH              TRAINEE                        22000
GEE                  MANAGER                        39500
KUNEY                DBA                            40200
NEEDHAM              PROGRAMMER                     32500
JACKSON              PROGRAMMER                     33000
PIETSCH              SECRETARY                      22000
PAUL                 SECRETARY                      23000
HERZOG               MANAGER                        48500
DEKKER               DBA                            48000
                                                         
                       AVERAGE SALARY: ...      34270   

Top of page