home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / programm / programi / adaed.lzh / Ada / Examples / Appt.ada next >
Encoding:
Text File  |  1992-03-07  |  17.9 KB  |  647 lines

  1. --This example doesn't seem to work completely.  But it is a start.
  2. --It hits end-of-file when adding to an existing item.
  3.  
  4. --From pnc-a@minster.york.ac.uk Sat Feb 29 19:24:13 1992
  5. --Return-Path: <pnc-a@minster.york.ac.uk>
  6. --Received: from sun2.nsfnet-relay.ac.uk by beno.CSS.GOV (4.1/SMI-4.1)
  7. --        id AA14724; Sat, 29 Feb 92 19:24:02 EST
  8. --Received: from minster.york.ac.uk by sun2.nsfnet-relay.ac.uk via JANET
  9. --          with NIFTP id <8562-0@sun2.nsfnet-relay.ac.uk>;
  10. --          Sat, 29 Feb 1992 23:12:21 +0000
  11. --Date: 29 Feb 1992 23:15:55 GMT
  12. --From: pnc-a@minster.york.ac.uk
  13. --To: black <@nsfnet-relay.ac.uk:black@beno.css.gov>
  14. --Message-Id: <swordfish.699405359@minster.york.ac.uk>
  15. --Status: R
  16. --
  17. --Here's some ADA code. It is not very complex, but you can play with
  18. --it if you wish.
  19. --This program sucks, as it is about the first program I did in ADA,
  20. --but as I don't know the standards, it is more likely to push ADA
  21. --over than a properly written program.
  22. --(Oh, and I haven't got the mark back for it...)
  23. --
  24. --A datafile is needed (default is test.dat), in the format
  25. --start_time/duration/day/month/year/comment
  26. --time is in form 0000-2359, date is UK format.
  27. --I could probably dredge up some docs for it if you wanted.
  28. --
  29. --
  30. -- Author:      P.N.D. Corlett
  31. --
  32. -- Address:     Department of Computer Science,
  33. --              University of York,
  34. --              Heslington,
  35. --              York, YO1 5DD,
  36. --              ENGLAND.
  37. --
  38. -- EMail:       pnc-a@uk.ac.york.minster
  39. --
  40. -- Last Edit:   7 December 1991
  41. --
  42. -- Filename:    xmas.A
  43. --
  44. -- Requires:    TEXT_IO,INTEGER_IO
  45. --
  46. -- Summary:
  47. --              (Hmm. I'll do this later... when I work out what it is doing...)
  48. --
  49. --
  50. --
  51. --
  52.  
  53. with TEXT_IO;
  54. use TEXT_IO;
  55.  
  56. -- ****MAIN*************************************************************
  57.  
  58. procedure MAIN is
  59.  
  60.     package INT_IO is new INTEGER_IO(INTEGER);
  61.  
  62.     use INT_IO;
  63.     STRLEN : constant := 100;
  64.  
  65.     -- change this to what you want
  66.     -- Subtypes for the record structure
  67.  
  68.     subtype TIME_TYPE is INTEGER range 0 .. (60 * 24 - 1);
  69.  
  70.     -- I prefer to use minutes since midnight.
  71.  
  72.     subtype DAY_TYPE is INTEGER range 1 .. 31;
  73.     subtype MONTH_TYPE is INTEGER range 1 .. 12;
  74.     subtype YEAR_TYPE is INTEGER range 1901 .. 2099;
  75.  
  76.     -- fairly arbitrary....
  77.     -- range for time checking
  78.  
  79.     subtype MINUTES is INTEGER range 0 .. 59;
  80.     subtype HOURS is INTEGER range 0 .. 23;
  81.  
  82.     -- The record structure itself
  83.  
  84.     type DIARY_ENTRY is
  85.         record
  86.             START_TIME : TIME_TYPE;
  87.             DURATION : TIME_TYPE;
  88.             DAY : DAY_TYPE;
  89.             MONTH : MONTH_TYPE;
  90.             YEAR : YEAR_TYPE;
  91.             APPOINTMENT : STRING(1 .. STRLEN);
  92.         end record;
  93.  
  94.     -- Variable used in menu testing
  95.  
  96.     THE_END : BOOLEAN := FALSE;
  97.     FILENAME : STRING(1 .. 50);
  98.  
  99.     -- ****EXPAND_STRING****************************************************
  100.     -- This function returns the string 'string', but padded out to
  101.     -- 'len' characters with NULs.
  102.  
  103.     function EXPAND_STRING(STR : STRING; LEN : INTEGER) return
  104.         STRING is
  105.         STR2 : STRING(1 .. LEN);
  106.     begin
  107.  
  108.         -- There is probably an easier way of doing this (but it's 4am...)
  109.  
  110.         for N in 1 .. STR'LAST loop
  111.             STR2(N) := STR(N);
  112.         end loop;
  113.         for N in STR'LAST + 1 .. LEN loop
  114.             STR2(N) := ASCII.NUL;
  115.         end loop;
  116.         return (STR2);
  117.     end EXPAND_STRING;
  118.  
  119.     -- ****PRINT_APPOINTMENT_TITLE******************************************
  120.     -- Just prints the header for the info printed by
  121.     -- print_appointment. 'head' says whether the header should be printed,
  122.     -- or just the underline
  123.  
  124.     procedure PRINT_APPOINTMENT_TITLE(HEAD : BOOLEAN) is
  125.     begin
  126.         if HEAD then
  127.             PUT("Time  Dur.  Date       Appointment");
  128.             NEW_LINE;
  129.         end if;
  130.         PUT("----- ----- ---------- --------------------------------------------------------"
  131.             );
  132.         NEW_LINE;
  133.  
  134.         --   TT:TT TT:TT DD/MM/YYYY AAAAAA....
  135.  
  136.     end PRINT_APPOINTMENT_TITLE;
  137.  
  138.     -- ****INPUT_APPOINTMENT************************************************
  139.     -- Fills in an appointment record with info from stdin
  140.  
  141.     procedure INPUT_APPOINTMENT(
  142.         APPOINTMENT : out DIARY_ENTRY; ERROR : out BOOLEAN) is
  143.         TEMP_CHAR : CHARACTER := '?';
  144.         TEMP : INTEGER;
  145.  
  146.         -- misc work
  147.  
  148.         INDEX : INTEGER := 1;
  149.  
  150.         -- index in string array
  151.  
  152.         MINUTE, HOUR : INTEGER;
  153.  
  154.         -- temp work for time
  155.  
  156.     begin
  157.         ERROR := FALSE;
  158.  
  159.         -- convert the start time from normal (0-2359) to internal format
  160.         -- and check it while I'm at it...
  161.  
  162.         PUT("Start time [0000-2359] : ");
  163.         GET(TEMP);
  164.         MINUTE := TEMP mod 100;
  165.         HOUR := TEMP / 100;
  166.         if MINUTE not in MINUTES or else HOUR not in HOURS then
  167.             ERROR := TRUE;
  168.         else
  169.             APPOINTMENT.START_TIME := HOUR * 60 + MINUTE;
  170.         end if;
  171.  
  172.         -- convert the duration from normal (0-2359) to internal format
  173.         -- and check it while I'm at it...
  174.  
  175.         PUT("Duration   [0000-2359] : ");
  176.         GET(TEMP);
  177.         MINUTE := TEMP mod 100;
  178.         HOUR := TEMP / 100;
  179.         if MINUTE not in MINUTES or else HOUR not in HOURS then
  180.             ERROR := TRUE;
  181.         else
  182.             APPOINTMENT.DURATION := HOUR * 60 + MINUTE;
  183.         end if;
  184.  
  185.         -- check date
  186.  
  187.         PUT("Date       [1-31]      : ");
  188.         GET(TEMP);
  189.         if TEMP not in DAY_TYPE then
  190.             ERROR := TRUE;
  191.         else
  192.             APPOINTMENT.DAY := TEMP;
  193.         end if;
  194.  
  195.         -- check month
  196.  
  197.         PUT("Month      [1-12]      : ");
  198.         GET(TEMP);
  199.         if TEMP not in MONTH_TYPE then
  200.             ERROR := TRUE;
  201.         else
  202.             APPOINTMENT.MONTH := TEMP;
  203.         end if;
  204.  
  205.         -- check year
  206.  
  207.         PUT("Year       [1901-2099] : ");
  208.         GET(TEMP);
  209.         if TEMP not in YEAR_TYPE then
  210.             ERROR := TRUE;
  211.         else
  212.             APPOINTMENT.YEAR := TEMP;
  213.         end if;
  214.         PUT("Comments   : ");
  215.  
  216.         -- the rest of the line is the comment
  217.  
  218.         APPOINTMENT.APPOINTMENT := EXPAND_STRING("", STRLEN);
  219.  
  220.         -- makes string field empty
  221.  
  222.         loop
  223.             GET(TEMP_CHAR);
  224.             if INDEX <= STRLEN then
  225.  
  226.                 -- trap lines longer than 'strlen' chars
  227.  
  228.                 APPOINTMENT.APPOINTMENT(INDEX) := TEMP_CHAR;
  229.             end if;
  230.             INDEX := INDEX + 1;
  231.             exit when END_OF_LINE;
  232.         end loop;
  233.     exception
  234.         when DATA_ERROR =>
  235.             ERROR := TRUE;
  236.     end INPUT_APPOINTMENT;
  237.  
  238.     -- ****PRINT_APPOINTMENT************************************************
  239.     -- this outputs the record data in a sensible format.
  240.  
  241.     procedure PRINT_APPOINTMENT(APPOINTMENT : in DIARY_ENTRY) is
  242.     begin
  243.         PUT(APPOINTMENT.START_TIME / 60, 2);
  244.         PUT(':');
  245.         if (APPOINTMENT.START_TIME mod 60) < 10 then
  246.             PUT('0');
  247.         end if;
  248.         PUT(APPOINTMENT.START_TIME mod 60, 1);
  249.         PUT(' ');
  250.         PUT(APPOINTMENT.DURATION / 60, 2);
  251.         PUT(':');
  252.         if (APPOINTMENT.DURATION mod 60) < 10 then
  253.             PUT('0');
  254.         end if;
  255.         PUT(APPOINTMENT.DURATION mod 60, 1);
  256.         PUT(' ');
  257.         PUT(APPOINTMENT.DAY, 2);
  258.         PUT('/');
  259.         PUT(APPOINTMENT.MONTH, 2);
  260.         PUT('/');
  261.         PUT(APPOINTMENT.YEAR, 4);
  262.         PUT(' ');
  263.         PUT(APPOINTMENT.APPOINTMENT);
  264.         NEW_LINE;
  265.     end PRINT_APPOINTMENT;
  266.  
  267.     -- ****READ_APPOINTMENT*************************************************
  268.     -- Reads an appointment from the file 'handle' into the record
  269.     -- 'appointment'. 'error' is true if the data is rubbish
  270.  
  271.     procedure READ_APPOINTMENT(HANDLE : FILE_TYPE;
  272.                                APPOINTMENT : out DIARY_ENTRY;
  273.                                ERROR : out BOOLEAN) is
  274.         TEMP_CHAR : CHARACTER := '?';
  275.         TEMP : INTEGER;
  276.  
  277.         -- misc work
  278.  
  279.         INDEX : INTEGER := 1;
  280.  
  281.         -- index in string array
  282.  
  283.         MINUTE, HOUR : INTEGER;
  284.  
  285.         -- temp work for time
  286.  
  287.     begin
  288.         ERROR := FALSE;
  289.  
  290.         -- convert the start time from normal (0-2359) to internal format
  291.         -- and check it while I'm at it...
  292.  
  293.         GET(HANDLE, TEMP);
  294.         MINUTE := TEMP mod 100;
  295.         HOUR := TEMP / 100;
  296.         if MINUTE not in MINUTES or else HOUR not in HOURS then
  297.             ERROR := TRUE;
  298.         else
  299.             APPOINTMENT.START_TIME := HOUR * 60 + MINUTE;
  300.         end if;
  301.         GET(HANDLE, TEMP_CHAR);
  302.  
  303.         -- Throw away '/'
  304.         -- convert the duration from normal (0-2359) to internal format
  305.         -- and check it while I'm at it...
  306.  
  307.         GET(HANDLE, TEMP);
  308.         MINUTE := TEMP mod 100;
  309.         HOUR := TEMP / 100;
  310.         if MINUTE not in MINUTES or else HOUR not in HOURS then
  311.             ERROR := TRUE;
  312.         else
  313.             APPOINTMENT.DURATION := HOUR * 60 + MINUTE;
  314.         end if;
  315.         GET(HANDLE, TEMP_CHAR);
  316.  
  317.         -- Throw away '/'
  318.         -- check date
  319.  
  320.         GET(HANDLE, TEMP);
  321.         if TEMP not in DAY_TYPE then
  322.             ERROR := TRUE;
  323.         else
  324.             APPOINTMENT.DAY := TEMP;
  325.         end if;
  326.         GET(HANDLE, TEMP_CHAR);
  327.  
  328.         -- Throw away '/'
  329.         -- check month
  330.  
  331.         GET(HANDLE, TEMP);
  332.         if TEMP not in MONTH_TYPE then
  333.             ERROR := TRUE;
  334.         else
  335.             APPOINTMENT.MONTH := TEMP;
  336.         end if;
  337.         GET(HANDLE, TEMP_CHAR);
  338.  
  339.         -- Throw away '/'
  340.         -- check year
  341.  
  342.         GET(HANDLE, TEMP);
  343.         if TEMP not in YEAR_TYPE then
  344.             ERROR := TRUE;
  345.         else
  346.             APPOINTMENT.YEAR := TEMP;
  347.         end if;
  348.         GET(HANDLE, TEMP_CHAR);
  349.  
  350.         -- Throw away '/'
  351.         -- the rest of the line is the comment
  352.  
  353.         APPOINTMENT.APPOINTMENT := EXPAND_STRING("", STRLEN);
  354.  
  355.         -- makes string field empty
  356.  
  357.         while not (END_OF_LINE(HANDLE)) loop
  358.             if INDEX <= STRLEN then
  359.  
  360.                 -- trap lines longer than 'strlen' chars
  361.  
  362.                 GET(HANDLE, APPOINTMENT.APPOINTMENT(INDEX));
  363.             else
  364.                 GET(HANDLE, TEMP_CHAR);
  365.  
  366.                 -- throw away what we can't read.
  367.  
  368.             end if;
  369.             INDEX := INDEX + 1;
  370.         end loop;
  371.     exception
  372.         when DATA_ERROR =>
  373.             ERROR := TRUE;
  374.     end READ_APPOINTMENT;
  375.  
  376.     procedure WRITE_APPOINTMENT(
  377.         HANDLE : FILE_TYPE; APPOINTMENT : DIARY_ENTRY) is
  378.         INDEX : INTEGER := 1;
  379.         TEMP : INTEGER;
  380.     begin
  381.         TEMP := APPOINTMENT.START_TIME;
  382.         PUT(HANDLE, TEMP / 60 * 100 + TEMP mod 60, 0);
  383.  
  384.         -- expands internal format into file
  385.  
  386.         PUT(HANDLE, '/');
  387.         TEMP := APPOINTMENT.DURATION;
  388.         PUT(HANDLE, TEMP / 60 * 100 + TEMP mod 60, 0);
  389.  
  390.         -- expands internal format into file
  391.  
  392.         PUT(HANDLE, '/');
  393.         PUT(HANDLE, APPOINTMENT.DAY, 0);
  394.         PUT(HANDLE, '/');
  395.         PUT(HANDLE, APPOINTMENT.MONTH, 0);
  396.         PUT(HANDLE, '/');
  397.         PUT(HANDLE, APPOINTMENT.YEAR, 0);
  398.         PUT(HANDLE, '/');
  399.         while APPOINTMENT.APPOINTMENT(INDEX) /= ASCII.NUL loop
  400.             PUT(HANDLE, APPOINTMENT.APPOINTMENT(INDEX));
  401.             INDEX := INDEX + 1;
  402.         end loop;
  403.         PUT(HANDLE, ASCII.LF);
  404.     end WRITE_APPOINTMENT;
  405.  
  406.     procedure CLS is
  407.     begin
  408. --        PUT(ASCII.ESC & "[2J" & ASCII.ESC & "[0;0H" & ASCII.ESC
  409. --            & "[0m");
  410.         PUT( ASCII.FF );
  411.     end CLS;
  412.  
  413.     function MENU(FILENAME : STRING) return CHARACTER is
  414.         subtype MENU_RANGE is CHARACTER range '1' .. '5';
  415.         OPTION : CHARACTER := ' ';
  416.     begin
  417.         while OPTION not in MENU_RANGE loop
  418.             CLS;
  419.             PUT_LINE(ASCII.ESC &
  420.                      "#3      ITP Christmas Diary Program");
  421.             PUT_LINE(ASCII.ESC &
  422.                      "#4      ITP Christmas Diary Program");
  423.             PUT_LINE(ASCII.ESC & "#6             Peter Corlett")
  424.                 ;
  425.             NEW_LINE;
  426.             PUT("Current diary is ");
  427.             PUT_LINE(FILENAME);
  428.             NEW_LINE;
  429.             PUT_LINE("1) List diary");
  430.             PUT_LINE("2) Add an entry");
  431.             PUT_LINE("3) Search for an entry");
  432.             PUT_LINE("4) Change diary");
  433.             PUT_LINE("5) Quit");
  434.             NEW_LINE;
  435.             PUT("Choose an option : ");
  436.             GET(OPTION);
  437.         end loop;
  438.         return (OPTION);
  439.     end MENU;
  440.  
  441.     procedure WAIT_KEY is
  442.         TEMP : INTEGER;
  443.         TEMP2 : STRING(1 .. 10);
  444.     begin
  445.         PUT("Press RETURN to continue ");
  446.         SKIP_LINE;
  447.  
  448.         -- there seems to be some stuff still in the buffer here..
  449.  
  450.         GET_LINE(TEMP2, TEMP);
  451.     end WAIT_KEY;
  452.  
  453.     function APPOINTMENT_CLASH(
  454.         APP1 : DIARY_ENTRY; APP2 : DIARY_ENTRY) return BOOLEAN
  455.         is
  456.     begin
  457.         if APP1.YEAR /= APP2.YEAR then
  458.             return (FALSE);
  459.         end if;
  460.         if APP1.MONTH /= APP2.MONTH then
  461.             return (FALSE);
  462.         end if;
  463.         if APP1.DAY /= APP2.DAY then
  464.             return (FALSE);
  465.         end if;
  466.         if APP1.START_TIME >= APP2.START_TIME + APP2.DURATION
  467.             then
  468.             return (FALSE);
  469.         end if;
  470.         if APP2.START_TIME >= APP1.START_TIME + APP1.DURATION
  471.             then
  472.             return (FALSE);
  473.         end if;
  474.         return (TRUE);
  475.     end APPOINTMENT_CLASH;
  476.  
  477.     function APPOINTMENT_MATCH(APP : DIARY_ENTRY; DAY : INTEGER;
  478.                                MONTH : INTEGER; YEAR : INTEGER)
  479.         return BOOLEAN is
  480.     begin
  481.         if DAY /= 0 and APP.DAY /= DAY then
  482.             return (FALSE);
  483.         end if;
  484.         if MONTH /= 0 and APP.MONTH /= MONTH then
  485.             return (FALSE);
  486.         end if;
  487.         if YEAR /= 0 and APP.YEAR /= YEAR then
  488.             return (FALSE);
  489.         end if;
  490.         return (TRUE);
  491.     end APPOINTMENT_MATCH;
  492.  
  493.     procedure LIST_DIARY(FILENAME : STRING) is
  494.         HANDLE : FILE_TYPE;
  495.         ERROR : BOOLEAN;
  496.         APP : DIARY_ENTRY;
  497.     begin
  498.         CLS;
  499.         PRINT_APPOINTMENT_TITLE(TRUE);
  500.         OPEN(HANDLE, IN_FILE, FILENAME);
  501.         while not END_OF_FILE(HANDLE) loop
  502.             READ_APPOINTMENT(HANDLE, APP, ERROR);
  503.             PRINT_APPOINTMENT(APP);
  504.         end loop;
  505.         CLOSE(HANDLE);
  506.         PRINT_APPOINTMENT_TITLE(FALSE);
  507.         WAIT_KEY;
  508.     end LIST_DIARY;
  509.  
  510.     procedure ADD_ENTRY(FILENAME : STRING) is
  511.         HANDLE : FILE_TYPE;
  512.         ERROR, CLASH : BOOLEAN := FALSE;
  513.         APP, NEWAPP : DIARY_ENTRY;
  514.     begin
  515.         CLS;
  516.         INPUT_APPOINTMENT(NEWAPP, ERROR);
  517.         if ERROR then
  518.             PUT_LINE("Sorry, there is something wrong there");
  519.         else
  520.             CLS;
  521.             PRINT_APPOINTMENT_TITLE(TRUE);
  522.             OPEN(HANDLE, IN_FILE, FILENAME);
  523.             while not END_OF_FILE(HANDLE) loop
  524.                 READ_APPOINTMENT(HANDLE, APP, ERROR);
  525.                 if APPOINTMENT_CLASH(APP, NEWAPP) then
  526.                     PUT(ASCII.ESC & "[5m");
  527.                     PRINT_APPOINTMENT(APP);
  528.                     PUT(ASCII.ESC & "[25m");
  529.                     CLASH := TRUE;
  530.                 else
  531.                     PRINT_APPOINTMENT(APP);
  532.                 end if;
  533.             end loop;
  534.             if CLASH then
  535.                 PUT(ASCII.ESC & "[5m" & ASCII.ESC & "[1m");
  536.                 PRINT_APPOINTMENT(NEWAPP);
  537.                 PUT(ASCII.ESC & "[0m");
  538.                 PRINT_APPOINTMENT_TITLE(FALSE);
  539.                 PUT_LINE("CLASH - New appointment not added");
  540.             else
  541.                 PUT(ASCII.ESC & "[1m");
  542.                 PRINT_APPOINTMENT(NEWAPP);
  543.                 PUT(ASCII.ESC & "[0m");
  544.                 PRINT_APPOINTMENT_TITLE(FALSE);
  545.                 PUT_LINE("No clashes - Adding appointment");
  546.                 RESET(HANDLE, OUT_FILE);
  547.                 WRITE_APPOINTMENT(HANDLE, NEWAPP);
  548.             end if;
  549.         end if;
  550.         WAIT_KEY;
  551.         CLOSE(HANDLE);
  552.     end ADD_ENTRY;
  553.  
  554.     procedure SEARCH_ENTRY(FILENAME : STRING) is
  555.         HANDLE : FILE_TYPE;
  556.         ERROR : BOOLEAN := FALSE;
  557.         APP : DIARY_ENTRY;
  558.         DAY, MONTH, YEAR : INTEGER := 42;
  559.  
  560.         -- nice dummy value that fails the test...
  561.  
  562.     begin
  563.         CLS;
  564.         PUT_LINE("Put 0 for 'any day/month/year'");
  565.         while DAY not in 0 .. 31 loop
  566.             PUT("Which day [1-31]       : ");
  567.             GET(DAY);
  568.         end loop;
  569.         while MONTH not in 0 .. 12 loop
  570.             PUT("Which month [1-12]     : ");
  571.             GET(MONTH);
  572.         end loop;
  573.         while YEAR /= 0 and then YEAR not in YEAR_TYPE loop
  574.             PUT("Which year [1901-2099] : ");
  575.             GET(YEAR);
  576.         end loop;
  577.         CLS;
  578.         PRINT_APPOINTMENT_TITLE(TRUE);
  579.         OPEN(HANDLE, IN_FILE, FILENAME);
  580.         while not END_OF_FILE(HANDLE) loop
  581.             READ_APPOINTMENT(HANDLE, APP, ERROR);
  582.             if APPOINTMENT_MATCH(APP, DAY, MONTH, YEAR) then
  583.                 PUT(ASCII.ESC & "[1m");
  584.                 PRINT_APPOINTMENT(APP);
  585.                 PUT(ASCII.ESC & "[0m");
  586.             else
  587.                 PRINT_APPOINTMENT(APP);
  588.             end if;
  589.         end loop;
  590.         PRINT_APPOINTMENT_TITLE(FALSE);
  591.         WAIT_KEY;
  592.         CLOSE(HANDLE);
  593.     end SEARCH_ENTRY;
  594.  
  595.     procedure GET_FILENAME(FILENAME : in out STRING) is
  596.         INDEX : INTEGER := 1;
  597.     begin
  598.         PUT("Old name : ");
  599.         PUT(FILENAME);
  600.         NEW_LINE;
  601.         PUT("New name : ");
  602.         FILENAME := EXPAND_STRING("", FILENAME'LENGTH);
  603.         loop
  604.             GET(FILENAME(INDEX));
  605.             INDEX := INDEX + 1;
  606.             exit when END_OF_LINE;
  607.         end loop;
  608.     end GET_FILENAME;
  609.  
  610.     -- ****MAIN procedure code *********************************************
  611.  
  612. begin
  613.     FILENAME := EXPAND_STRING("Appt.dat", 50);
  614.  
  615.     -- default filename
  616.  
  617.     while not (THE_END) loop
  618.         case MENU(FILENAME) is
  619.  
  620.             -- filename passed to menu so it can display it...
  621.  
  622.             when '1' =>
  623.                 LIST_DIARY(FILENAME);
  624.             when '2' =>
  625.                 ADD_ENTRY(FILENAME);
  626.             when '3' =>
  627.                 SEARCH_ENTRY(FILENAME);
  628.             when '4' =>
  629.                 GET_FILENAME(FILENAME);
  630.             when '5' =>
  631.                 THE_END := TRUE;
  632.             when others =>
  633.                 null;
  634.  
  635.                 -- user typed something silly
  636.  
  637.         end case;
  638.     end loop;
  639. exception
  640.     when END_ERROR =>
  641.         NEW_LINE;
  642.         PUT_LINE("OK then, bye!");
  643. end MAIN;
  644.  
  645.  
  646.  
  647.