$ ADA/LIST ENUMIO 1 2 -- ENUMIO a sample to demonstrate input and output of 3 -- enumeration type data, and using the case structure 4 5 -- The names of four transactions are defined as an Ada enumeration 6 -- type. i.e. a user chosen set of english words that can be input, 7 -- output, and recognized. In Ada these are not the same as character 8 -- strings. 9 10 -- BANK_TRANSACTIONS can be OPEN CLOSE DEPOSIT WITHDRAW 11 12 with TEXT_IO ; use TEXT_IO ; 13 14 procedure ENUMIO is 15 16 type BANK_TRANSACTIONS is ( OPEN , CLOSE , DEPOSIT , WITHDRAW ) ; 17 18 package ENU_IO is new ENUMERATION_IO ( BANK_TRANSACTIONS ) ; use ENU_IO ; 19 20 TRANSACTION : BANK_TRANSACTIONS ; 21 22 begin 23 24 loop 25 26 PUT_LINE ( " ENTER TRANSACTION. " ) ; 27 GET ( TRANSACTION ) ; 28 PUT ( TRANSACTION ) ; 29 PUT_LINE ( " transaction being processed" ) ; 30 31 case TRANSACTION is 32 when OPEN => 33 PUT_LINE ( " opening " ) ; 34 when CLOSE => 35 PUT_LINE ( " closing " ) ; 36 when DEPOSIT => 37 PUT_LINE ( " depositing " ) ; 38 when WITHDRAW => 39 PUT_LINE ( " withdrawing " ) ; 40 end case ; 41 42 end loop ; 43 44 end ENUMIO ; $ ACS LINK ENUMIO $ RUN ENUMIO ENTER TRANSACTION. <- line 26 OPEN <- line 27, I typed OPEN OPEN transaction being processed <- line 28 opening <- line 33 ENTER TRANSACTION. <- back to line 26 deposit <- line 27, I typed deposit DEPOSIT transaction being processed <- line 28 depositing <- line 37, lower case works ! ENTER TRANSACTION. JUNK <- will raise DATA_ERROR exception