DTRHELP.HLB  —  Commands Statements Clauses, CHOICE Statement, Examples
       The following example shows how to define a procedure MODIFY_
       YACHTS, prompt the user to identify a record by specifying the
       BUILDER and MODEL of a yacht, and print the record, prompting
       the user to modify a field from YACHTS. This process is continued
       until the user replies to a prompt that no further changes need
       to be made.

       DTR> SHOW MODIFY_YACHTS
       PROCEDURE MODIFY_YACHTS
       READY YACHTS WRITE
       FOR YACHTS WITH BUILDER = *."the builder" AND
             MODEL = *."the model"
       BEGIN
         PRINT
         PRINT SKIP
         PRINT "The fields you can modify are: RIG,LOA,DISP,BEAM,PRICE"
         MODIFY USING
         WHILE *."Y to modify a field, N to exit" CONT "Y"
           BEGIN
             DECLARE FLD PIC X(5).
             FLD = *."field to modify"
             CHOICE
                  FLD = "RIG" THEN RIG = *.RIG
                  FLD = "LOA" THEN LOA = *.LOA
                  FLD = "DISP" THEN DISP = *.DISP
                  FLD = "BEAM" THEN BEAM = *.BEAM
                  FLD = "PRICE" THEN PRICE = *.PRICE
                  ELSE PRINT "That's not a field in YACHTS."
             END_CHOICE
             PRINT
             PRINT SKIP
           END
         PRINT SKIP, "No more changes."
       END
       END_PROCEDURE

       DTR> :MODIFY_YACHTS
       Enter the builder: ALBIN
       Enter the model: 79

                                      LENGTH
                                       OVER
       MANUFACTURER   MODEL     RIG    ALL   WEIGHT BEAM  PRICE

        ALBIN       79         SLOOP   26     4,200  10  $17,900

       The fields you can modify are: RIG, LOA, DISP, BEAM, PRICE
       Enter Y to modify a field, N to exit: Y
       Enter field to modify: RIG
       Enter RIG: KETCH

                                      LENGTH
                                       OVER
       MANUFACTURER   MODEL     RIG    ALL   WEIGHT BEAM  PRICE

        ALBIN       79         KETCH   26     4,200  10  $17,900

       Enter Y to modify a field, N to exit: Y
       Enter field to modify: RUG
       That's not a field in YACHTS.
        ALBIN       79         KETCH   26     4,200  10  $17,900

       Enter Y to modify a field, N to exit: N

       No more changes.

       DTR>

       The following example shows how to print the TYPE and PRICE of
       the yachts by ALBERG and ALBIN, indicating whether the price
       is inexpensive, moderate, or expensive. Column headers are
       suppressed:

       DTR> READY YACHTS
       DTR> FOR YACHTS WITH BUILDER = "ALBERG" OR BUILDER = "ALBIN"
       CON> CHOICE
       CON> PRICE LT 20000 THEN PRINT TYPE(-),PRICE(-),"INEXPENSIVE"
       CON> PRICE LT 30000 THEN PRINT TYPE(-),PRICE(-),"MODERATE"
       CON> ELSE PRINT TYPE(-), PRICE(-), "EXPENSIVE"
       CON> END_CHOICE

       ALBERG     37 MK II   $36,951 EXPENSIVE
       ALBIN      79         $17,900 INEXPENSIVE
       ALBIN      BALLAD     $27,500 MODERATE
       ALBIN      VEGA       $18,600 INEXPENSIVE

       DTR>
Close Help