DTRHELP.HLB  —  Commands Statements Clauses, ON Statement, Examples
       The following example shows how to search all yachts built by
       AMERICAN and print the TYPE, PRICE, and RIG for each sloop. For
       all yachts built by AMERICAN which are not sloops, a line is
       skipped and a message is printed. The output is written to an RMS
       file.

       Since an IF-THEN-ELSE statement is used and the same file name
       is specified in the THEN and ELSE clauses, DEC DATATRIEVE creates
       two versions of the file.

       DTR> FOR YACHTS WITH BUILDER = "AMERICAN"
       CON> IF RIG = "SLOOP" THEN
       CON>     PRINT TYPE, PRICE, RIG ON BOAT.RNO ELSE
       CON>     PRINT SKIP, "NOT A SLOOP" ON BOAT.RNO
       Creating file DB0:[MORRISON.REF]BOAT.RNO;1 ...
       Creating file DB0:[MORRISON.REF]BOAT.RNO;2 ...

       The content of BOAT.RNO;1 is as follows:

       MANUFACTURER   MODEL     PRICE   RIG

        AMERICAN    26          $9,895 SLOOP

       The content of BOAT.RNO;2 is as follows:

       NOT A SLOOP

       However, if you use the ON statement, all of the data can be
       written to the same file as follows:

       DTR> ON SHIP.RNO
       CON> FOR YACHTS WITH BUILDER = "AMERICAN"
       CON> IF RIG = "SLOOP" THEN PRINT TYPE, PRICE, RIG ELSE
       CON> PRINT SKIP, "NOT A SLOOP"
       Creating file DB0:[MORRISON.REF]SHIP.RNO;1 ...

       The contents of SHIP.RNO is as follows:

       MANUFACTURER   MODEL     PRICE   RIG

        AMERICAN    26          $9,895 SLOOP

       NOT A SLOOP

       The following example shows how to write the output of a LIST
       statement to three files and display the output. Data on every
       family with three children is included:

       DTR> ON FAM1.RNO
       CON> ON FAM2.RNO
       CON> ON FAM3.RNO
       CON> ON TT:
       CON> LIST FAMILIES WITH NUMBER_KIDS = 3
       Creating file DB0:[MORRIS.REF]FAM1.RNO;1 ...
       Creating file DB0:[MORRIS.REF]FAM2.RNO;1 ...
       Creating file DB0:[MORRIS.REF]FAM3.RNO;1 ...
       Sending output to terminal TT.

       FATHER      : GEORGE
       MOTHER      : LOIS
       NUMBER_KIDS :  3

           KID_NAME    : JEFF
           AGE         : 23

           KID_NAME    : FRED
           AGE         : 26

           KID_NAME    : LAURA
           AGE         : 21

       FATHER      : HAROLD
       MOTHER      : SARAH
       NUMBER_KIDS :  3
           KID_NAME    : CHARLIE
           AGE         : 31

           KID_NAME    : HAROLD
           AGE         : 35

           KID_NAME    : SARAH
           AGE         : 27

       DTR>

       DEC DATATRIEVE sends the output to the terminal and creates the
       three files specified. All three files contain the data displayed
       on the terminal.
Close Help