home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / menu / mmgr.src < prev    next >
Encoding:
Text File  |  1988-05-03  |  256.1 KB  |  6,469 lines

  1. -------- SIMTEL20 Ada Software Repository Prologue ------------
  2. --                                                           -*
  3. -- Unit name    : Menu Manager Package
  4. -- Version      : 1.0
  5. -- Contact      : Lt. Colonel Falgiano
  6. --              : ESD/SCW
  7. --              : Hanscom AFB, MA  01731
  8. -- Author       : Jerry Horsewood
  9. --              : Adasoft, Inc, 9300
  10. --              : Anapolis Road
  11. --              : Lanham, MD 20706
  12. -- DDN Address  :
  13. -- Copyright    : (c) 1985 Adasoft, Inc.
  14. -- Date created : 19 January 1985
  15. -- Release date : May 1985
  16. -- Last update  : 
  17. --                                                           -*
  18. ---------------------------------------------------------------
  19. --                                                           -*
  20. -- Keywords     : 
  21. ----------------:
  22. --
  23. -- Abstract     : VIDEO is a menu manager package that is 
  24. ----------------: divided into four functional areas.  It will
  25. ----------------: provide application programmers with the 
  26. ----------------: ability to run various application systems     
  27. ----------------: from a menu driven user interface.                 
  28. ----------------: Applications to be invoked via menu selections
  29. ----------------: may be written in any language providing the
  30. ----------------: PRAGMA INTERFACE is supported.  The four 
  31. ----------------: functional areas are initialization of the 
  32. ----------------: overall application system, modeling of the 
  33. ----------------: application system, running the application,
  34. ----------------: and diagramming the system.
  35. ----------------:
  36. ----------------: This tool was developed as a precursor for 
  37. ----------------: the WMCCS Information System (WIS).  An
  38. ----------------: executable version of the tool has been 
  39. ----------------: demonstrated.  This source code has sub-
  40. ----------------: sequently been recompiled but has not under-
  41. ----------------: gone extensive testing.
  42. ----------------:
  43. --                                                           -*
  44. ------------------ Revision history ---------------------------
  45. --                                                           -*
  46. -- DATE         VERSION AUTHOR                  HISTORY 
  47. -- 05/84           1.0  Jerry Horsewood         Initial Release
  48. --                                                           -*
  49. ------------------ Distribution and Copyright -----------------
  50. --                                                           -*
  51. -- This prologue must be included in all copies of this software.
  52. -- 
  53. -- This software is copyright by the author.
  54. -- 
  55. -- This software is released to the Ada community.
  56. -- This software is released to the Public Domain (note:
  57. --   software released to the Public Domain is not subject
  58. --   to copyright protection).
  59. -- Restrictions on use or distribution:  NONE
  60. --                                                           -*
  61. ----------------- Disclaimer ----------------------------------
  62. --                                                           -*
  63. -- This software and its documentation are provided "AS IS" and
  64. -- without any expressed or implied warranties whatsoever.
  65. --
  66. -- No warranties as to performance, merchantability, or fitness
  67. -- for a particular purpose exist.
  68. --
  69. -- Because of the diversity of conditions and hardware under
  70. -- which this software may be used, no warranty of fitness for
  71. -- a particular purpose is offered.  The user is advised to 
  72. -- test the software thoroughly before relying on it.  The user
  73. -- must assume the entire risk and liability of using this 
  74. -- software.
  75. --
  76. -- In no event shall any person or organization of people be
  77. -- held responsible for any direct, indirect, consequential
  78. -- or inconsequential damages or lost profits.
  79. --                                                          -*
  80. ----------------- END-PROLOGUE -------------------------------
  81. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  82. --caisioco.txt
  83. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  84. -- **********************************************************************
  85. -- *                                                                    *
  86. -- *                     PACKAGE: CAIS_IO_CONTROL                       *
  87. -- *                     VERSION: 1.0a1                                 *
  88. -- *                     DATE   : APRIL, 1985                           *
  89. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  90. -- *                              AdaSoft, Inc.                         *
  91. -- *                              Lanham, MD                            *
  92. -- *                                                                    *
  93. -- **********************************************************************
  94. --
  95. -- CAIS_IO_CONTROL contains some definitions redefined in CAIS_PAGE_TERMINAL
  96. --
  97. package CAIS_IO_CONTROL is
  98.   type FILE_TYPE is ( CURRENT_INPUT, CURRENT_OUTPUT );
  99.   type SELECT_ENUMERATION is
  100.     ( FROM_ACTIVE_POSITION_TO_END,
  101.       FROM_START_TO_ACTIVE_POSITION,
  102.       ALL_POSITIONS );
  103.  
  104.   type FUNCTION_KEY_DESCRIPTOR is
  105.     ( KBS, KINSCH );
  106. end CAIS_IO_CONTROL;
  107. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  108. --caisio.txt
  109. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  110. -- **********************************************************************
  111. -- *                                                                    *
  112. -- *                     PACKAGE: CAIS_IO                               *
  113. -- *                     VERSION: 1.0a1                                 *
  114. -- *                     DATE   : APRIL, 1985                           *
  115. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  116. -- *                              AdaSoft, Inc.                         *
  117. -- *                              Lanham, MD                            *
  118. -- *                                                                    *
  119. -- **********************************************************************
  120. --
  121. -- CAIS_IO contains the procedures used to read from the keyboard and
  122. -- write to the terminal. This is NOT a CAIS standard package. Used only
  123. -- in the package body of CAIS_PAGE_TERMINAL. The package body has an
  124. -- initialization section that opens the keyboard file, using the result
  125. -- of TEXT_IO.STANDARD_INPUT for the name string .
  126. --
  127. package CAIS_IO is
  128.   procedure GET ( ITEM : out CHARACTER );
  129.     -- Get uses Sequential_io to get characters from the keyboard
  130.     --
  131.   procedure PUT ( ITEM : in CHARACTER );
  132.     -- Put is used to write characters to the screen
  133.     --
  134.   procedure PUT ( STR  : in STRING );
  135.     -- Put is used to write escape sequences to the terminal
  136.     --
  137. end CAIS_IO;
  138.  
  139. with TEXT_IO, SEQUENTIAL_IO;
  140. package body CAIS_IO is
  141.   package NEW_IO is new SEQUENTIAL_IO ( CHARACTER );
  142.   use NEW_IO;
  143.  
  144.   KEYBOARD : FILE_TYPE;
  145.  
  146.   procedure GET ( ITEM : out CHARACTER ) is
  147.   begin
  148.     NEW_IO.READ ( KEYBOARD, ITEM );
  149.   end GET;
  150.  
  151.   procedure PUT ( ITEM : in CHARACTER ) is
  152.   begin
  153.     TEXT_IO.PUT ( ITEM );
  154.   end PUT;
  155.  
  156.   procedure PUT ( STR  : in STRING ) is
  157.   begin
  158.     TEXT_IO.PUT ( STR );
  159.   end PUT;
  160.  
  161. begin
  162.   OPEN ( KEYBOARD, IN_FILE, TEXT_IO.NAME(TEXT_IO.STANDARD_INPUT) );
  163. end CAIS_IO;
  164. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  165. --passprocs.txt
  166. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  167. -- **********************************************************************
  168. -- *                                                                    *
  169. -- *                     PACKAGE: PASS_PROCS                            *
  170. -- *                     VERSION: 1.0a1                                 *
  171. -- *                     DATE   : JANUARY, 1985                         *
  172. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  173. -- *                              AdaSoft, Inc.                         *
  174. -- *                              Lanham, MD                            *
  175. -- *                                                                    *
  176. -- **********************************************************************
  177. --
  178. --  This package contains the definition of the Password type used throughout
  179. --  VIDEO, and the subroutines used for manipulating that password.
  180. --
  181. package PASS_PROCS is
  182.   
  183.   type PASSWORD_TYPE is private;
  184.   
  185.   procedure STRING_TO_PASS ( STR  : in     STRING;
  186.                              LNTH : in     NATURAL;
  187.                              PASS :    out PASSWORD_TYPE );
  188. -- procedure string_to_pass takes a string of up to eight characters (and
  189. -- the string length), and returns an encoded password.
  190.   
  191.   function PASS_TO_STRING ( PASS : in     PASSWORD_TYPE ) return STRING;
  192. -- pass_to_string takes an encoded password and returns it in a decoded string;
  193.   
  194.   function VERIFY_PASSWORD ( PASS1 : in PASSWORD_TYPE;
  195.                              PASS2 : in PASSWORD_TYPE ) return BOOLEAN;
  196. -- verify password compares two passwords and returns true if they match.
  197.                              
  198.   function HAS_PASSWORD ( PASS : in PASSWORD_TYPE ) return BOOLEAN;
  199. -- has_password determines if the password flag has been set.
  200.  
  201. private
  202.   type PASSWORD_TYPE is
  203.     record
  204.       LNTH : NATURAL range 1..8 := 0;
  205.       STR  : STRING (1..8) := "        ";
  206.       FLAG : BOOLEAN := FALSE;
  207.     end record;
  208.     
  209. end PASS_PROCS;
  210.  
  211. package body PASS_PROCS is
  212.  
  213.   type ENCIPHER_MODE is ( ENCIPHER, DECIPHER );
  214.   
  215.   procedure NBS_ENCIPHER ( PASS : in out PASSWORD_TYPE;
  216.                            MODE : in     ENCIPHER_MODE ) is
  217.   -- nbs_encipher is a non-exportable routine that enciphers or deciphers the
  218.   -- password string in a password.
  219.   begin
  220.     for I in 1..PASS.LNTH loop
  221.       if MODE = ENCIPHER then 
  222.         PASS.STR(I) := CHARACTER'val( CHARACTER'pos( PASS.STR(I) ) - 32 + I );
  223.       else  -- mode = decipher
  224.         PASS.STR(I) := CHARACTER'val( CHARACTER'pos( PASS.STR(I) ) + 32 - I );
  225.       end if; -- mode = encipher
  226.     end loop; -- 1..pass.lnth loop
  227.   end NBS_ENCIPHER;
  228.   
  229.   procedure STRING_TO_PASS ( STR  : in     STRING;
  230.                              LNTH : in     NATURAL;
  231.                              PASS :    out PASSWORD_TYPE ) is
  232.     
  233.     TEMP_PASS : PASSWORD_TYPE;
  234.     
  235.   begin
  236.     if LNTH > 0 then
  237.       TEMP_PASS.FLAG := TRUE;
  238.       TEMP_PASS.STR(1..LNTH) := STR(1..LNTH);
  239.       TEMP_PASS.LNTH := LNTH;
  240.     end if; -- lnth > 0
  241.     NBS_ENCIPHER ( TEMP_PASS, ENCIPHER );
  242.     PASS := TEMP_PASS;
  243.   end STRING_TO_PASS;
  244.   
  245.   function PASS_TO_STRING ( PASS : in     PASSWORD_TYPE ) return STRING is
  246.                              
  247.     TEMP_PASS : PASSWORD_TYPE;
  248.   
  249.   begin
  250.     TEMP_PASS := PASS;
  251.     NBS_ENCIPHER ( TEMP_PASS, DECIPHER );
  252.     if TEMP_PASS.FLAG then
  253.       return TEMP_PASS.STR;
  254.     end if; -- only if it has a password
  255.   end PASS_TO_STRING;
  256.   
  257.   function VERIFY_PASSWORD ( PASS1 : in PASSWORD_TYPE;
  258.                              PASS2 : in PASSWORD_TYPE ) return BOOLEAN is
  259.     RETURN_VAL : BOOLEAN := FALSE;
  260.   
  261.   begin
  262.     -- if they are equal in length and then they match character for character.
  263.     if PASS1.LNTH = PASS2.LNTH and then
  264.       PASS1.STR(1..PASS1.LNTH) = PASS2.STR(1..PASS1.LNTH) then
  265.         RETURN_VAL := TRUE;
  266.     end if;
  267.     return RETURN_VAL;
  268.   end VERIFY_PASSWORD;
  269.                              
  270.   function HAS_PASSWORD ( PASS : in PASSWORD_TYPE ) return BOOLEAN is
  271.   begin
  272.     return PASS.FLAG;
  273.   end HAS_PASSWORD;
  274.   
  275. end PASS_PROCS;
  276. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  277. --vidtypes.txt
  278. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  279. -- **********************************************************************
  280. -- *                                                                    *
  281. -- *                     PACKAGE: VIDEO_TYPES                           *
  282. -- *                     VERSION: 1.0a1                                 *
  283. -- *                     DATE   : JANUARY, 1985                         *
  284. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  285. -- *                              AdaSoft, Inc.                         *
  286. -- *                              Lanham, MD                            *
  287. -- *                                                                    *
  288. -- **********************************************************************
  289. --
  290. -- This package contains the global types, constants and variables used
  291. -- in all the VIDEO procedures.
  292. --
  293. with PASS_PROCS;
  294. package VIDEO_TYPES is
  295.   --
  296.   -- Global exceptions
  297.   --
  298.   USER_QUIT : exception;
  299.   BAD_PASSWORD : exception;
  300.  
  301.   --
  302.   -- General constants and types
  303.   --
  304.   subtype PRINTABLE is CHARACTER range ' '..'~';
  305.   subtype LOWER_CASE is CHARACTER range 'a'..'z';
  306.   
  307.   -- Terminal constants and types
  308.   --
  309.   FIRST_COL : constant NATURAL := 0;
  310.   FIRST_ROW : constant NATURAL := 0;
  311.   LAST_ROW  : constant NATURAL := 23;
  312.   LAST_COL  : constant NATURAL := 79;
  313.   
  314.   MAX_LINE_LNTH  : constant NATURAL := LAST_COL + 1;
  315.   MAX_DISP_LINES : constant NATURAL := LAST_ROW - 3;
  316.   
  317.   subtype COLUMN is NATURAL range FIRST_COL..LAST_COL;
  318.   subtype ROWS is NATURAL range FIRST_ROW..LAST_ROW;
  319.   
  320.   type POSITION_TYPE is 
  321.     record
  322.       COL : COLUMN;
  323.       ROW : ROWS;
  324.     end record;
  325.     
  326.   HOME_POSITION  : constant POSITION_TYPE := ( FIRST_COL, FIRST_ROW );
  327.   MAX_POSITION   : constant POSITION_TYPE := ( LAST_COL, LAST_ROW );
  328.   ERROR_LINE     : constant POSITION_TYPE := ( FIRST_COL, LAST_ROW - 1 );
  329.   PROMPT_LINE    : constant POSITION_TYPE := ( FIRST_COL, LAST_ROW );
  330.   
  331.   type PAGE_LINE is
  332.     record
  333.       LNTH : POSITIVE range 1..MAX_LINE_LNTH;
  334.       LINE : STRING (1..MAX_LINE_LNTH);
  335.     end record;
  336.     
  337.   type TEXT_PAGE is array (1..MAX_DISP_LINES) of PAGE_LINE;
  338.   
  339.   subtype HEADER_LINES is INTEGER range 1..5;
  340.   type HEADER_TYPE is array ( HEADER_LINES ) of STRING(1..MAX_LINE_LNTH);
  341.     
  342.   --
  343.   -- VIDEO constants and types
  344.   --
  345.   
  346.   type FLAG is ( ON, OFF );
  347.   
  348.   type OPTIONS is ( CR, SLASH, C, I, M, R, T, X, Z, ONE, TWO, THREE, 
  349.                     FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, ELEVEN,
  350.                     TWELVE, THIRTEEN, FOURTEEN, FIFTEEN );
  351.   
  352.   subtype CHOICES is OPTIONS range ONE..FIFTEEN;
  353.   type MENU_OPTIONS is array (CHOICES) of NATURAL;
  354.   
  355.   type VALID is array (OPTIONS) of STRING (1..2);
  356.   
  357.   type NODE is ( BOOT, MENU, INSTRUCTION, PROGRAM );
  358.   subtype USER_NODE is NODE range MENU..PROGRAM;
  359.   
  360.   type NAME_REC is
  361.     record
  362.       LENGTH : POSITIVE range 1..20 := 20;
  363.       NAME   : STRING (1..20) := "                    ";
  364.     end record;
  365.     
  366.   type FILE_NAME is
  367.     record
  368.       DEV : NAME_REC := (14,"                    ");
  369.       DIR : NAME_REC;
  370.       FIL : NAME_REC := (13,"                    ");
  371.     end record;
  372.       
  373.   type FILESPEC is
  374.     record
  375.       LENGTH : POSITIVE range 1..75 := 1;
  376.       NAME   : STRING (1..75);
  377.     end record;
  378.     
  379.   type NODE_RECORD ( NODE_TYPE : NODE := MENU ) is
  380.     record
  381.       LAST_NODE : NATURAL;
  382.       LAST_MENU : NATURAL;
  383.       POSITION  : NATURAL;
  384.       NODE_PASSWORD : PASS_PROCS.PASSWORD_TYPE;
  385.       case NODE_TYPE is
  386.         when BOOT =>
  387.           DEFAULT        : FILE_NAME;
  388.           LAST_FREE_NODE : NATURAL;
  389.           NEXT_FREE_NODE : NATURAL;
  390.         when MENU =>
  391.           MENU_PATH      : FILE_NAME;
  392.           OPTION         : MENU_OPTIONS;
  393.         when others =>
  394.           PATH           : FILE_NAME;
  395.           NEXT_NODE      : NATURAL;
  396.       end case;
  397.     end record;
  398.   
  399.   --
  400.   -- VIDEO global variables
  401.   --
  402.   ACTIVE_POSITION : POSITION_TYPE := HOME_POSITION;
  403.   
  404.   ECHO_ON : BOOLEAN := TRUE;
  405.   
  406. end VIDEO_TYPES;
  407. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  408. --videbug.txt
  409. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  410. -- **********************************************************************
  411. -- *                                                                    *
  412. -- *                     PACKAGE: VIDEO_DEBUG                           *
  413. -- *                     VERSION: 1.0a1                                 *
  414. -- *                     DATE   : JANUARY, 1985                         *
  415. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  416. -- *                              AdaSoft, Inc.                         *
  417. -- *                              Lanham, MD                            *
  418. -- *                                                                    *
  419. -- **********************************************************************
  420. --
  421. --  This package contains two routines for program development. These 
  422. --  routines trace exceptions from the lowest level they are raised in.
  423. --
  424. package VIDEO_DEBUG is
  425.   procedure TRACE_EXCEPTION ( MSG : in STRING );
  426.   --  this routine rights a message to a text file
  427.   
  428.   procedure PRINT_EXCEPTIONS;
  429.   -- this routine is included in the highest routine and closes the file 
  430.   
  431. end VIDEO_DEBUG;
  432.  
  433. with TEXT_IO;use TEXT_IO;
  434. package body VIDEO_DEBUG is
  435.  
  436.   PRINT : FILE_TYPE;
  437.   
  438.   procedure TRACE_EXCEPTION ( MSG : in STRING ) is
  439.   begin
  440.     while not IS_OPEN ( PRINT ) loop
  441.       begin
  442.         OPEN ( PRINT, OUT_FILE, "ERRORS.TXT" );
  443.       exception
  444.         when NAME_ERROR =>
  445.           CREATE ( PRINT, OUT_FILE, "ERRORS.TXT" );
  446.       end;
  447.     end loop;
  448.     PUT_LINE ( PRINT, MSG );
  449.   exception
  450.     when others => 
  451.       CLOSE ( PRINT );
  452.       raise;
  453.   end TRACE_EXCEPTION;
  454.   procedure PRINT_EXCEPTIONS is
  455.   begin
  456.       CLOSE ( PRINT );
  457.   exception
  458.     when others => 
  459.       raise;
  460.   end PRINT_EXCEPTIONS;
  461. end VIDEO_DEBUG;
  462. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  463. --commsgs.txt
  464. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  465. -- **********************************************************************
  466. -- *                                                                    *
  467. -- *                     PACKAGE: COMMON_MESSAGES                       *
  468. -- *                     VERSION: 1.0a1                                 *
  469. -- *                     DATE   : JANUARY, 1985                         *
  470. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  471. -- *                              AdaSoft, Inc.                         *
  472. -- *                              Lanham, MD                            *
  473. -- *                                                                    *
  474. -- **********************************************************************
  475. --
  476. --  This package contains the common_messages used throughout VIDEO
  477. --
  478. package COMMON_MESSAGES is
  479.   
  480.   type ERRS is ( NODETYPE,     FILE_ACCESS,    INVALID_RESP,
  481.                  CR_INVAL,     PROC_TERM,      INV_BR_NO,
  482.                  INV_NODETYPE, INV_FILNAM,     INV_PASS,
  483.                  NON_NUMERIC,  OPEN_ERR,       INV_DIRNAM,
  484.                  INV_DEVNAM                               );
  485.                  
  486.   type COMMON_ERRORS is array (ERRS) of STRING (1..80);
  487.   
  488.   type MSGS is ( SUCCESS,     CUR_FILNAM,     CUR_DIRNAM,
  489.                  CUR_DEV,     SUCCESS_INIT );
  490.                  
  491.   type COMMON_MSGS is array (MSGS) of STRING (1..80);
  492.   
  493.   type MENU_TYPES is ( COPYRIGHT, MAINT );
  494.   subtype LINES is INTEGER range 1..22;
  495.   type MENU_TABLE is array (MENU_TYPES, LINES) of STRING (1..80);
  496.   type MENU_LINES is array (MENU_TYPES ) of LINES;
  497.   
  498.   BLANKS : constant STRING (1..19) := "                   ";
  499.   
  500.   ERRORS :  constant COMMON_ERRORS := (
  501.     "**ERROR**NODE TYPE OUT-OF-RANGE                               " & BLANKS,
  502.     "**ERROR**UNABLE TO ACCESS FILE                                " & BLANKS,
  503.     "**ERROR**RESPONSE IS NOT A VALID OPTION OR SPECIAL CHARACTER  " & BLANKS,
  504.     "**ERROR**CARRIAGE RETURN RESPONSE IS NOT ACCEPTABLE           " & BLANKS,
  505.     "**ERROR**PROCESS TERMINATED - REASON                          " & BLANKS,
  506.     "**ERROR**INVALID BRANCH NUMBER ENTERED                        " & BLANKS,
  507.     "**ERROR**INVALID NODE TYPE ENTERED                            " & BLANKS,
  508.     "**ERROR**INVALID FILE NAME ENTERED                            " & BLANKS,
  509.     "**ERROR**INVALID PASSWORD ENTERED                             " & BLANKS,
  510.     "**ERROR**NON-NUMERIC DATA ENTERED                             " & BLANKS,
  511.     "**ERROR**OPEN ERROR OCCURRED WHILE ATTEMPTING TO OPEN FILE    " & BLANKS,
  512.     "**ERROR**INVALID DIRECTORY NAME ENTERED                       " & BLANKS,
  513.     "**ERROR**INVALID DEVICE NAME ENTERED                          " & BLANKS );
  514.   
  515.   MESSAGES : constant COMMON_MSGS := (
  516.     "PROCESS HAS COMPLETED SUCCESSFULLY                            " & BLANKS,
  517.     "THE CURRENT FILE NAME IS                                      " & BLANKS,
  518.     "THE CURRENT DIRECTORY NAME IS                                 " & BLANKS,
  519.     "THE CURRENT DEVICE NAME IS                                    " & BLANKS,
  520.     "APPLICATION MODEL INITIALIZATION HAS COMPLETED SUCCESSFULLY   " & BLANKS);
  521.    
  522.   LAST_LINE : MENU_LINES := ( 6, 7 );
  523.  
  524.   MENU_BLANKS : STRING(1..15) := "               ";
  525.  
  526.   MENUS : MENU_TABLE := (  
  527.    (1=>MENU_BLANKS & "VIDEO VERSION 1 LEVEL 0   RELEASE DATE: MAY-30-1985" & 
  528.        MENU_BLANKS,
  529.     2=>MENU_BLANKS & "                                                   " & 
  530.        MENU_BLANKS,
  531.     3=>MENU_BLANKS & "      Developed by AdaSoft, Inc., Lanham, MD.      " & 
  532.        MENU_BLANKS,
  533.     4=>MENU_BLANKS & "   For Naval Ocean Systems Center, San Diego, CA.  " & 
  534.        MENU_BLANKS,
  535.     5=>MENU_BLANKS & "        Under Contract No. N66001-85-C-0049        " & 
  536.        MENU_BLANKS,
  537.     6..22=>
  538.        MENU_BLANKS & "                                                   " & 
  539.        MENU_BLANKS ),
  540.      
  541.    (1=>MENU_BLANKS & "   * * * * M A I N T E N A N C E  M E N U * * * *  " & 
  542.        MENU_BLANKS,
  543.     2=>MENU_BLANKS & "                                                   " & 
  544.        MENU_BLANKS,
  545.     3=>MENU_BLANKS & "            1. ADD A NODE                          " & 
  546.        MENU_BLANKS,
  547.     4=>MENU_BLANKS & "            2. MODIFY/DISPLAY NODE                 " & 
  548.        MENU_BLANKS,
  549.     5=>MENU_BLANKS & "            3. DELETE ONE OR MORE NODES            " & 
  550.        MENU_BLANKS,
  551.     6=>MENU_BLANKS & "            4. INSERT A NODE                       " & 
  552.        MENU_BLANKS,
  553.     7=>MENU_BLANKS & "            5. MOVE A SUBMODEL                     " & 
  554.        MENU_BLANKS,
  555.     8..22 =>
  556.        MENU_BLANKS & "                                                   " & 
  557.        MENU_BLANKS  ));
  558.   
  559.  end COMMON_MESSAGES;
  560. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  561. --prompts.txt
  562. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  563. -- **********************************************************************
  564. -- *                                                                    *
  565. -- *                     PACKAGE: PROMPT_MESSAGES                       *
  566. -- *                     VERSION: 1.0a1                                 *
  567. -- *                     DATE   : JANUARY, 1985                         *
  568. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  569. -- *                              AdaSoft, Inc.                         *
  570. -- *                              Lanham, MD                            *
  571. -- *                                                                    *
  572. -- **********************************************************************
  573. --
  574. --  This package contains the prompts used throughout VIDEO
  575. --
  576. package PROMPT_MESSAGES is
  577.   type PROMPTS is (
  578.     OPTION_NO,     SLASH_RTN,        ADD_BR_NO,       ADD_TYP,
  579.     ADD_FILNAM,    PASSWRD,          EXIT_MAINT,      DEL_BR_NO,
  580.     NEW_FILNAM,    NEW_PASS,         DEL,             CNCT_BR,
  581.     CR_GO,         PASS_APL_MDL,     PASS_RUN_APL,    DEL_NOD,
  582.     CR_GO_SL_RTN,  DEL_THIS_NOD,     MOD_APL_PRMS,    MOD_DEL_PRMS,
  583.     PASS_APL_MORE, DEL_PASS,         RTNOD_DIR,       NAM_APL_INIT,
  584.     PASS_MDL,      RTNOD_NAM,        PASS_RUN_APPL,   RTNOD_TYP,
  585.     DIRNAM,        DIRNAM_APL_MDL,   NEW_DIRNAM,      DEVNAM,
  586.     DEVNAM_APL_MDL, NEW_DEVNAM,      RTNOD_DEV,       APL_NAM,
  587.     BR_NO_MOV_FRM, BR_NO_MOV_TO,     FILNAM   );
  588.     
  589.   type PROMPT_MSGS is array ( PROMPTS ) of STRING (1..72);
  590.   
  591.   BLANKS : constant STRING (1..8) := "        ";
  592.   
  593.   PROMPT : PROMPT_MSGS := (
  594.     "ENTER NUMBER CORRESPONDING TO SELECTED OPTION                   " & BLANKS,
  595.     "ENTER SLASH TO RETURN TO LAST MENU                              " & BLANKS,
  596.     "ENTER BRANCH NUMBER TO WHICH NODE IS TO BE ADDED                " & BLANKS,
  597.     "ENTER TYPE OF NODE TO BE ADDED (MENU, INST, PROG )              " & BLANKS,
  598.     "ENTER FILE NAME OF NODE TO BE ADDED                             " & BLANKS,
  599.     "ENTER PASSWORD OR CARRIAGE RETURN IF NONE                       " & BLANKS,
  600.     "ENTER CARRIAGE RETURN TO EXIT FROM MAINTENANCE                  " & BLANKS,
  601.     "ENTER BRANCH NUMBER FOR PORTION OF MODEL TO BE DELETED          " & BLANKS,
  602.     "ENTER NEW FILE NAME OR CARRIAGE RETURN IF NONE                  " & BLANKS,
  603.     "ENTER NEW PASSWORD OR CARRIAGE RETURN IF NONE                   " & BLANKS,
  604.     "ENTER 'YES' TO PERFORM DELETION                                 " & BLANKS,
  605.     "ENTER BRANCH NUMBER FOR CONNECTION OF REMAINING MODEL           " & BLANKS,
  606.     "ENTER CARRIAGE RETURN TO CONTINUE                               " & BLANKS,
  607.     "ENTER PASSWORD TO ACCESS THE APPLICATION MODEL                  " & BLANKS,
  608.     "ENTER PASSWORD TO RUN THE APPLICATION                           " & BLANKS,
  609.     "ENTER 'YES' TO DELETE ONLY THE SPECIFIED NODE                   " & BLANKS,
  610.     "ENTER CARRIAGE RETURN TO CONTINUE - SLASH TO RETURN TO LAST MENU" & BLANKS,
  611.     "ENTER 'YES' TO INCLUDE THIS NODE IN DELETION                    " & BLANKS,
  612.     "ENTER 'YES' TO MODIFY APPLICATION SYSTEM PARAMETERS             " & BLANKS,
  613.     "ENTER 'YES' TO MODIFY OR DELETE THE PARAMETER STRING            " & BLANKS,
  614.     "ENTER PASSWORD TO ACCESS APPLICATION BEYOND THIS POINT          " & BLANKS,
  615.     "ENTER 'YES' TO DELETE THE CURRENT PASSWORD                      " & BLANKS,
  616.     "ENTER ROOT NODE DIRECTORY OR CARRIAGE RETURN FOR DEFAULT        " & BLANKS,
  617.     "ENTER NAME OF APPLICATION MODEL BEING INITIALIZED               " & BLANKS,
  618.     "ENTER PASSWORD FOR ACCESS TO MODEL (1-8 CHARACTERS)             " & BLANKS,
  619.     "ENTER FILE NAME OF ROOT NODE FOR APPLICATION MODEL              " & BLANKS,
  620.     "ENTER PASSWORD TO RUN APPLICATION (1-8 CHARACTERS)              " & BLANKS,
  621.     "ENTER APPLICATION MODEL ROOT NODE TYPE ( MENU, INST )           " & BLANKS,
  622.     "ENTER DIRECTORY NAME OR CARRIAGE RETURN FOR DEFAULT             " & BLANKS,
  623.     "ENTER NAME OF DIRECTORY CONTAINING APPLICATION MODEL            " & BLANKS,
  624.     "ENTER NEW DIRECTORY NAME OR CARRIAGE RETURN FOR DEFAULT         " & BLANKS,
  625.     "ENTER DEVICE NAME OR CARRIAGE RETURN FOR DEFAULT                " & BLANKS,
  626.     "ENTER NAME OF DEVICE CONTAINING APPLICATION MODEL               " & BLANKS,
  627.     "ENTER NEW DEVICE NAME OR CARRIAGE RETURN FOR DEFAULT            " & BLANKS,
  628.     "ENTER ROOT NODE DEVICE OR CARRIAGE RETURN FOR DEFAULT           " & BLANKS,
  629.     "ENTER NAME OF APPLICATION TO BE RUN                             " & BLANKS,
  630.     "ENTER BRANCH NUMBER FROM WHICH SUBMODEL IS TO BE MOVED          " & BLANKS,
  631.     "ENTER BRANCH NUMBER TO WHICH SUBMODEL IS TO BE MOVED            " & BLANKS,
  632.     "ENTER FILE NAME OR CARRIAGE RETURN IF NONE                      " & 
  633.      BLANKS );
  634.     
  635. end PROMPT_MESSAGES;
  636. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  637. --caispage.txt
  638. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  639. -- **********************************************************************
  640. -- *                                                                    *
  641. -- *                     PACKAGE: CAIS_PAGE_TERMINAL                    *
  642. -- *                     VERSION: 1.0a1                                 *
  643. -- *                     DATE   : JANUARY, 1985                         *
  644. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  645. -- *                              AdaSoft, Inc.                         *
  646. -- *                              Lanham, MD                            *
  647. -- *                                                                    *
  648. -- **********************************************************************
  649. --
  650. -- This package contains the underlying terminal control features used 
  651. -- in all the VIDEO procedures. The interface specifications are in 
  652. -- conformance with the proposed CAIS Standard, and packages for specific 
  653. -- terminals that conform to this standard may be substituted.
  654. --
  655. -- The body for this package currently controls the terminal features of an
  656. -- ANSII terminal (in the package ANSII_TERMINAL), and it will be necessary to
  657. -- modify this for other terminal types.
  658. --
  659. with CAIS_IO_CONTROL, VIDEO_TYPES;
  660. package CAIS_PAGE_TERMINAL is
  661.   
  662.   --               ********************************
  663.   --               * NOTE: the following subtypes *
  664.   --               * are redefinitions of types   *
  665.   --               * declared in CAIS_IO_CONTROL. *
  666.   --               ********************************
  667.   
  668.   subtype FILE_TYPE is CAIS_IO_CONTROL.FILE_TYPE;
  669.   subtype POSITION_TYPE is VIDEO_TYPES.POSITION_TYPE;
  670.   subtype SELECT_ENUMERATION is CAIS_IO_CONTROL.SELECT_ENUMERATION;
  671.   subtype FUNCTION_KEY_DESCRIPTOR is CAIS_IO_CONTROL.FUNCTION_KEY_DESCRIPTOR;
  672.   
  673.   procedure SET_POSITION ( TERMINAL : in FILE_TYPE;
  674.                            POSITION : in POSITION_TYPE );
  675.   -- Set_position sets the position of the cursor on the screen and updates
  676.   -- the current position maintained as a global in VIDEO_TYPES.
  677.                            
  678.   function POSITION ( TERMINAL : in FILE_TYPE ) return POSITION_TYPE;
  679.   -- Position returns the current cursor position as a point_record.
  680.   
  681.   function SIZE ( TERMINAL : in FILE_TYPE ) return POSITION_TYPE;
  682.   -- Position returns the maximum screen size as a point_record.
  683.   
  684.   procedure PUT ( TERMINAL : in FILE_TYPE;
  685.                   ITEM     : in CHARACTER );
  686.   -- Put places a single character on the screen at the active cursor position
  687.   -- and updates the active position by one.
  688.                   
  689.   procedure ERASE_CHARACTER ( TERMINAL : in FILE_TYPE;
  690.                               COUNT    : in POSITIVE := 1 );
  691.   -- Erase_character erases the character immediately left of the cursor and
  692.   -- places the cursor at that location.
  693.   
  694.   procedure SET_ECHO ( TERMINAL : in FILE_TYPE;
  695.                        TO       : in BOOLEAN := TRUE );
  696.   -- Set_echo sets the global Echo_on in Video_types either on(TRUE) or off.
  697.                        
  698.   function ECHO ( TERMINAL : in FILE_TYPE ) return BOOLEAN;
  699.   -- Returns the current state of Video_types.Echo_on.
  700.   
  701.   procedure GET ( TERMINAL : in     FILE_TYPE;
  702.                   ITEM     :    out CHARACTER;
  703.                   KEYS     : in out FUNCTION_KEY_DESCRIPTOR );
  704.   -- Get captures a character or function key from the user.
  705.                   
  706.   procedure GET ( TERMINAL : in     FILE_TYPE;
  707.                   ITEM     :    out STRING;
  708.                   LAST     :    out NATURAL;
  709.                   KEYS     : in out FUNCTION_KEY_DESCRIPTOR );
  710.   -- Gets a string by making repeated calls to Get ( character );
  711.                   
  712.   procedure ERASE_IN_DISPLAY ( TERMINAL  : in FILE_TYPE;
  713.                                SELECTION : in SELECT_ENUMERATION );
  714.   -- Erase_in_display erases all or part of the screen, depending on the 
  715.   -- selection.
  716.                                
  717.   procedure ERASE_IN_LINE ( TERMINAL  : in FILE_TYPE;
  718.                             SELECTION : in SELECT_ENUMERATION );
  719.   -- Erase_in_line erases all or part of a line, depending on the selection.
  720.                             
  721.   procedure BELL ( TERMINAL : in FILE_TYPE );
  722.   -- rings the terminal bell.
  723.   
  724. end CAIS_PAGE_TERMINAL;
  725.  
  726. with CAIS_IO;
  727. package body CAIS_PAGE_TERMINAL is
  728.   use CAIS_IO_CONTROL, VIDEO_TYPES;
  729.  
  730.   -- The package ANSII_TERMINAL contains the ESC sequences used in this 
  731.   -- version of CAIS_PAGE_TERMINAL. Because TELESOFT-Ada Ver. 1.5 does
  732.   -- not allow catenation of a character and a string, this package has
  733.   -- a package body to add the ESC character to the first part of the strings.
  734.   --
  735.   package ANSII_TERMINAL is
  736.     ERASE : STRING(1..1);
  737.     TO_END : STRING(1..2) := "[0";
  738.     FROM_BEGINNING : STRING(1..2) := "[1";
  739.     ALL_PARTS : STRING(1..2) := "[2";
  740.     OF_SCREEN : STRING(1..1) := "J";
  741.     OF_LINE : STRING(1..1) := "K";
  742.     CURSOR_MOVE : STRING(1..2) := " [";
  743.   end ANSII_TERMINAL;
  744.  
  745.   package body ANSII_TERMINAL is
  746.   begin
  747.     ERASE(1) := ASCII.ESC;
  748.     CURSOR_MOVE(1) := ASCII.ESC;
  749.   end ANSII_TERMINAL;
  750.   use ANSII_TERMINAL;
  751.   
  752.   procedure UPDATE ( TERMINAL : in     FILE_TYPE;
  753.                      POSITION : in out POSITION_TYPE ) is
  754.   -- this procedure updates Video_types.active_position 
  755.   begin
  756.     if POSITION.COL < VIDEO_TYPES.COLUMN'last then
  757.       POSITION.COL := POSITION.COL + 1;
  758.     else
  759.       POSITION.ROW := POSITION.ROW + 1;
  760.       POSITION.COL := 0;
  761.     end if;
  762.   end UPDATE;
  763.                      
  764.   procedure SET_POSITION ( TERMINAL : in FILE_TYPE;
  765.                            POSITION : in POSITION_TYPE ) is
  766.   begin
  767.     CAIS_IO.PUT ( CURSOR_MOVE & INTEGER'image(POSITION.ROW) &
  768.                   ";" & INTEGER'image(POSITION.COL) & "H");
  769.     VIDEO_TYPES.ACTIVE_POSITION := POSITION;
  770.   end SET_POSITION;
  771.                            
  772.   function POSITION ( TERMINAL : in FILE_TYPE ) return POSITION_TYPE is
  773.   begin
  774.     return VIDEO_TYPES.ACTIVE_POSITION;
  775.   end POSITION;
  776.   
  777.   function SIZE ( TERMINAL : in FILE_TYPE ) return POSITION_TYPE is
  778.   begin
  779.     return VIDEO_TYPES.MAX_POSITION;
  780.   end SIZE;
  781.   
  782.   procedure PUT ( TERMINAL : in FILE_TYPE;
  783.                   ITEM     : in CHARACTER ) is
  784.   begin
  785.     CAIS_IO.PUT ( ITEM );
  786.     UPDATE ( TERMINAL, VIDEO_TYPES.ACTIVE_POSITION );
  787.   end PUT;
  788.                   
  789.   procedure ERASE_CHARACTER ( TERMINAL : in FILE_TYPE;
  790.                               COUNT    : in POSITIVE := 1 ) is
  791.     SPACE : constant CHARACTER := ' ';
  792.     LAST_POSITION : POSITION_TYPE;
  793.   begin
  794.     LAST_POSITION := POSITION ( CURRENT_OUTPUT );
  795.     for I in 1..COUNT loop
  796.       PUT ( CURRENT_OUTPUT, SPACE );
  797.     end loop;
  798.     SET_POSITION ( CURRENT_OUTPUT, LAST_POSITION );
  799.   end ERASE_CHARACTER;
  800.   
  801.   procedure SET_ECHO ( TERMINAL : in FILE_TYPE;
  802.                        TO       : in BOOLEAN := TRUE ) is
  803.   begin
  804.     VIDEO_TYPES.ECHO_ON := TO;
  805.   end SET_ECHO;
  806.   
  807.   function ECHO ( TERMINAL : in FILE_TYPE ) return BOOLEAN is
  808.   begin
  809.     return VIDEO_TYPES.ECHO_ON;
  810.   end ECHO;
  811.   
  812.   procedure GET ( TERMINAL : in     FILE_TYPE;
  813.                   ITEM     :    out CHARACTER;
  814.                   KEYS     : in out FUNCTION_KEY_DESCRIPTOR ) is
  815.   begin
  816.     CAIS_IO.GET ( ITEM );
  817.   end GET;
  818.                   
  819.   procedure GET ( TERMINAL : in     FILE_TYPE;
  820.                   ITEM     :    out STRING;
  821.                   LAST     :    out NATURAL;
  822.                   KEYS     : in out FUNCTION_KEY_DESCRIPTOR ) is
  823.                   
  824.    CHAR : CHARACTER;
  825.    
  826.   begin
  827.     LAST := 0;
  828.     loop  -- continue getting characters until a <CR> is recieved
  829.       GET ( TERMINAL, CHAR, KEYS );
  830.       exit when CHAR = ASCII.CR;
  831.       if CHAR in VIDEO_TYPES.PRINTABLE then
  832.         LAST := LAST + 1;
  833.         ITEM ( LAST ) := CHAR;
  834.       end if;
  835.     end loop;
  836.   end GET;
  837.                   
  838.   procedure ERASE_IN_DISPLAY ( TERMINAL  : in FILE_TYPE;
  839.                                SELECTION : in SELECT_ENUMERATION ) is
  840.   begin
  841.     case SELECTION is 
  842.       when FROM_ACTIVE_POSITION_TO_END =>
  843.         CAIS_IO.PUT ( ERASE & TO_END & OF_SCREEN );
  844.       when FROM_START_TO_ACTIVE_POSITION =>
  845.         CAIS_IO.PUT ( ERASE & FROM_BEGINNING & OF_SCREEN );
  846.       when ALL_POSITIONS =>
  847.         CAIS_IO.PUT ( ERASE & ALL_PARTS & OF_SCREEN );
  848.         SET_POSITION ( CURRENT_OUTPUT, HOME_POSITION );
  849.     end case;
  850.   end ERASE_IN_DISPLAY;
  851.                                
  852.   procedure ERASE_IN_LINE ( TERMINAL  : in FILE_TYPE;
  853.                             SELECTION : in SELECT_ENUMERATION ) is
  854.     LAST_POSITION : POSITION_TYPE;
  855.     LINE_START    : VIDEO_TYPES.POSITION_TYPE := ( 0,0 );
  856.   begin
  857.     case SELECTION is
  858.       when FROM_ACTIVE_POSITION_TO_END =>
  859.         CAIS_IO.PUT ( ERASE & TO_END & OF_LINE );
  860.       when  FROM_START_TO_ACTIVE_POSITION => 
  861.         CAIS_IO.PUT ( ERASE & FROM_BEGINNING & OF_LINE );
  862.       when ALL_POSITIONS => 
  863.         LAST_POSITION := POSITION ( CURRENT_OUTPUT );
  864.         LINE_START.ROW := LAST_POSITION.ROW;
  865.         SET_POSITION ( CURRENT_OUTPUT, LINE_START );
  866.         CAIS_IO.PUT ( ERASE & ALL_PARTS & OF_LINE );
  867.         SET_POSITION ( CURRENT_OUTPUT, LAST_POSITION );
  868.     end case;
  869.   end ERASE_IN_LINE;
  870.   
  871.   procedure BELL ( TERMINAL : in FILE_TYPE ) is 
  872.   begin
  873.     CAIS_IO.PUT ( ASCII.BEL );
  874.   end BELL;
  875.   
  876. end CAIS_PAGE_TERMINAL;
  877. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  878. --caisint.txt
  879. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  880. -- **********************************************************************
  881. -- *                                                                    *
  882. -- *                     PACKAGE: CAIS_INTERFACE                        *
  883. -- *                     VERSION: 1.0a1                                 *
  884. -- *                     DATE   : JANUARY, 1985                         *
  885. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  886. -- *                              AdaSoft, Inc.                         *
  887. -- *                              Lanham, MD                            *
  888. -- *                                                                    *
  889. -- **********************************************************************
  890. --
  891. -- This package contains the interface to the terminal control features used 
  892. -- in all the VIDEO procedures. The interface specifications are in 
  893. -- conformance with the proposed CAIS Standard, and packages for specific 
  894. -- terminals that conform to this standard may be substituted for the 
  895. -- underlying package CAIS_PAGE_TERMINAL without affecting this package.
  896. --
  897. with VIDEO_TYPES,CAIS_IO_CONTROL, CAIS_PAGE_TERMINAL;
  898. package CAIS_INTERFACE is
  899.  
  900.   -- These subtypes are redefinitions of the types defined in 
  901.   -- CAIS_PAGE_TERMINAL
  902.   --
  903.   subtype FILE_TYPE is CAIS_PAGE_TERMINAL.FILE_TYPE;
  904.   subtype POSITION_TYPE is CAIS_PAGE_TERMINAL.POSITION_TYPE;
  905.   subtype SELECT_ENUMERATION is CAIS_PAGE_TERMINAL.SELECT_ENUMERATION;
  906.   subtype FUNCTION_KEY_DESCRIPTOR is 
  907.           CAIS_PAGE_TERMINAL.FUNCTION_KEY_DESCRIPTOR;
  908.           
  909.   procedure HANDLE_EXCEPTION ( MSG : in STRING );
  910.   -- This procedure recurs throughout all of VIDEO and allows 
  911.   -- unhandled exceptions to be traced from their lowest level.
  912.   --
  913.   -- The following functions are in CAIS_PAGE_TERMINAL and perform
  914.   -- the same function.
  915.   --
  916.   procedure SET_POSITION ( POSITION : in POSITION_TYPE );
  917.   function POSITION return POSITION_TYPE;
  918.   function SIZE return POSITION_TYPE;
  919.   procedure PUT ( ITEM : in CHARACTER );
  920.   procedure PUT ( ITEM : in STRING );
  921.   procedure SET_ECHO ( TO : in BOOLEAN := TRUE );
  922.   function ECHO return BOOLEAN;
  923.   procedure GET ( ITEM :    out CHARACTER;
  924.                   KEYS : in out FUNCTION_KEY_DESCRIPTOR );
  925.   procedure GET ( ITEM :    out STRING;
  926.                   LAST :    out NATURAL;
  927.                   KEYS : in out FUNCTION_KEY_DESCRIPTOR );
  928.   procedure ERASE_CHARACTER ( COUNT : in POSITIVE := 1 );
  929.   procedure ERASE_IN_DISPLAY ( SELECTION : in SELECT_ENUMERATION );
  930.   procedure ERASE_IN_LINE ( SELECTION : in SELECT_ENUMERATION );
  931.   procedure BELL;
  932.   
  933. end CAIS_INTERFACE;
  934.  
  935. with VIDEO_DEBUG;
  936. package body CAIS_INTERFACE is
  937.   use VIDEO_TYPES,CAIS_IO_CONTROL, CAIS_PAGE_TERMINAL;
  938.   
  939.   EXCEPT : constant STRING (1..34) := "EXCEPTION RAISED IN CAIS_INTERFACE";
  940.   
  941.   procedure HANDLE_EXCEPTION ( MSG : in STRING ) is
  942.   begin
  943.     VIDEO_DEBUG.TRACE_EXCEPTION ( MSG );
  944.   end HANDLE_EXCEPTION;
  945.   
  946.   procedure SET_POSITION ( POSITION : in POSITION_TYPE ) is
  947.   begin
  948.     SET_POSITION ( CURRENT_OUTPUT, POSITION );
  949.   exception
  950.     when others =>
  951.       HANDLE_EXCEPTION ( EXCEPT & " SUB-ROUTINE IS SET_POSITION" );
  952.       raise;
  953.   end SET_POSITION;
  954.   
  955.   function POSITION return POSITION_TYPE is
  956.   begin
  957.     return POSITION ( CURRENT_OUTPUT );
  958.   exception
  959.     when others =>
  960.       HANDLE_EXCEPTION ( EXCEPT & " SUB-ROUTINE IS POSITION" );
  961.       raise;
  962.   end POSITION;
  963.   
  964.   function SIZE return POSITION_TYPE is
  965.   begin
  966.     return SIZE ( CURRENT_OUTPUT );
  967.   exception
  968.     when others =>
  969.       HANDLE_EXCEPTION ( EXCEPT & " SUB-ROUTINE IS SIZE" );
  970.       raise;
  971.   end SIZE;
  972.   
  973.   procedure PUT ( ITEM : in CHARACTER ) is
  974.   begin
  975.     PUT ( CURRENT_OUTPUT, ITEM );
  976.   exception
  977.     when others =>
  978.       HANDLE_EXCEPTION ( EXCEPT & " SUB-ROUTINE IS PUT (character)" );
  979.       raise;
  980.   end PUT;
  981.   
  982.   procedure PUT ( TERMINAL : in FILE_TYPE;
  983.                   ITEM     : in STRING    ) is
  984.   begin
  985.     for INDEX in ITEM'first..ITEM'last loop
  986.       PUT ( TERMINAL, ITEM (INDEX) );
  987.     end loop;
  988.   exception
  989.     when others =>
  990.       HANDLE_EXCEPTION ( EXCEPT & " SUB-ROUTINE IS PUT ( terminal, string )" );
  991.       raise;
  992.   end PUT;
  993.   
  994.   procedure PUT ( ITEM : in STRING ) is
  995.   begin
  996.     PUT ( CURRENT_OUTPUT, ITEM );
  997.   exception
  998.     when others =>
  999.       HANDLE_EXCEPTION ( EXCEPT & " SUB-ROUTINE IS PUT (string)" );
  1000.       raise;
  1001.   end PUT;
  1002.   
  1003.   procedure SET_ECHO ( TO : in BOOLEAN := TRUE ) is
  1004.   begin
  1005.     SET_ECHO ( CURRENT_INPUT, TO );
  1006.   exception
  1007.     when others =>
  1008.       HANDLE_EXCEPTION ( EXCEPT & " SUB-ROUTINE IS SET_ECHO" );
  1009.       raise;
  1010.   end SET_ECHO;
  1011.   
  1012.   function ECHO return BOOLEAN is
  1013.   begin
  1014.     return ECHO ( CURRENT_INPUT );
  1015.   exception
  1016.     when others =>
  1017.       HANDLE_EXCEPTION ( EXCEPT & " SUB-ROUTINE IS ECHO" );
  1018.       raise;
  1019.   end ECHO;
  1020.   
  1021.   procedure GET ( ITEM :    out CHARACTER;
  1022.                   KEYS : in out FUNCTION_KEY_DESCRIPTOR ) is
  1023.   begin
  1024.     GET ( CURRENT_INPUT, ITEM, KEYS );
  1025.   exception
  1026.     when others =>
  1027.       HANDLE_EXCEPTION ( EXCEPT & " SUB-ROUTINE IS GET (character)" );
  1028.       raise;
  1029.   end GET;
  1030.   
  1031.   procedure GET ( ITEM :    out STRING;
  1032.                   LAST :    out NATURAL;
  1033.                   KEYS : in out FUNCTION_KEY_DESCRIPTOR ) is
  1034.   begin
  1035.     GET ( CURRENT_INPUT, ITEM, LAST, KEYS );
  1036.   exception
  1037.     when others =>
  1038.       HANDLE_EXCEPTION ( EXCEPT & " SUB-ROUTINE IS GET ( string )" );
  1039.       raise;
  1040.   end GET;
  1041.   
  1042.   procedure ERASE_CHARACTER ( COUNT : in POSITIVE := 1 ) is
  1043.   begin
  1044.     ERASE_CHARACTER ( CURRENT_OUTPUT, COUNT );
  1045.   exception
  1046.     when others =>
  1047.       HANDLE_EXCEPTION ( EXCEPT & " SUB-ROUTINE IS ERASE_CHARACTER" );
  1048.       raise;
  1049.   end ERASE_CHARACTER;
  1050.   
  1051.   procedure ERASE_IN_DISPLAY ( SELECTION : in SELECT_ENUMERATION ) is
  1052.   begin
  1053.     ERASE_IN_DISPLAY ( CURRENT_OUTPUT, SELECTION );
  1054.   exception
  1055.     when others =>
  1056.       HANDLE_EXCEPTION ( EXCEPT & " SUB-ROUTINE IS ERASE_IN_DISPLAY" );
  1057.       raise;
  1058.   end ERASE_IN_DISPLAY;
  1059.   
  1060.   procedure ERASE_IN_LINE ( SELECTION : in SELECT_ENUMERATION ) is
  1061.   begin
  1062.     ERASE_IN_LINE ( CURRENT_OUTPUT, SELECTION );
  1063.   exception
  1064.     when others =>
  1065.       HANDLE_EXCEPTION ( EXCEPT & " SUB-ROUTINE IS ERASE_IN_LINE" );
  1066.       raise;
  1067.   end ERASE_IN_LINE;
  1068.   
  1069.   procedure BELL is
  1070.   begin
  1071.     BELL ( CURRENT_OUTPUT );
  1072.   exception
  1073.     when others =>
  1074.       HANDLE_EXCEPTION ( EXCEPT & " SUB-ROUTINE IS BELL" );
  1075.       raise;
  1076.   end BELL;
  1077.   
  1078. end CAIS_INTERFACE;
  1079. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1080. --comprocs.txt
  1081. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1082. -- **********************************************************************
  1083. -- *                                                                    *
  1084. -- *                     PACKAGE: COMMON_PROCS                          *
  1085. -- *                     VERSION: 1.0a1                                 *
  1086. -- *                     DATE   : JANUARY, 1985                         *
  1087. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  1088. -- *                              AdaSoft, Inc.                         *
  1089. -- *                              Lanham, MD                            *
  1090. -- *                                                                    *
  1091. -- **********************************************************************
  1092. --
  1093. -- This package contains the routines commonly used throughout VIDEO.
  1094. --
  1095. with VIDEO_TYPES, PASS_PROCS, COMMON_MESSAGES; 
  1096. package COMMON_PROCS is
  1097.  
  1098.   type MOVEMENT is ( UP, DOWN, LEFT, RIGHT );
  1099.   type NAME_PART is ( DEV, DIR, FIL );
  1100.   
  1101.   INVALID_CHOICE : exception;
  1102.   -- exception raised by a user entering an invalid choice.
  1103.   
  1104.   INVALID_NAME : exception;
  1105.   -- exception raised by a user entering an invalid name.
  1106.   
  1107.   procedure HANDLE_EXCEPTION ( MSG : in STRING );
  1108.   -- renames the procedure CAIS_INTERFACE.HANDLE_EXCEPTION;
  1109.   
  1110.   procedure HOME_CLEAR;
  1111.   -- moves the cursor to column 0, row 0 and clears the screen.
  1112.   
  1113.   procedure MOVE_CURSOR ( TO : in VIDEO_TYPES.POSITION_TYPE );
  1114.   -- moves the cursor to a specific location on the screen and updates the
  1115.   -- active position.
  1116.   
  1117.   procedure CLEAR_SCREEN;
  1118.   -- clears the screen from the active position to the end of the screen.
  1119.   
  1120.   procedure CLEAR_LINE;
  1121.   -- erases the line at the active position.
  1122.   
  1123.   procedure NEXT_LINE;
  1124.   -- moves the cursor to the begining of the next line. If such a move would
  1125.   -- go past the bottom of the screen, it beeps only.
  1126.   
  1127.   procedure SKIP_LINE ( NUMBER : in POSITIVE := 1 );
  1128.   -- moves the cursor down at least one line. Beeps if the move would go 
  1129.   -- past the bottom of the screen.
  1130.   
  1131.   
  1132.   procedure MOVE ( DIRECTION : in MOVEMENT );
  1133.   -- moves the cursor one position up, down, left or right unless such a 
  1134.   -- move would leave the screen.
  1135.   
  1136.   procedure GET_CHAR ( CHAR : out CHARACTER );
  1137.   -- gets a character from the keyboard.
  1138.   
  1139.   procedure GET_STRING ( STR      :    out STRING;
  1140.                          INDEX    :    out NATURAL;
  1141.                          LOCATION : in     VIDEO_TYPES.POSITION_TYPE;
  1142.                          DEFAULT  : in     STRING );
  1143.   -- moves the cursor to a particular location and gets a string. If a default
  1144.   -- is supplied, and the echo is on, it is displayed. If the echo is on, the
  1145.   -- maximum size of the string is displayed as a string of underbars. The 
  1146.   -- user can backspace to delete characters, and can delete all characters
  1147.   -- typed with CTL-U or CTL-X.
  1148.   
  1149.   procedure PUT_STRING ( STR : in STRING );
  1150.   -- displays a string at the active position.
  1151.   
  1152.   procedure MSG_PROC ( MSG  : in STRING; 
  1153.                        LINE : in VIDEO_TYPES.POSITION_TYPE );
  1154.   -- places a message on a particular line position.
  1155.   
  1156.   procedure PROMPT_MSG ( MSG : in STRING );
  1157.   -- places a prompt on the prompt_line, and leaves the active position set
  1158.   -- at the end of the displayed string.
  1159.   
  1160.   procedure SCREEN_DISPLAY ( WHICH : in COMMON_MESSAGES.MENU_TYPES );
  1161.   -- displays the menu arrays in common_messages.
  1162.   
  1163.   function GET_INPUT return VIDEO_TYPES.OPTIONS;
  1164.   -- returns a valid member of the enumeration type Options.
  1165.   
  1166.   procedure GET_PASSWORD ( MSG  : in     STRING;
  1167.                            PASS :    out PASS_PROCS.PASSWORD_TYPE );
  1168.   -- prompts for and returns the password. No default is allowed, and the 
  1169.   -- field characters are not displayed. The echo is turned off, and 
  1170.   -- the password is not echoed.
  1171.                            
  1172.   procedure GET_NEW_PASSWORD ( MSG     : in     STRING;
  1173.                                DEFAULT : in     STRING;
  1174.                                PASS    :    out PASS_PROCS.PASSWORD_TYPE );
  1175.   -- functions the same as Get_password, however, a default is allowed and
  1176.   -- the user will be asked to verify the password by entering it twice.
  1177.   
  1178.   procedure GET_DEV_NAME ( PROMPT  : in     STRING;
  1179.                            DEFAULT : in     STRING;
  1180.                            LENGTH  :    out POSITIVE;
  1181.                            NAME    :    out STRING );
  1182.   -- prompts for and gets the system-dependent device name.
  1183.  
  1184.   procedure GET_DIR_NAME ( PROMPT  : in     STRING;
  1185.                            DEFAULT : in     STRING;
  1186.                            LENGTH  :    out POSITIVE;
  1187.                            NAME    :    out STRING );
  1188.   -- prompts for and gets the system-dependent directory name.
  1189.     
  1190.   procedure GET_FIL_NAME ( PROMPT  : in     STRING;
  1191.                            DEFAULT : in     STRING;
  1192.                            LENGTH  :    out POSITIVE;
  1193.                            NAME    :    out STRING );
  1194.   -- prompts for and gets the system-dependent file name.
  1195.     
  1196.   function GET_NODE_TYPE ( MSG : in STRING ) return VIDEO_TYPES.USER_NODE;
  1197.   -- prompts for and gets the node type.
  1198.    
  1199.   function MATCH ( MATCH_STR : in STRING;
  1200.                    STR       : in STRING ) return NATURAL;
  1201.   -- determines if STR contains MATCH_STR and returns the position of the 
  1202.   -- first occurence of MATCH_STR, or else returns 0.
  1203.                    
  1204. end COMMON_PROCS;
  1205.  
  1206. with CAIS_IO_CONTROL, CAIS_INTERFACE, TERMINAL_CONTROL;
  1207. package BODY COMMON_PROCS is
  1208.   use CAIS_IO_CONTROL, VIDEO_TYPES,COMMON_MESSAGES,TERMINAL_CONTROL;
  1209.   
  1210.   EXCEPT : constant STRING (1..32) := "EXCEPTION RAISED IN COMMON_PROCS";
  1211.     
  1212.   ERROR_LINE : VIDEO_TYPES.POSITION_TYPE renames VIDEO_TYPES.ERROR_LINE;
  1213.   PROMPT_LINE : VIDEO_TYPES.POSITION_TYPE renames VIDEO_TYPES.PROMPT_LINE;
  1214.   
  1215.   procedure HANDLE_EXCEPTION ( MSG : in STRING ) is
  1216.   begin
  1217.     CAIS_INTERFACE.HANDLE_EXCEPTION ( MSG );
  1218.   end HANDLE_EXCEPTION;
  1219.  
  1220.   function COMPRESS ( MSG : in STRING ) 
  1221.     return STRING is
  1222.     -- removes spaces from the right end of a string
  1223.     
  1224.       subtype VALID_CHARS is CHARACTER range '!'..'~';
  1225.       LEN : POSITIVE := 1;
  1226.   begin
  1227.     for I in reverse MSG'range loop
  1228.       if MSG (I) in VALID_CHARS then
  1229.         LEN := I;
  1230.         exit;
  1231.       end if; -- character not a space
  1232.     end loop;
  1233.     if LEN = MSG'length then 
  1234.       return MSG (1..LEN);
  1235.     else -- otherwise, return the length + two spaces
  1236.       return MSG (1..LEN + 1);
  1237.     end if; -- len = msg'length
  1238.   exception 
  1239.     when others =>
  1240.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS COMPRESS" );
  1241.       raise;
  1242.   end COMPRESS;
  1243.     
  1244.   procedure HOME_CLEAR is
  1245.   begin
  1246.     CAIS_INTERFACE.ERASE_IN_DISPLAY ( ALL_POSITIONS );
  1247.   exception 
  1248.     when others =>
  1249.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS HOME_CLEAR" );
  1250.       raise;
  1251.   end HOME_CLEAR;
  1252.   
  1253.   procedure MOVE_CURSOR ( TO : in VIDEO_TYPES.POSITION_TYPE ) is
  1254.   begin
  1255.     CAIS_INTERFACE.SET_POSITION ( TO );
  1256.   exception 
  1257.     when others =>
  1258.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS MOVE_CURSOR" );
  1259.       raise;
  1260.   end MOVE_CURSOR;
  1261.   
  1262.   procedure CLEAR_SCREEN is
  1263.   begin
  1264.     CAIS_INTERFACE.ERASE_IN_DISPLAY ( FROM_ACTIVE_POSITION_TO_END );
  1265.   exception 
  1266.     when others =>
  1267.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS CLEAR_SCREEN" );
  1268.       raise;
  1269.   end CLEAR_SCREEN;
  1270.   
  1271.   procedure CLEAR_LINE is
  1272.   begin
  1273.     CAIS_INTERFACE.ERASE_IN_LINE ( FROM_ACTIVE_POSITION_TO_END );
  1274.   exception 
  1275.     when others =>
  1276.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS CLEAR_LINE" );
  1277.       raise;
  1278.   end CLEAR_LINE;
  1279.   
  1280.   procedure NEXT_LINE is
  1281.     POS : VIDEO_TYPES.POSITION_TYPE;
  1282.   begin
  1283.     POS := CAIS_INTERFACE.POSITION;
  1284.     if POS.ROW + 1 <= VIDEO_TYPES.LAST_ROW then
  1285.       POS.COL := 0;
  1286.       POS.ROW := POS.ROW + 1;
  1287.       CAIS_INTERFACE.SET_POSITION ( POS );
  1288.     else  -- trying to move past the last line
  1289.       CAIS_INTERFACE.BELL;
  1290.     end if;
  1291.   exception 
  1292.     when others =>
  1293.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS NEXT_LINE" );
  1294.       raise;
  1295.   end NEXT_LINE;
  1296.   
  1297.   procedure SKIP_LINE ( NUMBER : in POSITIVE := 1 ) is
  1298.     POS : VIDEO_TYPES.POSITION_TYPE;
  1299.   begin
  1300.     POS := CAIS_INTERFACE.POSITION;
  1301.     if POS.ROW + NUMBER <= VIDEO_TYPES.LAST_ROW then
  1302.       POS.COL := 0;
  1303.       POS.ROW := POS.ROW + NUMBER;
  1304.       CAIS_INTERFACE.SET_POSITION ( POS );
  1305.     else  -- trying to skip past the last row
  1306.       CAIS_INTERFACE.BELL;
  1307.     end if;
  1308.   exception 
  1309.     when others =>
  1310.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS SKIP_LINE" );
  1311.       raise;
  1312.   end SKIP_LINE;
  1313.   
  1314.   procedure MOVE ( DIRECTION : in MOVEMENT ) is
  1315.     CURSOR, LAST, FIRST  : VIDEO_TYPES.POSITION_TYPE;
  1316.   begin
  1317.     -- get the screen minimum and maximum positions, and the cursor location.
  1318.     FIRST := VIDEO_TYPES.HOME_POSITION;
  1319.     LAST := CAIS_INTERFACE.SIZE;
  1320.     CURSOR := CAIS_INTERFACE.POSITION;
  1321.     case DIRECTION is
  1322.       when UP =>
  1323.         if CURSOR.ROW < FIRST.ROW then
  1324.           CURSOR.ROW := CURSOR.ROW - 1;
  1325.         else -- illegal move
  1326.           CAIS_INTERFACE.BELL;
  1327.         end if;
  1328.       when DOWN =>
  1329.         if CURSOR.ROW < LAST.ROW then
  1330.           CURSOR.ROW := CURSOR.ROW + 1;
  1331.         else -- illegal move
  1332.           CAIS_INTERFACE.BELL;
  1333.         end if;
  1334.       when LEFT =>
  1335.         if CURSOR.COL > FIRST.COL then
  1336.           CURSOR.COL := CURSOR.COL - 1;
  1337.         else -- illegal move
  1338.           CAIS_INTERFACE.BELL;
  1339.         end if;
  1340.       when RIGHT =>
  1341.         if CURSOR.COL < LAST.COL then
  1342.           CURSOR.COL := CURSOR.COL + 1;
  1343.         else -- illegal move 
  1344.           CAIS_INTERFACE.BELL;
  1345.         end if;
  1346.       end case;
  1347.       CAIS_INTERFACE.SET_POSITION ( CURSOR );
  1348.   exception 
  1349.     when others =>
  1350.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS MOVE" );
  1351.       raise;
  1352.   end MOVE;
  1353.         
  1354.   procedure GET_CHAR ( CHAR : out CHARACTER ) is
  1355.     KEY : CAIS_INTERFACE.FUNCTION_KEY_DESCRIPTOR;
  1356.   begin
  1357.     CAIS_INTERFACE.GET ( CHAR, KEY );
  1358.   end GET_CHAR;
  1359.   
  1360.   procedure GET_STRING ( STR       :    out STRING;
  1361.                          INDEX     :    out NATURAL;
  1362.                          LOCATION  : in     VIDEO_TYPES.POSITION_TYPE;
  1363.                          DEFAULT   : in     STRING ) is
  1364.                          
  1365.     subtype CHARSET is VIDEO_TYPES.PRINTABLE;
  1366.     
  1367.     FIELDCHAR : constant CHARACTER := '_';
  1368.     SPACE     : constant CHARACTER := ' ';
  1369.     MAX_LENGTH : constant POSITIVE := STR'length;
  1370.     
  1371.     CHAR   : CHARACTER;
  1372.     KEY    : CAIS_INTERFACE.FUNCTION_KEY_DESCRIPTOR;
  1373.     CURSOR : VIDEO_TYPES.POSITION_TYPE;
  1374.     NEW_LOCATION : VIDEO_TYPES.POSITION_TYPE := LOCATION;
  1375.     
  1376.     procedure INITIALIZE_FIELD ( LOCATION : in VIDEO_TYPES.POSITION_TYPE ) is
  1377.     -- Initialize field moves the cursor to the specified location. If echo
  1378.     -- is on, it puts the fieldcharacters and the default ( if given ). It
  1379.     -- then moves the cursor to the field beginning.
  1380.     begin
  1381.       if CAIS_INTERFACE.ECHO then
  1382.         CAIS_INTERFACE.SET_POSITION ( LOCATION );
  1383.         -- display field characters for the maximum length expected.
  1384.         for I in STR'range loop
  1385.           CAIS_INTERFACE.PUT ( FIELDCHAR );
  1386.         end loop;
  1387.         CAIS_INTERFACE.SET_POSITION ( LOCATION );
  1388.         if DEFAULT (1) /= ' ' then
  1389.           CAIS_INTERFACE.PUT ( DEFAULT );
  1390.         end if; -- otherwise, no default to display
  1391.       end if; -- otherwise, display nothing
  1392.       CAIS_INTERFACE.SET_POSITION ( LOCATION );
  1393.       INDEX := 0;
  1394.     exception 
  1395.       when others =>
  1396.         HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS INITIALIZE_FIELD" );
  1397.         raise;
  1398.     end INITIALIZE_FIELD;
  1399.       
  1400.   begin
  1401.     NEW_LOCATION.COL := NEW_LOCATION.COL + 1;
  1402.     INITIALIZE_FIELD ( NEW_LOCATION );
  1403.     loop -- until <CR> is entered.
  1404.       CAIS_INTERFACE.GET ( CHAR, KEY );
  1405.       exit when CHAR = ASCII.CR;
  1406.       if ( CHAR = ASCII.BS or CHAR = ASCII.DEL ) and then INDEX > 0 then
  1407.         -- user wants to backspace at least one character
  1408.         STR ( INDEX ) := ' '; -- remove the character from the string
  1409.         INDEX := INDEX - 1;   -- decrement the index
  1410.         if CAIS_INTERFACE.ECHO then 
  1411.           MOVE ( LEFT );
  1412.           CAIS_INTERFACE.PUT ( FIELDCHAR );
  1413.           MOVE ( LEFT );
  1414.           if INDEX = 0 and then DEFAULT (1) /= ' ' then
  1415.             -- if backspacing to the begining of the field
  1416.             CAIS_INTERFACE.PUT ( DEFAULT );
  1417.             CAIS_INTERFACE.SET_POSITION ( LOCATION );
  1418.           end if;
  1419.         end if; -- Echo is on
  1420.       elsif ( CHAR = ASCII.CAN or CHAR = ASCII.NAK ) and then INDEX > 0 then
  1421.         -- user wants to re-type the entire field
  1422.         INITIALIZE_FIELD ( NEW_LOCATION );
  1423.       elsif CHAR in CHARSET and then INDEX < MAX_LENGTH then
  1424.         -- user has entered a valid character and not exceeded field length
  1425.         if CAIS_INTERFACE.ECHO then
  1426.           if INDEX = 0 and then DEFAULT (1) /= ' ' then
  1427.             -- user doesn't want default so get rid of it
  1428.             for I in DEFAULT'range loop
  1429.               CAIS_INTERFACE.PUT ( FIELDCHAR );
  1430.             end loop;
  1431.             CAIS_INTERFACE.SET_POSITION ( LOCATION );
  1432.           end if; -- index = 0 and then there is a default 
  1433.           CAIS_INTERFACE.PUT ( CHAR );
  1434.         end if; -- echo is on
  1435.         INDEX := INDEX + 1;
  1436.         STR ( INDEX ) := CHAR;
  1437.       else -- user did something wrong (invalid character or exceeded field)
  1438.         CAIS_INTERFACE.BELL;
  1439.       end if; -- evaluation of entered character
  1440.     end loop; -- MAIN
  1441.     if INDEX = 0 and then CHAR = ASCII.CR then
  1442.       -- user entered nothing but a <CR>
  1443.       if DEFAULT (1) /= ' ' then
  1444.         -- user accepted default
  1445.         INDEX := DEFAULT'length;
  1446.         STR(1..INDEX) := DEFAULT; -- sets string to default
  1447.       end if;
  1448.       if CAIS_INTERFACE.ECHO then
  1449.         -- blank out the field
  1450.         CURSOR := LOCATION;
  1451.         CURSOR.COL := CURSOR.COL + DEFAULT'length;
  1452.         CAIS_INTERFACE.SET_POSITION ( CURSOR );
  1453.         for I in DEFAULT'length + 1..MAX_LENGTH loop
  1454.           CAIS_INTERFACE.PUT ( SPACE );
  1455.         end loop;
  1456.       end if;
  1457.     end if;
  1458.   exception 
  1459.     when others =>
  1460.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS GET_STRING" );
  1461.       raise;
  1462.   end GET_STRING;
  1463.      
  1464. procedure PUT_STRING ( STR : in STRING ) is
  1465. begin
  1466.   CLEAR_LINE;
  1467.   CAIS_INTERFACE.PUT ( COMPRESS ( STR ) );
  1468. exception 
  1469.   when others =>
  1470.     HANDLE_EXCEPTION ( EXCEPT &  "SUB-ROUTINE IS PUT_STRING" );
  1471.     raise;
  1472. end PUT_STRING;
  1473.  
  1474. procedure MSG_PROC ( MSG  : in STRING; 
  1475.                      LINE : in VIDEO_TYPES.POSITION_TYPE ) is
  1476. begin 
  1477.   MOVE_CURSOR ( LINE );
  1478.   PUT_STRING ( MSG );
  1479. exception 
  1480.   when others =>
  1481.     HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS MSG_PROC" );
  1482.     raise;
  1483. end MSG_PROC;
  1484.  
  1485.   procedure PROMPT_MSG ( MSG : in STRING ) is
  1486.   begin
  1487.     MOVE_CURSOR ( PROMPT_LINE );
  1488.     PUT_STRING ( MSG );
  1489.   exception 
  1490.     when others =>
  1491.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS PROMPT_MSG" );
  1492.       raise;
  1493.   end PROMPT_MSG;
  1494.  
  1495.   procedure SCREEN_DISPLAY ( WHICH : in COMMON_MESSAGES.MENU_TYPES ) is
  1496.     DISPLAY_LINE : VIDEO_TYPES.POSITION_TYPE := ( 0,2 );
  1497.   begin
  1498.     HOME_CLEAR;
  1499.     MOVE_CURSOR ( DISPLAY_LINE );
  1500.     for I in 1..LAST_LINE ( WHICH ) loop
  1501.       -- display up to 22 lines
  1502.       DISPLAY_LINE.ROW := I;
  1503.       MSG_PROC ( COMMON_MESSAGES.MENUS ( WHICH, I ), DISPLAY_LINE );
  1504.     end loop;
  1505.   exception 
  1506.     when others =>
  1507.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS SCREEN_DISPLAY" );
  1508.       raise;
  1509.   end SCREEN_DISPLAY;
  1510.  
  1511.   function GET_INPUT return OPTIONS is
  1512.     -- because Telesoft-Ada does not implement enumeration_IO, this routine
  1513.     -- must convert character input to the corresponding enumeration type.
  1514.     -- The routine uses a look-up table of character strings, and returns the
  1515.     -- index corresponding to the match.
  1516.   
  1517.     VALID_OPTION : constant VIDEO_TYPES.VALID :=
  1518.     ( "CR", " /", " C", " I", " M", " R", " T", " X", " Z", " 1", " 2",
  1519.       " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", "12", "13",
  1520.       "14", "15" );
  1521.  
  1522.     SPACE : constant CHARACTER := ' ';
  1523.     DEFAULT : constant STRING (1..1) := " ";
  1524.     
  1525.     CHARS : STRING (1..2) := "  ";
  1526.     INDEX : NATURAL range 0..2;
  1527.     PROMPT_FIELD : VIDEO_TYPES.POSITION_TYPE;
  1528.     KEY   : CAIS_INTERFACE.FUNCTION_KEY_DESCRIPTOR;
  1529.     CHOICE : OPTIONS;
  1530.     GOOD_CHOICE : BOOLEAN := FALSE;
  1531.     
  1532.   begin
  1533.     PROMPT_FIELD := CAIS_INTERFACE.POSITION;
  1534.     for I in 1..2 loop
  1535.       -- user gets two chances
  1536.       exit when GOOD_CHOICE;
  1537.       begin -- local block with exception
  1538.         GET_STRING ( CHARS, INDEX, PROMPT_FIELD, DEFAULT );
  1539.         if INDEX = 0 then 
  1540.           CHARS := "CR";
  1541.         elsif INDEX = 1 then
  1542.           -- convert to upper-case if neccessary
  1543.           if CHARS (1) in VIDEO_TYPES.LOWER_CASE then
  1544.             CHARS (1) := CHARACTER'val ( CHARACTER'pos(CHARS(1) ) - 32 );
  1545.           end if;
  1546.           -- switch character positions if only one character was entered
  1547.           CHARS (2) := CHARS (1);
  1548.           CHARS (1) := SPACE;
  1549.         end if;
  1550.         for J in OPTIONS loop
  1551.           -- check characters entered against valid choices
  1552.           exit when GOOD_CHOICE;
  1553.           if CHARS = VALID_OPTION (J) then
  1554.             GOOD_CHOICE := TRUE;
  1555.             CHOICE := J;
  1556.           end if;
  1557.         end loop;
  1558.         if not GOOD_CHOICE then
  1559.           -- choice was not in valid choices
  1560.           raise INVALID_CHOICE;
  1561.         end if;
  1562.       exception 
  1563.         when INVALID_CHOICE =>
  1564.           -- this exception is handled here the first time the user enters
  1565.           -- a bad choice, and is raised to the calling routine after the 
  1566.           -- second try, in case it needs to be handled differently
  1567.           if I < 2 then
  1568.             MSG_PROC ( ERRORS ( INVALID_RESP ), ERROR_LINE );
  1569.             MOVE_CURSOR ( PROMPT_FIELD );
  1570.           else -- wrong on second try
  1571.             raise;
  1572.           end if;
  1573.         when others =>
  1574.           HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS CHOICE" );
  1575.           raise;
  1576.       end;
  1577.     end loop;  -- for i in 1..2 loop
  1578.     return CHOICE;
  1579.   end GET_INPUT;
  1580.   
  1581.   procedure READ_NOECHO ( DEFAULT : in     STRING;
  1582.                           PASS    :    out PASS_PROCS.PASSWORD_TYPE ) is
  1583.     -- this routine is the underlying routine for getting passwords. It turns 
  1584.     -- echoing off before getting the string, then turns it back on again.
  1585.     ON   : constant BOOLEAN := TRUE;
  1586.     OFF  : constant BOOLEAN := FALSE;
  1587.     
  1588.     KEY  : CAIS_INTERFACE.FUNCTION_KEY_DESCRIPTOR;
  1589.     STR  : STRING(1..8);
  1590.     LNTH : NATURAL;
  1591.   
  1592.   begin
  1593.     CAIS_INTERFACE.SET_ECHO ( OFF );
  1594.     GET_STRING ( STR, LNTH, CAIS_INTERFACE.POSITION, DEFAULT );
  1595.     if LNTH > 0 then
  1596.       -- some password was entered
  1597.       for I in 1..LNTH loop
  1598.         -- convert to upper case if necessary
  1599.         if STR (I) in VIDEO_TYPES.LOWER_CASE then
  1600.           STR (I) := CHARACTER'val ( CHARACTER'pos( STR(I) ) - 32 );
  1601.         end if;
  1602.       end loop; -- for loop
  1603.       -- pass to password procs and get back an ecrypted password
  1604.       PASS_PROCS.STRING_TO_PASS ( STR, LNTH, PASS );
  1605.     end if; -- length > 0
  1606.     CAIS_INTERFACE.SET_ECHO ( ON );
  1607.   exception 
  1608.     when others =>
  1609.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS READ_NOECHO" );
  1610.       raise;
  1611.   end READ_NOECHO;
  1612.     
  1613.   procedure GET_PASSWORD ( MSG  : in     STRING;
  1614.                            PASS :    out PASS_PROCS.PASSWORD_TYPE ) is
  1615.     
  1616.     DEFAULT : STRING(1..1) := " ";
  1617.     
  1618.   begin
  1619.     PROMPT_MSG ( MSG );
  1620.     READ_NOECHO ( DEFAULT, PASS );
  1621.   exception 
  1622.     when others =>
  1623.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS GET_PASSWORD" );
  1624.       raise;
  1625.   end GET_PASSWORD;
  1626.     
  1627.   procedure GET_NEW_PASSWORD ( MSG     : in     STRING;
  1628.                                DEFAULT : in     STRING;
  1629.                                PASS    :    out PASS_PROCS.PASSWORD_TYPE ) is
  1630.     
  1631.     PASS1 : PASS_PROCS.PASSWORD_TYPE;
  1632.     NULL_PASS  : PASS_PROCS.PASSWORD_TYPE;
  1633.   
  1634.   begin
  1635.     loop  -- loop until password is accepted
  1636.       PROMPT_MSG ( MSG );
  1637.       READ_NOECHO ( DEFAULT, PASS );
  1638.       if PASS_PROCS.HAS_PASSWORD ( PASS ) then
  1639.         -- if user entered a password, have it entered again to verify
  1640.         PROMPT_MSG ( "ENTER PASSWORD AGAIN TO VERIFY" );
  1641.         READ_NOECHO ( DEFAULT, PASS1 );
  1642.         if PASS_PROCS.VERIFY_PASSWORD ( PASS1, PASS ) then
  1643.           exit;
  1644.         else -- first and second passwords entered did not match
  1645.           MSG_PROC ( "PASSWORDS DO NOT MATCH - PLEASE RE-ENTER",
  1646.                       ERROR_LINE );
  1647.         end if;  -- verify_passwords
  1648.       else -- no password entered
  1649.         exit;
  1650.       end if;  -- has_password
  1651.       PASS1 := NULL_PASS;
  1652.       PASS  := NULL_PASS;
  1653.     end loop; -- main loop
  1654.   exception 
  1655.     when others =>
  1656.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS GET_NEW_PASSWORD" );
  1657.       raise;
  1658.   end GET_NEW_PASSWORD;
  1659.     
  1660.   function VERIFY ( MSG  : in COMMON_MESSAGES.MSGS;
  1661.                     NAME : in STRING ) return BOOLEAN is
  1662.     -- this routine displays the name the user entered and asks for 
  1663.     -- verification. 
  1664.                     
  1665.     RESPONSE : VIDEO_TYPES.OPTIONS;
  1666.     OK       : BOOLEAN := FALSE;
  1667.     
  1668.   begin
  1669.     loop  -- until user enters <C> or <CR>
  1670.     exit when OK;
  1671.       begin  -- local block with exception
  1672.         MSG_PROC ( MESSAGES (MSG), ERROR_LINE );
  1673.         PUT_STRING ( NAME );  -- display the current string
  1674.         PROMPT_MSG ( "ENTER <CR> TO CONFIRM - <C> TO CHANGE ");
  1675.         RESPONSE := GET_INPUT;  -- prompt for change or accept
  1676.         if ( RESPONSE = CR OR RESPONSE = C ) then 
  1677.           OK := TRUE;
  1678.         else   -- response not cr or c
  1679.           raise INVALID_CHOICE;
  1680.         end if;
  1681.       exception 
  1682.         when INVALID_CHOICE =>
  1683.           CAIS_INTERFACE.BELL;
  1684.         when others =>
  1685.           HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS VERIFY" );
  1686.           raise;
  1687.       end;  -- end of local block
  1688.     end loop;  -- end of main loop
  1689.     if RESPONSE = C then
  1690.       OK := FALSE;
  1691.     end if;  -- otherwise, user confirmed name
  1692.     return OK;
  1693.   end VERIFY;
  1694.   
  1695.   procedure GET_NAME ( PART    : in     NAME_PART;
  1696.                        PROMPT  : in     STRING;
  1697.                        DEFAULT : in     STRING;
  1698.                        LENGTH  :    out POSITIVE;
  1699.                        NAME    :    out STRING ) is
  1700.     -- pseudo-generic routine for getting any part of the filespec from the user
  1701.  
  1702.     
  1703.     VALID    : BOOLEAN := FALSE;
  1704.     MSG      : COMMON_MESSAGES.MSGS;
  1705.     ERROR    : STRING (1..80);
  1706.    
  1707.   begin
  1708.     for I in NAME'range loop
  1709.       -- initialize name to blanks
  1710.       NAME (I) := ' ';
  1711.     end loop;
  1712.     case PART is
  1713.       -- set up the appropriate prompt and error message
  1714.       when DEV =>
  1715.         ERROR := ERRORS (INV_DEVNAM);
  1716.         MSG   := CUR_DEV;
  1717.       when DIR =>
  1718.         ERROR := ERRORS (INV_DIRNAM);
  1719.         MSG   := CUR_DIRNAM;
  1720.       when FIL => 
  1721.         ERROR := ERRORS (INV_FILNAM);
  1722.         MSG   := CUR_FILNAM;
  1723.     end case;
  1724.     loop  -- until a valid name is entered
  1725.       exit when VALID;
  1726.       begin  -- local block and exception
  1727.         COMMON_PROCS.PROMPT_MSG (PROMPT);
  1728.         COMMON_PROCS.GET_STRING ( NAME, LENGTH, 
  1729.                                   CAIS_INTERFACE.POSITION, DEFAULT );
  1730.         if LENGTH > 0 then 
  1731.           if NAME(1) = '/' then -- user wants to quit
  1732.             VALID := TRUE;
  1733.           else  -- user entered a name so verify it
  1734.             VALID := VERIFY ( MSG, NAME(1..LENGTH) );
  1735.           end if;  -- user wants to quit or entered valid name
  1736.         else  -- it is an error
  1737.           raise INVALID_NAME;
  1738.         end if;  -- valid string entered
  1739.       exception
  1740.         when INVALID_NAME =>
  1741.           MSG_PROC ( ERROR, ERROR_LINE );
  1742.         when others =>
  1743.           HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS GET_NAME" ); 
  1744.           raise;
  1745.       end;  -- local block
  1746.     end loop;  -- main loop
  1747.   end GET_NAME;
  1748.   
  1749.   procedure GET_DEV_NAME ( PROMPT  : in     STRING;
  1750.                            DEFAULT : in     STRING;
  1751.                            LENGTH  :    out POSITIVE;
  1752.                            NAME    :    out STRING ) is
  1753.   begin
  1754.     GET_NAME ( DEV, PROMPT, DEFAULT, LENGTH, NAME );
  1755.   exception 
  1756.     when others =>
  1757.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS GET_DEV_NAME" );
  1758.       raise;
  1759.   end GET_DEV_NAME;
  1760.     
  1761.   procedure GET_DIR_NAME ( PROMPT  : in     STRING;
  1762.                            DEFAULT : in     STRING;
  1763.                            LENGTH  :    out POSITIVE;
  1764.                            NAME    :    out STRING ) is
  1765.   begin
  1766.     GET_NAME ( DIR, PROMPT, DEFAULT, LENGTH, NAME );
  1767.   exception 
  1768.     when others =>
  1769.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS GET_DIR_NAME" );
  1770.       raise;
  1771.   end GET_DIR_NAME;
  1772.     
  1773.   procedure GET_FIL_NAME ( PROMPT  : in     STRING;
  1774.                            DEFAULT : in     STRING;
  1775.                            LENGTH  :    out POSITIVE;
  1776.                            NAME    :    out STRING ) is
  1777.   begin
  1778.     GET_NAME ( FIL, PROMPT, DEFAULT, LENGTH, NAME );
  1779.   exception 
  1780.     when others =>
  1781.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS GET_FIL_NAME" );
  1782.       raise;
  1783.   end GET_FIL_NAME;
  1784.   
  1785.   function GET_NODE_TYPE ( MSG : in STRING ) return USER_NODE is
  1786.   
  1787.     NO_DEFAULT : constant STRING (1..2) := "  ";
  1788.   
  1789.     NODE_TYPE : STRING (1..4);
  1790.     LENGTH    : POSITIVE;
  1791.     OK        : BOOLEAN := FALSE;
  1792.     RETURN_VAL : VIDEO_TYPES.USER_NODE;
  1793.     
  1794.   begin
  1795.     while not OK loop  -- loop until valid node type entered
  1796.       begin
  1797.         PROMPT_MSG ( MSG );
  1798.         GET_STRING ( NODE_TYPE, LENGTH, CAIS_INTERFACE.POSITION, NO_DEFAULT );
  1799.         for I in 1..4 loop
  1800.           -- convert to upper case
  1801.           if NODE_TYPE (I) in VIDEO_TYPES.LOWER_CASE then
  1802.             NODE_TYPE (I) := CHARACTER'val( CHARACTER'pos(NODE_TYPE(I) ) - 32 );
  1803.           end if;
  1804.         end loop; -- i in 1..4 
  1805.         -- then convert type entered to enumeration type
  1806.         if NODE_TYPE = "PROG" then
  1807.           RETURN_VAL := PROGRAM;
  1808.           OK := TRUE;
  1809.         elsif NODE_TYPE = "INST" then
  1810.           RETURN_VAL := INSTRUCTION;
  1811.           OK := TRUE;
  1812.         elsif NODE_TYPE = "MENU" then
  1813.           RETURN_VAL := MENU;
  1814.           OK := TRUE;
  1815.         else 
  1816.           raise INVALID_CHOICE;
  1817.         end if;
  1818.       exception
  1819.         when INVALID_CHOICE =>
  1820.           MSG_PROC ( ERRORS (INV_NODETYPE), ERROR_LINE );
  1821.         when others =>
  1822.           HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS GET_NODE_TYPE" );
  1823.           raise;
  1824.       end;
  1825.     end loop;  -- main loop
  1826.     return RETURN_VAL;
  1827.   end GET_NODE_TYPE;
  1828.    
  1829.   function MATCH ( MATCH_STR : in STRING;
  1830.                    STR       : in STRING ) return NATURAL is
  1831.     -- the algorithm for this can be found in the Sept. 1984 issue
  1832.     -- of Scientific American. The function first sets up a look up
  1833.     -- table of characters with the position value set to the length
  1834.     -- of the string to match (MATCH_STR). It then places the position 
  1835.     -- value of each character in match_str into the table, starting with
  1836.     -- the second position from the end ( position 1 ) and working left.
  1837.     --   The search is conducted by matching the positions of the nth char
  1838.     -- of match_str with the nth char of str. If they match, then the next
  1839.     -- character to the left is checked. If there is no character match 
  1840.     -- found, the match_str is moved right by the number of spaces in the
  1841.     -- look-up table for the character in str that did not match. Match_str
  1842.     -- will be moved it's full length if the character in str is not found
  1843.     -- in match_str, otherwise it will be moved only far enough to line up
  1844.     -- matching characters, and the search will be ended when not enough
  1845.     -- characters remain in str. Supposedly, it`s pretty fast.
  1846.     
  1847.     subtype PRINTABLE is VIDEO_TYPES.PRINTABLE;
  1848.     type CHAR_TABLE is array (PRINTABLE) of POSITIVE;
  1849.      
  1850.     RETURN_VALUE : NATURAL := 0;
  1851.     INDEX  : NATURAL := MATCH_STR'last;
  1852.     POS    : NATURAL := 0;
  1853.     TABLE  : CHAR_TABLE := 
  1854.                ( PRINTABLE'first..PRINTABLE'last => MATCH_STR'length);
  1855.    
  1856.   begin
  1857.     --  starting from the right side of MATCH STR
  1858.     for I in reverse MATCH_STR'first..MATCH_STR'last - 1 loop
  1859.       for J in PRINTABLE loop
  1860.         -- look up the character in the table
  1861.         if MATCH_STR (I) = J then
  1862.           -- enter the position of that character within MATCH_STR in the table
  1863.           POS := POS + 1;
  1864.           TABLE (J) := POS;
  1865.           exit;
  1866.         end if;  -- characters match
  1867.       end loop;  -- j in printable
  1868.     end loop;  -- i in match_str'last..match_str'first
  1869.     while RETURN_VALUE = 0 and INDEX <= STR'last loop
  1870.       -- while no match found and still more to check
  1871.       for I in reverse MATCH_STR'range loop
  1872.         -- beginning with the last character in MATCH_STR
  1873.         if MATCH_STR (I) = STR (INDEX) then
  1874.           -- if they match
  1875.           if I = MATCH_STR'first then
  1876.             -- and if it is the first character in match_str
  1877.             -- then string was found
  1878.             RETURN_VALUE := INDEX;
  1879.             exit;
  1880.           end if;  -- match_str'first
  1881.           -- otherwise, do nothing but check the next character
  1882.         else  -- move the index 
  1883.           INDEX := INDEX + TABLE ( STR (INDEX) );
  1884.           exit;
  1885.         end if; -- match_str(i) = str(index)
  1886.         INDEX := INDEX - 1;
  1887.       end loop;  -- for i in reverse match_str'range
  1888.     end loop;  -- main loop
  1889.     return RETURN_VALUE;
  1890.   exception 
  1891.     when others =>
  1892.       HANDLE_EXCEPTION ( EXCEPT & "SUB-ROUTINE IS MATCH" );
  1893.       raise;
  1894.   end MATCH;
  1895.    
  1896. end COMMON_PROCS;
  1897.   
  1898. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1899. --videoio.txt
  1900. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1901. -- **********************************************************************
  1902. -- *                                                                    *
  1903. -- *                     PACKAGE: VIDEO_IO                              *
  1904. -- *                     VERSION: 1.0a1                                 *
  1905. -- *                     DATE   : JANUARY, 1985                         *
  1906. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  1907. -- *                              AdaSoft, Inc.                         *
  1908. -- *                              Lanham, MD                            *
  1909. -- *                                                                    *
  1910. -- **********************************************************************
  1911. --
  1912. --  This package contains the io_routines for video. It also redefines the
  1913. --  standard exceptions for io.
  1914. --
  1915. with VIDEO_TYPES,IO_EXCEPTIONS;
  1916. package VIDEO_IO is
  1917.   PAGE_TERMINATOR : constant STRING(1..6) := "<PAGE>";
  1918.   END_REC         : constant NATURAL := 0;
  1919.   
  1920.   type DISP is ( SAVE_FILE, DELETE_FILE );
  1921.   
  1922.   FILE_EXISTS  : exception;
  1923.   STATUS_ERROR : exception renames IO_EXCEPTIONS.STATUS_ERROR;
  1924.   MODE_ERROR   : exception renames IO_EXCEPTIONS.MODE_ERROR;
  1925.   NAME_ERROR   : exception renames IO_EXCEPTIONS.NAME_ERROR;
  1926.   USE_ERROR    : exception renames IO_EXCEPTIONS.USE_ERROR;
  1927.   DEVICE_ERROR : exception renames IO_EXCEPTIONS.DEVICE_ERROR;
  1928.   END_ERROR    : exception renames IO_EXCEPTIONS.END_ERROR;
  1929.   DATA_ERROR   : exception renames IO_EXCEPTIONS.DATA_ERROR;
  1930.   
  1931.   procedure CREATE_NODE_FILE ( FILE : in VIDEO_TYPES.FILESPEC );
  1932.   -- procedure to create a node file
  1933.   
  1934.   procedure OPEN_NODE_FILE ( FILE : in VIDEO_TYPES.FILESPEC );
  1935.   -- procedure to open an existing node file
  1936.   
  1937.   function NODE_FILE_OPEN return BOOLEAN;
  1938.   -- determine if node file is open
  1939.   
  1940.   function END_OF_NODE_FILE return BOOLEAN;
  1941.   -- check for end of node file
  1942.   
  1943.   procedure READ_NODE ( ITEM  :    out VIDEO_TYPES.NODE_RECORD;
  1944.                         INDEX : in     NATURAL );
  1945.   -- reads a node record from the node file
  1946.                         
  1947.   procedure WRITE_NODE ( ITEM  : in out VIDEO_TYPES.NODE_RECORD );
  1948.   -- writes a node record to the position stored in the node record
  1949.   
  1950.   procedure CLOSE_NODE_FILE ( DISPOSITION : in DISP );
  1951.   -- closes or deletes a node file
  1952.   
  1953.   procedure OPEN_TEXT_FILE ( FILE : in VIDEO_TYPES.FILESPEC );
  1954.   -- opens an instruction or menu file
  1955.   
  1956.   function END_OF_TEXT return BOOLEAN;
  1957.   -- checks for end of file
  1958.   
  1959.   function TEXT_FILE_OPEN return BOOLEAN;
  1960.   -- determines if text file is open
  1961.   
  1962.   procedure READ_PAGE ( DISP : out VIDEO_TYPES.TEXT_PAGE );
  1963.   -- reads lines from instruction or menu file until it encounters <PAGE>,
  1964.   -- end of file, or max_lines.
  1965.   
  1966.   procedure READ_NAME ( BOOT_NAME : out STRING;
  1967.                         LEN       : out NATURAL );
  1968.   -- trys to read a string from a file. Reads only the first line of the 
  1969.   -- file.
  1970.   
  1971.   procedure CLOSE_TEXT_FILE;
  1972.   -- closes text_file ( no delete )
  1973.   
  1974. end VIDEO_IO;
  1975.  
  1976. with DIRECT_IO, TEXT_IO, COMMON_PROCS;
  1977. package body VIDEO_IO is
  1978.   -- due to the use of renamed exceptions, standard expections had to 
  1979.   -- raise the renamed exception in some cases.
  1980.   
  1981.   EXCEPT : constant STRING (1..28) := "EXCEPTION RAISED IN VIDEO_IO";
  1982.  
  1983.   package VIDEO_FILE_IO is new DIRECT_IO ( VIDEO_TYPES.NODE_RECORD );
  1984.   
  1985.   NODE_FILE : VIDEO_FILE_IO.FILE_TYPE;
  1986.   TEXT_FILE : TEXT_IO.FILE_TYPE;
  1987.   
  1988.   procedure OPEN_NODE_FILE ( FILE : in VIDEO_TYPES.FILESPEC ) is
  1989.     use VIDEO_FILE_IO;
  1990.   begin
  1991.     VIDEO_FILE_IO.OPEN ( NODE_FILE, INOUT_FILE, FILE.NAME(1..FILE.LENGTH) );
  1992.   exception
  1993.     when NAME_ERROR =>
  1994.       raise VIDEO_IO.NAME_ERROR;
  1995.     when USE_ERROR =>
  1996.       raise VIDEO_IO.USE_ERROR;
  1997.     when STATUS_ERROR =>
  1998.       raise VIDEO_IO.STATUS_ERROR;
  1999.     when others =>
  2000.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS OPEN_NODE_FILE");
  2001.       raise;
  2002.   end OPEN_NODE_FILE;
  2003.   
  2004.   procedure CREATE_NODE_FILE ( FILE : in VIDEO_TYPES.FILESPEC ) is
  2005.     use VIDEO_FILE_IO;
  2006.   begin
  2007.     -- attempts to open the file with the name given. If name_error raised,
  2008.     -- then file does not exist and is created.
  2009.     VIDEO_FILE_IO.OPEN ( NODE_FILE, INOUT_FILE, FILE.NAME(1..FILE.LENGTH) );
  2010.     CLOSE_NODE_FILE ( SAVE_FILE );
  2011.     -- file of that name does exist, and so exception raised to calling routine
  2012.     raise FILE_EXISTS;
  2013.   exception
  2014.     when FILE_EXISTS =>
  2015.       raise FILE_EXISTS;
  2016.     when NAME_ERROR =>
  2017.       -- handler for creating file
  2018.       VIDEO_FILE_IO.CREATE ( NODE_FILE, INOUT_FILE, FILE.NAME(1..FILE.LENGTH));
  2019.     when VIDEO_IO.STATUS_ERROR =>
  2020.       raise FILE_EXISTS;
  2021.     when USE_ERROR =>
  2022.       raise VIDEO_IO.USE_ERROR;
  2023.     when others =>
  2024.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS CREATE_NODE_FILE");
  2025.       raise;
  2026.   end CREATE_NODE_FILE;
  2027.   
  2028.   procedure READ_NODE ( ITEM  : out VIDEO_TYPES.NODE_RECORD;
  2029.                         INDEX : in NATURAL ) is
  2030.     NDEX : VIDEO_FILE_IO.POSITIVE_COUNT;
  2031.   begin
  2032.     -- convert natural to positive_count
  2033.     NDEX := VIDEO_FILE_IO.COUNT(INDEX + 1);
  2034.     VIDEO_FILE_IO.READ ( NODE_FILE, ITEM, NDEX );
  2035.   exception
  2036.     when DATA_ERROR =>
  2037.       raise VIDEO_IO.DATA_ERROR;
  2038.     when MODE_ERROR =>
  2039.       raise VIDEO_IO.MODE_ERROR;
  2040.     when END_ERROR =>
  2041.       raise VIDEO_IO.END_ERROR;
  2042.     when others =>
  2043.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS READ_NODE");
  2044.       raise;
  2045.   end READ_NODE;
  2046.   
  2047.   procedure WRITE_NODE ( ITEM  : in out VIDEO_TYPES.NODE_RECORD ) is
  2048.     NDEX : VIDEO_FILE_IO.POSITIVE_COUNT;
  2049.   begin
  2050.     -- convert natural to positive_count
  2051.     NDEX := VIDEO_FILE_IO.COUNT( ITEM.POSITION + 1 );
  2052.     -- index for write is stored in node_record as position
  2053.     VIDEO_FILE_IO.WRITE (NODE_FILE, ITEM, NDEX );
  2054.   exception
  2055.     when USE_ERROR =>
  2056.       raise VIDEO_IO.USE_ERROR;
  2057.     when MODE_ERROR =>
  2058.       raise VIDEO_IO.MODE_ERROR;
  2059.     when others =>
  2060.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS WRITE_NODE");
  2061.       raise;
  2062.   end WRITE_NODE;
  2063.   
  2064.   procedure CLOSE_NODE_FILE ( DISPOSITION : in DISP ) is
  2065.   begin
  2066.     if DISPOSITION = SAVE_FILE then
  2067.       VIDEO_FILE_IO.CLOSE ( NODE_FILE );
  2068.     else
  2069.       VIDEO_FILE_IO.DELETE ( NODE_FILE );
  2070.     end if;
  2071.   exception
  2072.     when STATUS_ERROR =>
  2073.       raise VIDEO_IO.STATUS_ERROR;
  2074.     when others =>
  2075.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS CLOSE_NODE_FILE");
  2076.       raise;
  2077.   end CLOSE_NODE_FILE;
  2078.   
  2079.   function NODE_FILE_OPEN return BOOLEAN is
  2080.   begin
  2081.     return VIDEO_FILE_IO.IS_OPEN ( NODE_FILE );
  2082.   exception 
  2083.     when others =>
  2084.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS NODE_FILE_OPEN");
  2085.       raise;
  2086.   end NODE_FILE_OPEN;
  2087.   
  2088.   function END_OF_NODE_FILE return BOOLEAN is
  2089.   begin
  2090.     return VIDEO_FILE_IO.END_OF_FILE ( NODE_FILE );
  2091.   exception 
  2092.     when MODE_ERROR =>
  2093.       raise VIDEO_IO.MODE_ERROR;
  2094.     when others =>
  2095.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & 
  2096.                                     " SUBROUTINE IS END_OF_NODE_FILE");
  2097.       raise;
  2098.   end END_OF_NODE_FILE;
  2099.   
  2100.   procedure OPEN_TEXT_FILE ( FILE : in out VIDEO_TYPES.FILESPEC ) is
  2101.     use TEXT_IO;
  2102.   begin
  2103.     TEXT_IO.OPEN ( TEXT_FILE, IN_FILE, FILE.NAME(1..FILE.LENGTH) );
  2104.   exception 
  2105.     when NAME_ERROR =>
  2106.       raise VIDEO_IO.NAME_ERROR;
  2107.     when USE_ERROR =>
  2108.       raise VIDEO_IO.USE_ERROR;
  2109.     when STATUS_ERROR =>
  2110.       raise VIDEO_IO.STATUS_ERROR;
  2111.     when others =>
  2112.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS OPEN_TEXT_FILE");
  2113.       raise;
  2114.   end OPEN_TEXT_FILE;
  2115.   
  2116.   function END_OF_TEXT return BOOLEAN is
  2117.   begin
  2118.     return TEXT_IO.END_OF_FILE ( TEXT_FILE );
  2119.   exception 
  2120.     when MODE_ERROR =>
  2121.       raise VIDEO_IO.MODE_ERROR;
  2122.     when others =>
  2123.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS END_OF_TEXT");
  2124.       raise;
  2125.   end END_OF_TEXT;
  2126.   
  2127.   function TEXT_FILE_OPEN return BOOLEAN is
  2128.   begin
  2129.     return TEXT_IO.IS_OPEN ( TEXT_FILE );
  2130.   exception 
  2131.     when others =>
  2132.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS TEXT_FILE_OPEN");
  2133.       raise;
  2134.   end TEXT_FILE_OPEN;
  2135.   
  2136.   procedure READ_PAGE ( DISP : out VIDEO_TYPES.TEXT_PAGE ) is
  2137.   begin
  2138.     for I in 1..VIDEO_TYPES.MAX_DISP_LINES loop
  2139.       -- for the maximum number of displayable lines
  2140.       if END_OF_TEXT then
  2141.         -- insert a dummy <PAGE>
  2142.         DISP(I).LNTH := PAGE_TERMINATOR'length;
  2143.         DISP(I).LINE(1..DISP(I).LNTH) := PAGE_TERMINATOR;
  2144.       else  -- get the next_line
  2145.         TEXT_IO.GET_LINE ( TEXT_FILE, DISP(I).LINE, DISP(I).LNTH );
  2146.         if DISP(I).LNTH = 0 then
  2147.           -- take care of blank lines
  2148.           DISP(I).LNTH := 1;
  2149.           DISP(I).LINE(1..1) := " ";
  2150.         end if;
  2151.       end if;  -- end of text
  2152.       exit when DISP(I).LINE(1..DISP(I).LNTH) = PAGE_TERMINATOR;
  2153.     end loop;  -- main loop
  2154.   exception 
  2155.     when DATA_ERROR =>
  2156.       raise VIDEO_IO.DATA_ERROR;
  2157.     when MODE_ERROR =>
  2158.       raise VIDEO_IO.MODE_ERROR;
  2159.     when END_ERROR =>
  2160.       raise VIDEO_IO.END_ERROR;
  2161.     when others =>
  2162.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS READ_PAGE" );
  2163.       raise;
  2164.   end READ_PAGE;
  2165.  
  2166.   procedure READ_NAME ( BOOT_NAME : out STRING;
  2167.                         LEN       : out NATURAL ) is
  2168.   begin
  2169.     TEXT_IO.GET_LINE ( TEXT_FILE, BOOT_NAME, LEN );
  2170.   exception
  2171.     when DATA_ERROR =>
  2172.       raise VIDEO_IO.DATA_ERROR;
  2173.     when MODE_ERROR =>
  2174.       raise VIDEO_IO.MODE_ERROR;
  2175.     when END_ERROR =>
  2176.       raise VIDEO_IO.END_ERROR;
  2177.     when others =>
  2178.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS READ_NAME" );
  2179.       raise;
  2180.   end READ_NAME;
  2181.   
  2182.   procedure CLOSE_TEXT_FILE is
  2183.   begin
  2184.     TEXT_IO.CLOSE ( TEXT_FILE );
  2185.   exception 
  2186.     when STATUS_ERROR =>
  2187.       raise VIDEO_IO.STATUS_ERROR;
  2188.     when others =>
  2189.       COMMON_PROCS.HANDLE_EXCEPTION(EXCEPT & " SUBROUTINE IS CLOSE_TEXT_FILE");
  2190.       raise;
  2191.   end CLOSE_TEXT_FILE;
  2192.   
  2193. end VIDEO_IO;
  2194. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2195. --sysdepd.txt
  2196. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2197. -- **********************************************************************
  2198. -- *                                                                    *
  2199. -- *                     PACKAGE: SYSTEM_DEPENDENT                      *
  2200. -- *                     VERSION: 1.0a1                                 *
  2201. -- *                     DATE   : JANUARY, 1985                         *
  2202. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  2203. -- *                              AdaSoft, Inc.                         *
  2204. -- *                              Lanham, MD                            *
  2205. -- *                                                                    *
  2206. -- **********************************************************************
  2207. --
  2208. --  This package contains the system dependent area of VIDEO. Specifically,
  2209. --  building of filenames has been isolated in the package body, and must
  2210. --  be changed for each hardware system running VIDEO. Areas requiring 
  2211. --  such changes will be highlighted.
  2212. --
  2213. with VIDEO_TYPES; 
  2214. package SYSTEM_DEPENDENT is
  2215.   
  2216.   procedure SET_MODIFY_FLAG ( TO : in VIDEO_TYPES.FLAG );
  2217.   -- this procedure toggles the modify_flag, which determines whether a
  2218.   -- filename can be modified in a model session.
  2219.  
  2220.   function BUILD_FILESPEC ( FROM : in VIDEO_TYPES.FILE_NAME )
  2221.     return VIDEO_TYPES.FILESPEC;
  2222.     -- this function takes a filename record as it is stored in the node
  2223.     -- record and return a filename string for opening files.
  2224.     
  2225.   function GET_FILENAME ( DEFAULT     : in VIDEO_TYPES.FILE_NAME;
  2226.                           DEV_PROMPT  : in STRING;
  2227.                           DIR_PROMPT  : in STRING;
  2228.                           FIL_PROMPT  : in STRING;
  2229.                           NODE_TYPE   : in VIDEO_TYPES.NODE )
  2230.     return VIDEO_TYPES.FILE_NAME;
  2231.     -- this function prompts for each required part of the filename
  2232.     -- and returns it in a record format for storage in the node file.
  2233.   
  2234.   procedure GET_BOOT_NAME ( NAME : out VIDEO_TYPES.FILESPEC;
  2235.                             OK   : out BOOLEAN );
  2236.   -- this procedure attempts to read the boot file name from a file
  2237.   -- called 'video.dat'. This file may be created in a command file or
  2238.   -- may be created with the text editor and reference in a command file to 
  2239.   -- start video or vidmodl. If found, the procedure will return TRUE in ok
  2240.   -- and the filename in name.
  2241.  
  2242. end SYSTEM_DEPENDENT;
  2243.  
  2244. with COMMON_PROCS, VIDEO_IO;
  2245. package body SYSTEM_DEPENDENT is
  2246.   use  VIDEO_TYPES;
  2247.   
  2248.   EXCEPT    : constant STRING (1..36) := "EXCEPTION RAISED IN SYSTEM_DEPENDENT";
  2249.   
  2250.   --                 ******************************************
  2251.   --                 *  The following constants will change   *
  2252.   --                 *  to the appropriate form for the host  *
  2253.   --                 *  system.                               *
  2254.   --                 ******************************************
  2255.   --
  2256.   DEV_DELIM : constant STRING (1..1) := ":";
  2257.   LEFT_DELIM: constant STRING (1..1) := "[";
  2258.   DIR_DELIM : constant STRING (1..1) := "]";
  2259.   DATA_EXT  : constant STRING (1..4) := ".DAT";
  2260.   TEXT_EXT  : constant STRING (1..4) := ".TXT";
  2261.   PROG_EXT  : constant STRING (1..4) := ".COD";
  2262.   MAX_EXT_LEN : constant NATURAL := 4;
  2263.  
  2264.   BOOT_NAME : VIDEO_TYPES.FILESPEC;  -- initialized when elaborated; 
  2265.                                      -- see end of pkg
  2266.   --
  2267.   --                 ********************************************
  2268.   --                 *  The following constants determine the   *
  2269.   --                 *  filename part that will be prompted     *
  2270.   --                 *  for and must be changed for other hosts *
  2271.   --                 ********************************************
  2272.   --
  2273.   DEV_REQUIRED : constant BOOLEAN := TRUE;
  2274.   DIR_REQUIRED : constant BOOLEAN := TRUE;
  2275.   
  2276.   MODIFY_FLAG  : VIDEO_TYPES.FLAG := OFF;
  2277.   
  2278.   procedure MAKE_CAPS ( THIS : in out STRING ) is
  2279.     -- this is a local procedure that sets a string to upper_case
  2280.   begin
  2281.     for I in 1..THIS'last loop
  2282.       if THIS(I) in VIDEO_TYPES.LOWER_CASE then
  2283.         THIS(I) := CHARACTER'val ( CHARACTER'pos ( THIS(I) ) - 32 );
  2284.       end if;
  2285.     end loop;
  2286.   end MAKE_CAPS;
  2287.   
  2288.   procedure SET_MODIFY_FLAG ( TO : in VIDEO_TYPES.FLAG ) is
  2289.   begin
  2290.     MODIFY_FLAG := TO;
  2291.   end SET_MODIFY_FLAG;
  2292.   
  2293.   function BUILD_FILESPEC ( FROM : in VIDEO_TYPES.FILE_NAME )
  2294.     return VIDEO_TYPES.FILESPEC is
  2295.     
  2296.     FILSPEC : VIDEO_TYPES.FILESPEC;
  2297.     
  2298.   begin
  2299.     if DEV_REQUIRED then
  2300.       if DIR_REQUIRED then
  2301.         -- build the filespec from device, directory and filename
  2302.         FILSPEC.LENGTH := FROM.DEV.LENGTH + FROM.DIR.LENGTH + FROM.FIL.LENGTH;
  2303.         FILSPEC.NAME(1..FILSPEC.LENGTH) := FROM.DEV.NAME(1..FROM.DEV.LENGTH) & 
  2304.                                            FROM.DIR.NAME(1..FROM.DIR.LENGTH) & 
  2305.                                            FROM.FIL.NAME(1..FROM.FIL.LENGTH);
  2306.       else  -- build filespec from device and filename
  2307.         FILSPEC.LENGTH := FROM.DEV.LENGTH + FROM.FIL.LENGTH;
  2308.         FILSPEC.NAME(1..FILSPEC.LENGTH) := FROM.DEV.NAME(1..FROM.DEV.LENGTH) & 
  2309.                                            FROM.FIL.NAME(1..FROM.FIL.LENGTH);
  2310.       end if;
  2311.     elsif DIR_REQUIRED then
  2312.       -- build filespec from directory and filename
  2313.       FILSPEC.LENGTH := FROM.DIR.LENGTH + FROM.FIL.LENGTH;
  2314.       FILSPEC.NAME(1..FILSPEC.LENGTH) := FROM.DIR.NAME(1..FROM.DIR.LENGTH) & 
  2315.                                            FROM.FIL.NAME(1..FROM.FIL.LENGTH);
  2316.     else
  2317.       -- build filespec from filename only
  2318.       FILSPEC.LENGTH := FROM.FIL.LENGTH;
  2319.       FILSPEC.NAME(1..FILSPEC.LENGTH) := FROM.FIL.NAME(1..FROM.FIL.LENGTH);
  2320.     end if;
  2321.     return FILSPEC;
  2322.   exception
  2323.     when others =>
  2324.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUB-ROUTINE IS BUILD_FILESPEC");
  2325.       raise;
  2326.   end BUILD_FILESPEC;
  2327.     
  2328.   function GET_FILENAME ( DEFAULT     : in VIDEO_TYPES.FILE_NAME;
  2329.                           DEV_PROMPT  : in STRING;
  2330.                           DIR_PROMPT  : in STRING;
  2331.                           FIL_PROMPT  : in STRING;
  2332.                           NODE_TYPE   : in VIDEO_TYPES.NODE )
  2333.     return VIDEO_TYPES.FILE_NAME is
  2334.     
  2335.     NO_MATCH   : constant NATURAL := 0;
  2336.     EXTENSION  : STRING(1..MAX_EXT_LEN);
  2337.     FILNAME    : VIDEO_TYPES.FILE_NAME;
  2338.     TEMP_STR   : VIDEO_TYPES.NAME_REC;
  2339.     MAX_DIR_LEN: POSITIVE := FILNAME.DIR.LENGTH;
  2340.     MAX_DEV_LEN: POSITIVE := FILNAME.DEV.LENGTH;
  2341.     MAX_FIL_LEN: POSITIVE := FILNAME.FIL.LENGTH;
  2342.     
  2343.   begin
  2344.     case NODE_TYPE is
  2345.       -- determine the appropriate extension 
  2346.       when MENU|INSTRUCTION => 
  2347.         EXTENSION := TEXT_EXT;
  2348.       when PROGRAM =>
  2349.         EXTENSION := PROG_EXT;
  2350.       when BOOT =>
  2351.         EXTENSION := DATA_EXT;
  2352.     end case;
  2353.     if DEV_REQUIRED then
  2354.       COMMON_PROCS.GET_DEV_NAME ( DEV_PROMPT, 
  2355.                                   DEFAULT.DEV.NAME(1..DEFAULT.DEV.LENGTH),
  2356.                                   FILNAME.DEV.LENGTH, 
  2357.                                   FILNAME.DEV.NAME(1..MAX_DEV_LEN) );
  2358.       if FILNAME.DEV.LENGTH = 1 and then FILNAME.DEV.NAME(1) = '/' then
  2359.         raise USER_QUIT;
  2360.       end if;
  2361.       MAKE_CAPS ( FILNAME.DEV.NAME(1..FILNAME.DEV.LENGTH) );
  2362.       if COMMON_PROCS.MATCH ( DEV_DELIM, FILNAME.DEV.NAME(1..FILNAME.DEV.LENGTH) )
  2363.         = NO_MATCH then
  2364.         -- if user did not enter the device delimiter then add to end
  2365.         FILNAME.DEV.NAME(1..FILNAME.DEV.LENGTH + DEV_DELIM'length) :=
  2366.           FILNAME.DEV.NAME(1..FILNAME.DEV.LENGTH) & DEV_DELIM;
  2367.         FILNAME.DEV.LENGTH := FILNAME.DEV.LENGTH + DEV_DELIM'length;
  2368.       end if;  -- match
  2369.     end if;  -- device required
  2370.     if DIR_REQUIRED then
  2371.       COMMON_PROCS.GET_DIR_NAME ( DIR_PROMPT, 
  2372.                                   DEFAULT.DIR.NAME(1..DEFAULT.DIR.LENGTH),
  2373.                                   FILNAME.DIR.LENGTH, 
  2374.                                   FILNAME.DIR.NAME(1..MAX_DIR_LEN) );
  2375.       if FILNAME.DIR.LENGTH = 1 and then FILNAME.DIR.NAME(1) = '/' then
  2376.         raise USER_QUIT;
  2377.       end if;
  2378.       MAKE_CAPS ( FILNAME.DIR.NAME(1..FILNAME.DIR.LENGTH) );
  2379.       if COMMON_PROCS.MATCH ( DIR_DELIM, FILNAME.DIR.NAME(1..FILNAME.DIR.LENGTH) )
  2380.         = NO_MATCH then
  2381.         -- if user did not enter the directory delimiter then add to end
  2382.         FILNAME.DIR.NAME(1..FILNAME.DIR.LENGTH + DIR_DELIM'length) :=
  2383.           FILNAME.DIR.NAME(1..FILNAME.DIR.LENGTH) & DIR_DELIM;
  2384.         FILNAME.DIR.LENGTH := FILNAME.DIR.LENGTH + DIR_DELIM'length;
  2385.       end if;  -- match dir_delim
  2386.       if FILNAME.DIR.NAME(1) /= LEFT_DELIM(1) then  -- first char must be '['
  2387.         TEMP_STR.NAME(1..FILNAME.DIR.LENGTH) :=   -- if missing, add it in
  2388.           FILNAME.DIR.NAME(1..FILNAME.DIR.LENGTH);
  2389.         TEMP_STR.LENGTH := FILNAME.DIR.LENGTH;
  2390.         FILNAME.DIR.LENGTH := FILNAME.DIR.LENGTH + 1;
  2391.         FILNAME.DIR.NAME(1..FILNAME.DIR.LENGTH) :=
  2392.           LEFT_DELIM & TEMP_STR.NAME(1..TEMP_STR.LENGTH);
  2393.       end if; -- dir.name(1) /= '['
  2394.     end if;  -- directory required
  2395.     if MODIFY_FLAG = OFF then
  2396.       COMMON_PROCS.GET_FIL_NAME ( FIL_PROMPT, 
  2397.                                   DEFAULT.FIL.NAME(1..DEFAULT.FIL.LENGTH),
  2398.                                   FILNAME.FIL.LENGTH, 
  2399.                                   FILNAME.FIL.NAME(1..MAX_FIL_LEN) );
  2400.       if FILNAME.FIL.LENGTH = 1 and then FILNAME.FIL.NAME(1) = '/' then
  2401.         raise USER_QUIT;
  2402.       end if;
  2403.       MAKE_CAPS ( FILNAME.FIL.NAME(1..FILNAME.FIL.LENGTH) );
  2404.       if EXTENSION = PROG_EXT then
  2405.         if COMMON_PROCS.MATCH (EXTENSION, 
  2406.            FILNAME.FIL.NAME(1..FILNAME.FIL.LENGTH)) /= NO_MATCH then
  2407.           -- if user did enter the file extension then delete from end
  2408.           FILNAME.FIL.LENGTH := FILNAME.FIL.LENGTH - EXTENSION'length;
  2409.         end if;  -- match extension
  2410.       else  -- node type is not program
  2411.         if COMMON_PROCS.MATCH (EXTENSION,
  2412.           FILNAME.FIL.NAME(1..FILNAME.FIL.LENGTH)) = NO_MATCH then
  2413.           FILNAME.FIL.NAME(1..FILNAME.FIL.LENGTH + EXTENSION'length) :=
  2414.             FILNAME.FIL.NAME(1..FILNAME.FIL.LENGTH) & EXTENSION;
  2415.           FILNAME.FIL.LENGTH := FILNAME.FIL.LENGTH + EXTENSION'length;
  2416.         end if; -- user did not enter file extension so add to the end
  2417.       end if; --  extension = program
  2418.     end if;  -- ok to modify
  2419.     return FILNAME;
  2420.   exception
  2421.     when USER_QUIT =>
  2422.       raise;
  2423.     when others =>
  2424.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUB-ROUTINE IS GET_FILENAME");
  2425.       raise;
  2426.   end GET_FILENAME;
  2427.  
  2428.   procedure GET_BOOT_NAME ( NAME : out VIDEO_TYPES.FILESPEC;
  2429.                             OK   : out BOOLEAN ) is 
  2430.   begin
  2431.     VIDEO_IO.OPEN_TEXT_FILE ( BOOT_NAME );
  2432.     VIDEO_IO.READ_NAME ( NAME.NAME, NAME.LENGTH );
  2433.     VIDEO_IO.CLOSE_TEXT_FILE;
  2434.     OK := TRUE;
  2435.   exception
  2436.     when VIDEO_IO.NAME_ERROR|VIDEO_IO.DATA_ERROR|
  2437.          VIDEO_IO.MODE_ERROR|VIDEO_IO.END_ERROR =>
  2438.       OK := FALSE;
  2439.     when others =>
  2440.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUB-ROUTINE IS GET_BOOT_NAME");
  2441.       raise;
  2442.   end GET_BOOT_NAME;
  2443.  
  2444. begin
  2445.   BOOT_NAME.LENGTH := 5 + DATA_EXT'length;
  2446.   BOOT_NAME.NAME(1..BOOT_NAME.LENGTH) := "VIDEO" & DATA_EXT;
  2447. end SYSTEM_DEPENDENT;
  2448. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2449. --vidprocs.txt
  2450. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2451. -- **********************************************************************
  2452. -- *                                                                    *
  2453. -- *                     PACKAGE: VIDEO_PROCS                           *
  2454. -- *                     VERSION: 1.0a1                                 *
  2455. -- *                     DATE   : FEBRUARY, 1985                        *
  2456. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  2457. -- *                              AdaSoft, Inc.                         *
  2458. -- *                              Lanham, MD                            *
  2459. -- *                                                                    *
  2460. -- **********************************************************************
  2461. --  This package contains types, global variables and subroutines used in
  2462. --  VIDEO_MODEL, VIDEO, and VIDEO_DIAGRAM.
  2463. --
  2464. with VIDEO_TYPES;
  2465. package VIDEO_PROCS is
  2466.  
  2467.   -- The following are global constants:
  2468.   
  2469.   INST_ENABLED : constant VIDEO_TYPES.FLAG := VIDEO_TYPES.ON;
  2470.   INST_DISABLED: constant VIDEO_TYPES.FLAG := VIDEO_TYPES.OFF;
  2471.   
  2472.   -- the value of Inst_flag determines if instruction pages are displayed
  2473.   INST_FLAG : VIDEO_TYPES.FLAG := INST_ENABLED;
  2474.   
  2475.   --
  2476.   -- VIDEO_PROCS visible procedures and subroutines
  2477.   --
  2478.   function HAS_PASSWORD ( REC : in VIDEO_TYPES.NODE_RECORD ) return BOOLEAN;
  2479.   -- Has_password is an interface to a routine in Password_procs.
  2480.   
  2481.   function PASSWORD_OK ( REC  : in VIDEO_TYPES.NODE_RECORD;
  2482.                          MSG  : in STRING ) return BOOLEAN;
  2483.   -- Password_ok prompts for a password and checks it against the password
  2484.   -- in the node record. The user gets three tries then raises Bad_password 
  2485.   -- if incorrect.
  2486.                          
  2487.   procedure DISPLAY_PAGE ( DISP : in VIDEO_TYPES.TEXT_PAGE );
  2488.   -- Display_page will display up to Video_types.max_display_lines. If it
  2489.   -- encounters a <PAGE> mark in the text file, or reaches the end of file
  2490.   -- before max_lines are read, it displays only those lines. 
  2491.   
  2492.   procedure MENU_PROC ( MENU_MSG : in     STRING;
  2493.                         REC      : in     VIDEO_TYPES.NODE_RECORD;
  2494.                         CHOICE   :    out VIDEO_TYPES.OPTIONS;
  2495.                         NEXT_REC :    out NATURAL );
  2496.   -- Menu_proc displays a menu. The user is prompted to enter a valid
  2497.   -- numeric choice, a special character, or a slash to return to the 
  2498.   -- previous menu.
  2499.                         
  2500.   procedure INST_PROC ( INST_MSG : in     STRING;
  2501.                         REC      : in     VIDEO_TYPES.NODE_RECORD;
  2502.                         CHOICE   :    out VIDEO_TYPES.OPTIONS;
  2503.                         NEXT_REC :    out NATURAL );
  2504.   -- Inst_proc displays instruction pages until there are no more pages,
  2505.   -- or the user enters a slash. No instructions are displayed if the
  2506.   -- instruction flag is disabled. Special characters may also be entered.
  2507.     
  2508.   procedure MENU_INIT ( MSG       : in     STRING;
  2509.                         HDR       : in     VIDEO_TYPES.HEADER_TYPE;
  2510.                         FILNAM    :    out VIDEO_TYPES.FILESPEC;
  2511.                         BOOT_REC  :    out VIDEO_TYPES.NODE_RECORD;
  2512.                         SUCCESS   :    out BOOLEAN );
  2513.   -- Menu_init first displays the header, then prompts for the name
  2514.   -- of the node file. If the file can be opened, and there is a 
  2515.   -- password for the boot record, the user is prompted for the 
  2516.   -- password. If the password is correct, success becomes true,
  2517.   -- otherwise, bad_password is raised.
  2518.  
  2519.   function CONFIRMED ( MSG : in STRING ) return BOOLEAN;
  2520.   -- Confirmed prompts with a message, accepts only Y or N, and
  2521.   -- returns the corresponding boolean.
  2522.     
  2523. end VIDEO_PROCS;
  2524.  
  2525. with PASS_PROCS, COMMON_PROCS, PROMPT_MESSAGES, COMMON_MESSAGES, 
  2526.      SYSTEM_DEPENDENT, VIDEO_IO;
  2527. package body VIDEO_PROCS is
  2528.   use PROMPT_MESSAGES, COMMON_MESSAGES, VIDEO_TYPES, 
  2529.       SYSTEM_DEPENDENT;
  2530.   
  2531.   EXCEPT : constant STRING (1..31) := "EXCEPTION RAISED IN VIDEO_PROCS";
  2532.   
  2533.   function CONFIRMED ( MSG : in STRING ) return BOOLEAN is
  2534.     OK     : BOOLEAN := FALSE;
  2535.     ANSWER : CHARACTER;
  2536.   begin
  2537.     loop  -- until response is valid
  2538.       COMMON_PROCS.PROMPT_MSG ( MSG );
  2539.       COMMON_PROCS.GET_CHAR ( ANSWER );
  2540.       case ANSWER is 
  2541.         when 'N'|'n' => 
  2542.           exit;
  2543.         when 'Y'|'y' =>
  2544.           OK := TRUE;
  2545.           exit;
  2546.         when others =>
  2547.           COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP),ERROR_LINE );
  2548.       end case;  -- answer
  2549.     end loop;  -- valid response
  2550.     return OK;
  2551.   exception 
  2552.     when others =>
  2553.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS CONFIRMED");
  2554.       raise;
  2555.   end CONFIRMED;
  2556.   
  2557.   function HANDLE_NO_FILE return VIDEO_TYPES.OPTIONS is
  2558.   -- Handle_no_file is used when an attempt to access an instruction
  2559.   -- or menu file named in the corresponding node raises Name_error.
  2560.   -- The user is prompted to enter a slash to return to the previous menu
  2561.   -- although other special characters may be entered.
  2562.     
  2563.     CHOICE : VIDEO_TYPES.OPTIONS;
  2564.   begin
  2565.     COMMON_PROCS.MSG_PROC ( ERRORS(FILE_ACCESS), ERROR_LINE );
  2566.     loop  -- until valid response
  2567.       COMMON_PROCS.PROMPT_MSG ( PROMPT(SLASH_RTN) );
  2568.       CHOICE := COMMON_PROCS.GET_INPUT;
  2569.       if CHOICE in SLASH..Z then
  2570.         return CHOICE;
  2571.       else  -- invalid response
  2572.         COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP), ERROR_LINE );
  2573.       end if;  -- choice in slash..z
  2574.     end loop;  -- valid response
  2575.   end HANDLE_NO_FILE;
  2576.   
  2577.   function HAS_PASSWORD ( REC : in VIDEO_TYPES.NODE_RECORD ) return BOOLEAN is
  2578.   begin
  2579.     return PASS_PROCS.HAS_PASSWORD ( REC.NODE_PASSWORD );
  2580.   exception
  2581.     when others =>
  2582.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS HAS_PASSWORD");
  2583.       raise;
  2584.   end HAS_PASSWORD;
  2585.   
  2586.   function PASSWORD_OK ( REC  : in VIDEO_TYPES.NODE_RECORD;
  2587.                          MSG  : in STRING ) return BOOLEAN is
  2588.     PASS : PASS_PROCS.PASSWORD_TYPE;
  2589.     OK    : BOOLEAN := FALSE;
  2590.     
  2591.   begin
  2592.     for TRIES in 1..3 loop
  2593.       COMMON_PROCS.GET_PASSWORD ( MSG, PASS );
  2594.       OK := PASS_PROCS.VERIFY_PASSWORD ( PASS, REC.NODE_PASSWORD );
  2595.       exit when OK;
  2596.       COMMON_PROCS.MSG_PROC ( ERRORS(INV_PASS), ERROR_LINE );
  2597.     end loop;
  2598.     return OK;
  2599.   exception
  2600.     when others =>
  2601.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS PASSWORD_OK");
  2602.       raise;
  2603.   end PASSWORD_OK;
  2604.   
  2605.   procedure DISPLAY_PAGE ( DISP : in VIDEO_TYPES.TEXT_PAGE ) is
  2606.     DISPLAY_LINE : VIDEO_TYPES.POSITION_TYPE := ( 0,0 );
  2607.   begin
  2608.     COMMON_PROCS.HOME_CLEAR;
  2609.     COMMON_PROCS.MOVE_CURSOR ( DISPLAY_LINE );
  2610.     for I in 1..VIDEO_TYPES.MAX_DISP_LINES loop
  2611.       exit when DISP(I).LINE(1..DISP(I).LNTH) = VIDEO_IO.PAGE_TERMINATOR;
  2612.       DISPLAY_LINE.ROW := I;
  2613.       COMMON_PROCS.MSG_PROC ( DISP(I).LINE(1..DISP(I).LNTH), DISPLAY_LINE);
  2614.     end loop;  -- i in 1..max_disp_lines
  2615.   exception
  2616.     when others =>
  2617.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS DISPLAY_PAGE");
  2618.       raise;
  2619.   end DISPLAY_PAGE;
  2620.   
  2621.   procedure MENU_PROC ( MENU_MSG : in     STRING;
  2622.                         REC      : in     VIDEO_TYPES.NODE_RECORD;
  2623.                         CHOICE   :    out VIDEO_TYPES.OPTIONS;
  2624.                         NEXT_REC :    out NATURAL ) is
  2625.                         
  2626.     VALID     : BOOLEAN := FALSE;
  2627.     DISP_PAGE : VIDEO_TYPES.TEXT_PAGE;
  2628.     FILNAM    : VIDEO_TYPES.FILESPEC;
  2629.     
  2630.     INVALID_CHOICE : exception;  -- local exception
  2631.     
  2632.   begin
  2633.     FILNAM := SYSTEM_DEPENDENT.BUILD_FILESPEC ( REC.MENU_PATH );
  2634.     VIDEO_IO.OPEN_TEXT_FILE( FILNAM );
  2635.     VIDEO_IO.READ_PAGE ( DISP_PAGE );
  2636.     VIDEO_IO.CLOSE_TEXT_FILE;
  2637.     DISPLAY_PAGE ( DISP_PAGE );
  2638.     while not VALID loop
  2639.       COMMON_PROCS.PROMPT_MSG ( MENU_MSG );
  2640.       CHOICE := COMMON_PROCS.GET_INPUT;
  2641.       case CHOICE is
  2642.         -- accepts any option
  2643.         when CR =>
  2644.           COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP), ERROR_LINE );
  2645.         when ONE..FIFTEEN =>
  2646.           if REC.OPTION(CHOICE) = VIDEO_IO.END_REC then
  2647.             -- no node attached to this branch
  2648.             COMMON_PROCS.MSG_PROC ( "NOT A VALID CHOICE", ERROR_LINE );
  2649.           else  -- node attached to this branch
  2650.             NEXT_REC := REC.OPTION(CHOICE);
  2651.             CHOICE := CR;
  2652.             VALID := TRUE;
  2653.           end if;  -- rec.option(choice) = end_rec
  2654.         when others =>  
  2655.           -- special character entered
  2656.           VALID := TRUE;
  2657.       end case;  -- choice
  2658.     end loop;  -- while not valid
  2659.   exception
  2660.     when VIDEO_IO.NAME_ERROR =>
  2661.       -- could not locate text file for that node
  2662.       CHOICE := HANDLE_NO_FILE;
  2663.     when others =>
  2664.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS MENU_PROC");
  2665.       raise;
  2666.   end MENU_PROC;
  2667.     
  2668.   procedure INST_PROC ( INST_MSG : in     STRING;
  2669.                         REC      : in     VIDEO_TYPES.NODE_RECORD;
  2670.                         CHOICE   :    out VIDEO_TYPES.OPTIONS;
  2671.                         NEXT_REC :    out NATURAL ) is
  2672.  
  2673.     ROOT_REC_NO : constant NATURAL := 1;    
  2674.     DISP_PAGE : VIDEO_TYPES.TEXT_PAGE;
  2675.     FILNAM    : VIDEO_TYPES.FILESPEC;
  2676.     DONE      : BOOLEAN := FALSE;
  2677.     
  2678.   begin
  2679.     if INST_FLAG = INST_ENABLED or else REC.POSITION = ROOT_REC_NO then
  2680.       -- display text only if instruction enabled or root node
  2681.       FILNAM := SYSTEM_DEPENDENT.BUILD_FILESPEC ( REC.PATH );
  2682.       VIDEO_IO.OPEN_TEXT_FILE ( FILNAM );
  2683.     else  -- don't display text
  2684.       COMMON_PROCS.HOME_CLEAR;
  2685.     end if; -- inst_enabled
  2686.     while not DONE loop  -- outer loop
  2687.       if INST_FLAG = INST_ENABLED or else REC.POSITION = ROOT_REC_NO then
  2688.         VIDEO_IO.READ_PAGE ( DISP_PAGE );
  2689.         DISPLAY_PAGE ( DISP_PAGE );
  2690.       end if;  -- inst_enabled
  2691.       loop  -- inner loop
  2692.         if not VIDEO_IO.END_OF_TEXT then
  2693.           COMMON_PROCS.PROMPT_MSG ( PROMPT(CR_GO_SL_RTN));
  2694.         else
  2695.           COMMON_PROCS.PROMPT_MSG ( INST_MSG );
  2696.         end if;
  2697.         CHOICE := COMMON_PROCS.GET_INPUT;
  2698.         case CHOICE is
  2699.           -- accept only <CR>, slash, or special characters
  2700.           when CR =>
  2701.             if (INST_FLAG = INST_DISABLED and then REC.POSITION /= ROOT_REC_NO)
  2702.             or else VIDEO_IO.END_OF_TEXT then 
  2703.               -- don't display text or no more to display
  2704.               DONE := TRUE;
  2705.               if REC.NEXT_NODE /= VIDEO_IO.END_REC then
  2706.                 -- there is a node after this one
  2707.                 NEXT_REC := REC.NEXT_NODE;
  2708.                 exit;
  2709.               else  -- no further nodes
  2710.                 COMMON_PROCS.MSG_PROC ( "**ERROR** NO NODES BEYOND THIS NODE", 
  2711.                                         ERROR_LINE );
  2712.               end if;  -- next_node /= end_rec
  2713.             else  -- more to come
  2714.               exit;
  2715.             end if;  -- inst-disabled or else end of text
  2716.           when SLASH..Z =>
  2717.             DONE := TRUE;
  2718.             exit;
  2719.           when others =>
  2720.             COMMON_PROCS.MSG_PROC (ERRORS(INVALID_RESP),ERROR_LINE);
  2721.         end case;  -- choice
  2722.       end loop;  -- inner loop
  2723.     end loop; -- while not done (outer loop)
  2724.     if INST_FLAG = INST_ENABLED or else REC.POSITION = ROOT_REC_NO then
  2725.       VIDEO_IO.CLOSE_TEXT_FILE;
  2726.     end if;
  2727.   exception
  2728.     when VIDEO_IO.NAME_ERROR =>
  2729.       -- cannot find the associated text_file
  2730.       CHOICE := HANDLE_NO_FILE;
  2731.     when others =>
  2732.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS INST_PROC");
  2733.       VIDEO_IO.CLOSE_TEXT_FILE;
  2734.       raise;
  2735.   end INST_PROC;        
  2736.  
  2737.   procedure MENU_INIT ( MSG      : in     STRING;
  2738.                         HDR      : in     VIDEO_TYPES.HEADER_TYPE;
  2739.                         FILNAM   :    out VIDEO_TYPES.FILESPEC;
  2740.                         BOOT_REC :    out VIDEO_TYPES.NODE_RECORD;
  2741.                         SUCCESS  :    out BOOLEAN ) is
  2742.  
  2743.     BOOT_REC_NUM : constant NATURAL := 0;
  2744.     BOOT_FILE    : VIDEO_TYPES.FILE_NAME;
  2745.     CONTINUE     : BOOLEAN := TRUE;
  2746.     OPEN_OK      : BOOLEAN := FALSE;
  2747.     FOUND        : BOOLEAN := FALSE;
  2748.  
  2749.   begin
  2750.     SUCCESS := FALSE;
  2751.     COMMON_PROCS.SCREEN_DISPLAY ( COPYRIGHT );
  2752.     COMMON_PROCS.SKIP_LINE;
  2753.     for I in HEADER_LINES loop
  2754.       COMMON_PROCS.PUT_STRING ( HDR(I) );
  2755.       COMMON_PROCS.NEXT_LINE;
  2756.     end loop;
  2757.     while CONTINUE loop
  2758.       begin  -- local block
  2759.         -- first look to see if a file name has been placed in the file
  2760.         -- video.dat
  2761.         SYSTEM_DEPENDENT.GET_BOOT_NAME ( FILNAM, FOUND );
  2762.         if not FOUND then  -- get the filename from the user
  2763.           BOOT_FILE := SYSTEM_DEPENDENT.GET_FILENAME ( BOOT_FILE,
  2764.                                                        PROMPT(DEVNAM_APL_MDL),
  2765.                                                        PROMPT(DIRNAM_APL_MDL),
  2766.                                                        PROMPT(APL_NAM), BOOT);
  2767.           FILNAM := SYSTEM_DEPENDENT.BUILD_FILESPEC ( BOOT_FILE );
  2768.         end if;  -- found
  2769.         VIDEO_IO.OPEN_NODE_FILE ( FILNAM );
  2770.         CONTINUE := FALSE;
  2771.         OPEN_OK := TRUE;
  2772.       exception
  2773.         when VIDEO_IO.NAME_ERROR =>
  2774.           COMMON_PROCS.MSG_PROC ( "**ERROR** CANNOT FIND FILE " & 
  2775.                                   FILNAM.NAME(1..FILNAM.LENGTH), ERROR_LINE );
  2776.           if not CONFIRMED ("DO YOU WANT TO TRY ANOTHER FILENAME (Y/N)?") then
  2777.             raise USER_QUIT;
  2778.           end if;  -- not confirmed
  2779.       end; -- local block
  2780.     end loop; -- while continue
  2781.     if OPEN_OK then
  2782.       -- node file was located and opened
  2783.       VIDEO_IO.READ_NODE ( BOOT_REC, BOOT_REC_NUM );
  2784.       if HAS_PASSWORD (BOOT_REC) and then not PASSWORD_OK(BOOT_REC, MSG) then
  2785.         -- user entered an invalid password
  2786.         raise BAD_PASSWORD;
  2787.       end if; 
  2788.       SUCCESS := TRUE;
  2789.     end if;  -- open ok
  2790.   exception
  2791.     when USER_QUIT =>
  2792.       raise;
  2793.     when BAD_PASSWORD =>
  2794.       raise;
  2795.     when others =>
  2796.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS MENU_INIT");
  2797.       raise;
  2798.   end MENU_INIT;
  2799.  
  2800. end VIDEO_PROCS;
  2801. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2802. --modlprocs.txt
  2803. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2804. -- **********************************************************************
  2805. -- *                                                                    *
  2806. -- *                     PACKAGE: MODEL_PROCS                           *
  2807. -- *                     VERSION: 1.0a1                                 *
  2808. -- *                     DATE   : FEBRUARY, 1985                        *
  2809. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  2810. -- *                              AdaSoft, Inc.                         *
  2811. -- *                              Lanham, MD                            *
  2812. -- *                                                                    *
  2813. -- **********************************************************************
  2814. --
  2815. --  This package contains global types, variables and subroutines used 
  2816. --  only in VIDEO_MODEL.
  2817. --
  2818. with VIDEO_TYPES, PASS_PROCS;
  2819. package MODEL_PROCS is
  2820.   
  2821.   procedure GET_ANSWER ( MSG         : in     STRING;
  2822.                          AFFIRMATIVE :    out BOOLEAN;
  2823.                          CHOICE      :    out VIDEO_TYPES.OPTIONS );
  2824.   -- Get_answer prompts the user for a yes, no, slash, or <CR> response. 
  2825.   -- If yes or no, it returns a boolean. If <CR> or slash, it is returned 
  2826.   -- in CHOICE and AFFIRMATIVE is set to false.
  2827.                          
  2828.   function CONFIRMED ( MSG : in STRING ) return BOOLEAN;
  2829.   -- Confirmed prompts for a Y/N answer and returns a corresponding boolean.
  2830.   -- No other characters are accepted.
  2831.   
  2832.   function GET_BRANCH ( MSG : in STRING ) return VIDEO_TYPES.OPTIONS;
  2833.   -- Get_branch prompts the user for the menu branch number. It returns 
  2834.   -- either ONE..FIFTEEN, <CR>, or SLASH.
  2835.   
  2836.   procedure PUT_HEADER ( HEADER : in VIDEO_TYPES.HEADER_TYPE );
  2837.   -- This is a pseudo-generic header routine. It clears the screen and
  2838.   -- displays all the strings in the header array.
  2839.   
  2840.   procedure GET_COMMON ( DEF_NAME    : in     VIDEO_TYPES.FILE_NAME;
  2841.                          DEV_PROMPT  : in     STRING;
  2842.                          DIR_PROMPT  : in     STRING;
  2843.                          FIL_PROMPT  : in     STRING;
  2844.                          PASS_PROMPT : in     STRING;
  2845.                          NODE_TYP    : in     VIDEO_TYPES.NODE;
  2846.                          FILNAM      :    out VIDEO_TYPES.FILE_NAME;
  2847.                          PASS        :    out PASS_PROCS.PASSWORD_TYPE );
  2848.   -- Get_common passes all the appropriate prompts and defaults and 
  2849.   -- returns the file name and node password. Calls are made to routines
  2850.   -- defined in the package Common_procs.
  2851.  
  2852.  
  2853. end MODEL_PROCS;
  2854.  
  2855. with COMMON_MESSAGES, COMMON_PROCS, SYSTEM_DEPENDENT;
  2856. package body MODEL_PROCS is
  2857.   use VIDEO_TYPES, COMMON_MESSAGES;
  2858.   
  2859.   EXCEPT : constant STRING(1..31) := "EXCEPTION RAISED IN MODEL_PROCS";
  2860.   
  2861.   procedure GET_ANSWER ( MSG         : in     STRING;
  2862.                          AFFIRMATIVE :    out BOOLEAN;
  2863.                          CHOICE      :    out VIDEO_TYPES.OPTIONS ) is
  2864.                          
  2865.     DONE : BOOLEAN := FALSE;
  2866.     POS  : VIDEO_TYPES.POSITION_TYPE;
  2867.     ANSWER : STRING(1..3);
  2868.     LEN    : NATURAL;
  2869.     DEFAULT : STRING (1..3) := "   ";
  2870.   
  2871.   begin
  2872.     CHOICE := CR;
  2873.     while not DONE loop
  2874.       COMMON_PROCS.PROMPT_MSG ( MSG );
  2875.       POS := VIDEO_TYPES.ACTIVE_POSITION;
  2876.       COMMON_PROCS.GET_STRING ( ANSWER, LEN, POS, DEFAULT );
  2877.       if LEN > 0 then
  2878.         -- response was not a <CR>      
  2879.         case ANSWER(1) is
  2880.           -- look only at the first character
  2881.           when 'y'|'Y' =>
  2882.             AFFIRMATIVE := TRUE;
  2883.             DONE := TRUE;
  2884.           when 'n'|'N' =>
  2885.             AFFIRMATIVE := FALSE;
  2886.             DONE := TRUE;
  2887.           when '/' =>
  2888.             CHOICE := SLASH;
  2889.             DONE := TRUE;
  2890.           when others =>
  2891.             COMMON_PROCS.MSG_PROC (ERRORS(INVALID_RESP), ERROR_LINE );
  2892.         end case;
  2893.       else  -- response was a <CR>      
  2894.         AFFIRMATIVE := FALSE;
  2895.         DONE := TRUE;
  2896.       end if;  -- len > 0
  2897.     end loop;  -- while not done
  2898.   exception 
  2899.     when others =>
  2900.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS GET_ANSWER");
  2901.   end GET_ANSWER;
  2902.                          
  2903.   function CONFIRMED ( MSG : in STRING ) return BOOLEAN is
  2904.     OK     : BOOLEAN := FALSE;
  2905.     ANSWER : CHARACTER;
  2906.   begin
  2907.     loop  -- until y or n entered
  2908.       COMMON_PROCS.PROMPT_MSG ( MSG );
  2909.       COMMON_PROCS.GET_CHAR ( ANSWER );
  2910.       case ANSWER is 
  2911.         when 'N'|'n' => 
  2912.           exit;
  2913.         when 'Y'|'y' =>
  2914.           OK := TRUE;
  2915.           exit;
  2916.         when others =>
  2917.           COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP),ERROR_LINE );
  2918.       end case;  -- answer
  2919.     end loop;  -- main loop
  2920.     return OK;
  2921.   exception 
  2922.     when others =>
  2923.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS CONFIRMED");
  2924.       raise;
  2925.   end CONFIRMED;
  2926.   
  2927.   function GET_BRANCH ( MSG : in STRING ) return VIDEO_TYPES.OPTIONS is
  2928.     CHOICE : VIDEO_TYPES.OPTIONS;
  2929.     VALID  : BOOLEAN := FALSE;
  2930.   begin
  2931.     while not VALID loop  -- until response is valid
  2932.       begin
  2933.         COMMON_PROCS.PROMPT_MSG ( MSG );
  2934.         CHOICE := COMMON_PROCS.GET_INPUT;
  2935.         case CHOICE is
  2936.           when SLASH|ONE..FIFTEEN =>
  2937.             VALID := TRUE;
  2938.           when others => 
  2939.             COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP), ERROR_LINE );
  2940.         end case;  -- choice
  2941.       exception
  2942.         when COMMON_PROCS.INVALID_CHOICE =>
  2943.           COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP), ERROR_LINE );
  2944.       end;
  2945.     end loop;  -- response loop
  2946.     return CHOICE;
  2947.   exception 
  2948.     when others =>
  2949.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS GET_BRANCH");
  2950.       raise;
  2951.   end GET_BRANCH;
  2952.   
  2953.   procedure PUT_HEADER ( HEADER : in VIDEO_TYPES.HEADER_TYPE ) is
  2954.     DISPLAY_LINE : VIDEO_TYPES.POSITION_TYPE := ( 0,0 );
  2955.   begin
  2956.     COMMON_PROCS.HOME_CLEAR;
  2957.     COMMON_PROCS.MOVE_CURSOR ( DISPLAY_LINE );
  2958.     for I in VIDEO_TYPES.HEADER_LINES loop
  2959.       DISPLAY_LINE.ROW := I;
  2960.       COMMON_PROCS.MSG_PROC ( HEADER(I), DISPLAY_LINE );
  2961.     end loop;  -- i in header_lines
  2962.   exception 
  2963.     when others =>
  2964.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS PUT_HEADER");
  2965.       raise;
  2966.   end PUT_HEADER;
  2967.   
  2968.   procedure GET_COMMON ( DEF_NAME    : in     VIDEO_TYPES.FILE_NAME;
  2969.                          DEV_PROMPT  : in     STRING;
  2970.                          DIR_PROMPT  : in     STRING;
  2971.                          FIL_PROMPT  : in     STRING;
  2972.                          PASS_PROMPT : in     STRING;
  2973.                          NODE_TYP    : in     VIDEO_TYPES.NODE;
  2974.                          FILNAM      :    out VIDEO_TYPES.FILE_NAME;
  2975.                          PASS        :    out PASS_PROCS.PASSWORD_TYPE ) is
  2976.   
  2977.     DEFAULT : STRING(1..1) := " "; -- default string for password
  2978.   
  2979.   begin
  2980.     FILNAM := 
  2981.       SYSTEM_DEPENDENT.GET_FILENAME ( DEF_NAME, DEV_PROMPT, DIR_PROMPT, 
  2982.                                       FIL_PROMPT, NODE_TYP );
  2983.     COMMON_PROCS.GET_NEW_PASSWORD ( PASS_PROMPT, DEFAULT, PASS );
  2984.   exception 
  2985.     when USER_QUIT =>
  2986.       raise;
  2987.     when others =>
  2988.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS GET_COMMON");
  2989.       raise;
  2990.   end GET_COMMON;
  2991.   
  2992. end MODEL_PROCS;
  2993. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2994. --progprocs.txt
  2995. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2996. -- **********************************************************************
  2997. -- *                                                                    *
  2998. -- *                     PACKAGE: PROGRAM_PROCS                         *
  2999. -- *                     VERSION: 1.0a1                                 *
  3000. -- *                     DATE   : FEBRUARY, 1985                        *
  3001. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  3002. -- *                              AdaSoft, Inc.                         *
  3003. -- *                              Lanham, MD                            *
  3004. -- *                                                                    *
  3005. -- **********************************************************************
  3006. --
  3007. --  This package provides a system_dependent function that forks a user
  3008. --  application program as a process. The implementation of this routine
  3009. --  must be changed for each operating system.
  3010. -- 
  3011. package PROGRAM_PROCS is
  3012.   procedure RUN_PROGRAM ( NAME : in STRING;
  3013.                           LEN  : in POSITIVE );
  3014.   --
  3015.   -- Run_program is an interface to the operating system function that
  3016.   -- starts an application program as a process. The full filename is
  3017.   -- provided as a string, and the length of the name_string must be 
  3018.   -- passed also.
  3019.   --
  3020. end PROGRAM_PROCS;
  3021.  
  3022. with TEXT_IO, HOST_LCD_IF;
  3023. package body PROGRAM_PROCS is
  3024.   use HOST_LCD_IF;
  3025.  
  3026.   procedure RUN_PROGRAM ( NAME : in STRING;
  3027.                           LEN  : in POSITIVE ) is
  3028.     FRTN_INT : LONG_INTEGER;
  3029.     RESULT   : HOST_LCD_IF.ERROR_CLASS;
  3030.   begin
  3031.     if CanForkProgram then
  3032.       HOST_LCD_IF.FORK_PROGRAM ( NAME(1..LEN), " ", TRUE,
  3033.                                  FRTN_INT, RESULT);
  3034.     else
  3035.       TEXT_IO.PUT_LINE ("PROGRAM " & NAME(1..LEN) & " CANNOT BE RUN" );
  3036.     end if;
  3037.     TEXT_IO.SET_INPUT (TEXT_IO.STANDARD_INPUT);
  3038.     TEXT_IO.SET_OUTPUT ( TEXT_IO.STANDARD_OUTPUT);
  3039.   end RUN_PROGRAM;
  3040.  
  3041. end PROGRAM_PROCS;
  3042. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3043. --videomain.txt
  3044. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3045. -- **********************************************************************
  3046. -- *                                                                    *
  3047. -- *                     PACKAGE: VIDEO_MAIN                            *
  3048. -- *                     VERSION: 1.0a1                                 *
  3049. -- *                     DATE   : FEBRUARY, 1985                        *
  3050. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  3051. -- *                              AdaSoft, Inc.                         *
  3052. -- *                              Lanham, MD                            *
  3053. -- *                                                                    *
  3054. -- **********************************************************************
  3055. --
  3056. with VIDEO_TYPES, PASS_PROCS;
  3057. package VIDEO_MAIN is
  3058.     
  3059.   --
  3060.   -- VIDEO_MAIN global variables
  3061.   --
  3062.   
  3063.   PASSWORD_FLAG : VIDEO_TYPES.FLAG := VIDEO_TYPES.ON;
  3064.   ERROR_MSG     : VIDEO_TYPES.FLAG := VIDEO_TYPES.ON;
  3065.   
  3066.   READ_REC_NUM  : NATURAL;
  3067.   CUR_REC_NUM   : NATURAL;
  3068.   
  3069.   procedure MENU_INIT ( MSG      : in     STRING;
  3070.                         HDR      : in     VIDEO_TYPES.HEADER_TYPE;
  3071.                         FILNAM   :    out VIDEO_TYPES.FILESPEC;
  3072.                         BOOT_REC :    out VIDEO_TYPES.NODE_RECORD;
  3073.                         SUCCESS  :    out BOOLEAN );
  3074.   
  3075.   procedure PROG_PROC ( MSG      : in     STRING;
  3076.                         REC      : in     VIDEO_TYPES.NODE_RECORD;
  3077.                         CHOICE   :    out VIDEO_TYPES.OPTIONS;
  3078.                         NEXT_REC :    out NATURAL );
  3079.                               
  3080.   procedure PROCESS_OPTION ( LAST_MENU_PTR : in     NATURAL;
  3081.                              CUR_REC       : in out VIDEO_TYPES.NODE_RECORD;
  3082.                              ROOT_NUM      : in     NATURAL;
  3083.                              BOOT_REC      : in out VIDEO_TYPES.NODE_RECORD;
  3084.                              CHOICE        : in out VIDEO_TYPES.OPTIONS );
  3085.     
  3086.   procedure GET_ANSWER ( MSG         : in     STRING;
  3087.                          AFFIRMATIVE :    out BOOLEAN;
  3088.                          CHOICE      :    out VIDEO_TYPES.OPTIONS );
  3089.                          
  3090.   function CONFIRMED ( MSG : in STRING ) return BOOLEAN;
  3091.   
  3092.   function GET_BRANCH ( MSG : in STRING ) return VIDEO_TYPES.OPTIONS;
  3093.   
  3094.   procedure PUT_HEADER ( HEADER : in VIDEO_TYPES.HEADER_TYPE );
  3095.   
  3096.   procedure GET_COMMON ( DEF_NAME    : in     VIDEO_TYPES.FILE_NAME;
  3097.                          DEV_PROMPT  : in     STRING;
  3098.                          DIR_PROMPT  : in     STRING;
  3099.                          FIL_PROMPT  : in     STRING;
  3100.                          PASS_PROMPT : in     STRING;
  3101.                          NODE_TYP    : in     VIDEO_TYPES.NODE;
  3102.                          FILNAM      :    out VIDEO_TYPES.FILE_NAME;
  3103.                          PASS        :    out PASS_PROCS.PASSWORD_TYPE );
  3104.  
  3105.  
  3106. end VIDEO_MAIN;
  3107.  
  3108. with COMMON_PROCS, COMMON_MESSAGES, PROMPT_MESSAGES, PROGRAM_PROCS,
  3109.      VIDEO_IO, SYSTEM_DEPENDENT, VIDEO_PROCS, TEXT_IO;
  3110. package body VIDEO_MAIN is
  3111.   use VIDEO_TYPES, COMMON_MESSAGES, PROMPT_MESSAGES;
  3112.   
  3113.   EXCEPT : constant STRING(1..30) := "EXCEPTION RAISED IN VIDEO_MAIN";
  3114.   
  3115.   procedure MENU_INIT ( MSG      : in     STRING;
  3116.                         HDR      : in     VIDEO_TYPES.HEADER_TYPE;
  3117.                         FILNAM   :    out VIDEO_TYPES.FILESPEC;
  3118.                         BOOT_REC :    out VIDEO_TYPES.NODE_RECORD;
  3119.                         SUCCESS  :    out BOOLEAN ) is
  3120.     
  3121.     BOOT_FILE    : VIDEO_TYPES.FILE_NAME;
  3122.     CONTINUE     : BOOLEAN := TRUE;
  3123.     OPEN_OK      : BOOLEAN := FALSE;
  3124.     FOUND        : BOOLEAN := FALSE;
  3125.                         
  3126.   begin
  3127.     SUCCESS := FALSE;
  3128.     COMMON_PROCS.SCREEN_DISPLAY ( COPYRIGHT );
  3129.     COMMON_PROCS.SKIP_LINE;
  3130.     for I in VIDEO_TYPES.HEADER_LINES loop
  3131.       COMMON_PROCS.PUT_STRING ( HDR(I) );
  3132.       COMMON_PROCS.NEXT_LINE;
  3133.     end loop;
  3134.     while CONTINUE loop
  3135.       begin
  3136.         -- first look to see if a file name has been placed in the file
  3137.         -- video.dat
  3138.         SYSTEM_DEPENDENT.GET_BOOT_NAME ( FILNAM, FOUND );  
  3139.         if not FOUND then  -- get the filename from the user
  3140.           BOOT_FILE := SYSTEM_DEPENDENT.GET_FILENAME ( BOOT_FILE,
  3141.                                                        PROMPT(DEVNAM_APL_MDL),
  3142.                                                        PROMPT(DIRNAM_APL_MDL),
  3143.                                                        PROMPT(APL_NAM), BOOT);
  3144.           FILNAM := SYSTEM_DEPENDENT.BUILD_FILESPEC ( BOOT_FILE );
  3145.         end if; -- found
  3146.         VIDEO_IO.OPEN_NODE_FILE ( FILNAM );
  3147.         CONTINUE := FALSE;
  3148.         OPEN_OK := TRUE;
  3149.       exception
  3150.         when VIDEO_IO.NAME_ERROR =>
  3151.           COMMON_PROCS.MSG_PROC ("**ERROR** CANNOT FIND FILE " &
  3152.                                   FILNAM.NAME(1..FILNAM.LENGTH), ERROR_LINE );
  3153.           if not CONFIRMED ("DO YOU WANT TO TRY ANOTHER FILENAME (Y/N) ?") then
  3154.             raise USER_QUIT;
  3155.           end if;
  3156.       end;
  3157.     end loop;
  3158.     if OPEN_OK then
  3159.       SUCCESS := TRUE;
  3160.     end if;
  3161.   exception
  3162.     when USER_QUIT =>
  3163.       raise;
  3164.     when others =>
  3165.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS MENU_INIT" );
  3166.       raise;
  3167.   end MENU_INIT;
  3168.   
  3169.   procedure PROG_PROC ( MSG      : in     STRING;
  3170.                         REC      : in     VIDEO_TYPES.NODE_RECORD;
  3171.                         CHOICE   :    out VIDEO_TYPES.OPTIONS;
  3172.                         NEXT_REC :    out NATURAL ) is
  3173.                               
  3174.     NO_MATCH : constant NATURAL := 0;
  3175.     FILSPEC  : VIDEO_TYPES.FILESPEC;
  3176.     
  3177.   begin
  3178.     COMMON_PROCS.HOME_CLEAR;
  3179.     FILSPEC := SYSTEM_DEPENDENT.BUILD_FILESPEC ( REC.PATH );
  3180.     PROGRAM_PROCS.RUN_PROGRAM ( FILSPEC.NAME, FILSPEC.LENGTH );
  3181.     COMMON_PROCS.PROMPT_MSG ( MSG );
  3182.     loop
  3183.       CHOICE := COMMON_PROCS.GET_INPUT;
  3184.       if CHOICE in CR..Z then
  3185.         exit;
  3186.       else
  3187.         COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP), ERROR_LINE );
  3188.       end if;
  3189.     end loop;
  3190.     if CHOICE = CR then
  3191.       if REC.NEXT_NODE /= VIDEO_IO.END_REC then
  3192.         NEXT_REC := REC.NEXT_NODE;
  3193.       else
  3194.         COMMON_PROCS.MSG_PROC ( "**ERROR** NO NODES BEYOND THIS NODE", 
  3195.                                  ERROR_LINE );
  3196.         PASSWORD_FLAG := VIDEO_TYPES.OFF;
  3197.       end if;
  3198.     end if;
  3199.   exception
  3200.     when others =>
  3201.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS PROG_PROC");
  3202.       raise;
  3203.   end PROG_PROC;
  3204.     
  3205.  
  3206.   procedure PROCESS_OPTION ( LAST_MENU_PTR : in     NATURAL;
  3207.                              CUR_REC       : in out VIDEO_TYPES.NODE_RECORD;
  3208.                              ROOT_NUM      : in     NATURAL;
  3209.                              BOOT_REC      : in out VIDEO_TYPES.NODE_RECORD;
  3210.                              CHOICE        : in out VIDEO_TYPES.OPTIONS ) is
  3211.   begin
  3212.     case CHOICE is
  3213.       when SLASH =>
  3214.         PASSWORD_FLAG := VIDEO_TYPES.OFF;
  3215.         if LAST_MENU_PTR /= BOOT_REC.POSITION then
  3216.           READ_REC_NUM  := LAST_MENU_PTR;
  3217.         else 
  3218.           COMMON_PROCS.MSG_PROC ( "** ERROR ** CURRENT NODE IS FIRST NODE",
  3219.                                    ERROR_LINE );
  3220.           COMMON_PROCS.PROMPT_MSG ("ENTER 'T' TO TERMINATE OR <CR> TO PROCEED");
  3221.         end if;
  3222.       when R =>
  3223.         READ_REC_NUM := ROOT_NUM;
  3224.         PASSWORD_FLAG := VIDEO_TYPES.OFF;
  3225.       when I =>
  3226.         VIDEO_PROCS.INST_FLAG := VIDEO_PROCS.INST_ENABLED;
  3227.         ERROR_MSG := VIDEO_PROCS.INST_ENABLED;
  3228.         READ_REC_NUM := CUR_REC_NUM;
  3229.         PASSWORD_FLAG := VIDEO_TYPES.OFF;
  3230.         COMMON_PROCS.MSG_PROC ("INSTRUCTION PAGE DISPLAY HAS BEEN ENABLED",
  3231.                                ERROR_LINE );
  3232.       when X =>
  3233.         VIDEO_PROCS.INST_FLAG := VIDEO_PROCS.INST_DISABLED;
  3234.         ERROR_MSG := VIDEO_PROCS.INST_DISABLED;
  3235.         READ_REC_NUM := CUR_REC_NUM;
  3236.         PASSWORD_FLAG := VIDEO_TYPES.OFF;     
  3237.         COMMON_PROCS.MSG_PROC ("INSTRUCTION PAGE DISPLAY HAS BEEN DISABLED",
  3238.                                ERROR_LINE );
  3239.       when T =>
  3240.         COMMON_PROCS.HOME_CLEAR;
  3241.         READ_REC_NUM := BOOT_REC.POSITION;
  3242.       when others =>
  3243.         null;
  3244.     end case;
  3245.   exception
  3246.     when others =>
  3247.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS PROCESS_OPTION");
  3248.       raise;
  3249.   end PROCESS_OPTION;
  3250.   
  3251.   procedure GET_ANSWER ( MSG         : in     STRING;
  3252.                          AFFIRMATIVE :    out BOOLEAN;
  3253.                          CHOICE      :    out VIDEO_TYPES.OPTIONS ) is
  3254.                          
  3255.     DONE : BOOLEAN := FALSE;
  3256.     POS  : VIDEO_TYPES.POSITION_TYPE;
  3257.     ANSWER : STRING(1..3);
  3258.     LEN    : NATURAL;
  3259.     DEFAULT : STRING (1..3) := "   ";
  3260.   
  3261.   begin
  3262.     CHOICE := CR;
  3263.     while not DONE loop
  3264.       COMMON_PROCS.PROMPT_MSG ( MSG );
  3265.       POS := VIDEO_TYPES.ACTIVE_POSITION;
  3266.       COMMON_PROCS.GET_STRING ( ANSWER, LEN, POS, DEFAULT );
  3267.       if LEN > 0 then
  3268.         case ANSWER(1) is
  3269.           when 'y'|'Y' =>
  3270.             AFFIRMATIVE := TRUE;
  3271.             DONE := TRUE;
  3272.           when 'n'|'N' =>
  3273.             AFFIRMATIVE := FALSE;
  3274.             DONE := TRUE;
  3275.           when '/' =>
  3276.             CHOICE := SLASH;
  3277.             DONE := TRUE;
  3278.           when others =>
  3279.             COMMON_PROCS.MSG_PROC (ERRORS(INVALID_RESP), ERROR_LINE );
  3280.         end case;
  3281.       else
  3282.         AFFIRMATIVE := FALSE;
  3283.         DONE := TRUE;
  3284.       end if;
  3285.     end loop;
  3286.   exception 
  3287.     when others =>
  3288.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS GET_ANSWER");
  3289.   end GET_ANSWER;
  3290.                          
  3291.   function CONFIRMED ( MSG : in STRING ) return BOOLEAN is
  3292.     OK     : BOOLEAN := FALSE;
  3293.     ANSWER : CHARACTER;
  3294.   begin
  3295.     loop
  3296.       COMMON_PROCS.PROMPT_MSG ( MSG );
  3297.       COMMON_PROCS.GET_CHAR ( ANSWER );
  3298.       case ANSWER is 
  3299.         when 'N'|'n' => 
  3300.           exit;
  3301.         when 'Y'|'y' =>
  3302.           OK := TRUE;
  3303.           exit;
  3304.         when others =>
  3305.           COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP),ERROR_LINE );
  3306.       end case;
  3307.     end loop;
  3308.     return OK;
  3309.   exception 
  3310.     when others =>
  3311.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS CONFIRMED");
  3312.       raise;
  3313.   end CONFIRMED;
  3314.   
  3315.   function GET_BRANCH ( MSG : in STRING ) return VIDEO_TYPES.OPTIONS is
  3316.     CHOICE : VIDEO_TYPES.OPTIONS;
  3317.   begin
  3318.     loop
  3319.       COMMON_PROCS.PROMPT_MSG ( MSG );
  3320.       CHOICE := COMMON_PROCS.GET_INPUT;
  3321.       case CHOICE is
  3322.         when SLASH|ONE..FIFTEEN =>
  3323.           exit;
  3324.         when others => 
  3325.           COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP), ERROR_LINE );
  3326.       end case;
  3327.     end loop;
  3328.     return CHOICE;
  3329.   exception 
  3330.     when others =>
  3331.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS GET_BRANCH");
  3332.       raise;
  3333.   end GET_BRANCH;
  3334.   
  3335.   procedure PUT_HEADER ( HEADER : in VIDEO_TYPES.HEADER_TYPE ) is
  3336.     DISPLAY_LINE : VIDEO_TYPES.POSITION_TYPE := ( 0,0 );
  3337.   begin
  3338.     COMMON_PROCS.HOME_CLEAR;
  3339.     COMMON_PROCS.MOVE_CURSOR ( DISPLAY_LINE );
  3340.     for I in VIDEO_TYPES.HEADER_LINES loop
  3341.       DISPLAY_LINE.ROW := I;
  3342.       COMMON_PROCS.MSG_PROC ( HEADER(I), DISPLAY_LINE );
  3343.     end loop;
  3344.   exception 
  3345.     when others =>
  3346.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS PUT_HEADER");
  3347.       raise;
  3348.   end PUT_HEADER;
  3349.   
  3350.   procedure GET_COMMON ( DEF_NAME    : in     VIDEO_TYPES.FILE_NAME;
  3351.                          DEV_PROMPT  : in     STRING;
  3352.                          DIR_PROMPT  : in     STRING;
  3353.                          FIL_PROMPT  : in     STRING;
  3354.                          PASS_PROMPT : in     STRING;
  3355.                          NODE_TYP    : in     VIDEO_TYPES.NODE;
  3356.                          FILNAM      :    out VIDEO_TYPES.FILE_NAME;
  3357.                          PASS        :    out PASS_PROCS.PASSWORD_TYPE ) is
  3358.   
  3359.   begin
  3360.     FILNAM := 
  3361.       SYSTEM_DEPENDENT.GET_FILENAME ( DEF_NAME, DEV_PROMPT, DIR_PROMPT, 
  3362.                                       FIL_PROMPT, NODE_TYP );
  3363.     COMMON_PROCS.GET_PASSWORD ( PASS_PROMPT, PASS );
  3364.   exception 
  3365.     when BAD_PASSWORD => 
  3366.       raise;
  3367.     when USER_QUIT =>
  3368.       raise;
  3369.     when others =>
  3370.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS GET_COMMON");
  3371.       raise;
  3372.   end GET_COMMON;
  3373.   
  3374. end VIDEO_MAIN;
  3375.  
  3376. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3377. --diagmsg.txt
  3378. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3379. -- **********************************************************************
  3380. -- *                                                                    *
  3381. -- *                     PACKAGE: DIAGRAM_MESSAGES                      *
  3382. -- *                     VERSION: 1.0a1                                 *
  3383. -- *                     DATE   : FEBRUARY, 1985                        *
  3384. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  3385. -- *                              AdaSoft, Inc.                         *
  3386. -- *                              Lanham, MD                            *
  3387. -- *                                                                    *
  3388. -- **********************************************************************
  3389. --
  3390. --  This package contains the prompts and error messages used in VIDEO_DIAGRAM.
  3391. --
  3392. package DIAGRAM_MESSAGES is
  3393.     
  3394.   type ERRORS is ( 
  3395.     READ_SPEC,          NO_SPEC,          OPEN_MODEL,          READ_MODEL, 
  3396.     END_OF_MODEL,       TRAVERSE_MODEL,   OPEN_TEMP,           FREE_TEMP,
  3397.     OPEN_NODE,          READ_NODE,        PRINT_PASS );
  3398.   
  3399.   type PROMPTS is ( DEV_NAME, DIR_NAME, FIL_NAME, 
  3400.                     PASS_RUN_APL, PASSWRD, SUCCESS );
  3401.   
  3402.   type ERROR_MESSAGES is array (ERRORS) of STRING(1..75);
  3403.   
  3404.   ERROR : ERROR_MESSAGES := (
  3405.   "**ERROR** AN ERROR OCCURRED READING THE MODEL FILE SPECIFICATION           ",
  3406.   "**ERROR** NO MODEL FILE SPECIFICATION WAS ENTERED                          ",
  3407.   "**ERROR** AN ERROR OCCURRED OPENING THE MODEL FILE:                        ",
  3408.   "**ERROR** AN ERROR OCCURRED READING THE MODEL FILE AT RECORD:              ",
  3409.   "**ERROR** AN END-OF-FILE WAS ENCOUNTERED READING THE MODEL FILE AT RECORD: ",
  3410.   "**ERROR** AN ERROR OCCURRED WHILE TRAVERSING THE MODEL                     ",
  3411.   "**ERROR** AN ERROR OCCURRED ATTEMPTING TO ALLOCATE TEMPORARY STORAGE       ",
  3412.   "**ERROR** AN ERROR OCCURRED FREEING TEMPORARY STORAGE                      ",
  3413.   "**ERROR** AN ERROR OCCURRED OPENING THE NODE FILE:                         ",
  3414.   "**ERROR** AN ERROR OCCURRED READING THE NODE FILE:                         ",
  3415.   "**WARNING** MODEL PASSWORD INVALID-ACCESS PASSWORDS WILL NOT BE PRINTED    ");
  3416.    
  3417.   type PROMPT_MESSAGES is array (PROMPTS) of STRING(1..58);
  3418.   
  3419.   PROMPT : PROMPT_MESSAGES := (
  3420.   "ENTER DEVICE NAME OF MODEL TO BE DIAGRAMMED               ",
  3421.   "ENTER DIRECTORY NAME OF MODEL TO BE DIAGRAMMED            ",
  3422.   "ENTER FILENAME OF MODEL TO BE DIAGRAMMED                  ",
  3423.   "ENTER PASSWORD TO RUN APPLICATION                         ",
  3424.   "ENTER APPLICATION MODEL PASSWORD TO PRINT ACCESS PASSWORD ",
  3425.   "THE VIDEO DIAGRAM PROGRAM HAS COMPLETED SUCCESSFULLY      " );
  3426.   
  3427. end DIAGRAM_MESSAGES;
  3428. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3429. --diagtypes.txt
  3430. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3431. -- **********************************************************************
  3432. -- *                                                                    *
  3433. -- *                     PACKAGE: DIAGRAM_TYPES                         *
  3434. -- *                     VERSION: 1.0a1                                 *
  3435. -- *                     DATE   : FEBRUARY, 1985                        *
  3436. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  3437. -- *                              AdaSoft, Inc.                         *
  3438. -- *                              Lanham, MD                            *
  3439. -- *                                                                    *
  3440. -- **********************************************************************
  3441. --
  3442. --  This package contains the constants and types used in DIAGRAM.
  3443. --
  3444. with VIDEO_TYPES;
  3445. package DIAGRAM_TYPES is
  3446.   use VIDEO_TYPES;
  3447.   
  3448.   MAX_PAGE_LENGTH : constant LONG_INTEGER := 55;
  3449.   MAX_LINE_LENGTH : constant LONG_INTEGER := 132;
  3450.   
  3451.   OUTPUT_FILE : constant STRING(1..12) := "DIAGPRNT.TXT";
  3452.   
  3453.   RPT_HDR_1 : constant STRING(1..50) := 
  3454.      "VIDEO VERSION 1.0 LEVEL 0  RELEASE DATE: MAY, 1985";
  3455.      
  3456.   RPT_HDR_2 : constant STRING(1..19) := "DIAGRAM OF MODEL:  ";
  3457.   
  3458.   PAGE_HDR_1 : constant STRING(1..132) :=
  3459.    "  <--------- M O D E L   S T R U C T U R E --------->  NODE  ACCES" &
  3460.    "S                                                                 ";
  3461.    
  3462.   PAGE_HDR_2 : constant STRING(1..132) :=
  3463.    "   1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16>16   TYPE   NODE" &
  3464.    "     N O D E   F I L E S P E C                         PASSWORD   ";
  3465.   
  3466.   subtype NODE_LEVEL is INTEGER range 1..17;
  3467.   
  3468.   type PRINT_RECORD  is
  3469.     record
  3470.       NODE_TYPE : VIDEO_TYPES.NODE;
  3471.       PREV_NODE : VIDEO_TYPES.NODE;
  3472.       LEVEL     : NODE_LEVEL := 1;
  3473.       FILSPEC   : VIDEO_TYPES.FILESPEC;
  3474.       PASSWORD  : STRING(1..8) := "        ";
  3475.     end record;
  3476.     
  3477. end DIAGRAM_TYPES;
  3478.   
  3479. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3480. --diagramio.txt
  3481. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3482. -- **********************************************************************
  3483. -- *                                                                    *
  3484. -- *                     PACKAGE: DIAGRAM_IO                            *
  3485. -- *                     VERSION: 1.0a1                                 *
  3486. -- *                     DATE   : JANUARY, 1985                         *
  3487. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  3488. -- *                              AdaSoft, Inc.                         *
  3489. -- *                              Lanham, MD                            *
  3490. -- *                                                                    *
  3491. -- **********************************************************************
  3492. --
  3493. --  This package contains the io_routines for DIAGRAM. 
  3494. --
  3495. with DIAGRAM_TYPES;
  3496. package DIAGRAM_IO is
  3497.  
  3498.   procedure CREATE_PRINT_FILE;
  3499.   -- procedure to create a print file
  3500.   
  3501.   function PRINT_FILE_OPEN return BOOLEAN;
  3502.   -- determine if print file is open
  3503.   
  3504.   procedure PRINT ( ITEM  : in STRING );
  3505.   -- writes a print record to the print file
  3506.   
  3507.   function LINE return INTEGER;
  3508.   -- returns the current line number
  3509.   
  3510.   procedure SKIP_LINES ( NUMBER : in POSITIVE := 1 );
  3511.   -- Outputs at least one blank line
  3512.   
  3513.   procedure CLOSE_PRINT_FILE;
  3514.   -- closes a print file
  3515.   
  3516.   procedure DELETE_PRINT_FILE;
  3517.   -- deletes a print file
  3518.   
  3519. end DIAGRAM_IO;
  3520.  
  3521. with TEXT_IO, COMMON_PROCS;
  3522. package body DIAGRAM_IO is
  3523.   
  3524.   EXCEPT : constant STRING (1..30) := "EXCEPTION RAISED IN DIAGRAM_IO";
  3525.  
  3526.   PRINT_FILE : TEXT_IO.FILE_TYPE;
  3527.   
  3528.   procedure CREATE_PRINT_FILE is
  3529.     use DIAGRAM_TYPES, TEXT_IO;
  3530.   begin
  3531.     TEXT_IO.CREATE ( PRINT_FILE, OUT_FILE, OUTPUT_FILE );
  3532.     TEXT_IO.SET_PAGE_LENGTH ( PRINT_FILE, MAX_PAGE_LENGTH );
  3533.     TEXT_IO.SET_LINE_LENGTH ( PRINT_FILE, MAX_LINE_LENGTH );
  3534.   exception
  3535.     when others =>
  3536.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS CREATE_PRINT_FILE");
  3537.       raise;
  3538.   end CREATE_PRINT_FILE;
  3539.   
  3540.   procedure PRINT ( ITEM  : in STRING ) is
  3541.   begin
  3542.     TEXT_IO.PUT_LINE ( PRINT_FILE, ITEM );
  3543.   exception
  3544.     when others =>
  3545.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS PRINT");
  3546.       raise;
  3547.   end PRINT;
  3548.   
  3549.   function LINE return INTEGER is
  3550.     LINE_COUNT : TEXT_IO.COUNT;
  3551.   begin
  3552.     LINE_COUNT := TEXT_IO.LINE ( PRINT_FILE );
  3553.     return INTEGER(LINE_COUNT);
  3554.   exception
  3555.     when others =>
  3556.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS LINE");
  3557.       raise;
  3558.   end LINE;
  3559.     
  3560.   procedure SKIP_LINES ( NUMBER : in POSITIVE := 1 ) is
  3561.     SPACING : TEXT_IO.POSITIVE_COUNT;
  3562.   begin
  3563.     SPACING := TEXT_IO.POSITIVE_COUNT(NUMBER);
  3564.     TEXT_IO.NEW_LINE ( PRINT_FILE, SPACING );
  3565.   exception 
  3566.     when others =>
  3567.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS SKIP_LINES");
  3568.       raise;
  3569.   end SKIP_LINES;
  3570.   
  3571.   procedure CLOSE_PRINT_FILE is
  3572.   begin
  3573.     TEXT_IO.CLOSE ( PRINT_FILE );
  3574.   exception
  3575.     when others =>
  3576.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS CLOSE_PRINT_FILE");
  3577.       raise;
  3578.   end CLOSE_PRINT_FILE;
  3579.   
  3580.   function PRINT_FILE_OPEN return BOOLEAN is
  3581.   begin
  3582.     return TEXT_IO.IS_OPEN ( PRINT_FILE );
  3583.   exception 
  3584.     when others =>
  3585.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS PRINT_FILE_OPEN");
  3586.       raise;
  3587.   end PRINT_FILE_OPEN;
  3588.   
  3589.   procedure DELETE_PRINT_FILE is
  3590.   begin
  3591.     if PRINT_FILE_OPEN then
  3592.       TEXT_IO.DELETE (PRINT_FILE);
  3593.     end if;
  3594.   exception 
  3595.     when others =>
  3596.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS DELETE_PRINT_FILE");
  3597.   end DELETE_PRINT_FILE;
  3598.   
  3599. end DIAGRAM_IO;
  3600. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3601. --init.txt
  3602. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3603. -- **********************************************************************
  3604. -- *                                                                    *
  3605. -- *                     PACKAGE: INIT                                  *
  3606. -- *                     VERSION: 1.0a1                                 *
  3607. -- *                     DATE   : JANUARY, 1985                         *
  3608. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  3609. -- *                              AdaSoft, Inc.                         *
  3610. -- *                              Lanham, MD                            *
  3611. -- *                                                                    *
  3612. -- **********************************************************************
  3613. --
  3614. --  This package contains the main routines used in VIDEO_INIT.
  3615. --
  3616. with VIDEO_TYPES;
  3617. package INIT is
  3618.  
  3619.   procedure INIT_HEADER ( HDR : in VIDEO_TYPES.HEADER_TYPE );
  3620.   -- this displays the copyright message and initialization header.
  3621.   
  3622.   procedure INIT_TREE ( BOOT_REC : in out VIDEO_TYPES.NODE_RECORD;
  3623.                         SUCCESS  :    out BOOLEAN );
  3624.   -- init_tree prompts the user for the name of the node(boot) file,
  3625.   -- then attempts to create the file. If successful, init_tree sets up 
  3626.   -- the boot record, and prompts for the boot password, which controls 
  3627.   -- access to the node.
  3628.   --   exceptions raised are file_exists, status_error, and name error.
  3629.   -- The handler for these asks the user to continue(Y/N). If yes, user
  3630.   -- is again prompted for a file name, otherwise, the program will end.
  3631.                         
  3632.   procedure INIT_ROOT ( BOOT_REC : in out VIDEO_TYPES.NODE_RECORD;
  3633.                         ROOT_REC : in out VIDEO_TYPES.NODE_RECORD;
  3634.                         SUCCESS  :    out BOOLEAN );
  3635.   -- The root node is the first node displayed when a user has successfully
  3636.   -- opened the node file. Init_root prompts the user for the root node type, 
  3637.   -- the name of the file to display, and the root password. The root record
  3638.   -- is then created, and written to the file. If the write is successful,
  3639.   -- the boot record is updated to point to the next free node.
  3640.   --  The exception use_error is handled when file capacity exceeded.
  3641.                         
  3642.   procedure WRAP_UP ( SAVE : in BOOLEAN );
  3643.   -- If the entire process has been successful, wrap_up closes the node
  3644.   -- file. Otherwise, wrap_up deletes the node_file.
  3645.   
  3646. end INIT;
  3647.  
  3648. with PASS_PROCS, COMMON_MESSAGES, PROMPT_MESSAGES, 
  3649.      COMMON_PROCS, SYSTEM_DEPENDENT, VIDEO_IO, VIDEO_DEBUG;
  3650. package body INIT is
  3651.   use VIDEO_TYPES, COMMON_MESSAGES, PROMPT_MESSAGES;
  3652.   
  3653.   EXCEPT : constant STRING (1..24) := "EXCEPTION RAISED IN INIT";
  3654.   
  3655.   NO_DEFAULT : STRING(1..1) := " ";
  3656.    
  3657.   procedure INIT_HEADER (HDR : in VIDEO_TYPES.HEADER_TYPE ) is
  3658.   begin
  3659.     COMMON_PROCS.SCREEN_DISPLAY ( COPYRIGHT );
  3660.     COMMON_PROCS.SKIP_LINE (2);
  3661.     for I in VIDEO_TYPES.HEADER_LINES loop
  3662.       COMMON_PROCS.PUT_STRING ( HDR (I) );
  3663.       COMMON_PROCS.NEXT_LINE;
  3664.     end loop;
  3665.   exception
  3666.     when others =>
  3667.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUB-ROUTINE IS INIT_HEADER");
  3668.       raise;
  3669.   end INIT_HEADER;
  3670.   
  3671.   procedure INIT_TREE ( BOOT_REC : in out VIDEO_TYPES.NODE_RECORD;
  3672.                         SUCCESS  :    out BOOLEAN ) is
  3673.                         
  3674.     CONTINUE     : BOOLEAN := TRUE;
  3675.     ANSWER       : CHARACTER;
  3676.     BOOT_FILSPEC : VIDEO_TYPES.FILESPEC;
  3677.     REC_DEFAULT  : VIDEO_TYPES.FILE_NAME;
  3678.     
  3679.   begin
  3680.     SUCCESS := FALSE;
  3681.     while CONTINUE loop
  3682.       begin
  3683.         BOOT_REC.DEFAULT :=
  3684.           SYSTEM_DEPENDENT.GET_FILENAME ( REC_DEFAULT, 
  3685.                                           PROMPT(DEVNAM_APL_MDL),
  3686.                                           PROMPT(DIRNAM_APL_MDL), 
  3687.                                           PROMPT(NAM_APL_INIT),
  3688.                                           BOOT );
  3689.         BOOT_FILSPEC := SYSTEM_DEPENDENT.BUILD_FILESPEC ( BOOT_REC.DEFAULT );
  3690.         VIDEO_IO.CREATE_NODE_FILE ( BOOT_FILSPEC );
  3691.         BOOT_REC.DEFAULT.FIL := REC_DEFAULT.FIL;
  3692.         BOOT_REC.LAST_NODE := 0;
  3693.         BOOT_REC.LAST_MENU := 0;
  3694.         BOOT_REC.POSITION := 0;
  3695.         COMMON_PROCS.GET_NEW_PASSWORD ( PROMPT(PASS_MDL), 
  3696.                                         NO_DEFAULT,
  3697.                                         BOOT_REC.NODE_PASSWORD );
  3698.         BOOT_REC.NEXT_FREE_NODE := 0;
  3699.         BOOT_REC.LAST_FREE_NODE := 1;
  3700.         VIDEO_IO.WRITE_NODE ( BOOT_REC );
  3701.         CONTINUE := FALSE;
  3702.         SUCCESS := TRUE;
  3703.       exception  -- local block exception handlers
  3704.         when USER_QUIT =>
  3705.           COMMON_PROCS.PROMPT_MSG ( "ARE YOU SURE YOU WANT TO QUIT(Y/N) ?");
  3706.           COMMON_PROCS.GET_CHAR ( ANSWER );
  3707.           if ANSWER = 'y' or ANSWER = 'Y' then
  3708.             raise USER_QUIT;
  3709.           end if;
  3710.         when VIDEO_IO.FILE_EXISTS =>
  3711.           COMMON_PROCS.MSG_PROC ( "FILE ALREADY EXISTS", ERROR_LINE );
  3712.           COMMON_PROCS.PROMPT_MSG ( "DO YOU WANT TO CONTINUE(Y/N) ?");
  3713.           COMMON_PROCS.GET_CHAR ( ANSWER );
  3714.           if ANSWER = 'N' or ANSWER = 'n' then
  3715.             raise USER_QUIT;
  3716.           end if;
  3717.         when VIDEO_IO.STATUS_ERROR =>
  3718.           COMMON_PROCS.MSG_PROC ( "FILE ALREADY OPEN", ERROR_LINE );
  3719.           COMMON_PROCS.PROMPT_MSG ( "DO YOU WANT TO CONTINUE(Y/N) ?");
  3720.           COMMON_PROCS.GET_CHAR ( ANSWER );
  3721.           if ANSWER = 'N' or ANSWER = 'n' then
  3722.             raise USER_QUIT;
  3723.           end if;
  3724.         when VIDEO_IO.NAME_ERROR =>
  3725.           COMMON_PROCS.MSG_PROC ("NOT A VALID NAME", ERROR_LINE );
  3726.           COMMON_PROCS.PROMPT_MSG ( "DO YOU WANT TO CONTINUE(Y/N) ?");
  3727.           COMMON_PROCS.GET_CHAR ( ANSWER );
  3728.           if ANSWER = 'N' or ANSWER = 'n' then
  3729.             raise USER_QUIT;
  3730.           end if;
  3731.         when VIDEO_IO.USE_ERROR =>
  3732.           COMMON_PROCS.MSG_PROC ("FILE CAPACITY EXCEEDED - SEE SYSTEM MANAGER",
  3733.                                   ERROR_LINE );
  3734.           raise;
  3735.         when others =>
  3736.           COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUB-ROUTINE IS INIT_TREE");
  3737.           raise;
  3738.      end; -- local block
  3739.    end loop; -- while continue
  3740.   end INIT_TREE;
  3741.   
  3742.   procedure INIT_ROOT ( BOOT_REC : in out VIDEO_TYPES.NODE_RECORD;
  3743.                         ROOT_REC : in out VIDEO_TYPES.NODE_RECORD;
  3744.                         SUCCESS  :    out BOOLEAN ) is
  3745.   
  3746.     VALID          : BOOLEAN := FALSE;
  3747.     ANSWER         : CHARACTER;
  3748.     PASS           : PASS_PROCS.PASSWORD_TYPE;
  3749.     ROOT_NODE_TYPE : VIDEO_TYPES.USER_NODE;
  3750.     REC_FILNAM     : VIDEO_TYPES.FILE_NAME;
  3751.     
  3752.   begin
  3753.     while not VALID loop  -- main
  3754.     begin
  3755.       ROOT_NODE_TYPE := COMMON_PROCS.GET_NODE_TYPE ( PROMPT(RTNOD_TYP) );
  3756.       if ROOT_NODE_TYPE in MENU..INSTRUCTION then
  3757.         REC_FILNAM := 
  3758.           SYSTEM_DEPENDENT.GET_FILENAME ( BOOT_REC.DEFAULT, PROMPT(RTNOD_DEV),
  3759.                                           PROMPT(RTNOD_DIR), PROMPT(RTNOD_NAM),
  3760.                                           ROOT_NODE_TYPE );
  3761.         COMMON_PROCS.GET_NEW_PASSWORD ( PROMPT(PASS_RUN_APL), NO_DEFAULT, PASS );
  3762.         if ROOT_NODE_TYPE = MENU then
  3763.           ROOT_REC := ( MENU, 0, 1, BOOT_REC.LAST_FREE_NODE, 
  3764.                         PASS, REC_FILNAM, (ONE..FIFTEEN => VIDEO_IO.END_REC) );
  3765.         else  -- root_node_type = instruction
  3766.           ROOT_REC := ( INSTRUCTION, 0, 1, BOOT_REC.LAST_FREE_NODE, 
  3767.                         PASS, REC_FILNAM, VIDEO_IO.END_REC );
  3768.         end if;  -- root_node_type = menu
  3769.         VIDEO_IO.WRITE_NODE ( ROOT_REC );
  3770.         BOOT_REC.LAST_FREE_NODE := BOOT_REC.LAST_FREE_NODE + 1;
  3771.         VIDEO_IO.WRITE_NODE ( BOOT_REC );
  3772.         VALID := TRUE;
  3773.         SUCCESS := TRUE;
  3774.       else  -- node type entered was program or boot
  3775.         COMMON_PROCS.MSG_PROC ( ERRORS(INV_NODETYPE), ERROR_LINE );
  3776.       end if;  -- root node type is valid
  3777.     exception
  3778.       when USER_QUIT =>
  3779.         COMMON_PROCS.PROMPT_MSG ( "ARE YOU SURE YOU WANT TO QUIT(Y/N) ?");
  3780.         COMMON_PROCS.GET_CHAR ( ANSWER );
  3781.         if ANSWER = 'y' or ANSWER = 'Y' then
  3782.           raise USER_QUIT;
  3783.         end if;
  3784.     end;
  3785.     end loop;  -- main
  3786.   exception 
  3787.     when USER_QUIT =>
  3788.       raise;
  3789.     when VIDEO_IO.USE_ERROR => 
  3790.       COMMON_PROCS.MSG_PROC ( "FILE CAPACITY EXCEEDED - SEE SYSTEM MANAGER",
  3791.                                ERROR_LINE );
  3792.       raise;
  3793.     when others =>
  3794.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUB-ROUTINE IS INIT_ROOT");
  3795.       raise;
  3796.   end INIT_ROOT;
  3797.   
  3798.   procedure WRAP_UP ( SAVE : in BOOLEAN ) is
  3799.     use VIDEO_IO;
  3800.   begin
  3801.     if VIDEO_IO.NODE_FILE_OPEN then
  3802.       if SAVE then
  3803.         VIDEO_IO.CLOSE_NODE_FILE ( SAVE_FILE );
  3804.       else  -- delete the file
  3805.         VIDEO_IO.CLOSE_NODE_FILE ( DELETE_FILE );
  3806.       end if;  -- save
  3807.     end if;  -- node_file_open
  3808.   end WRAP_UP;
  3809.   
  3810. end INIT;
  3811. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3812. --vidinit.txt
  3813. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3814. -- **********************************************************************
  3815. -- *                                                                    *
  3816. -- *                     MAIN_PROCEDURE : VIDEO_INIT                    *
  3817. -- *                     VERSION        : 1.0a1                         *
  3818. -- *                     DATE           : JANUARY, 1985                 *
  3819. -- *                     AUTHOR         : STEPHEN J. HYLAND             *
  3820. -- *                                      AdaSoft, Inc.                 *
  3821. -- *                                      Lanham, MD                    *
  3822. -- *                                                                    *
  3823. -- **********************************************************************
  3824. --
  3825. --  This is the main procedure for initialization of the video node file.
  3826. --
  3827. with VIDEO_TYPES, COMMON_MESSAGES, COMMON_PROCS, INIT, VIDEO_DEBUG;
  3828. procedure VIDEO_INIT is
  3829.   use VIDEO_TYPES, COMMON_MESSAGES, INIT;
  3830.   
  3831.   EXCEPT : constant STRING (1..30) := "EXCEPTION RAISED IN VIDEO_INIT";
  3832.   
  3833.   BLANKS : STRING (1..14) := "              ";
  3834.     
  3835.   INIT_HDR : constant VIDEO_TYPES.HEADER_TYPE :=
  3836.      (1=>BLANKS & "*****************************************************" &
  3837.          BLANKS,
  3838.       2=>BLANKS & "*                                                   *" &
  3839.          BLANKS,
  3840.       3=>BLANKS & "*                VIDEO INITIALIZATION               *" &
  3841.          BLANKS,
  3842.       4=>BLANKS & "*                                                   *" &
  3843.          BLANKS,
  3844.       5=>BLANKS & "*****************************************************" &
  3845.          BLANKS );
  3846.    
  3847.   BOOT_REC : VIDEO_TYPES.NODE_RECORD (BOOT);
  3848.   ROOT_REC : VIDEO_TYPES.NODE_RECORD;  -- uses the default type menu
  3849.   OK       : BOOLEAN := FALSE;
  3850.   
  3851. begin
  3852.   INIT_HEADER ( INIT_HDR );
  3853.   INIT_TREE ( BOOT_REC, OK );
  3854.   if OK then  -- node file created and boot record written
  3855.     INIT_ROOT ( BOOT_REC, ROOT_REC, OK );
  3856.     if OK then  -- root record written and boot record updated
  3857.       COMMON_PROCS.HOME_CLEAR;
  3858.       COMMON_PROCS.MOVE_CURSOR ( HOME_POSITION );
  3859.       COMMON_PROCS.PUT_STRING (MESSAGES (SUCCESS_INIT) );
  3860.       COMMON_PROCS.NEXT_LINE;
  3861.     else  -- init_root failed
  3862.       COMMON_PROCS.HOME_CLEAR;
  3863.       COMMON_PROCS.MOVE_CURSOR ( HOME_POSITION );
  3864.       COMMON_PROCS.PUT_STRING ( ERRORS(PROC_TERM) );
  3865.       COMMON_PROCS.PUT_STRING ( ": INIT_ROOT FAILED" );
  3866.       COMMON_PROCS.NEXT_LINE;
  3867.     end if;  -- init_root ok
  3868.   else  -- init_tree failed
  3869.     COMMON_PROCS.HOME_CLEAR;
  3870.     COMMON_PROCS.MOVE_CURSOR ( HOME_POSITION );
  3871.     COMMON_PROCS.PUT_STRING ( ERRORS(PROC_TERM) );
  3872.     COMMON_PROCS.PUT_STRING ( ": INIT_TREE FAILED" );
  3873.     COMMON_PROCS.NEXT_LINE;
  3874.   end if;  -- init_tree ok
  3875.   INIT.WRAP_UP ( OK );  -- saves or deletes the file depending on value of ok
  3876. exception
  3877.   when USER_QUIT =>
  3878.     COMMON_PROCS.HOME_CLEAR;
  3879.     COMMON_PROCS.MOVE_CURSOR ( HOME_POSITION );
  3880.     COMMON_PROCS.PUT_STRING ( "VIDEO INITIALIZATION SESSION STOPPED" );
  3881.     COMMON_PROCS.NEXT_LINE;
  3882.     -- if user quit, delete the node file
  3883.     OK := FALSE;
  3884.     INIT.WRAP_UP ( OK );
  3885.   when others =>
  3886.     -- if anything else went wrong, delete the node file
  3887.     OK := FALSE;
  3888.     INIT.WRAP_UP ( OK );
  3889.     -- close the file containing the exception trace
  3890.     VIDEO_DEBUG.PRINT_EXCEPTIONS;
  3891. end VIDEO_INIT;
  3892. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3893. --add.txt
  3894. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3895. -- **********************************************************************
  3896. -- *                                                                    *
  3897. -- *                     PACKAGE: ADD                                   *
  3898. -- *                     VERSION: 1.0a1                                 *
  3899. -- *                     DATE   : JANUARY, 1985                         *
  3900. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  3901. -- *                              AdaSoft, Inc.                         *
  3902. -- *                              Lanham, MD                            *
  3903. -- *                                                                    *
  3904. -- **********************************************************************
  3905. --
  3906. --  This package contains all the routines used by VIDEO_MODEL for adding nodes.
  3907. --
  3908. with VIDEO_TYPES;
  3909. package ADD is
  3910.     
  3911.   procedure NODE_DIAG ( CUR_REC : in out VIDEO_TYPES.NODE_RECORD;
  3912.                         BOOT_REC: in out VIDEO_TYPES.NODE_RECORD;
  3913.                         CHOICE  : in out VIDEO_TYPES.OPTIONS );
  3914.   -- Node_diag is the main routine for adding and the only routine visible
  3915.   -- outside the package. When called by model, it first displays the add
  3916.   -- header, then prompts for the type of node to add. It then calls the
  3917.   -- add routine corresponding to the node type. These routines prompt the
  3918.   -- user for the necessary information, add the node, and if successful,
  3919.   -- update the current node and boot node.
  3920.   
  3921. end ADD;
  3922.  
  3923. with PASS_PROCS, COMMON_MESSAGES, PROMPT_MESSAGES, 
  3924.      VIDEO_IO, COMMON_PROCS, MODEL_PROCS;
  3925. package body ADD is
  3926.   use VIDEO_TYPES, COMMON_MESSAGES, PROMPT_MESSAGES;
  3927.   
  3928.   EXCEPT : constant STRING(1..23) := "EXCEPTION RAISED IN ADD";
  3929.     
  3930.   NO_DEFAULT: STRING(1..1) := " ";
  3931.   BLANKS : STRING (1..14) := "              ";
  3932.     
  3933.   ADD_HEADER : constant VIDEO_TYPES.HEADER_TYPE :=
  3934.      (1=>BLANKS & "*****************************************************" &
  3935.          BLANKS,
  3936.       2=>BLANKS & "*                                                   *" &
  3937.          BLANKS,
  3938.       3=>BLANKS & "*             ***** ADD   MODE *****                *" &
  3939.          BLANKS,
  3940.       4=>BLANKS & "*                                                   *" &
  3941.          BLANKS,
  3942.       5=>BLANKS & "*****************************************************" &
  3943.          BLANKS );
  3944.          
  3945.   procedure ADD_COMMON ( BOOT_REC : in    VIDEO_TYPES.NODE_RECORD;
  3946.                          NODE_TYP : in    VIDEO_TYPES.NODE;
  3947.                          FILENAM  :   out VIDEO_TYPES.FILE_NAME;
  3948.                          PASS     :   out PASS_PROCS.PASSWORD_TYPE ) is
  3949.   -- Add_common prompts the user for the filename and the password of the
  3950.   -- node to be added.
  3951.  
  3952.   begin
  3953.     MODEL_PROCS.GET_COMMON ( BOOT_REC.DEFAULT, PROMPT (DEVNAM), 
  3954.                              PROMPT (DIRNAM), PROMPT (ADD_FILNAM), 
  3955.                              PROMPT(PASSWRD), NODE_TYP, FILENAM, PASS );
  3956.   exception
  3957.     when USER_QUIT =>
  3958.       raise;
  3959.     when others =>
  3960.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS ADD_COMMON");
  3961.       raise;
  3962.   end ADD_COMMON;
  3963.   
  3964.   function ADD_BRANCH ( MSG : in STRING;
  3965.                         CUR_REC : in VIDEO_TYPES.NODE_RECORD )
  3966.     return VIDEO_TYPES.OPTIONS is
  3967.   --
  3968.   -- Add_branch is called by the add routines if the current record is
  3969.   -- a menu node. It prompts the user for the menu branch to add the new
  3970.   -- node to.
  3971.   --
  3972.     CHOICE : VIDEO_TYPES.OPTIONS;
  3973.     TRIES  : NATURAL range 0..2 := 0;
  3974.   
  3975.   begin
  3976.     loop  -- until valid branch or tries > 2
  3977.       TRIES := TRIES + 1;
  3978.       CHOICE := MODEL_PROCS.GET_BRANCH ( MSG );
  3979.       case CHOICE is
  3980.         when SLASH =>
  3981.           -- cancel add
  3982.           exit;
  3983.         when ONE..FIFTEEN =>
  3984.           if CUR_REC.OPTION(CHOICE) /= VIDEO_IO.END_REC then
  3985.             -- invalid branch choosen
  3986.             COMMON_PROCS.MSG_PROC ( ERRORS(INV_BR_NO), ERROR_LINE );
  3987.             if TRIES = 2 then
  3988.               COMMON_PROCS.MSG_PROC ( "**ERROR** BRANCH IS ALREADY CONNECTED" &
  3989.                                       " TO A NODE", ERROR_LINE );
  3990.               if MODEL_PROCS.CONFIRMED ( "DO YOU WANT TO TRY ANOTHER " &
  3991.                                          "BRANCH (Y/N)?") then
  3992.                 TRIES := 0;  -- try again
  3993.               else  -- tell user to insert node
  3994.                 COMMON_PROCS.MSG_PROC ( "TO ADD AT THIS NODE USE INSERT MODE",
  3995.                                         ERROR_LINE );
  3996.                 loop  -- until valid response
  3997.                   COMMON_PROCS.PROMPT_MSG ("ENTER SLASH TO RETURN TO " &
  3998.                                            "MAINTENANCE MENU" );
  3999.                   CHOICE := COMMON_PROCS.GET_INPUT;
  4000.                   exit when CHOICE = SLASH;
  4001.                 end loop;  -- valid response
  4002.               end if;  -- confirmed try again
  4003.             end if;  -- tries = 2
  4004.           else  -- valid branch number choosen
  4005.             exit;
  4006.           end if;  -- cur_rec.option(choice) /= end_rec
  4007.         when others =>
  4008.           -- ignore all other responses
  4009.           null;
  4010.       end case;  -- choice
  4011.     end loop;  -- main
  4012.     return CHOICE;
  4013.   exception
  4014.     when others =>
  4015.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS ADD_BRANCH");
  4016.       raise;
  4017.   end ADD_BRANCH;
  4018.     
  4019.   procedure ADD_NODE (NEW_REC : in out VIDEO_TYPES.NODE_RECORD;
  4020.                       SUCCESS :    out BOOLEAN ) is
  4021.   -- Add_node prompts the user to confirm the add. If yes, the record is
  4022.   -- added, and success becomes true. If no, or if the write fails, success
  4023.   -- returns as false.
  4024.   --
  4025.   begin
  4026.     SUCCESS := FALSE;
  4027.     if MODEL_PROCS.CONFIRMED ( "ADD THIS NODE (Y/N) ?" ) then
  4028.       VIDEO_IO.WRITE_NODE ( NEW_REC );
  4029.       SUCCESS := TRUE;
  4030.     end if;
  4031.   exception
  4032.     when others =>
  4033.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS ADD_NODE");
  4034.       raise;
  4035.   end ADD_NODE;
  4036.   
  4037.   procedure ADD_MENU ( CUR_REC   : in out VIDEO_TYPES.NODE_RECORD;
  4038.                        BOOT_REC  : in out VIDEO_TYPES.NODE_RECORD;
  4039.                        IN_BRANCH : in out VIDEO_TYPES.OPTIONS ) is
  4040.   -- Add_menu looks first at the current_node and prompts for the branch
  4041.   -- to attach to if the current_node is a menu. If it is not a menu and 
  4042.   -- the next_node is free, or if it is a menu and the choosen branch is
  4043.   -- free, add_common is called to get the filename and password of the 
  4044.   -- new node. If the boot record pointers indicate that there are no
  4045.   -- free nodes within the file, (i.e. no free space needs to be recovered),
  4046.   -- then the position is set to end-of-file, otherwise, the first available
  4047.   -- space is used. The record is then created, and, if the node is added,
  4048.   -- the boot and current records are updated.
  4049.   --
  4050.     NEW_REC        : VIDEO_TYPES.NODE_RECORD;
  4051.     FILENAM        : VIDEO_TYPES.FILE_NAME;
  4052.     PASS           : PASS_PROCS.PASSWORD_TYPE;
  4053.     NEW_POSITION   : NATURAL;
  4054.     NEXT_FREE_NODE : NATURAL;
  4055.     LAST_MENU      : NATURAL;
  4056.     ADD_OK         : BOOLEAN;
  4057.     
  4058.   begin
  4059.     if CUR_REC.NODE_TYPE = MENU then
  4060.       -- prompt for in_branch
  4061.       IN_BRANCH := ADD_BRANCH ( PROMPT(ADD_BR_NO),
  4062.                                 CUR_REC );
  4063.       LAST_MENU := CUR_REC.POSITION;
  4064.     else  -- current_node = instruction or program
  4065.       if CUR_REC.NEXT_NODE /= VIDEO_IO.END_REC then
  4066.         -- user should use insert mode
  4067.         COMMON_PROCS.MSG_PROC ( "**ERROR** THERE IS A NODE ATTACHED TO " &
  4068.                                 "THIS NODE - USE INSERT MODE", ERROR_LINE );
  4069.         IN_BRANCH := SLASH;
  4070.       end if;  -- cur_rec.next_node not free
  4071.       LAST_MENU := CUR_REC.LAST_MENU;
  4072.     end if;  -- cur_rec.node_type = menu
  4073.     if IN_BRANCH /= SLASH then
  4074.       -- user did not cancel
  4075.       ADD_COMMON ( BOOT_REC, MENU, FILENAM, PASS );
  4076.       if BOOT_REC.NEXT_FREE_NODE = 0 then
  4077.         -- no free space to recover
  4078.         NEW_POSITION := BOOT_REC.LAST_FREE_NODE;
  4079.       else  -- recover free space
  4080.         VIDEO_IO.READ_NODE ( NEW_REC, BOOT_REC.NEXT_FREE_NODE );
  4081.         NEXT_FREE_NODE := NEW_REC.LAST_NODE;
  4082.         NEW_POSITION := BOOT_REC.NEXT_FREE_NODE;
  4083.       end if;  -- next_free_node = 0
  4084.       NEW_REC := ( MENU, CUR_REC.POSITION, LAST_MENU, NEW_POSITION,
  4085.                    PASS, FILENAM, (ONE..FIFTEEN => VIDEO_IO.END_REC) );
  4086.       ADD_NODE ( NEW_REC, ADD_OK );
  4087.       if ADD_OK then
  4088.         -- new_record was added
  4089.         if BOOT_REC.NEXT_FREE_NODE = 0 then
  4090.           -- update pointer to end of file
  4091.           BOOT_REC.LAST_FREE_NODE := BOOT_REC.LAST_FREE_NODE + 1;
  4092.         else  -- recover free space
  4093.           BOOT_REC.NEXT_FREE_NODE := NEXT_FREE_NODE;
  4094.         end if;  -- next_free_node = 0
  4095.         if CUR_REC.NODE_TYPE = MENU then
  4096.           CUR_REC.OPTION ( IN_BRANCH ) := NEW_REC.POSITION;
  4097.         else  -- type is instruction or program
  4098.           CUR_REC.NEXT_NODE := NEW_REC.POSITION;
  4099.         end if;  -- node type is menu
  4100.         VIDEO_IO.WRITE_NODE ( BOOT_REC );
  4101.         VIDEO_IO.WRITE_NODE ( CUR_REC );
  4102.       end if;  -- add_ok
  4103.     end if;  -- in_branch /= slash
  4104.   exception
  4105.     when USER_QUIT =>
  4106.       raise;
  4107.     when others =>
  4108.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS ADD_MENU");
  4109.       raise;
  4110.   end ADD_MENU;
  4111.   
  4112.   procedure ADD_INST ( CUR_REC   : in out VIDEO_TYPES.NODE_RECORD;
  4113.                        BOOT_REC  : in out VIDEO_TYPES.NODE_RECORD;
  4114.                        IN_BRANCH : in out VIDEO_TYPES.OPTIONS ) is
  4115.   --
  4116.   -- Add_inst behaves exactly as add_menu, except in setting up the node_record
  4117.   --
  4118.     NEW_REC        : VIDEO_TYPES.NODE_RECORD;
  4119.     FILENAM        : VIDEO_TYPES.FILE_NAME;
  4120.     PASS           : PASS_PROCS.PASSWORD_TYPE;
  4121.     NEW_POSITION   : NATURAL;
  4122.     NEXT_FREE_NODE : NATURAL;
  4123.     LAST_MENU      : NATURAL;
  4124.     ADD_OK         : BOOLEAN;
  4125.     
  4126.   begin
  4127.     if CUR_REC.NODE_TYPE = MENU then
  4128.       IN_BRANCH := ADD_BRANCH ( PROMPT(ADD_BR_NO),
  4129.                                 CUR_REC );
  4130.       LAST_MENU := CUR_REC.POSITION;
  4131.     else  -- cur_rec.node_type = instruction or program
  4132.       if CUR_REC.NEXT_NODE /= VIDEO_IO.END_REC then
  4133.         -- next node is not free
  4134.         COMMON_PROCS.MSG_PROC ( "**ERROR** THERE IS A NODE ATTACHED TO " &
  4135.                                 "THIS NODE - USE INSERT MODE", ERROR_LINE );
  4136.         IN_BRANCH := SLASH;
  4137.       end if;  -- next_node /= end_rec
  4138.       LAST_MENU := CUR_REC.LAST_MENU;
  4139.     end if;  -- node_type = menu
  4140.     if IN_BRANCH /= SLASH then
  4141.       -- user did not cancel
  4142.       ADD_COMMON ( BOOT_REC, INSTRUCTION, FILENAM, PASS );
  4143.       if BOOT_REC.NEXT_FREE_NODE = 0 then
  4144.         -- no free space to recover
  4145.         NEW_POSITION := BOOT_REC.LAST_FREE_NODE;
  4146.       else  -- free space to recover
  4147.         VIDEO_IO.READ_NODE ( NEW_REC, BOOT_REC.NEXT_FREE_NODE );
  4148.         NEXT_FREE_NODE := NEW_REC.LAST_NODE;
  4149.         NEW_POSITION := BOOT_REC.NEXT_FREE_NODE;
  4150.       end if;  -- next_free_node = 0
  4151.       NEW_REC := ( INSTRUCTION, CUR_REC.POSITION, LAST_MENU, NEW_POSITION,
  4152.                    PASS, FILENAM, VIDEO_IO.END_REC );
  4153.       ADD_NODE ( NEW_REC, ADD_OK );
  4154.       if ADD_OK then
  4155.         if BOOT_REC.NEXT_FREE_NODE = 0 then
  4156.           -- update pointer to end of file
  4157.           BOOT_REC.LAST_FREE_NODE := BOOT_REC.LAST_FREE_NODE + 1;
  4158.         else  -- recover free space
  4159.           BOOT_REC.NEXT_FREE_NODE := NEXT_FREE_NODE;
  4160.         end if;  -- next_free_node = 0
  4161.         if CUR_REC.NODE_TYPE = MENU then
  4162.           CUR_REC.OPTION ( IN_BRANCH ) := NEW_REC.POSITION;
  4163.         else  -- node_type = instruction or program
  4164.           CUR_REC.NEXT_NODE := NEW_REC.POSITION;
  4165.         end if;  -- node_type = menu
  4166.         VIDEO_IO.WRITE_NODE ( BOOT_REC );
  4167.         VIDEO_IO.WRITE_NODE ( CUR_REC );
  4168.       end if;  -- add_ok
  4169.     end if;  -- in_branch /= slash
  4170.   exception
  4171.     when USER_QUIT =>
  4172.       raise;
  4173.     when others =>
  4174.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS ADD_INST");
  4175.       raise;
  4176.   end ADD_INST;
  4177.                        
  4178.   procedure ADD_PROG ( CUR_REC   : in out VIDEO_TYPES.NODE_RECORD;
  4179.                        BOOT_REC  : in out VIDEO_TYPES.NODE_RECORD;
  4180.                        IN_BRANCH : in out VIDEO_TYPES.OPTIONS ) is
  4181.   --
  4182.   -- Add_prog performs the same way as Add_menu except in creating node_record
  4183.   --
  4184.     NEW_REC        : VIDEO_TYPES.NODE_RECORD;
  4185.     FILENAM        : VIDEO_TYPES.FILE_NAME;
  4186.     PASS           : PASS_PROCS.PASSWORD_TYPE;
  4187.     NEW_POSITION   : NATURAL;
  4188.     NEXT_FREE_NODE : NATURAL;
  4189.     LAST_MENU      : NATURAL;
  4190.     ADD_OK         : BOOLEAN;
  4191.     
  4192.   begin
  4193.     if CUR_REC.NODE_TYPE = MENU then
  4194.       IN_BRANCH := ADD_BRANCH ( PROMPT(ADD_BR_NO),
  4195.                                 CUR_REC );
  4196.       LAST_MENU := CUR_REC.POSITION;
  4197.     else  -- node_type = instruction or program
  4198.       if CUR_REC.NEXT_NODE /= VIDEO_IO.END_REC then
  4199.         -- next_node is not free
  4200.         COMMON_PROCS.MSG_PROC ( "**ERROR** THERE IS A NODE ATTACHED TO " &
  4201.                                 "THIS NODE - USE INSERT MODE", ERROR_LINE );
  4202.         IN_BRANCH := SLASH;
  4203.       end if;  -- next_node /= end_rec
  4204.       LAST_MENU := CUR_REC.LAST_MENU;
  4205.     end if;  -- node_type = menu
  4206.     if IN_BRANCH /= SLASH then
  4207.       -- user did not cancel
  4208.       ADD_COMMON ( BOOT_REC, PROGRAM, FILENAM, PASS );
  4209.       if BOOT_REC.NEXT_FREE_NODE = 0 then
  4210.         -- no free space to recover
  4211.         NEW_POSITION := BOOT_REC.LAST_FREE_NODE;
  4212.       else  -- free space to recover
  4213.         VIDEO_IO.READ_NODE ( NEW_REC, BOOT_REC.NEXT_FREE_NODE );
  4214.         NEXT_FREE_NODE := NEW_REC.LAST_NODE;
  4215.         NEW_POSITION := BOOT_REC.NEXT_FREE_NODE;
  4216.       end if;  -- next_free_node = 0
  4217.       NEW_REC := ( PROGRAM, CUR_REC.POSITION, LAST_MENU, NEW_POSITION,
  4218.                    PASS, FILENAM, VIDEO_IO.END_REC );
  4219.       ADD_NODE ( NEW_REC, ADD_OK );
  4220.       if ADD_OK then
  4221.         if BOOT_REC.NEXT_FREE_NODE = 0 then
  4222.           -- no free space to recover
  4223.           BOOT_REC.LAST_FREE_NODE := BOOT_REC.LAST_FREE_NODE + 1;
  4224.         else  -- free space to recover
  4225.           BOOT_REC.NEXT_FREE_NODE := NEXT_FREE_NODE;
  4226.         end if;  -- next_free_node = 0
  4227.         if CUR_REC.NODE_TYPE = MENU then
  4228.           CUR_REC.OPTION ( IN_BRANCH ) := NEW_REC.POSITION;
  4229.         else  -- node_type = instruction or program
  4230.           CUR_REC.NEXT_NODE := NEW_REC.POSITION;
  4231.         end if;  -- node_type = menu
  4232.         VIDEO_IO.WRITE_NODE ( BOOT_REC );
  4233.         VIDEO_IO.WRITE_NODE ( CUR_REC );
  4234.       end if;  -- add_ok
  4235.     end if;  -- in_branch /= slash
  4236.   exception
  4237.     when USER_QUIT =>
  4238.       raise;
  4239.     when others =>
  4240.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS ADD_PROG");
  4241.       raise;
  4242.   end ADD_PROG;
  4243.                        
  4244.   procedure NODE_DIAG ( CUR_REC : in out VIDEO_TYPES.NODE_RECORD;
  4245.                         BOOT_REC: in out VIDEO_TYPES.NODE_RECORD;
  4246.                         CHOICE  : in out VIDEO_TYPES.OPTIONS ) is
  4247.     
  4248.     NEW_NODE_TYPE : VIDEO_TYPES.USER_NODE;
  4249.   begin
  4250.     MODEL_PROCS.PUT_HEADER ( ADD_HEADER );
  4251.     NEW_NODE_TYPE := COMMON_PROCS.GET_NODE_TYPE ( PROMPT(ADD_TYP) );
  4252.     case NEW_NODE_TYPE is
  4253.       -- evaluate new_node_type
  4254.       when MENU =>
  4255.         ADD_MENU ( CUR_REC, BOOT_REC, CHOICE );
  4256.       when INSTRUCTION =>
  4257.         ADD_INST ( CUR_REC, BOOT_REC, CHOICE );
  4258.       when PROGRAM =>
  4259.         ADD_PROG ( CUR_REC, BOOT_REC, CHOICE );
  4260.     end case;  -- new_node_type
  4261.   exception
  4262.     when USER_QUIT =>
  4263.       CHOICE := SLASH;
  4264.     when others =>
  4265.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS ADD_NODE_DIAG");
  4266.       raise;
  4267.   end NODE_DIAG;
  4268.   
  4269. end ADD;
  4270. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4271. --delete.txt
  4272. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4273. -- **********************************************************************
  4274. -- *                                                                    *
  4275. -- *                     PACKAGE: DELETE                                *
  4276. -- *                     VERSION: 1.0a1                                 *
  4277. -- *                     DATE   : JANUARY, 1985                         *
  4278. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  4279. -- *                              AdaSoft, Inc.                         *
  4280. -- *                              Lanham, MD                            *
  4281. -- *                                                                    *
  4282. -- **********************************************************************
  4283. --
  4284. --  This package contains all the routines used by VIDEO_MODEL for deleting
  4285. --  nodes.
  4286. --
  4287. with VIDEO_TYPES;
  4288. package DELETE is
  4289.   procedure NODE_DIAG ( CUR_REC  : in out VIDEO_TYPES.NODE_RECORD;
  4290.                         BOOT_REC : in out VIDEO_TYPES.NODE_RECORD;
  4291.                         CHOICE   :    out VIDEO_TYPES.OPTIONS );
  4292.   -- Node_diag is the only routine visible outside the package body. It
  4293.   -- first displays the delete header. Then, if the current node is a
  4294.   -- menu, it prompts for a branch number to delete. If a <CR> is entered,
  4295.   -- the current node will be deleted, otherwise, only the node attached
  4296.   -- to the choosen branch will be marked for delete. If the current node
  4297.   -- is a program or instruction node, the user will be prompted to include
  4298.   -- the current node in the delete. The user will then be asked if the
  4299.   -- selected node is the only node to be deleted. If yes, then the user
  4300.   -- is asked to confirm single node deletion, if no, to confirm multiple
  4301.   -- node deletion. If the user confirms, deletion will proceed, and a
  4302.   -- result message will be displayed. An attempt to perform single 
  4303.   -- deletion on a menu node with subtrees will not be allowed. If the 
  4304.   -- process is successful, the boot record and current record will be
  4305.   -- updated.
  4306.   --   Delete recovers free space within the file by marking deleted
  4307.   -- records as usable for subsequent adds or inserts. If the deletion
  4308.   -- fails, Delete will attempt to recover the deleted nodes, and will
  4309.   -- indicate the success or failure of this process. Since the likely
  4310.   -- cause of failure is a hardware or file_io error, it is important
  4311.   -- that a back-up copy of the file be made prior to any modeling session.
  4312.   --
  4313. end DELETE;
  4314.  
  4315. with COMMON_MESSAGES, PROMPT_MESSAGES, VIDEO_IO, COMMON_PROCS, MODEL_PROCS;
  4316. package body DELETE is
  4317.   use VIDEO_TYPES, COMMON_MESSAGES, PROMPT_MESSAGES;
  4318.     
  4319.   EXCEPT : constant STRING(1..26) := "EXCEPTION RAISED IN DELETE";
  4320.   
  4321.   DELETE_FAILED : exception;
  4322.     
  4323.   BLANKS : STRING (1..14) := "              ";
  4324.     
  4325.   DELETE_HEADER : constant VIDEO_TYPES.HEADER_TYPE :=
  4326.      (1=>BLANKS & "*****************************************************" &
  4327.          BLANKS,
  4328.       2=>BLANKS & "*                                                   *" &
  4329.          BLANKS,
  4330.       3=>BLANKS & "*            ***** DELETE  MODE *****               *" &
  4331.          BLANKS,
  4332.       4=>BLANKS & "*                                                   *" &
  4333.          BLANKS,
  4334.       5=>BLANKS & "*****************************************************" &
  4335.          BLANKS );
  4336.          
  4337.   function GET_BRANCH ( MSG : in STRING ) return VIDEO_TYPES.OPTIONS is
  4338.   --
  4339.   -- Get_branch prompts the user for a branch number. It will accept
  4340.   -- 1..15, slash, or <CR>.
  4341.   --
  4342.     CHOICE : VIDEO_TYPES.OPTIONS;
  4343.     
  4344.   begin
  4345.     loop  -- until valid response
  4346.       COMMON_PROCS.PROMPT_MSG ( MSG );
  4347.       CHOICE := COMMON_PROCS.GET_INPUT;
  4348.       case CHOICE is
  4349.         when CR|SLASH|ONE..FIFTEEN =>
  4350.           exit;
  4351.         when others => 
  4352.           COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP), ERROR_LINE );
  4353.       end case;
  4354.     end loop;  -- until valid response
  4355.     return CHOICE;
  4356.   exception 
  4357.     when others =>
  4358.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS GET_BRANCH");
  4359.       raise;
  4360.   end GET_BRANCH;
  4361.   
  4362.   function GET_DELETE_BRANCH ( REC : in VIDEO_TYPES.NODE_RECORD;
  4363.                                MSG : in STRING ) return VIDEO_TYPES.OPTIONS is
  4364.   --
  4365.   -- Get_delete_branch gets the branch number to be deleted, then confirms
  4366.   -- that the choosen branch has a subtree attached. If not, an error is
  4367.   -- indicated.
  4368.   --
  4369.     BRANCH : VIDEO_TYPES.OPTIONS;
  4370.   
  4371.   begin
  4372.     loop  -- until valid branch entered
  4373.       BRANCH := GET_BRANCH ( MSG );
  4374.       case BRANCH is
  4375.         when CR|SLASH =>
  4376.           exit;
  4377.         when ONE..FIFTEEN =>
  4378.           if REC.OPTION(BRANCH) = VIDEO_IO.END_REC then
  4379.             COMMON_PROCS.MSG_PROC ( ERRORS(INV_BR_NO), ERROR_LINE );
  4380.           else  -- branch has a subtree
  4381.             exit;
  4382.           end if;  -- rec.option(branch) = end_rec
  4383.         when others =>
  4384.           COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP), ERROR_LINE );
  4385.       end case;  -- branch
  4386.     end loop;  -- until valid
  4387.     return BRANCH;
  4388.   exception 
  4389.     when others =>
  4390.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & 
  4391.                                      " SUBROUTINE IS GET_DELETE_BRANCH");
  4392.       raise;
  4393.   end GET_DELETE_BRANCH;
  4394.   
  4395.   procedure GET_NODES ( CUR_REC  : in     VIDEO_TYPES.NODE_RECORD;
  4396.                         PREV_REC :    out VIDEO_TYPES.NODE_RECORD;
  4397.                         DEL_REC  :    out VIDEO_TYPES.NODE_RECORD;
  4398.                         CHOICE   :    out VIDEO_TYPES.OPTIONS ) is
  4399.   -- Get_nodes first determines if the current node is a menu node. If so
  4400.   -- it prompts the user to enter the number of the branch to be deleted.
  4401.   -- If the user enters a <CR>, then the current_node is marked for deletion,
  4402.   -- otherwise, the node attached to the choosen branch is marked.
  4403.   --   If the current node is a program or instruction, the user is prompted
  4404.   -- to delete the current node. If the user confirms, the current record
  4405.   -- is marked for deletion, otherwise, the next_node is marked.
  4406.   --   If the current node is to be deleted, then it becomes the delete_record,
  4407.   -- and the previous node is read from the file, and will be updated if
  4408.   -- the deletion succeeds. If the current node is not to be deleted, the
  4409.   -- current record becomes the previous record, and the next node becomes
  4410.   -- the delete record. 
  4411.   --
  4412.     BRANCH      : VIDEO_TYPES.OPTIONS;
  4413.     INCLUDE_CUR : BOOLEAN := FALSE;
  4414.     
  4415.   begin
  4416.     case CUR_REC.NODE_TYPE is
  4417.       when MENU =>
  4418.         BRANCH := GET_DELETE_BRANCH ( CUR_REC, PROMPT(DEL_BR_NO) );
  4419.         case BRANCH is
  4420.           when SLASH =>
  4421.           -- user canceled operation
  4422.             CHOICE := SLASH;
  4423.           when CR =>
  4424.           -- current_record is to be included in deletion
  4425.             DEL_REC := CUR_REC;
  4426.             VIDEO_IO.READ_NODE ( PREV_REC, DEL_REC.LAST_NODE );
  4427.           when ONE..FIFTEEN =>
  4428.           -- delete part or all of a sub-tree
  4429.             PREV_REC := CUR_REC;
  4430.             VIDEO_IO.READ_NODE ( DEL_REC, PREV_REC.OPTION(BRANCH) );
  4431.           when others =>
  4432.             -- ignore anything else
  4433.             null;
  4434.         end case;  -- branch
  4435.       when others =>
  4436.         -- cur_rec.node_type = program or instruction
  4437.         -- so ask if user wants to include this node
  4438.         MODEL_PROCS.GET_ANSWER ( PROMPT(DEL_THIS_NOD), INCLUDE_CUR, CHOICE );
  4439.         if INCLUDE_CUR then
  4440.           DEL_REC := CUR_REC;
  4441.           VIDEO_IO.READ_NODE ( PREV_REC, DEL_REC.LAST_NODE );
  4442.         else  -- begin deletion with the next node
  4443.           PREV_REC := CUR_REC;
  4444.           VIDEO_IO.READ_NODE ( DEL_REC, PREV_REC.NEXT_NODE );
  4445.         end if;  -- include current node
  4446.     end case;  -- cur_rec.node_type
  4447.   exception
  4448.     when others =>
  4449.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS GET_NODES");
  4450.       raise;
  4451.   end GET_NODES;
  4452.     
  4453.   procedure DELETE_MULTIPLE_NODES (PREV_REC : in     VIDEO_TYPES.NODE_RECORD;
  4454.                                    BOOT_REC : in out VIDEO_TYPES.NODE_RECORD;
  4455.                                    SUCCESS  :    out BOOLEAN ) is
  4456.   -- Delete_multiple_nodes is a recursive routine that deletes a subtree. Since
  4457.   -- it is recursive, a node that is not a leaf will not be deleted until it's
  4458.   -- subtrees are deleted. There are two cases for this routine, depending 
  4459.   -- on the type of the previous record. The routine first determines this type.
  4460.   -- If it is a menu node, then for each branch that has a subtree, it reads
  4461.   -- the next node into Delete_record, and passes that record in a recursive 
  4462.   -- call. If the call returns successfully, the delete_record is updated to
  4463.   -- indicate the next free node (last node deleted) and the boot record is
  4464.   -- updated to point to the next free space. 
  4465.   --   If it is a program or instruction node and it has a subtree, it reads
  4466.   -- the next_node into the delete_record, then passes this delete_record in
  4467.   -- a recursive call. If the call returns successfully, the delete and boot
  4468.   -- records are updated to reflect the free space.
  4469.   --
  4470.     DEL_REC   : VIDEO_TYPES.NODE_RECORD;
  4471.   
  4472.   begin
  4473.     SUCCESS := FALSE;
  4474.     case PREV_REC.NODE_TYPE is
  4475.       when MENU =>
  4476.         -- then node may have more than one subtree
  4477.         for I in ONE..FIFTEEN loop
  4478.           if PREV_REC.OPTION(I) /= VIDEO_IO.END_REC then
  4479.             -- there is a subtree attached
  4480.             VIDEO_IO.READ_NODE ( DEL_REC, PREV_REC.OPTION(I) );
  4481.             DELETE_MULTIPLE_NODES ( DEL_REC, BOOT_REC, SUCCESS );
  4482.             if SUCCESS then
  4483.               -- the subtree for this delete record has been deleted so
  4484.               -- set delete record's pointer to the last deleted node.
  4485.               DEL_REC.LAST_NODE := BOOT_REC.NEXT_FREE_NODE;
  4486.               DEL_REC.LAST_MENU := VIDEO_IO.END_REC;  -- zero out last menu
  4487.               -- set boot record pointer for recoverable space to this 
  4488.               -- node position
  4489.               BOOT_REC.NEXT_FREE_NODE := DEL_REC.POSITION;
  4490.               -- write the node back to the file
  4491.               VIDEO_IO.WRITE_NODE ( DEL_REC );
  4492.             end if;  -- success
  4493.           end if;  -- prev_rec.option(i) /= end_rec
  4494.         end loop;  -- for i in one..fifteen
  4495.       when PROGRAM|INSTRUCTION =>
  4496.         if PREV_REC.NEXT_NODE /= VIDEO_IO.END_REC then
  4497.           -- node has a subtree
  4498.           VIDEO_IO.READ_NODE ( DEL_REC, PREV_REC.NEXT_NODE );
  4499.           DELETE_MULTIPLE_NODES ( DEL_REC, BOOT_REC, SUCCESS );
  4500.           if SUCCESS then
  4501.           -- subtree has been deleted so
  4502.           -- point this record to the last record deleted
  4503.             DEL_REC.LAST_NODE := BOOT_REC.NEXT_FREE_NODE;
  4504.             -- zero out the last_menu pointer
  4505.             DEL_REC.LAST_MENU := VIDEO_IO.END_REC;
  4506.             -- update the boot record
  4507.             BOOT_REC.NEXT_FREE_NODE := DEL_REC.POSITION;
  4508.             -- rewrite the node
  4509.             VIDEO_IO.WRITE_NODE ( DEL_REC );
  4510.           end if;  -- success
  4511.         end if;  -- prev_rec.next_node /= end_rec
  4512.       when others =>
  4513.         null;
  4514.     end case;  -- prev_rec.node_type
  4515.     SUCCESS := TRUE;
  4516.   exception
  4517.     when VIDEO_IO.DEVICE_ERROR|VIDEO_IO.DATA_ERROR|VIDEO_IO.END_ERROR =>
  4518.       raise DELETE_FAILED;
  4519.     when others =>
  4520.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS " &
  4521.                                       "DELETE_MULTIPLE_NODES" );
  4522.       raise;
  4523.   end DELETE_MULTIPLE_NODES;
  4524.   
  4525.   procedure DELETE_SINGLE_NODE ( DEL_REC  : in out VIDEO_TYPES.NODE_RECORD;
  4526.                                  BOOT_REC : in out VIDEO_TYPES.NODE_RECORD;
  4527.                                  SUCCESS  :    out BOOLEAN ) is
  4528.   -- Delete_single_node first determines the node type. If it is a menu,
  4529.   -- the operation is terminated. Otherwise, the user is prompted to confirm
  4530.   -- the deletion. If confirmed, the next_record is read and connected to
  4531.   -- the prior node, and the delete_record is deleted. If successful, the 
  4532.   -- boot record is updated, and the delete and next records are rewritten.
  4533.   --
  4534.     NEXT_REC : VIDEO_TYPES.NODE_RECORD;
  4535.     CHOICE   : VIDEO_TYPES.OPTIONS;
  4536.     DELETE_OK: BOOLEAN := FALSE;
  4537.   
  4538.   begin
  4539.     SUCCESS := FALSE;
  4540.     if DEL_REC.NODE_TYPE = MENU then
  4541.       -- cannot single delete a menu node
  4542.       COMMON_PROCS.MSG_PROC ( "**ERROR** NODE CANNOT BE DELETED AS " &
  4543.                               "IT HAS MORE THAN ONE BRANCH", ERROR_LINE );
  4544.     else  -- node is a program or instruction node
  4545.       COMMON_PROCS.MSG_PROC ( "**WARNING** SINGLE NODE DELETION IS " &
  4546.                               "QUEUED FOR PROCESSING", ERROR_LINE );
  4547.       MODEL_PROCS.GET_ANSWER ( PROMPT(DEL), DELETE_OK, CHOICE );
  4548.     end if;  -- del_rec.node_type = menu
  4549.     if CHOICE /= SLASH and then DELETE_OK then 
  4550.       -- user has not canceled process so get the next record
  4551.       VIDEO_IO.READ_NODE ( NEXT_REC, DEL_REC.NEXT_NODE );
  4552.       -- point the next record to the previous record and last menu
  4553.       NEXT_REC.LAST_NODE := DEL_REC.LAST_NODE;
  4554.       NEXT_REC.LAST_MENU := DEL_REC.LAST_MENU;
  4555.       -- point the delete record to the next free space
  4556.       DEL_REC.LAST_NODE := BOOT_REC.NEXT_FREE_NODE;
  4557.       DEL_REC.LAST_MENU := VIDEO_IO.END_REC;
  4558.       -- point the boot record free space pointer to this node
  4559.       BOOT_REC.NEXT_FREE_NODE := DEL_REC.POSITION;
  4560.       -- rewrite the delete_record and the next_record
  4561.       VIDEO_IO.WRITE_NODE ( DEL_REC );
  4562.       VIDEO_IO.WRITE_NODE ( NEXT_REC );
  4563.       SUCCESS := TRUE;
  4564.     end if;
  4565.   exception
  4566.     when VIDEO_IO.DEVICE_ERROR|VIDEO_IO.DATA_ERROR|VIDEO_IO.END_ERROR =>
  4567.       raise DELETE_FAILED;
  4568.     when others =>
  4569.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS " &
  4570.                                       "DELETE_SINGLE_NODE" );
  4571.       raise;
  4572.   end DELETE_SINGLE_NODE;
  4573.     
  4574.   procedure RECOVER_NODES ( PREV_REC : in     VIDEO_TYPES.NODE_RECORD;
  4575.                             SUCCESS  :    out BOOLEAN ) is
  4576.   -- Recover nodes is a recursive routine that attempts to recover nodes
  4577.   -- that have been deleted by tracing forward from the last node deleted
  4578.   -- to the first node deleted.
  4579.   --
  4580.     DEL_REC : VIDEO_TYPES.NODE_RECORD;
  4581.   
  4582.   begin
  4583.     SUCCESS := FALSE;
  4584.     case PREV_REC.NODE_TYPE is
  4585.       when MENU =>
  4586.         for I in ONE..FIFTEEN loop
  4587.           if PREV_REC.OPTION(I) /= VIDEO_IO.END_REC then
  4588.             VIDEO_IO.READ_NODE ( DEL_REC, PREV_REC.OPTION(I) );
  4589.             DEL_REC.LAST_NODE := PREV_REC.POSITION;
  4590.             VIDEO_IO.WRITE_NODE ( DEL_REC );
  4591.           end if;
  4592.         end loop;
  4593.       when PROGRAM|INSTRUCTION =>
  4594.         if PREV_REC.NEXT_NODE /= VIDEO_IO.END_REC then
  4595.           VIDEO_IO.READ_NODE ( DEL_REC, PREV_REC.NEXT_NODE );
  4596.           DEL_REC.LAST_NODE := PREV_REC.POSITION;
  4597.           VIDEO_IO.WRITE_NODE ( DEL_REC );
  4598.         end if;
  4599.       when others =>
  4600.         null;
  4601.     end case;
  4602.     SUCCESS := TRUE;
  4603.   exception
  4604.     when others =>
  4605.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS " &
  4606.                                       "DELETE_MULTIPLE_NODES" );
  4607.       raise;
  4608.   end RECOVER_NODES;
  4609.   
  4610.   procedure NODE_DIAG ( CUR_REC  : in out VIDEO_TYPES.NODE_RECORD;
  4611.                         BOOT_REC : in out VIDEO_TYPES.NODE_RECORD;
  4612.                         CHOICE   :    out VIDEO_TYPES.OPTIONS ) is
  4613.   
  4614.     ROOT_REC_POSITION : constant NATURAL := 1;
  4615.  
  4616.     PREV_REC    : VIDEO_TYPES.NODE_RECORD;
  4617.     DEL_REC     : VIDEO_TYPES.NODE_RECORD;
  4618.     BRANCH      : VIDEO_TYPES.OPTIONS;
  4619.     NEXT_NODE   : NATURAL := VIDEO_IO.END_REC;
  4620.     DELETE_OK   : BOOLEAN := FALSE;
  4621.     RECOVER_OK  : BOOLEAN := FALSE;
  4622.     SINGLE_NODE : BOOLEAN := FALSE;
  4623.     DELETE_DONE : BOOLEAN := FALSE;
  4624.     
  4625.   begin
  4626.     MODEL_PROCS.PUT_HEADER ( DELETE_HEADER );
  4627.     GET_NODES ( CUR_REC, PREV_REC, DEL_REC, CHOICE );
  4628.     if CHOICE /= SLASH then
  4629.       -- user has not canceled operation
  4630.       MODEL_PROCS.GET_ANSWER ( PROMPT(DEL_NOD), SINGLE_NODE, CHOICE );
  4631.       if SINGLE_NODE then 
  4632.         if DEL_REC.POSITION /= ROOT_REC_POSITION then
  4633.           -- delete only this node
  4634.           DELETE_SINGLE_NODE ( DEL_REC, BOOT_REC, DELETE_DONE );
  4635.           if DELETE_DONE then
  4636.             -- if deletion worked
  4637.             NEXT_NODE := DEL_REC.NEXT_NODE;
  4638.           end if;  -- single delete_done
  4639.         else
  4640.           COMMON_PROCS.MSG_PROC ( "**ERROR** DELETION OF APPLICATION " &
  4641.                                   "MODEL ROOT NODE IS NOT PERMITTED",
  4642.                                   ERROR_LINE );
  4643.         end if; -- del_rec.position /= root_rec_position
  4644.       else  -- multiple node deletion
  4645.         if DEL_REC.POSITION /= ROOT_REC_POSITION then
  4646.           COMMON_PROCS.MSG_PROC ( "**WARNING** MULTIPLE NODE DELETION IS " &
  4647.                                   "QUEUED FOR PROCESSING", ERROR_LINE );
  4648.           MODEL_PROCS.GET_ANSWER ( PROMPT(DEL), DELETE_OK, CHOICE );
  4649.           if CHOICE /= SLASH and then DELETE_OK then
  4650.             -- user has not canceled
  4651.             DELETE_MULTIPLE_NODES ( DEL_REC, BOOT_REC, DELETE_DONE );
  4652.             if DELETE_DONE then
  4653.               -- deletion has completed so far so delete the deletenode
  4654.               DEL_REC.LAST_NODE := BOOT_REC.NEXT_FREE_NODE;
  4655.               DEL_REC.LAST_MENU := VIDEO_IO.END_REC;
  4656.               BOOT_REC.NEXT_FREE_NODE := DEL_REC.POSITION;
  4657.               VIDEO_IO.WRITE_NODE ( DEL_REC );
  4658.             end if;  --  multiple delete_done
  4659.           end if;  -- choice /= slash and then delete_ok
  4660.         else
  4661.           COMMON_PROCS.MSG_PROC ( "**ERROR** APPLICATION MODEL ROOT NODE " &
  4662.                                   "CANNOT BE DELETED", ERROR_LINE );
  4663.         end if;  -- del_rec /= root_rec_position
  4664.       end if;  -- single node
  4665.       if DELETE_DONE then
  4666.         -- nodes were deleted
  4667.         if PREV_REC.NODE_TYPE = MENU then
  4668.           -- set the branch to end rec
  4669.           for I in ONE..FIFTEEN loop
  4670.             if PREV_REC.OPTION(I) = DEL_REC.POSITION then
  4671.               PREV_REC.OPTION(I) := NEXT_NODE;
  4672.               exit;
  4673.             end if;  -- prev_rec.option(i) = del_rec.position
  4674.           end loop;  -- for i in one..fifteen
  4675.         else  -- prev_node is program or instruction
  4676.           PREV_REC.NEXT_NODE := NEXT_NODE;
  4677.         end if;  -- prev_rec.node_type = menu
  4678.         VIDEO_IO.WRITE_NODE ( PREV_REC );
  4679.         VIDEO_IO.WRITE_NODE ( BOOT_REC );
  4680.         CUR_REC := PREV_REC;  -- display prev_rec on return
  4681.       else  -- deletion not done
  4682.         CHOICE := SLASH;
  4683.       end if;  -- delete_done
  4684.     end if;  -- choice /= slash
  4685.   exception
  4686.     when DELETE_FAILED =>
  4687.       -- attempt to recover
  4688.       COMMON_PROCS.MSG_PROC ( "**WARNING** DELETE FAILED - ATTEMPTING " &
  4689.                               "RECOVERY", ERROR_LINE );
  4690.       RECOVER_NODES ( PREV_REC, RECOVER_OK );
  4691.       if RECOVER_OK then 
  4692.         COMMON_PROCS.MSG_PROC ("RECOVERY SUCCESSFUL - PLEASE TEST FILE",
  4693.                                 ERROR_LINE );
  4694.       else
  4695.         COMMON_PROCS.MSG_PROC ("RECOVERY FAILED - EXIT MODEL AND USE " &
  4696.                                "BACK-UP OF NODE FILE", ERROR_LINE );
  4697.       end if;
  4698.     when others =>
  4699.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS NODE_DIAG");
  4700.       raise;
  4701.   end NODE_DIAG;
  4702.   
  4703. end DELETE;
  4704.         
  4705. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4706. --move.txt
  4707. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4708. -- **********************************************************************
  4709. -- *                                                                    *
  4710. -- *                     PACKAGE: MOVE                                  *
  4711. -- *                     VERSION: 1.0a1                                 *
  4712. -- *                     DATE   : JANUARY, 1985                         *
  4713. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  4714. -- *                              AdaSoft, Inc.                         *
  4715. -- *                              Lanham, MD                            *
  4716. -- *                                                                    *
  4717. -- **********************************************************************
  4718. --
  4719. --  This package contains all the routines used in VIDEO_MODEL to move nodes.
  4720. --  Subtrees can only be moved from one branch to another on the same menu.
  4721. --
  4722. with VIDEO_TYPES;
  4723. package MOVE is
  4724.   procedure NODE_DIAG ( CUR_REC : in out VIDEO_TYPES.NODE_RECORD;
  4725.                         CHOICE  :    out VIDEO_TYPES.OPTIONS );
  4726.   --
  4727.   -- Node_diag is the only routine visible outside this package. 
  4728.   -- It begins by displaying the move header, then, if the current_node
  4729.   -- is a menu, it prompts for the branch to move from, and the branch to
  4730.   -- move to. If the branch to move from has no subtree or the branch to 
  4731.   -- move to has a subtree, the user is warned, and prompted for another 
  4732.   -- branch. If the move is successful, the current_record is 
  4733.   -- rewritten. If the current_node is not a menu, the move operation
  4734.   -- is not allowed.
  4735.   --
  4736. end MOVE;
  4737.   
  4738. with PASS_PROCS, COMMON_MESSAGES, PROMPT_MESSAGES, VIDEO_IO, 
  4739.      COMMON_PROCS, MODEL_PROCS;
  4740. package body MOVE is
  4741.   use VIDEO_TYPES, COMMON_MESSAGES, PROMPT_MESSAGES;
  4742.   
  4743.   EXCEPT : constant STRING(1..24) := "EXCEPTION RAISED IN MOVE";
  4744.     
  4745.   BLANKS : STRING (1..14) := "              ";
  4746.     
  4747.   MOVE_HEADER : constant VIDEO_TYPES.HEADER_TYPE :=
  4748.      (1=>BLANKS & "*****************************************************" &
  4749.          BLANKS,
  4750.       2=>BLANKS & "*                                                   *" &
  4751.          BLANKS,
  4752.       3=>BLANKS & "*             ***** MOVE  MODE *****                *" &
  4753.          BLANKS,
  4754.       4=>BLANKS & "*                                                   *" &
  4755.          BLANKS,
  4756.       5=>BLANKS & "*****************************************************" &
  4757.          BLANKS );
  4758.          
  4759.   type NUMBER_ARRAY is array (ONE..FIFTEEN) of STRING(1..2);
  4760.   
  4761.   NUMBER : constant NUMBER_ARRAY := ( "1 ","2 ","3 ","4 ","5 ","6 ","7 ","8 ",
  4762.                                       "9 ","10","11","12","13","14","15" );
  4763.                              
  4764.   procedure NODE_DIAG ( CUR_REC : in out VIDEO_TYPES.NODE_RECORD;
  4765.                         CHOICE  :    out VIDEO_TYPES.OPTIONS ) is
  4766.                         
  4767.     NEW_BRANCH_NUM : VIDEO_TYPES.OPTIONS;
  4768.     NEXT_REC       : VIDEO_TYPES.NODE_RECORD;
  4769.     
  4770.   begin
  4771.     MODEL_PROCS.PUT_HEADER ( MOVE_HEADER );
  4772.     if CUR_REC.NODE_TYPE = MENU then
  4773.       loop  -- until choice is valid
  4774.         CHOICE := MODEL_PROCS.GET_BRANCH ( PROMPT(BR_NO_MOV_FRM) );
  4775.         case CHOICE is
  4776.           when SLASH =>
  4777.             exit;
  4778.           when ONE..FIFTEEN =>
  4779.             if CUR_REC.OPTION( CHOICE ) /= VIDEO_IO.END_REC then
  4780.               exit;
  4781.             else  -- no submodel at this branch
  4782.               COMMON_PROCS.MSG_PROC ( "**ERROR** THERE IS NO SUBMODEL " &
  4783.                                       "CONNECTED TO BRANCH " & NUMBER(CHOICE),
  4784.                                        ERROR_LINE );
  4785.             end if;  -- cur_rec.option(choice) /= end_rec
  4786.           when others =>
  4787.             COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP), ERROR_LINE );
  4788.         end case;  -- choice
  4789.       end loop;  -- until choice is valid
  4790.       while CHOICE /= SLASH loop
  4791.         NEW_BRANCH_NUM := MODEL_PROCS.GET_BRANCH ( PROMPT(BR_NO_MOV_TO) );
  4792.         case NEW_BRANCH_NUM is
  4793.           when SLASH =>
  4794.             CHOICE := NEW_BRANCH_NUM;
  4795.           when ONE..FIFTEEN =>
  4796.             if CUR_REC.OPTION(NEW_BRANCH_NUM) = VIDEO_IO.END_REC then
  4797.               VIDEO_IO.READ_NODE ( NEXT_REC, CUR_REC.OPTION(CHOICE) );
  4798.               NEXT_REC.LAST_NODE := CUR_REC.POSITION;
  4799.               exit;
  4800.             else  -- new_branch is not free
  4801.               COMMON_PROCS.MSG_PROC ( "**ERROR** THERE IS ALREADY A SUBMODEL " &
  4802.                                       "CONNECTED TO BRANCH " &
  4803.                                        NUMBER(NEW_BRANCH_NUM), ERROR_LINE );
  4804.             end if;  -- cur_rec.option(new_branch_num) = end_rec
  4805.           when others =>
  4806.             COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP), ERROR_LINE );
  4807.         end case;  -- new_branch_num
  4808.       end loop;  -- choice /= slash
  4809.       if CHOICE /= SLASH then 
  4810.         -- user did not cancel
  4811.         VIDEO_IO.WRITE_NODE ( NEXT_REC );
  4812.         CUR_REC.OPTION( CHOICE ) := VIDEO_IO.END_REC;
  4813.         CUR_REC.OPTION( NEW_BRANCH_NUM ) := NEXT_REC.POSITION;
  4814.         VIDEO_IO.WRITE_NODE ( CUR_REC );
  4815.       end if;  -- choice /= slash
  4816.     else  -- cur_rec.node_type = program or menu
  4817.       COMMON_PROCS.MSG_PROC ( "**ERROR** THE MOVE OPERATION WAS NOT " &
  4818.                               "INVOKED AT A MENU NODE", ERROR_LINE );
  4819.       CHOICE := SLASH;
  4820.     end if;  -- cur_rec.node_type = menu
  4821.   exception
  4822.     when others =>
  4823.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS NODE_DIAG");
  4824.       raise;
  4825.   end NODE_DIAG;
  4826.   
  4827. end MOVE;
  4828. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4829. --modify.txt
  4830. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4831. -- **********************************************************************
  4832. -- *                                                                    *
  4833. -- *                     PACKAGE: MODIFY                                *
  4834. -- *                     VERSION: 1.0a1                                 *
  4835. -- *                     DATE   : FEBRUARY, 1985                        *
  4836. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  4837. -- *                              AdaSoft, Inc.                         *
  4838. -- *                              Lanham, MD                            *
  4839. -- *                                                                    *
  4840. -- **********************************************************************
  4841. -- 
  4842. --  This package contains subroutines used by VIDEO_MODEL to modify nodes.
  4843. --
  4844. with VIDEO_TYPES;
  4845. package MODIFY is
  4846.     
  4847.   procedure NODE_DIAG ( CUR_REC : in out VIDEO_TYPES.NODE_RECORD;
  4848.                         BOOT_REC: in out VIDEO_TYPES.NODE_RECORD;
  4849.                         CHOICE  :    out VIDEO_TYPES.OPTIONS );
  4850.   -- Node_diag is the only routine visible outside of this package. It
  4851.   -- prompts the user to modify the boot record defaults, or the current
  4852.   -- node. If boot record is to be modified, only the default directory or
  4853.   -- device names can be modified. In addition, if there is a password, it
  4854.   -- is displayed, and can be modified or removed. If there is no password,
  4855.   -- a password can be added.
  4856.   --   If the user wishes to modify the current node, the current filename
  4857.   -- will be displayed and can be modified, and the current password will
  4858.   -- be displayed and can be modified. 
  4859.   --   The user can choose to display only by accepting the defaults ( the
  4860.   -- current parameters ). If nothing new is entered, the record is not
  4861.   -- updated. 
  4862.   --   If any parameters have been changed, the user is asked to confirm
  4863.   -- that these changes are to be accepted. If no, no changes are made.
  4864.   --
  4865. end MODIFY;
  4866.  
  4867. with PASS_PROCS, COMMON_MESSAGES, PROMPT_MESSAGES, SYSTEM_DEPENDENT,
  4868.      VIDEO_IO, COMMON_PROCS, MODEL_PROCS;
  4869. package body MODIFY is
  4870.   use VIDEO_TYPES, COMMON_MESSAGES, PROMPT_MESSAGES;
  4871.   
  4872.   EXCEPT : constant STRING(1..32) := "EXCEPTION RAISED IN MODEL_PROCS ";
  4873.   
  4874.   type MOD_CHOICE is ( PARMS, CUR_NODE, QUIT );  -- local type
  4875.     
  4876.   BLANKS : STRING (1..14) := "              ";
  4877.     
  4878.   MODIFY_HEADER : constant VIDEO_TYPES.HEADER_TYPE :=
  4879.      (1=>BLANKS & "*****************************************************" &
  4880.          BLANKS,
  4881.       2=>BLANKS & "*                                                   *" &
  4882.          BLANKS,
  4883.       3=>BLANKS & "*            ***** MODIFY  MODE *****               *" &
  4884.          BLANKS,
  4885.       4=>BLANKS & "*                                                   *" &
  4886.          BLANKS,
  4887.       5=>BLANKS & "*****************************************************" &
  4888.          BLANKS );
  4889.          
  4890.   procedure MODIFY_COMMON ( CUR_REC : in    VIDEO_TYPES.NODE_RECORD;
  4891.                             FILENAM :   out VIDEO_TYPES.FILE_NAME;
  4892.                             PASS    :   out PASS_PROCS.PASSWORD_TYPE ) is
  4893.   -- Modify_common displays the current filename and prompts for changes.
  4894.   -- It then displays the current password and prompts for changes. These
  4895.   -- are returned to the calling routine.
  4896.  
  4897.     DEF_FILNAM : VIDEO_TYPES.FILE_NAME;
  4898.     DEF_PASS   : STRING(1..1) := " ";
  4899.     AFFIRMATIVE: BOOLEAN := FALSE;
  4900.     CHOICE     : VIDEO_TYPES.OPTIONS;
  4901.     
  4902.   begin
  4903.     case CUR_REC.NODE_TYPE is
  4904.       -- set up the default filename for display
  4905.       when BOOT =>
  4906.         DEF_FILNAM := CUR_REC.DEFAULT;
  4907.       when MENU =>
  4908.         DEF_FILNAM := CUR_REC.MENU_PATH;
  4909.       when others =>
  4910.         DEF_FILNAM := CUR_REC.PATH;
  4911.     end case;
  4912.     FILENAM :=
  4913.       SYSTEM_DEPENDENT.GET_FILENAME ( DEF_FILNAM, PROMPT(NEW_DEVNAM), 
  4914.                                       PROMPT (NEW_DIRNAM), PROMPT (NEW_FILNAM), 
  4915.                                       CUR_REC.NODE_TYPE );
  4916.     if PASS_PROCS.HAS_PASSWORD ( CUR_REC.NODE_PASSWORD ) then
  4917.       COMMON_PROCS.MSG_PROC ("THE CURRENT PASSWORD IS " & 
  4918.                               PASS_PROCS.PASS_TO_STRING (CUR_REC.NODE_PASSWORD),
  4919.                               ERROR_LINE );
  4920.     else  -- node is not password protected
  4921.       COMMON_PROCS.MSG_PROC ( "NODE IS NOT CURRENTLY PASSWORD PROTECTED", 
  4922.                                ERROR_LINE );
  4923.     end if;  -- has_password
  4924.     MODEL_PROCS.GET_ANSWER ("ENTER 'YES' TO MODIFY PASSWORD",
  4925.                              AFFIRMATIVE, CHOICE );
  4926.     if AFFIRMATIVE then  
  4927.       -- user wants to modify or add password
  4928.       COMMON_PROCS.GET_NEW_PASSWORD ( PROMPT(NEW_PASS), DEF_PASS, PASS );
  4929.     end if;  -- if affirmative
  4930.       COMMON_PROCS.MOVE_CURSOR ( ERROR_LINE );
  4931.       COMMON_PROCS.CLEAR_LINE;
  4932.   exception
  4933.     when USER_QUIT =>
  4934.       raise;
  4935.     when others =>
  4936.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS MODIFY_COMMON");
  4937.       raise;
  4938.   end MODIFY_COMMON;
  4939.   
  4940.   procedure MODIFY_NODE ( REC     : in out VIDEO_TYPES.NODE_RECORD;
  4941.                           CHOICE  :    out VIDEO_TYPES.OPTIONS ) is
  4942.   -- Modify_node first displays the type of node being modified. It then
  4943.   -- calls modify common to display current parameters and get changes.
  4944.   -- If the filename returned has been changed, or the password has been
  4945.   -- changed, the user is asked to confirm the changes. If yes, then the 
  4946.   -- filename and/or password parts of the node record are updated. Otherwise,
  4947.   -- the record remains the same. 
  4948.   --
  4949.     DISPLAY_NODE : STRING(1..4);
  4950.     NEW_FILENAME : VIDEO_TYPES.FILE_NAME;
  4951.     DEF_NAME     : VIDEO_TYPES.FILE_NAME;
  4952.     NEW_PASSWRD  : PASS_PROCS.PASSWORD_TYPE;
  4953.     FILE_CHANGED : BOOLEAN := TRUE;
  4954.     PASS_CHANGED : BOOLEAN := TRUE;
  4955.   
  4956.   begin
  4957.     case REC.NODE_TYPE is
  4958.       -- set up defaults
  4959.       when BOOT =>
  4960.         DISPLAY_NODE := "BOOT";
  4961.         DEF_NAME := REC.DEFAULT;
  4962.       when MENU        => 
  4963.         DISPLAY_NODE := "MENU";
  4964.         DEF_NAME := REC.MENU_PATH;
  4965.       when INSTRUCTION => 
  4966.         DISPLAY_NODE := "INST";
  4967.         DEF_NAME := REC.PATH;
  4968.       when PROGRAM     => 
  4969.         DISPLAY_NODE := "PROG";
  4970.         DEF_NAME := REC.PATH;
  4971.     end case;
  4972.     COMMON_PROCS.MSG_PROC ("THE TYPE OF NODE BEING MODIFIED OR DISPLAYED IS " &
  4973.                             DISPLAY_NODE, ERROR_LINE );
  4974.     MODIFY_COMMON ( REC, NEW_FILENAME, NEW_PASSWRD );
  4975.     if NEW_FILENAME = DEF_NAME then
  4976.       -- file was not changed
  4977.       FILE_CHANGED := FALSE;
  4978.     end if;  -- otherwise, filename was changed
  4979.     if NEW_PASSWRD = REC.NODE_PASSWORD then
  4980.       -- password was not changed
  4981.       PASS_CHANGED := FALSE;
  4982.     end if;  -- otherwise, password was changed
  4983.     if FILE_CHANGED or else PASS_CHANGED then
  4984.       -- filename or password were changed
  4985.       if MODEL_PROCS.CONFIRMED ("SAVE CHANGES TO THIS NODE (Y/N) ?") then
  4986.         -- user confirmed changes
  4987.         if PASS_CHANGED then
  4988.           -- update the password
  4989.           REC.NODE_PASSWORD := NEW_PASSWRD;
  4990.         end if;
  4991.         if FILE_CHANGED then
  4992.           -- update the filename
  4993.           case REC.NODE_TYPE is
  4994.             when BOOT =>
  4995.               REC.DEFAULT := NEW_FILENAME;
  4996.             when MENU =>
  4997.               REC.MENU_PATH := NEW_FILENAME;
  4998.             when others =>
  4999.               REC.PATH := NEW_FILENAME;
  5000.           end case;  -- node type
  5001.         end if;  -- file was changed
  5002.       else  -- user did not confirm changes
  5003.         CHOICE := SLASH;
  5004.       end if;  -- confirmed changes
  5005.     else -- no changes were made
  5006.       CHOICE := SLASH;
  5007.     end if;  -- changes were made
  5008.   exception
  5009.     when USER_QUIT =>
  5010.       raise;
  5011.     when others =>
  5012.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS MODIFY_NODE");
  5013.       raise;
  5014.   end MODIFY_NODE;
  5015.   
  5016.   function MODIFY_WHAT return MOD_CHOICE is
  5017.   -- Modify_what asks if the user wishes to modify the boot record. If so,
  5018.   -- the boot record becomes the current record. Otherwise, the current 
  5019.   -- record will be modified. 
  5020.   
  5021.     CHOICE  : MOD_CHOICE := QUIT;
  5022.     AFFIRMATIVE : BOOLEAN := FALSE;
  5023.     OPT     : VIDEO_TYPES.OPTIONS;
  5024.   
  5025.   begin
  5026.     MODEL_PROCS.GET_ANSWER ( PROMPT(MOD_APL_PRMS), AFFIRMATIVE, OPT );
  5027.     if AFFIRMATIVE then
  5028.       -- boot rec will be displayed or modified
  5029.       CHOICE := PARMS;
  5030.       SYSTEM_DEPENDENT.SET_MODIFY_FLAG ( ON );
  5031.     else  -- current record will be modified
  5032.       CHOICE := CUR_NODE;
  5033.     end if;  -- affirmative, otherwise quit
  5034.     return CHOICE;
  5035.   exception 
  5036.     when others =>
  5037.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS MODIFY_WHAT");
  5038.   end MODIFY_WHAT;
  5039.   
  5040.   procedure NODE_DIAG ( CUR_REC : in out VIDEO_TYPES.NODE_RECORD;
  5041.                         BOOT_REC: in out VIDEO_TYPES.NODE_RECORD;
  5042.                         CHOICE  :    out VIDEO_TYPES.OPTIONS ) is
  5043.                         
  5044.     CHANGE : MOD_CHOICE;
  5045.     
  5046.   begin
  5047.     MODEL_PROCS.PUT_HEADER ( MODIFY_HEADER );
  5048.     CHANGE := MODIFY_WHAT;
  5049.     case CHANGE is
  5050.       -- evaluated user response
  5051.       when PARMS =>
  5052.         MODIFY_NODE ( BOOT_REC, CHOICE );
  5053.         if CHOICE /= SLASH then
  5054.           -- user made changes
  5055.           VIDEO_IO.WRITE_NODE ( BOOT_REC );
  5056.         end if;
  5057.       when CUR_NODE =>
  5058.         MODIFY_NODE ( CUR_REC, CHOICE );
  5059.         if CHOICE /= SLASH then
  5060.           -- user made changes
  5061.           VIDEO_IO.WRITE_NODE ( CUR_REC );
  5062.         end if;
  5063.       when QUIT =>
  5064.         CHOICE := SLASH;
  5065.     end case;
  5066.   exception
  5067.     when USER_QUIT =>
  5068.       CHOICE := SLASH;
  5069.     when others =>
  5070.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS NODE_DIAG");
  5071.       raise;
  5072.   end NODE_DIAG;
  5073.   
  5074. end MODIFY;
  5075. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  5076. --insert.txt
  5077. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  5078. -- **********************************************************************
  5079. -- *                                                                    *
  5080. -- *                     PACKAGE: INSERT                                *
  5081. -- *                     VERSION: 1.0a1                                 *
  5082. -- *                     DATE   : JANUARY, 1985                         *
  5083. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  5084. -- *                              AdaSoft, Inc.                         *
  5085. -- *                              Lanham, MD                            *
  5086. -- *                                                                    *
  5087. -- **********************************************************************
  5088. --
  5089. --   This package contains all the routines used by VIDEO_MODEL to insert nodes.
  5090. --
  5091. with VIDEO_TYPES;
  5092. package INSERT is
  5093.     
  5094.   procedure NODE_DIAG ( CUR_REC : in out VIDEO_TYPES.NODE_RECORD;
  5095.                         BOOT_REC: in out VIDEO_TYPES.NODE_RECORD;
  5096.                         CHOICE  : in out VIDEO_TYPES.OPTIONS );
  5097.   --
  5098.   -- Node_diag is the only procedure in insert visible outside the package.
  5099.   -- It first displays the insert header, then prompts for the node type to
  5100.   -- be inserted. It then calls the insert routine corresponding to the 
  5101.   -- node type.
  5102.   --
  5103. end INSERT;
  5104.  
  5105. with PASS_PROCS, COMMON_MESSAGES, PROMPT_MESSAGES, 
  5106.      VIDEO_IO, COMMON_PROCS, MODEL_PROCS;
  5107. package body INSERT is
  5108.   use VIDEO_TYPES, COMMON_MESSAGES, PROMPT_MESSAGES;
  5109.   
  5110.   EXCEPT : constant STRING(1..27) := "EXCEPTION RAISED IN INSERT ";
  5111.     
  5112.   NO_DEFAULT: STRING(1..1) := " ";
  5113.   BLANKS : STRING (1..14) := "              ";
  5114.     
  5115.   INSERT_HEADER : constant VIDEO_TYPES.HEADER_TYPE :=
  5116.      (1=>BLANKS & "*****************************************************" &
  5117.          BLANKS,
  5118.       2=>BLANKS & "*                                                   *" &
  5119.          BLANKS,
  5120.       3=>BLANKS & "*            ***** INSERT  MODE *****               *" &
  5121.          BLANKS,
  5122.       4=>BLANKS & "*                                                   *" &
  5123.          BLANKS,
  5124.       5=>BLANKS & "*****************************************************" &
  5125.          BLANKS );
  5126.          
  5127.   procedure INSERT_COMMON ( BOOT_REC : in    VIDEO_TYPES.NODE_RECORD;
  5128.                             NODE_TYP : in    VIDEO_TYPES.NODE;
  5129.                             FILENAM  :   out VIDEO_TYPES.FILE_NAME;
  5130.                             PASS     :   out PASS_PROCS.PASSWORD_TYPE ) is
  5131.   --
  5132.   -- Insert_common prompts the user for the filename and password for the
  5133.   -- node to be inserted.
  5134.   --
  5135.   begin
  5136.     MODEL_PROCS.GET_COMMON ( BOOT_REC.DEFAULT, PROMPT (DEVNAM), 
  5137.                              PROMPT (DIRNAM), PROMPT (ADD_FILNAM), 
  5138.                              PROMPT(PASSWRD), NODE_TYP, FILENAM, PASS );
  5139.   exception
  5140.     when USER_QUIT =>
  5141.       raise;
  5142.     when others =>
  5143.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS INSERT_COMMON");
  5144.       raise;
  5145.   end INSERT_COMMON;
  5146.   
  5147.   function INSERT_BRANCH ( MSG : in STRING;
  5148.                            CUR_REC : in VIDEO_TYPES.NODE_RECORD )
  5149.     return VIDEO_TYPES.OPTIONS is
  5150.   -- 
  5151.   -- Insert_branch is called when the current_record is a menu. It 
  5152.   -- prompts the user for a valid input branch. If the branch number 
  5153.   -- entered is free, it tells the user to either choose another branch
  5154.   -- or use the add mode.
  5155.   --
  5156.     CHOICE : VIDEO_TYPES.OPTIONS;
  5157.     TRIES  : NATURAL range 0..2 := 0;
  5158.   
  5159.   begin
  5160.     loop  -- main loop
  5161.       TRIES := TRIES + 1;
  5162.       CHOICE := MODEL_PROCS.GET_BRANCH ( MSG );
  5163.       case CHOICE is
  5164.         when SLASH =>
  5165.           exit;
  5166.         when ONE..FIFTEEN =>
  5167.           if CUR_REC.OPTION(CHOICE) = VIDEO_IO.END_REC then
  5168.             COMMON_PROCS.MSG_PROC ( ERRORS(INV_BR_NO), ERROR_LINE );
  5169.             if TRIES = 2 then
  5170.               COMMON_PROCS.MSG_PROC ( "**ERROR** BRANCH IS NOT CONNECTED" &
  5171.                                       " TO A NODE", ERROR_LINE );
  5172.               if MODEL_PROCS.CONFIRMED ( "DO YOU WANT TO TRY ANOTHER " &
  5173.                                          "BRANCH (Y/N)?") then
  5174.                 TRIES := 0;
  5175.               else  -- not confirmed
  5176.                 COMMON_PROCS.MSG_PROC ( "TO ADD AT THIS NODE USE ADD MODE",
  5177.                                          ERROR_LINE );
  5178.                 loop  -- until slash is entered
  5179.                   COMMON_PROCS.PROMPT_MSG ("ENTER SLASH TO RETURN TO " &
  5180.                                            "MAINTENANCE MENU" );
  5181.                   CHOICE := COMMON_PROCS.GET_INPUT;
  5182.                   exit when CHOICE = SLASH;
  5183.                 end loop;  -- until slash is entered
  5184.               end if;  -- confirmed try again
  5185.             end if;  -- tries = 2
  5186.           else  -- cur_rec.option(choice) /= end_rec
  5187.             exit;
  5188.           end if;  -- cur_rec.option(choice) = end_rec
  5189.         when others =>
  5190.           null;
  5191.       end case;  -- choice
  5192.     end loop;  -- main
  5193.     return CHOICE;
  5194.   exception
  5195.     when others =>
  5196.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & " SUBROUTINE IS INSERT_BRANCH");
  5197.       raise;
  5198.   end INSERT_BRANCH;
  5199.     
  5200.   function GET_OUT_BRANCH ( MSG : in STRING ) return VIDEO_TYPES.OPTIONS is
  5201.     
  5202.     CHOICE : VIDEO_TYPES.OPTIONS;
  5203.   --
  5204.   -- Get_out_branch is called if the node to be inserted is a menu. It
  5205.   -- prompts the user for the branch to attach the existing subtree.
  5206.   --
  5207.   begin
  5208.     loop  -- until valid branch
  5209.       CHOICE := MODEL_PROCS.GET_BRANCH ( MSG );
  5210.       case CHOICE is
  5211.         when SLASH|ONE..FIFTEEN =>
  5212.           exit;
  5213.         when others =>
  5214.           COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP), ERROR_LINE );
  5215.       end case;  -- choice
  5216.     end loop;  -- until valid branch
  5217.     return CHOICE;
  5218.   exception
  5219.     when others =>
  5220.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS GET_OUT_BRANCH");
  5221.       raise;
  5222.   end GET_OUT_BRANCH;
  5223.   
  5224.   procedure INSERT_NODE (NEW_REC : in out VIDEO_TYPES.NODE_RECORD;
  5225.                          SUCCESS :    out BOOLEAN ) is
  5226.   --
  5227.   -- Insert_node prompts the user to confirm the insert. If confirmed, and
  5228.   -- node is inserted, success := true. Otherwise, success = false.
  5229.   --
  5230.   begin
  5231.     SUCCESS := FALSE;
  5232.     if MODEL_PROCS.CONFIRMED ( "INSERT THIS NODE (Y/N) ?" ) then
  5233.       VIDEO_IO.WRITE_NODE ( NEW_REC );
  5234.       SUCCESS := TRUE;
  5235.     end if;  -- confirmed insert
  5236.   exception
  5237.     when others =>
  5238.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS INSERT_NODE");
  5239.       raise;
  5240.   end INSERT_NODE;
  5241.   
  5242.   procedure INSERT_MENU ( CUR_REC   : in out VIDEO_TYPES.NODE_RECORD;
  5243.                           BOOT_REC  : in out VIDEO_TYPES.NODE_RECORD;
  5244.                           IN_BRANCH : in out VIDEO_TYPES.OPTIONS ) is
  5245.   --
  5246.   -- Insert_menu first prompts for the in_branch if the current_node is
  5247.   -- a menu. Otherwise, it checks to see if current_node.next_node is 
  5248.   -- attached to a subtree. If the user does not cancel insert, then the
  5249.   -- user is prompted for the out_branch to attach the subtree. If there
  5250.   -- is no free space to recover, the position of the new record is set
  5251.   -- to end of file, otherwise, it is set to the first free space. The 
  5252.   -- user is then prompted for the filename and password for the node, and
  5253.   -- the record is created. If the user confirms the insert, and the 
  5254.   -- write is successful, the next_node is updated and written. If that
  5255.   -- write succeeds, the boot and current records are updated.
  5256.   --
  5257.     NEW_REC        : VIDEO_TYPES.NODE_RECORD;
  5258.     NEXT_REC       : VIDEO_TYPES.NODE_RECORD;
  5259.     FILENAM        : VIDEO_TYPES.FILE_NAME;
  5260.     BRANCHES       : VIDEO_TYPES.MENU_OPTIONS := 
  5261.                                             (ONE..FIFTEEN => VIDEO_IO.END_REC);
  5262.     OUT_BRANCH     : VIDEO_TYPES.OPTIONS;
  5263.     PASS           : PASS_PROCS.PASSWORD_TYPE;
  5264.     NEW_POSITION   : NATURAL;
  5265.     NEXT_FREE_NODE : NATURAL;
  5266.     LAST_MENU      : NATURAL;
  5267.     NEXT_NODE      : NATURAL;
  5268.     INSERT_OK      : BOOLEAN;
  5269.     
  5270.   begin
  5271.     if CUR_REC.NODE_TYPE = MENU then
  5272.       IN_BRANCH := INSERT_BRANCH ( PROMPT(ADD_BR_NO),
  5273.                                    CUR_REC );
  5274.       if IN_BRANCH /= SLASH then
  5275.         NEXT_NODE := CUR_REC.OPTION(IN_BRANCH);
  5276.         LAST_MENU := CUR_REC.POSITION;
  5277.       end if;
  5278.     else  -- node_type = program or instruction
  5279.       if CUR_REC.NEXT_NODE = VIDEO_IO.END_REC then
  5280.         COMMON_PROCS.MSG_PROC ( "**ERROR** THERE IS NO NODE ATTACHED TO " &
  5281.                                 "THIS NODE - USE ADD MODE", ERROR_LINE );
  5282.         IN_BRANCH := SLASH;
  5283.       else  -- current_record has a subtree
  5284.         NEXT_NODE := CUR_REC.NEXT_NODE;
  5285.       end if;  -- next_node = end_rec
  5286.       LAST_MENU := CUR_REC.LAST_MENU;
  5287.     end if;  -- node_type = menu
  5288.     if IN_BRANCH /= SLASH then
  5289.       -- user did not cancel
  5290.       OUT_BRANCH := GET_OUT_BRANCH ( PROMPT(CNCT_BR) );
  5291.       if OUT_BRANCH /= SLASH then
  5292.         -- user did not cancel
  5293.         BRANCHES(OUT_BRANCH) := NEXT_NODE;
  5294.         if BOOT_REC.NEXT_FREE_NODE = 0 then
  5295.           -- no free space to recover
  5296.           NEW_POSITION := BOOT_REC.LAST_FREE_NODE;
  5297.         else  -- free space to recover
  5298.           VIDEO_IO.READ_NODE ( NEW_REC, BOOT_REC.NEXT_FREE_NODE );
  5299.           NEXT_FREE_NODE := NEW_REC.LAST_NODE;
  5300.           NEW_POSITION := BOOT_REC.NEXT_FREE_NODE;
  5301.         end if;  -- next_free_node = 0
  5302.         INSERT_COMMON ( BOOT_REC, MENU, FILENAM, PASS );
  5303.         NEW_REC := ( MENU, CUR_REC.POSITION, LAST_MENU, NEW_POSITION,
  5304.                      PASS, FILENAM, BRANCHES );
  5305.         INSERT_NODE ( NEW_REC, INSERT_OK );
  5306.         if INSERT_OK then
  5307.           VIDEO_IO.READ_NODE ( NEXT_REC, NEW_REC.OPTION(OUT_BRANCH) );
  5308.           NEXT_REC.LAST_NODE := NEW_REC.POSITION;
  5309.           NEXT_REC.LAST_MENU := NEW_REC.POSITION;
  5310.           if BOOT_REC.NEXT_FREE_NODE = 0 then
  5311.             -- no free space to recover
  5312.             BOOT_REC.LAST_FREE_NODE := BOOT_REC.LAST_FREE_NODE + 1;
  5313.           else  -- free space to recover
  5314.             BOOT_REC.NEXT_FREE_NODE := NEXT_FREE_NODE;
  5315.           end if;  -- next_free_node = 0
  5316.           if CUR_REC.NODE_TYPE = MENU then
  5317.             CUR_REC.OPTION ( IN_BRANCH ) := NEW_REC.POSITION;
  5318.           else  -- node_type = program or instruction
  5319.             CUR_REC.NEXT_NODE := NEW_REC.POSITION;
  5320.           end if;  -- node_type = menu
  5321.           VIDEO_IO.WRITE_NODE ( BOOT_REC );
  5322.           VIDEO_IO.WRITE_NODE ( CUR_REC );
  5323.           VIDEO_IO.WRITE_NODE ( NEXT_REC );
  5324.         else  -- insert failed or was canceled
  5325.           IN_BRANCH := OUT_BRANCH;
  5326.         end if;  -- insert_ok
  5327.       end if;  -- out_branch /= slash
  5328.     end if;  -- in_branch /= slash
  5329.   exception
  5330.     when USER_QUIT =>
  5331.       raise;
  5332.     when others =>
  5333.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS INSERT_MENU");
  5334.       raise;
  5335.   end INSERT_MENU;
  5336.   
  5337.   procedure INSERT_INST ( CUR_REC   : in out VIDEO_TYPES.NODE_RECORD;
  5338.                           BOOT_REC  : in out VIDEO_TYPES.NODE_RECORD;
  5339.                           IN_BRANCH : in out VIDEO_TYPES.OPTIONS ) is
  5340.   --
  5341.   -- Insert_inst performs in the same manner as insert_menu except it does
  5342.   -- not prompt for an out_branch, and the record format is somewhat different.
  5343.   --
  5344.     NEW_REC        : VIDEO_TYPES.NODE_RECORD;
  5345.     NEXT_REC       : VIDEO_TYPES.NODE_RECORD;
  5346.     FILENAM        : VIDEO_TYPES.FILE_NAME;
  5347.     PASS           : PASS_PROCS.PASSWORD_TYPE;
  5348.     NEW_POSITION   : NATURAL;
  5349.     NEXT_FREE_NODE : NATURAL;
  5350.     NEXT_NODE      : NATURAL;
  5351.     LAST_MENU      : NATURAL;
  5352.     INSERT_OK      : BOOLEAN;
  5353.     
  5354.   begin
  5355.     if CUR_REC.NODE_TYPE = MENU then
  5356.       IN_BRANCH := INSERT_BRANCH ( PROMPT(ADD_BR_NO),
  5357.                                    CUR_REC );
  5358.       if IN_BRANCH /= SLASH then
  5359.         NEXT_NODE := CUR_REC.OPTION(IN_BRANCH);
  5360.         LAST_MENU := CUR_REC.POSITION;
  5361.       end if;
  5362.     else  -- node_type = program or instruction
  5363.       if CUR_REC.NEXT_NODE = VIDEO_IO.END_REC then
  5364.         -- next_node is free
  5365.         COMMON_PROCS.MSG_PROC ( "**ERROR** THERE IS NO NODE ATTACHED TO " &
  5366.                                 "THIS NODE - USE ADD MODE", ERROR_LINE );
  5367.         IN_BRANCH := SLASH;
  5368.       else  -- next_node has a subtree 
  5369.         NEXT_NODE := CUR_REC.NEXT_NODE;
  5370.       end if;  -- next_node = end_rec
  5371.       LAST_MENU := CUR_REC.LAST_MENU;
  5372.     end if;  -- node_type = menu
  5373.     if IN_BRANCH /= SLASH then
  5374.       -- user did not cancel
  5375.       INSERT_COMMON ( BOOT_REC, INSTRUCTION, FILENAM, PASS );
  5376.       if BOOT_REC.NEXT_FREE_NODE = 0 then
  5377.         -- no free space to recover
  5378.         NEW_POSITION := BOOT_REC.LAST_FREE_NODE;
  5379.       else  -- free space to recover
  5380.         VIDEO_IO.READ_NODE ( NEW_REC, BOOT_REC.NEXT_FREE_NODE );
  5381.         NEXT_FREE_NODE := NEW_REC.LAST_NODE;
  5382.         NEW_POSITION := BOOT_REC.NEXT_FREE_NODE;
  5383.       end if;  -- next_free_node = 0
  5384.       NEW_REC := ( INSTRUCTION, CUR_REC.POSITION, LAST_MENU, NEW_POSITION,
  5385.                    PASS, FILENAM, NEXT_NODE );
  5386.       INSERT_NODE ( NEW_REC, INSERT_OK );
  5387.       if INSERT_OK then
  5388.         -- update the next node
  5389.         VIDEO_IO.READ_NODE ( NEXT_REC, NEW_REC.NEXT_NODE );
  5390.         NEXT_REC.LAST_NODE := NEW_REC.POSITION;
  5391.         NEXT_REC.LAST_MENU := LAST_MENU;
  5392.         if BOOT_REC.NEXT_FREE_NODE = 0 then
  5393.           -- no free space to recover
  5394.           BOOT_REC.LAST_FREE_NODE := BOOT_REC.LAST_FREE_NODE + 1;
  5395.         else  -- free space to recover
  5396.           BOOT_REC.NEXT_FREE_NODE := NEXT_FREE_NODE;
  5397.         end if;  -- next_free_node = 0
  5398.         if CUR_REC.NODE_TYPE = MENU then
  5399.           CUR_REC.OPTION ( IN_BRANCH ) := NEW_REC.POSITION;
  5400.         else  -- node_type = program or instruction
  5401.           CUR_REC.NEXT_NODE := NEW_REC.POSITION;
  5402.         end if;  -- node_type = menu
  5403.         VIDEO_IO.WRITE_NODE ( BOOT_REC );
  5404.         VIDEO_IO.WRITE_NODE ( CUR_REC );
  5405.         VIDEO_IO.WRITE_NODE ( NEXT_REC );
  5406.       end if;  -- insert ok
  5407.     end if;  -- in_branch /= slash
  5408.   exception
  5409.     when USER_QUIT =>
  5410.       raise;
  5411.     when others =>
  5412.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS INSERT_INST");
  5413.       raise;
  5414.   end INSERT_INST;
  5415.                        
  5416.   procedure INSERT_PROG ( CUR_REC   : in out VIDEO_TYPES.NODE_RECORD;
  5417.                           BOOT_REC  : in out VIDEO_TYPES.NODE_RECORD;
  5418.                           IN_BRANCH : in out VIDEO_TYPES.OPTIONS ) is
  5419.   --
  5420.   -- Insert_prog performs in the same manner as insert_menu except it does
  5421.   -- not prompt for an out_branch, and the record format is somewhat different.
  5422.   --
  5423.     NEW_REC        : VIDEO_TYPES.NODE_RECORD;
  5424.     NEXT_REC       : VIDEO_TYPES.NODE_RECORD;
  5425.     FILENAM        : VIDEO_TYPES.FILE_NAME;
  5426.     PASS           : PASS_PROCS.PASSWORD_TYPE;
  5427.     NEW_POSITION   : NATURAL;
  5428.     NEXT_FREE_NODE : NATURAL;
  5429.     NEXT_NODE      : NATURAL;
  5430.     LAST_MENU      : NATURAL;
  5431.     INSERT_OK      : BOOLEAN;
  5432.     
  5433.   begin
  5434.     if CUR_REC.NODE_TYPE = MENU then
  5435.       IN_BRANCH := INSERT_BRANCH ( PROMPT(ADD_BR_NO),
  5436.                                    CUR_REC );
  5437.       if IN_BRANCH /= SLASH then
  5438.         NEXT_NODE := CUR_REC.OPTION(IN_BRANCH);
  5439.         LAST_MENU := CUR_REC.POSITION;
  5440.       end if;
  5441.     else  -- node_type = program or instruction
  5442.       if CUR_REC.NEXT_NODE = VIDEO_IO.END_REC then
  5443.         COMMON_PROCS.MSG_PROC ( "**ERROR** THERE IS NO NODE ATTACHED TO " &
  5444.                                 "THIS NODE - USE ADD MODE", ERROR_LINE );
  5445.         IN_BRANCH := SLASH;
  5446.       else  -- next_node has a subtree
  5447.         NEXT_NODE := CUR_REC.NEXT_NODE;
  5448.       end if;  -- next_node = end_rec
  5449.       LAST_MENU := CUR_REC.LAST_MENU;
  5450.     end if;  -- node_type = menu
  5451.     if IN_BRANCH /= SLASH then
  5452.       -- user did not cancel
  5453.       INSERT_COMMON ( BOOT_REC, PROGRAM, FILENAM, PASS );
  5454.       if BOOT_REC.NEXT_FREE_NODE = 0 then
  5455.         -- no free space to recover
  5456.         NEW_POSITION := BOOT_REC.LAST_FREE_NODE;
  5457.       else  -- free space to recover
  5458.         VIDEO_IO.READ_NODE ( NEW_REC, BOOT_REC.NEXT_FREE_NODE );
  5459.         NEXT_FREE_NODE := NEW_REC.LAST_NODE;
  5460.         NEW_POSITION := BOOT_REC.NEXT_FREE_NODE;
  5461.       end if;  -- next_free_node = 0
  5462.       NEW_REC := ( PROGRAM, CUR_REC.POSITION, LAST_MENU, NEW_POSITION,
  5463.                    PASS, FILENAM, NEXT_NODE );
  5464.       INSERT_NODE ( NEW_REC, INSERT_OK );
  5465.       if INSERT_OK then
  5466.         -- update next record
  5467.         VIDEO_IO.READ_NODE ( NEXT_REC, NEW_REC.NEXT_NODE );
  5468.         NEXT_REC.LAST_NODE := NEW_REC.POSITION;
  5469.         NEXT_REC.LAST_MENU := NEW_REC.LAST_MENU;
  5470.         if BOOT_REC.NEXT_FREE_NODE = 0 then
  5471.           -- no free space to recover
  5472.           BOOT_REC.LAST_FREE_NODE := BOOT_REC.LAST_FREE_NODE + 1;
  5473.         else  -- free space to recover
  5474.           BOOT_REC.NEXT_FREE_NODE := NEXT_FREE_NODE;
  5475.         end if;  -- next_free_node = 0
  5476.         if CUR_REC.NODE_TYPE = MENU then
  5477.           CUR_REC.OPTION ( IN_BRANCH ) := NEW_REC.POSITION;
  5478.         else  -- node_type = program or instruction
  5479.           CUR_REC.NEXT_NODE := NEW_REC.POSITION;
  5480.         end if;  -- node_type = menu
  5481.         VIDEO_IO.WRITE_NODE ( BOOT_REC );
  5482.         VIDEO_IO.WRITE_NODE ( CUR_REC );
  5483.         VIDEO_IO.WRITE_NODE ( NEXT_REC );
  5484.       end if;  -- insert ok
  5485.     end if;  -- in_branch /= slash
  5486.   exception
  5487.     when USER_QUIT =>
  5488.       raise;
  5489.     when others =>
  5490.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS INSERT_PROG");
  5491.       raise;
  5492.   end INSERT_PROG;
  5493.                        
  5494.   procedure NODE_DIAG ( CUR_REC : in out VIDEO_TYPES.NODE_RECORD;
  5495.                         BOOT_REC: in out VIDEO_TYPES.NODE_RECORD;
  5496.                         CHOICE  : in out VIDEO_TYPES.OPTIONS ) is
  5497.     
  5498.     NEW_NODE_TYPE : VIDEO_TYPES.USER_NODE;
  5499.   begin
  5500.     MODEL_PROCS.PUT_HEADER ( INSERT_HEADER );
  5501.     NEW_NODE_TYPE := COMMON_PROCS.GET_NODE_TYPE ( PROMPT(ADD_TYP) );
  5502.     case NEW_NODE_TYPE is
  5503.       when MENU =>
  5504.         INSERT_MENU ( CUR_REC, BOOT_REC, CHOICE );
  5505.       when INSTRUCTION =>
  5506.         INSERT_INST ( CUR_REC, BOOT_REC, CHOICE );
  5507.       when PROGRAM =>
  5508.         INSERT_PROG ( CUR_REC, BOOT_REC, CHOICE );
  5509.     end case;
  5510.   exception
  5511.     when USER_QUIT =>
  5512.       CHOICE := SLASH;
  5513.     when others =>
  5514.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS INSERT_NODE_DIAG");
  5515.       raise;
  5516.   end NODE_DIAG;
  5517.   
  5518. end INSERT;
  5519. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  5520. --model.txt
  5521. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  5522. -- **********************************************************************
  5523. -- *                                                                    *
  5524. -- *                     PACKAGE: MODEL                                 *
  5525. -- *                     VERSION: 1.0a1                                 *
  5526. -- *                     DATE   : FEBRUARY, 1985                        *
  5527. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  5528. -- *                              AdaSoft, Inc.                         *
  5529. -- *                              Lanham, MD                            *
  5530. -- *                                                                    *
  5531. -- **********************************************************************
  5532. --
  5533. --  This package exports several routines to VIDEO_MODEL. It also serves
  5534. --  as a repository for some global variables.
  5535. --
  5536. with VIDEO_TYPES;
  5537. package MODEL is
  5538.   --
  5539.   -- MODEL global variables
  5540.   --
  5541.   PASSWORD_FLAG : VIDEO_TYPES.FLAG := VIDEO_TYPES.ON;
  5542.   ERROR_MSG     : VIDEO_TYPES.FLAG := VIDEO_TYPES.ON;
  5543.   READ_REC_NUM  : NATURAL;
  5544.   CUR_REC_NUM   : NATURAL;
  5545.   
  5546.   procedure PROG_PROC ( PROG_MSG : in     STRING;
  5547.                         REC      : in     VIDEO_TYPES.NODE_RECORD;
  5548.                         CHOICE   :    out VIDEO_TYPES.OPTIONS;
  5549.                         NEXT_REC :    out NATURAL );
  5550.    --
  5551.    -- Prog_proc is the routine used by VIDEO_MODEL when it encounters a
  5552.    -- program node. It displays the name of the program that will be run
  5553.    -- during an application session, and prompts the user to either
  5554.    -- return to the previous menu or proceed to the next node. It also
  5555.    -- accepts any special character.
  5556.    --
  5557.                               
  5558.   procedure PROCESS_OPTION ( LAST_MENU_PTR : in     NATURAL;
  5559.                              CUR_REC       : in out VIDEO_TYPES.NODE_RECORD;
  5560.                              ROOT_NUM      : in     NATURAL;
  5561.                              BOOT_REC      : in out VIDEO_TYPES.NODE_RECORD;
  5562.                              CHOICE        : in out VIDEO_TYPES.OPTIONS );
  5563.   -- 
  5564.   -- Process_option recieves the special character entered at any node and
  5565.   -- responds to it. The only difference between the modelling version and
  5566.   -- the run-time version is that in this version, Z is an acceptable 
  5567.   -- choice, and causes maintenance mode to be entered.
  5568.   --   Allowable special characters and their response are:
  5569.   --          Z   -  Enter Maintenance
  5570.   --          R   -  Return to the Root Node
  5571.   --          I   -  Causes Instruction pages to be displayed
  5572.   --          X   -  Disables Instruction page display
  5573.   --          T   -  Terminates a model session
  5574.   --          /   -  Return to the previous menu
  5575.   --        <CR>  -  In general, proceed to the next node
  5576.     
  5577. end MODEL;
  5578.  
  5579. with COMMON_PROCS, COMMON_MESSAGES, PROMPT_MESSAGES, VIDEO_IO, 
  5580.      SYSTEM_DEPENDENT, ADD, MODIFY, DELETE, INSERT, MOVE, VIDEO_PROCS;
  5581. package body MODEL is
  5582.   use VIDEO_TYPES, COMMON_MESSAGES, PROMPT_MESSAGES;
  5583.   
  5584.   EXCEPT : constant STRING(1..32) := "EXCEPTION RAISED IN MODEL_PROCS ";
  5585.   
  5586.   procedure MAINT_INIT is
  5587.   -- 
  5588.   -- Maint_init displays the maintenance menu in Common_messages.
  5589.   --
  5590.   begin
  5591.     COMMON_PROCS.SCREEN_DISPLAY ( MAINT );
  5592.   exception
  5593.     when others =>
  5594.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS MAINT_INIT");
  5595.       raise;
  5596.   end MAINT_INIT;
  5597.   
  5598.   procedure PROG_PROC ( PROG_MSG : in     STRING;
  5599.                         REC      : in     VIDEO_TYPES.NODE_RECORD;
  5600.                         CHOICE   :    out VIDEO_TYPES.OPTIONS;
  5601.                         NEXT_REC :    out NATURAL ) is
  5602.                               
  5603.     NO_MATCH : constant NATURAL := 0;
  5604.     FILSPEC  : VIDEO_TYPES.FILESPEC;
  5605.     
  5606.   begin
  5607.     COMMON_PROCS.HOME_CLEAR;
  5608.     FILSPEC := SYSTEM_DEPENDENT.BUILD_FILESPEC ( REC.PATH );
  5609.     COMMON_PROCS.MSG_PROC ("PROGRAM " & 
  5610.                            FILSPEC.NAME(1..FILSPEC.LENGTH) &
  5611.                            " WILL BE RUN AT THIS NODE", ERROR_LINE );
  5612.     COMMON_PROCS.PROMPT_MSG ( PROG_MSG );
  5613.     loop  -- until valid response
  5614.       CHOICE := COMMON_PROCS.GET_INPUT;
  5615.       if CHOICE in CR..Z then
  5616.         exit;
  5617.       else  -- invalid choice
  5618.         COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP), ERROR_LINE );
  5619.       end if;  -- choice in cr..z
  5620.     end loop;  -- until valid response
  5621.     if CHOICE = CR then
  5622.       if REC.NEXT_NODE /= VIDEO_IO.END_REC then
  5623.         NEXT_REC := REC.NEXT_NODE;
  5624.       else  -- node is a leaf node
  5625.         COMMON_PROCS.MSG_PROC ( "**ERROR** NO NODES BEYOND THIS NODE", 
  5626.                                  ERROR_LINE );
  5627.         PASSWORD_FLAG := VIDEO_TYPES.OFF;
  5628.       end if;  -- next_node /= end_rec
  5629.     end if;  -- choice = cr
  5630.   exception
  5631.     when others =>
  5632.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS PROG_PROC");
  5633.       raise;
  5634.   end PROG_PROC;
  5635.     
  5636.  
  5637.   procedure MAINT_PROC ( CUR_REC  : in out VIDEO_TYPES.NODE_RECORD;
  5638.                          BOOT_REC : in out VIDEO_TYPES.NODE_RECORD;
  5639.                          CHOICE   :    out VIDEO_TYPES.OPTIONS;
  5640.                          NEXT_REC :    out NATURAL ) is
  5641.   --
  5642.   -- Maint_proc is invoked when the user enters a Z at any node. It begins
  5643.   -- by closing the text file if open, then displays the maintenance menu.
  5644.   -- The user is prompted for a maintenance mode ( add, delete, insert, move,
  5645.   -- modify ). Valid responses are 1..5, slash, and <CR>. If 1..5, the 
  5646.   -- corresponding mode is entered. Otherwise, maintenance is terminated.
  5647.   -- If maintenance has been successful, the user is prompted to exit
  5648.   -- maintenance with a <CR>.
  5649.   --
  5650.     VALID : BOOLEAN;
  5651.     EXIT_MAINTENANCE : BOOLEAN := FALSE;
  5652.     MSG   : STRING(1..52);    
  5653.   begin
  5654.     if VIDEO_IO.TEXT_FILE_OPEN then
  5655.       -- close the test file if necessary
  5656.       VIDEO_IO.CLOSE_TEXT_FILE;
  5657.     end if;
  5658.     MAIN: loop  -- main
  5659.       MAINT_INIT;
  5660.       VALID := FALSE;
  5661.       COMMON_PROCS.PROMPT_MSG ( PROMPT(OPTION_NO) );
  5662.       while not VALID loop
  5663.         CHOICE := COMMON_PROCS.GET_INPUT;
  5664.         case CHOICE is
  5665.           when CR|SLASH|ONE..FIVE =>
  5666.             VALID := TRUE;
  5667.           when others =>
  5668.             COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP), ERROR_LINE );
  5669.         end case;  -- choice
  5670.       end loop;  -- while not valid
  5671.       case CHOICE is
  5672.         when ONE =>
  5673.           ADD.NODE_DIAG ( CUR_REC, BOOT_REC, CHOICE );
  5674.           if CHOICE /= SLASH then
  5675.             MSG := "ADDITION HAS BEEN COMPLETED SUCCESSFULLY            ";
  5676.           end if;
  5677.         when TWO =>
  5678.           MODIFY.NODE_DIAG (CUR_REC, BOOT_REC, CHOICE );
  5679.           SYSTEM_DEPENDENT.SET_MODIFY_FLAG ( OFF );
  5680.           if CHOICE /= SLASH then
  5681.             MSG := "MODIFICATION/DISPLAY HAS BEEN COMPLETED SUCCESSFULLY";
  5682.           end if;
  5683.         when THREE =>
  5684.           DELETE.NODE_DIAG (CUR_REC, BOOT_REC, CHOICE );
  5685.           if CHOICE /= SLASH then
  5686.             MSG := "DELETION HAS BEEN COMPLETED SUCCESSFULLY            ";
  5687.           end if;
  5688.         when FOUR =>
  5689.           INSERT.NODE_DIAG (CUR_REC, BOOT_REC, CHOICE );
  5690.           if CHOICE /= SLASH then
  5691.             MSG := "INSERTION HAS BEEN COMPLETED SUCCESSFULLY           ";
  5692.           end if;
  5693.         when FIVE => 
  5694.           MOVE.NODE_DIAG (CUR_REC, CHOICE );
  5695.           if CHOICE /= SLASH then
  5696.             MSG := "MOVE HAS BEEN COMPLETED SUCCESSFULLY                ";
  5697.           end if;
  5698.         when others =>
  5699.           exit;
  5700.       end case;
  5701.       if CHOICE /= SLASH then
  5702.         COMMON_PROCS.MSG_PROC ( MSG, ERROR_LINE );
  5703.       end if;
  5704.       while not EXIT_MAINTENANCE loop
  5705.         begin
  5706.           COMMON_PROCS.PROMPT_MSG ( PROMPT(EXIT_MAINT) );
  5707.           if COMMON_PROCS.GET_INPUT = CR then
  5708.             -- maintenance session done
  5709.             NEXT_REC := CUR_REC.POSITION;
  5710.             EXIT_MAINTENANCE := TRUE;
  5711.           else
  5712.             COMMON_PROCS.MSG_PROC ( ERRORS(INVALID_RESP), ERROR_LINE);
  5713.           end if;  -- get_input = cr
  5714.         exception
  5715.           when COMMON_PROCS.INVALID_CHOICE =>
  5716.             COMMON_PROCS.MSG_PROC ("ONLY <CR> WILL BE ACCEPTED HERE",
  5717.                                    ERROR_LINE );
  5718.         end;  -- local block
  5719.       end loop; -- for get input
  5720.       exit MAIN when EXIT_MAINTENANCE;
  5721.     end loop;  -- main
  5722.   exception
  5723.     when others =>
  5724.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS MAINT_PROC");
  5725.       raise;
  5726.   end MAINT_PROC;
  5727.   
  5728.   procedure PROCESS_OPTION ( LAST_MENU_PTR : in     NATURAL;
  5729.                              CUR_REC       : in out VIDEO_TYPES.NODE_RECORD;
  5730.                              ROOT_NUM      : in     NATURAL;
  5731.                              BOOT_REC      : in out VIDEO_TYPES.NODE_RECORD;
  5732.                              CHOICE        : in out VIDEO_TYPES.OPTIONS ) is
  5733.   begin
  5734.     case CHOICE is
  5735.       when SLASH =>
  5736.         -- go back to the previous menu
  5737.         PASSWORD_FLAG := VIDEO_TYPES.OFF;  -- disable password
  5738.         if LAST_MENU_PTR /= BOOT_REC.POSITION then
  5739.           READ_REC_NUM  := LAST_MENU_PTR;
  5740.         else   -- can't go back further than root node
  5741.           COMMON_PROCS.MSG_PROC ( "** ERROR ** CURRENT NODE IS FIRST NODE",
  5742.                                    ERROR_LINE );
  5743.           COMMON_PROCS.PROMPT_MSG ("ENTER 'T' TO TERMINATE OR <CR> TO PROCEED");
  5744.         end if;  -- last_menu_ptr /= boot_rec.position
  5745.       when Z =>
  5746.         -- enter maintenance mode
  5747.         READ_REC_NUM := CUR_REC_NUM;
  5748.         MAINT_PROC ( CUR_REC, BOOT_REC, CHOICE, READ_REC_NUM );
  5749.         PASSWORD_FLAG := VIDEO_TYPES.OFF;
  5750.       when R =>
  5751.         -- go back to root node
  5752.         READ_REC_NUM := ROOT_NUM;
  5753.         PASSWORD_FLAG := VIDEO_TYPES.OFF;
  5754.       when I =>
  5755.         -- enable instruction display
  5756.         VIDEO_PROCS.INST_FLAG := VIDEO_PROCS.INST_ENABLED;
  5757.         ERROR_MSG := VIDEO_PROCS.INST_ENABLED;
  5758.         READ_REC_NUM := CUR_REC_NUM;
  5759.         PASSWORD_FLAG := VIDEO_TYPES.OFF;
  5760.         COMMON_PROCS.MSG_PROC ( "INSTRUCTION PAGE DISPLAYING HAS BEEN ENABLED",
  5761.                                 ERROR_LINE );
  5762.       when X =>
  5763.         -- disable instruction display
  5764.         VIDEO_PROCS.INST_FLAG := VIDEO_PROCS.INST_DISABLED;
  5765.         ERROR_MSG := VIDEO_PROCS.INST_DISABLED;
  5766.         READ_REC_NUM := CUR_REC_NUM;
  5767.         PASSWORD_FLAG := VIDEO_TYPES.OFF;
  5768.         COMMON_PROCS.MSG_PROC ("INSTRUCTION PAGE DISPLAYING HAS BEEN DISABLED",
  5769.                                 ERROR_LINE );
  5770.       when T =>
  5771.         -- terminate the session
  5772.         COMMON_PROCS.HOME_CLEAR;
  5773.         READ_REC_NUM := BOOT_REC.POSITION;
  5774.       when others =>
  5775.         -- ignore anything else
  5776.         null;
  5777.     end case;  -- choice
  5778.   exception
  5779.     when others =>
  5780.       COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT & " SUBROUTINE IS PROCESS_OPTION");
  5781.       raise;
  5782.   end PROCESS_OPTION;
  5783.   
  5784. end MODEL;
  5785. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  5786. --vidmodl.txt
  5787. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  5788. -- **********************************************************************
  5789. -- *                                                                    *
  5790. -- *                     PACKAGE: VIDEO_MODEL                           *
  5791. -- *                     VERSION: 1.0a1                                 *
  5792. -- *                     DATE   : FEBRUARY, 1985                        *
  5793. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  5794. -- *                              AdaSoft, Inc.                         *
  5795. -- *                              Lanham, MD                            *
  5796. -- *                                                                    *
  5797. -- **********************************************************************
  5798. --
  5799. --  This is the main procedure for VIDEO_MODEL.
  5800. --  It begins by displaying the copyright message and the model header. 
  5801. --  The user is prompted for the application file name and the password 
  5802. --  for modelling. If this succeeds, the user is then prompted for the
  5803. --  password to run the application. The program then loops until the
  5804. --  user terminates the session. The next node is read, and if password
  5805. --  protected, the user is prompted for the password. If the password is
  5806. --  correct, the node type is determined and the proper routine for that
  5807. --  node type is run. The user may then enter a special character or
  5808. --  choice to proceed further, to back-track, to terminate, to initiate
  5809. --  maintenance, or to disable/enable instruction pages. The model session
  5810. --  proceeds as does a run-time VIDEO session, except that at any node,
  5811. --  maintenance may be performed. 
  5812. --    The maintenance functions are add a node, delete a node, insert a 
  5813. --  node, move a subtree on a menu, and modify a node. 
  5814. --    If the session is terminated for any reason, the node file is closed
  5815. --  and saved.
  5816. --
  5817. with VIDEO_TYPES, PROMPT_MESSAGES, COMMON_MESSAGES, COMMON_PROCS,
  5818.      VIDEO_IO, SYSTEM_DEPENDENT, VIDEO_DEBUG, VIDEO_PROCS, MODEL;
  5819. procedure VIDEO_MODEL is
  5820.   use VIDEO_TYPES, PROMPT_MESSAGES, COMMON_MESSAGES,
  5821.       VIDEO_IO, SYSTEM_DEPENDENT;
  5822.       
  5823.   EXCEPT : constant STRING(1..31) := "EXCEPTION RAISED IN VIDEO_MODEL";
  5824.   ROOT_REC_NUM : constant NATURAL := 1;
  5825.   
  5826.   subtype SPECIAL_CHARS is VIDEO_TYPES.OPTIONS range SLASH..Z;
  5827.   
  5828.   BOOT_REC     : VIDEO_TYPES.NODE_RECORD;
  5829.   NODE_REC     : VIDEO_TYPES.NODE_RECORD;
  5830.   NODE_FILENAM : VIDEO_TYPES.FILESPEC;
  5831.   OPTION       : VIDEO_TYPES.CHOICES;
  5832.   INIT_OK      : BOOLEAN := FALSE;
  5833.   PASS_PROMPT  : STRING(1..72) := PROMPT(PASS_RUN_APL);
  5834.   USER_PROMPT  : STRING(1..72) := PROMPT(SLASH_RTN);
  5835.  
  5836.   INVALID_NODE   : exception;
  5837.   INVALID_OPTION : exception;
  5838.   
  5839.   BLANKS : STRING (1..14) := "              ";
  5840.     
  5841.   HEADER : constant VIDEO_TYPES.HEADER_TYPE :=
  5842.      (1=>BLANKS & "*****************************************************" &
  5843.          BLANKS,
  5844.       2=>BLANKS & "*                                                   *" &
  5845.          BLANKS,
  5846.       3=>BLANKS & "*            *****  VIDEO  MODEL  *****             * " &
  5847.          BLANKS,
  5848.       4=>BLANKS & "*                                                   *" &
  5849.          BLANKS,
  5850.       5=>BLANKS & "*****************************************************" &
  5851.          BLANKS );
  5852.    
  5853.  
  5854. begin
  5855.   VIDEO_PROCS.MENU_INIT ( PROMPT(PASS_APL_MDL), HEADER, NODE_FILENAM, 
  5856.                           BOOT_REC, INIT_OK );
  5857.   if INIT_OK then
  5858.     -- begin by reading and displaying the root node
  5859.     MODEL.READ_REC_NUM := ROOT_REC_NUM;
  5860.     MODEL.CUR_REC_NUM := BOOT_REC.POSITION;
  5861.     MODEL.PASSWORD_FLAG := ON;
  5862.     while MODEL.READ_REC_NUM > BOOT_REC.POSITION loop  -- main loop
  5863.       begin  -- local block and exception handlers
  5864.         USER_PROMPT := PROMPT(SLASH_RTN);
  5865.         VIDEO_IO.READ_NODE ( NODE_REC, MODEL.READ_REC_NUM );
  5866.         if MODEL.PASSWORD_FLAG = ON and then 
  5867.         VIDEO_PROCS.HAS_PASSWORD ( NODE_REC ) then
  5868.           -- proceeding forward and node is password protected
  5869.           if not VIDEO_PROCS.PASSWORD_OK (NODE_REC, PASS_PROMPT ) then
  5870.             -- user will not be able to proceed further
  5871.             raise BAD_PASSWORD;
  5872.           end if;  -- not password_ok
  5873.         end if;  -- password_flag on and then node has password
  5874.         MODEL.CUR_REC_NUM := MODEL.READ_REC_NUM;
  5875.         MODEL.PASSWORD_FLAG := ON;  -- password flag must always be on 
  5876.         case NODE_REC.NODE_TYPE is 
  5877.           when MENU =>
  5878.             for I in VIDEO_TYPES.CHOICES loop
  5879.               if NODE_REC.OPTION (I) /= VIDEO_IO.END_REC then
  5880.                 USER_PROMPT := PROMPT(OPTION_NO);
  5881.                 exit;
  5882.               end if;
  5883.             end loop;
  5884.             VIDEO_PROCS.MENU_PROC (USER_PROMPT, NODE_REC,
  5885.                                    OPTION, MODEL.READ_REC_NUM );
  5886.           when INSTRUCTION =>
  5887.             if NODE_REC.NEXT_NODE /= VIDEO_IO.END_REC then
  5888.               USER_PROMPT := PROMPT(CR_GO_SL_RTN);
  5889.             end if;
  5890.             VIDEO_PROCS.INST_PROC (USER_PROMPT, NODE_REC,
  5891.                                    OPTION, MODEL.READ_REC_NUM );
  5892.           when PROGRAM =>
  5893.             if NODE_REC.NEXT_NODE /= VIDEO_IO.END_REC then
  5894.               USER_PROMPT := PROMPT(CR_GO_SL_RTN);
  5895.             end if;
  5896.             MODEL.PROG_PROC ( USER_PROMPT, NODE_REC, 
  5897.                               OPTION, MODEL.READ_REC_NUM );
  5898.           when others =>
  5899.             raise INVALID_NODE;
  5900.         end case;  -- node_rec.node_type
  5901.         if OPTION in SPECIAL_CHARS then
  5902.           -- handle special characters
  5903.           MODEL.PROCESS_OPTION ( NODE_REC.LAST_MENU,
  5904.                                  NODE_REC, ROOT_REC_NUM, 
  5905.                                  BOOT_REC, OPTION );
  5906.         end if;  -- option in special_chars
  5907.       exception   -- local exception handler
  5908.         when BAD_PASSWORD =>
  5909.           if MODEL.CUR_REC_NUM = BOOT_REC.POSITION then
  5910.             -- bad root password
  5911.             raise;
  5912.           else  -- bad node password, no further access
  5913.             MODEL.READ_REC_NUM := MODEL.CUR_REC_NUM;
  5914.             MODEL.PASSWORD_FLAG := OFF;
  5915.           end if;  -- cur_rec_num = boot_rec.position
  5916.         when INVALID_OPTION =>
  5917.           -- ignore invalid options
  5918.           null;
  5919.         when others =>
  5920.           COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT );
  5921.           raise;
  5922.       end;  -- local block
  5923.       PASS_PROMPT := PROMPT(PASS_APL_MORE);
  5924.     end loop;  -- main loop
  5925.   end if;  -- init_ok
  5926.   VIDEO_IO.CLOSE_NODE_FILE (SAVE_FILE);
  5927.   COMMON_PROCS.HOME_CLEAR;
  5928.   COMMON_PROCS.MSG_PROC ( MESSAGES(SUCCESS), ERROR_LINE );
  5929. exception 
  5930.   when USER_QUIT =>
  5931.     COMMON_PROCS.HOME_CLEAR;
  5932.     COMMON_PROCS.PUT_STRING ("VIDEO MODEL SESSION STOPPED");
  5933.     if VIDEO_IO.NODE_FILE_OPEN then
  5934.       VIDEO_IO.CLOSE_NODE_FILE (SAVE_FILE);
  5935.     end if;
  5936.     COMMON_PROCS.NEXT_LINE;
  5937.   when BAD_PASSWORD => 
  5938.     -- bad boot or root password
  5939.     COMMON_PROCS.HOME_CLEAR;
  5940.     COMMON_PROCS.PUT_STRING ( " PROCESS TERMINATED " & ": ACCESS DENIED" );
  5941.     VIDEO_IO.CLOSE_NODE_FILE ( SAVE_FILE );
  5942.     COMMON_PROCS.NEXT_LINE;
  5943.   when others =>
  5944.     if VIDEO_IO.NODE_FILE_OPEN then
  5945.       VIDEO_IO.CLOSE_NODE_FILE ( SAVE_FILE );
  5946.     end if;
  5947.     VIDEO_DEBUG.PRINT_EXCEPTIONS;
  5948. end VIDEO_MODEL;
  5949. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  5950. --video.txt
  5951. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  5952. -- **********************************************************************
  5953. -- *                                                                    *
  5954. -- *                     PACKAGE: VIDEO                                 *
  5955. -- *                     VERSION: 1.0a1                                 *
  5956. -- *                     DATE   : FEBRUARY, 1985                        *
  5957. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  5958. -- *                              AdaSoft, Inc.                         *
  5959. -- *                              Lanham, MD                            *
  5960. -- *                                                                    *
  5961. -- **********************************************************************
  5962. --
  5963. with VIDEO_TYPES, PROMPT_MESSAGES, COMMON_MESSAGES, COMMON_PROCS,
  5964.      VIDEO_IO, SYSTEM_DEPENDENT, VIDEO_DEBUG, VIDEO_PROCS, VIDEO_MAIN;
  5965. procedure VIDEO is
  5966.   use VIDEO_TYPES, PROMPT_MESSAGES, COMMON_MESSAGES,
  5967.       VIDEO_IO, SYSTEM_DEPENDENT;
  5968.       
  5969.   EXCEPT : constant STRING(1..25) := "EXCEPTION RAISED IN VIDEO";
  5970.   ROOT_REC_NUM : constant NATURAL := 1;
  5971.   
  5972.   subtype SPECIAL_CHARS is VIDEO_TYPES.OPTIONS range SLASH..Z;
  5973.   
  5974.   BOOT_REC     : VIDEO_TYPES.NODE_RECORD;
  5975.   NODE_REC     : VIDEO_TYPES.NODE_RECORD;
  5976.   NODE_FILENAM : VIDEO_TYPES.FILESPEC;
  5977.   OPTION       : VIDEO_TYPES.CHOICES;
  5978.   INIT_OK      : BOOLEAN := FALSE;
  5979.   PASS_PROMPT  : STRING(1..72) := PROMPT(PASS_RUN_APL);
  5980.   USER_PROMPT  : STRING(1..72);
  5981.   
  5982.     INVALID_NODE   : exception;
  5983.   INVALID_OPTION : exception;
  5984.   
  5985.   BLANKS : STRING (1..14) := "              ";
  5986.     
  5987.   VIDEO_HEADER : constant VIDEO_TYPES.HEADER_TYPE :=
  5988.      (1=>BLANKS & "*****************************************************" &
  5989.          BLANKS,
  5990.       2=>BLANKS & "*                                                   *" &
  5991.          BLANKS,
  5992.       3=>BLANKS & "*            *****      VIDEO     *****             * " &
  5993.          BLANKS,
  5994.       4=>BLANKS & "*                                                   *" &
  5995.          BLANKS,
  5996.       5=>BLANKS & "*****************************************************" &
  5997.          BLANKS );
  5998.    
  5999. begin
  6000.   VIDEO_MAIN.MENU_INIT ( PROMPT(PASS_APL_MDL), VIDEO_HEADER, NODE_FILENAM, 
  6001.                           BOOT_REC, INIT_OK );
  6002.   if INIT_OK then
  6003.     VIDEO_MAIN.READ_REC_NUM := ROOT_REC_NUM;
  6004.     VIDEO_MAIN.CUR_REC_NUM := BOOT_REC.POSITION;
  6005.     VIDEO_MAIN.PASSWORD_FLAG := ON;
  6006.     while VIDEO_MAIN.READ_REC_NUM > BOOT_REC.POSITION loop
  6007.       begin
  6008.         USER_PROMPT := PROMPT(SLASH_RTN);
  6009.         VIDEO_IO.READ_NODE ( NODE_REC, VIDEO_MAIN.READ_REC_NUM );
  6010.         if VIDEO_MAIN.PASSWORD_FLAG = ON and then 
  6011.         VIDEO_PROCS.HAS_PASSWORD ( NODE_REC ) then
  6012.           if not VIDEO_PROCS.PASSWORD_OK (NODE_REC, PASS_PROMPT ) then
  6013.             raise BAD_PASSWORD;
  6014.           end if;
  6015.         end if;
  6016.         VIDEO_MAIN.CUR_REC_NUM := VIDEO_MAIN.READ_REC_NUM;
  6017.         VIDEO_MAIN.PASSWORD_FLAG := ON;
  6018.         case NODE_REC.NODE_TYPE is 
  6019.           when MENU =>
  6020.             for I in VIDEO_TYPES.CHOICES loop
  6021.               if NODE_REC.OPTION (I) /= VIDEO_IO.END_REC then
  6022.                 USER_PROMPT := PROMPT (OPTION_NO);
  6023.                 exit;
  6024.               end if;
  6025.             end loop;
  6026.             VIDEO_PROCS.MENU_PROC (USER_PROMPT, NODE_REC,
  6027.                                    OPTION, VIDEO_MAIN.READ_REC_NUM );
  6028.           when INSTRUCTION =>
  6029.             if NODE_REC.NEXT_NODE /= VIDEO_IO.END_REC then
  6030.               USER_PROMPT := PROMPT (CR_GO_SL_RTN);
  6031.             end if;
  6032.             VIDEO_PROCS.INST_PROC (USER_PROMPT, NODE_REC,
  6033.                                    OPTION, VIDEO_MAIN.READ_REC_NUM );
  6034.           when PROGRAM =>
  6035.             if NODE_REC.NEXT_NODE /= VIDEO_IO.END_REC then
  6036.               USER_PROMPT := PROMPT (CR_GO_SL_RTN);
  6037.             end if;
  6038.             VIDEO_MAIN.PROG_PROC ( USER_PROMPT, NODE_REC, 
  6039.                                    OPTION, VIDEO_MAIN.READ_REC_NUM );
  6040.           when others =>
  6041.             raise INVALID_NODE;
  6042.         end case;
  6043.         if OPTION in SPECIAL_CHARS then
  6044.           VIDEO_MAIN.PROCESS_OPTION ( NODE_REC.LAST_MENU,
  6045.                                        NODE_REC, ROOT_REC_NUM, 
  6046.                                        BOOT_REC, OPTION );
  6047.         end if;
  6048.       exception 
  6049.         when BAD_PASSWORD =>
  6050.           if VIDEO_MAIN.CUR_REC_NUM = BOOT_REC.POSITION then
  6051.             raise;
  6052.           else
  6053.             VIDEO_MAIN.READ_REC_NUM := VIDEO_MAIN.CUR_REC_NUM;
  6054.             VIDEO_MAIN.PASSWORD_FLAG := OFF;
  6055.           end if;
  6056.         when INVALID_OPTION =>
  6057.           null;
  6058.         when others =>
  6059.           COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT );
  6060.           raise;
  6061.       end;
  6062.       PASS_PROMPT := PROMPT(PASS_APL_MORE);
  6063.     end loop;
  6064.   end if;
  6065.   VIDEO_IO.CLOSE_NODE_FILE (SAVE_FILE);
  6066.   COMMON_PROCS.HOME_CLEAR;
  6067.   COMMON_PROCS.MSG_PROC ( MESSAGES(SUCCESS), ERROR_LINE );
  6068. exception 
  6069.   when USER_QUIT =>
  6070.     COMMON_PROCS.HOME_CLEAR;
  6071.     COMMON_PROCS.PUT_STRING ( "VIDEO SESSION STOPPED" );
  6072.     if VIDEO_IO.NODE_FILE_OPEN then
  6073.       VIDEO_IO.CLOSE_NODE_FILE (SAVE_FILE );
  6074.     end if;
  6075.   when BAD_PASSWORD => 
  6076.     COMMON_PROCS.HOME_CLEAR;
  6077.     COMMON_PROCS.PUT_STRING ( " PROCESS TERMINATED " & ": ACCESS DENIED" );
  6078.     VIDEO_IO.CLOSE_NODE_FILE ( SAVE_FILE );
  6079.     COMMON_PROCS.NEXT_LINE;
  6080.   when others =>
  6081.     if VIDEO_IO.NODE_FILE_OPEN then
  6082.       VIDEO_IO.CLOSE_NODE_FILE ( SAVE_FILE );
  6083.     end if;
  6084.     VIDEO_DEBUG.PRINT_EXCEPTIONS;
  6085. end VIDEO;
  6086. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  6087. --diagram.txt
  6088. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  6089. -- **********************************************************************
  6090. -- *                                                                    *
  6091. -- *                     PACKAGE: DIAGRAM                               *
  6092. -- *                     VERSION: 1.0a1                                 *
  6093. -- *                     DATE   : FEBRUARY, 1985                        *
  6094. -- *                     AUTHOR : STEPHEN J. HYLAND                     *
  6095. -- *                              AdaSoft, Inc.                         *
  6096. -- *                              Lanham, MD                            *
  6097. -- *                                                                    *
  6098. -- **********************************************************************
  6099. --
  6100. --  This package contains the routines used directly by VIDEO_DIAGRAM.
  6101. --
  6102. with VIDEO_TYPES, DIAGRAM_TYPES;
  6103. package DIAGRAM is
  6104.  
  6105.   procedure INIT ( SHOW_PASS : out BOOLEAN;
  6106.                    SUCCESS   : out BOOLEAN );
  6107.   
  6108.   procedure PRINT_NODE ( CURRENT_NODE : in     VIDEO_TYPES.NODE_RECORD;
  6109.                          CUR_LEVEL    : in     DIAGRAM_TYPES.NODE_LEVEL;
  6110.                          LAST_NODE    : in     VIDEO_TYPES.NODE;
  6111.                          SHOW_PASS    : in     BOOLEAN;
  6112.                          SUCCESS      :    out BOOLEAN );
  6113.   
  6114.   procedure WRAP_UP ( SUCCESS : in BOOLEAN );
  6115.   
  6116. end DIAGRAM;
  6117.  
  6118. with PASS_PROCS, COMMON_MESSAGES, COMMON_PROCS, SYSTEM_DEPENDENT, VIDEO_IO, 
  6119.      VIDEO_PROCS, DIAGRAM_IO, DIAGRAM_MESSAGES, TEXT_IO;
  6120. package body DIAGRAM is
  6121.   use VIDEO_TYPES, COMMON_MESSAGES, DIAGRAM_MESSAGES;
  6122.   
  6123.   EXCEPT : constant STRING(1..28) := "EXCEPTION RAISED IN DIAGRAM ";
  6124.   
  6125.   MAX_LINE_LENGTH : constant NATURAL := NATURAL(DIAGRAM_TYPES.MAX_LINE_LENGTH);
  6126.   
  6127.   procedure INIT_HEADER is
  6128.   
  6129.   BLANKS : STRING (1..14) := "              ";
  6130.     
  6131.   DIAGRAM_HEADER : constant VIDEO_TYPES.HEADER_TYPE :=
  6132.      (1=>BLANKS & "*****************************************************" &
  6133.          BLANKS,
  6134.       2=>BLANKS & "*                                                   *" &
  6135.          BLANKS,
  6136.       3=>BLANKS & "*             ***** VIDEO DIAGRAM *****             *" & 
  6137.          BLANKS,
  6138.       4=>BLANKS & "*                                                   *" &
  6139.          BLANKS,
  6140.       5=>BLANKS & "*****************************************************" &
  6141.          BLANKS );
  6142.    
  6143.   begin
  6144.     COMMON_PROCS.SCREEN_DISPLAY ( COPYRIGHT );
  6145.     COMMON_PROCS.SKIP_LINE (2);
  6146.     for I in VIDEO_TYPES.HEADER_LINES loop
  6147.       COMMON_PROCS.PUT_STRING ( DIAGRAM_HEADER(I) );
  6148.       COMMON_PROCS.NEXT_LINE;
  6149.     end loop;
  6150.   exception 
  6151.     when others =>
  6152.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS INIT_HEADER");
  6153.       raise;
  6154.   end INIT_HEADER;
  6155.   
  6156.   procedure CENTER ( STR       : in     STRING;
  6157.                      PRINT_STR :    out STRING ) is
  6158.   
  6159.     STR_LEN   : NATURAL;
  6160.     FIRST_COL : NATURAL;
  6161.     
  6162.   begin
  6163.     STR_LEN := STR'length;
  6164.     FIRST_COL := ( PRINT_STR'length - STR_LEN) / 2;
  6165.     for I in 1..PRINT_STR'last loop
  6166.       PRINT_STR (I) := ' ';
  6167.     end loop;
  6168.     PRINT_STR(FIRST_COL..(FIRST_COL + STR_LEN) - 1) := STR;
  6169.   exception 
  6170.     when others =>
  6171.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS CENTER");
  6172.       raise;
  6173.   end CENTER;
  6174.   
  6175.   procedure INIT ( SHOW_PASS: out BOOLEAN;
  6176.                    SUCCESS  : out BOOLEAN ) is
  6177.     use VIDEO_PROCS;
  6178.                    
  6179.     NODE_FILENAME : VIDEO_TYPES.FILE_NAME;
  6180.     BOOT_FILESPEC : VIDEO_TYPES.FILESPEC;
  6181.     ROOT_REC      : VIDEO_TYPES.NODE_RECORD;
  6182.     BOOT_REC      : VIDEO_TYPES.NODE_RECORD;
  6183.     HDR_LINE      : STRING(1..MAX_LINE_LENGTH);
  6184.     DONE          : BOOLEAN := FALSE;
  6185.     
  6186.   begin
  6187.     INIT_HEADER;
  6188.     while not DONE loop
  6189.       begin
  6190.         NODE_FILENAME := 
  6191.           SYSTEM_DEPENDENT.GET_FILENAME ( NODE_FILENAME,  PROMPT (DEV_NAME),
  6192.                                           PROMPT (DIR_NAME), PROMPT (FIL_NAME),
  6193.                                           BOOT );
  6194.         BOOT_FILESPEC := SYSTEM_DEPENDENT.BUILD_FILESPEC ( NODE_FILENAME );
  6195.         VIDEO_IO.OPEN_NODE_FILE ( BOOT_FILESPEC );
  6196.         DONE := TRUE;
  6197.       exception
  6198.         when VIDEO_IO.NAME_ERROR|VIDEO_IO.USE_ERROR =>
  6199.           COMMON_PROCS.MSG_PROC ( "**ERROR** FILE DOES NOT EXIST", ERROR_LINE );
  6200.           if not CONFIRMED ("DO YOU WANT TO TRY AGAIN (Y/N) ?" ) then
  6201.             raise USER_QUIT;
  6202.           end if;
  6203.       end;
  6204.     end loop;  -- while not done
  6205.     VIDEO_IO.READ_NODE ( ROOT_REC, 1 );
  6206.     if VIDEO_PROCS.HAS_PASSWORD (ROOT_REC) and then 
  6207.        not VIDEO_PROCS.PASSWORD_OK (ROOT_REC, PROMPT(PASS_RUN_APL) ) then
  6208.          raise BAD_PASSWORD;
  6209.     end if;
  6210.     VIDEO_IO.READ_NODE ( BOOT_REC, 0 );
  6211.     if VIDEO_PROCS.HAS_PASSWORD ( BOOT_REC ) and then
  6212.       not VIDEO_PROCS.PASSWORD_OK ( BOOT_REC, PROMPT(PASSWRD) ) then
  6213.         SHOW_PASS := FALSE;
  6214.         COMMON_PROCS.MSG_PROC ( ERROR(PRINT_PASS), ERROR_LINE );
  6215.     else
  6216.       SHOW_PASS := TRUE;
  6217.     end if;
  6218.     DIAGRAM_IO.CREATE_PRINT_FILE;
  6219.     CENTER ( DIAGRAM_TYPES.RPT_HDR_1, HDR_LINE );
  6220.     DIAGRAM_IO.PRINT ( HDR_LINE );
  6221.     CENTER ( DIAGRAM_TYPES.RPT_HDR_2 & 
  6222.              BOOT_FILESPEC.NAME(1..BOOT_FILESPEC.LENGTH), HDR_LINE );
  6223.     DIAGRAM_IO.PRINT ( HDR_LINE );
  6224.     DIAGRAM_IO.SKIP_LINES (2);
  6225.     DIAGRAM_IO.PRINT ( DIAGRAM_TYPES.PAGE_HDR_1 );
  6226.     DIAGRAM_IO.PRINT ( DIAGRAM_TYPES.PAGE_HDR_2 );
  6227.     SUCCESS := TRUE;
  6228.   exception 
  6229.     when USER_QUIT =>
  6230.       raise;
  6231.     when BAD_PASSWORD =>
  6232.       COMMON_PROCS.MSG_PROC ("**PROCESS TERMINATED - ACCESS DENIED**",
  6233.                               ERROR_LINE );
  6234.       raise;
  6235.     when OTHERS =>
  6236.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS INIT" );
  6237.       raise;
  6238.   end INIT;
  6239.   
  6240.   function BUILD ( NODE_REC : in VIDEO_TYPES.NODE_RECORD;
  6241.                    LEVEL    : in DIAGRAM_TYPES.NODE_LEVEL;
  6242.                    LAST_NODE: in VIDEO_TYPES.NODE;
  6243.                    SHOW_PASS: in BOOLEAN ) return DIAGRAM_TYPES.PRINT_RECORD is
  6244.                    
  6245.     PRINT_REC     : DIAGRAM_TYPES.PRINT_RECORD;
  6246.     
  6247.   begin
  6248.     if VIDEO_PROCS.HAS_PASSWORD (NODE_REC) then
  6249.       if SHOW_PASS then
  6250.         PRINT_REC.PASSWORD := 
  6251.           PASS_PROCS.PASS_TO_STRING ( NODE_REC.NODE_PASSWORD );
  6252.       else
  6253.         PRINT_REC.PASSWORD := "YES     ";
  6254.       end if;
  6255.     else
  6256.         PRINT_REC.PASSWORD := "NO PASS ";
  6257.     end if;
  6258.     case NODE_REC.NODE_TYPE is
  6259.       when MENU =>
  6260.         PRINT_REC.FILSPEC := 
  6261.           SYSTEM_DEPENDENT.BUILD_FILESPEC ( NODE_REC.MENU_PATH );
  6262.       when INSTRUCTION|PROGRAM =>
  6263.         PRINT_REC.FILSPEC := 
  6264.           SYSTEM_DEPENDENT.BUILD_FILESPEC ( NODE_REC.PATH );
  6265.       when others =>
  6266.         null;
  6267.     end case;
  6268.     PRINT_REC.NODE_TYPE := NODE_REC.NODE_TYPE;
  6269.     PRINT_REC.PREV_NODE := LAST_NODE;
  6270.     PRINT_REC.LEVEL := LEVEL;
  6271.     return PRINT_REC;
  6272.   exception 
  6273.     when others =>
  6274.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS BUILD");
  6275.       raise;
  6276.   end BUILD;
  6277.                                       
  6278.   function FORMAT_STRING ( PRINT_REC : in DIAGRAM_TYPES.PRINT_RECORD;
  6279.                            SHOW_PASS : in BOOLEAN ) return STRING is
  6280.     
  6281.     TWENTY_SIX_BLANKS : constant STRING(1..26) := "                          ";
  6282.     TWO_BLANKS        : constant STRING(1..2)  := "  ";
  6283.     BLANK             : constant STRING(1..1)  := " ";
  6284.     
  6285.     PRINT_LINE        : STRING(1..MAX_LINE_LENGTH );
  6286.     LEVEL_FIELD       : STRING(1..54) := 
  6287.                           TWENTY_SIX_BLANKS & TWENTY_SIX_BLANKS & TWO_BLANKS;
  6288.     FILESPEC_FIELD    : STRING(1..52) := TWENTY_SIX_BLANKS & TWENTY_SIX_BLANKS;
  6289.     NODE_TYPE_FIELD   : STRING(1..7)  := "       ";
  6290.     ACCESS_NODE_FIELD : STRING(1..7)  := "       ";
  6291.     PASSWORD_FIELD    : STRING(1..11) := "           ";
  6292.     
  6293.   begin
  6294.     case PRINT_REC.NODE_TYPE is
  6295.       when MENU =>
  6296.         NODE_TYPE_FIELD := "MENU   ";
  6297.       when INSTRUCTION =>
  6298.         NODE_TYPE_FIELD := "INST   ";
  6299.       when PROGRAM =>
  6300.         NODE_TYPE_FIELD := "PROG   ";
  6301.       when others =>
  6302.         null;
  6303.     end case;
  6304.     case PRINT_REC.PREV_NODE is
  6305.       when MENU =>
  6306.         ACCESS_NODE_FIELD := "MENU   ";
  6307.       when INSTRUCTION =>
  6308.         ACCESS_NODE_FIELD := "INST   ";
  6309.       when PROGRAM =>
  6310.         ACCESS_NODE_FIELD := "PROG   ";
  6311.       when others =>
  6312.         ACCESS_NODE_FIELD := "BOOT   ";
  6313.     end case;
  6314.     LEVEL_FIELD(3*PRINT_REC.LEVEL) := NODE_TYPE_FIELD(1);
  6315.     FILESPEC_FIELD(1..PRINT_REC.FILSPEC.LENGTH) := 
  6316.       PRINT_REC.FILSPEC.NAME(1..PRINT_REC.FILSPEC.LENGTH);
  6317.     if SHOW_PASS then
  6318.       PASSWORD_FIELD(1..8) := PRINT_REC.PASSWORD;
  6319.     end if;
  6320.     PRINT_LINE := BLANK & LEVEL_FIELD & NODE_TYPE_FIELD & 
  6321.                   ACCESS_NODE_FIELD & FILESPEC_FIELD & PASSWORD_FIELD;
  6322.     return PRINT_LINE;
  6323.   exception 
  6324.     when others =>
  6325.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS FORMAT_STRING");
  6326.       raise;
  6327.   end FORMAT_STRING;
  6328.   
  6329.   procedure PRINT ( RPT_LINE : in STRING ) is
  6330.   begin
  6331.     if DIAGRAM_IO.LINE = 1 then
  6332.       DIAGRAM_IO.PRINT ( DIAGRAM_TYPES.PAGE_HDR_1 );
  6333.       DIAGRAM_IO.PRINT ( DIAGRAM_TYPES.PAGE_HDR_2 );
  6334.     end if;
  6335.     DIAGRAM_IO.PRINT ( RPT_LINE );
  6336.   exception 
  6337.     when others =>
  6338.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS PRINT");
  6339.       raise;
  6340.   end PRINT;
  6341.  
  6342.   procedure PRINT_NODE ( CURRENT_NODE : in     VIDEO_TYPES.NODE_RECORD;
  6343.                          CUR_LEVEL    : in     DIAGRAM_TYPES.NODE_LEVEL;
  6344.                          LAST_NODE    : in     VIDEO_TYPES.NODE;
  6345.                          SHOW_PASS    : in     BOOLEAN;
  6346.                          SUCCESS      :    out BOOLEAN ) is
  6347.     
  6348.     NEXT_NODE  : VIDEO_TYPES.NODE_RECORD;
  6349.     PRINT_REC  : DIAGRAM_TYPES.PRINT_RECORD;
  6350.     RPT_LINE   : STRING (1..MAX_LINE_LENGTH);
  6351.     NEXT_LEVEL : DIAGRAM_TYPES.NODE_LEVEL := CUR_LEVEL + 1;
  6352.     
  6353.   begin
  6354.     PRINT_REC := BUILD (CURRENT_NODE, CUR_LEVEL, LAST_NODE, SHOW_PASS );
  6355.     RPT_LINE := FORMAT_STRING ( PRINT_REC, SHOW_PASS );
  6356.     PRINT ( RPT_LINE );
  6357.     case CURRENT_NODE.NODE_TYPE is
  6358.       when MENU =>
  6359.         for I in ONE..FIFTEEN loop
  6360.           if CURRENT_NODE.OPTION(I) /= VIDEO_IO.END_REC then
  6361.             VIDEO_IO.READ_NODE ( NEXT_NODE, CURRENT_NODE.OPTION(I) );
  6362.             PRINT_NODE ( NEXT_NODE, NEXT_LEVEL, CURRENT_NODE.NODE_TYPE,
  6363.                          SHOW_PASS, SUCCESS );
  6364.           else
  6365.             SUCCESS := TRUE;
  6366.           end if;
  6367.         end loop;
  6368.       when others =>
  6369.         if CURRENT_NODE.NEXT_NODE /= VIDEO_IO.END_REC then
  6370.           VIDEO_IO.READ_NODE ( NEXT_NODE, CURRENT_NODE.NEXT_NODE );
  6371.           PRINT_NODE ( NEXT_NODE, NEXT_LEVEL, CURRENT_NODE.NODE_TYPE,
  6372.                        SHOW_PASS, SUCCESS );
  6373.         else
  6374.           SUCCESS := TRUE;
  6375.         end if;
  6376.     end case;
  6377.   exception 
  6378.     when others =>
  6379.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS PRINT_NODE");
  6380.       raise;
  6381.   end PRINT_NODE;
  6382.   
  6383.   procedure WRAP_UP ( SUCCESS : in BOOLEAN ) is
  6384.     use VIDEO_IO;
  6385.   begin
  6386.     VIDEO_IO.CLOSE_NODE_FILE ( SAVE_FILE );
  6387.     if SUCCESS then 
  6388.       DIAGRAM_IO.CLOSE_PRINT_FILE;
  6389.     else
  6390.       DIAGRAM_IO.DELETE_PRINT_FILE;
  6391.     end if;
  6392.   exception
  6393.     when others =>
  6394.       COMMON_PROCS.HANDLE_EXCEPTION (EXCEPT & "SUBROUTINE IS WRAP_UP");
  6395.       raise;
  6396.   end WRAP_UP;
  6397.   
  6398. end DIAGRAM;
  6399. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  6400. --vidiag.txt
  6401. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  6402. -- **********************************************************************
  6403. -- *                                                                    *
  6404. -- *                     MAIN_PROCEDURE : VIDEO_DIAGRAM                 *
  6405. -- *                     VERSION        : 1.0a1                         *
  6406. -- *                     DATE           : FEBRUARY, 1985                *
  6407. -- *                     AUTHOR         : STEPHEN J. HYLAND             *
  6408. -- *                                      AdaSoft, Inc.                 *
  6409. -- *                                      Lanham, MD                    *
  6410. -- *                                                                    *
  6411. -- **********************************************************************
  6412. --
  6413. --   This is the main procedure for diagramming the application model. The
  6414. -- initialization process displays the copyright message, then prompts for
  6415. -- the model filename. The user must enter the model password to run
  6416. -- VIDEO_DIAGRAM. The user is then prompted for the model password. If it
  6417. -- is entered, the passwords associated with each node will be printed. If
  6418. -- it is not entered, or it is incorrect, the report will only indicate if
  6419. -- the node is password-protected. 
  6420. --   Upon completion of initialization, the procedure will begin creating
  6421. -- the application diagram. When this completes, the process will have 
  6422. -- created a text file that must then be printed by the user. This report
  6423. -- is 132 columns long. Appropriate messages indicate the successful or 
  6424. -- unsuccessful completion of the program.
  6425. --
  6426. with VIDEO_TYPES, VIDEO_IO, VIDEO_DEBUG, COMMON_PROCS, 
  6427.      DIAGRAM_TYPES, DIAGRAM_IO, DIAGRAM_MESSAGES, DIAGRAM;
  6428. procedure VIDEO_DIAGRAM is
  6429.   use VIDEO_TYPES, DIAGRAM_MESSAGES;
  6430.   
  6431.   EXCEPT : constant STRING(1..33) := "EXCEPTION RAISED IN VIDEO_DIAGRAM";
  6432.   
  6433.   ROOT_NODE_POSITION : constant NATURAL := 1;
  6434.   
  6435.   ROOT_NODE  : VIDEO_TYPES.NODE_RECORD;
  6436.   ROOT_LEVEL : DIAGRAM_TYPES.NODE_LEVEL := DIAGRAM_TYPES.NODE_LEVEL'first;
  6437.   SHOW_PASS  : BOOLEAN := FALSE;
  6438.   RESULT_OK    : BOOLEAN := FALSE;
  6439.   
  6440. begin
  6441.   DIAGRAM.INIT ( SHOW_PASS, RESULT_OK );
  6442.   if RESULT_OK then 
  6443.     begin
  6444.       VIDEO_IO.READ_NODE ( ROOT_NODE, ROOT_NODE_POSITION );
  6445.       DIAGRAM.PRINT_NODE ( ROOT_NODE, ROOT_LEVEL, BOOT, SHOW_PASS, RESULT_OK );
  6446.       COMMON_PROCS.HOME_CLEAR;
  6447.       COMMON_PROCS.MSG_PROC ( PROMPT(SUCCESS), ERROR_LINE );
  6448.     exception
  6449.       when BAD_PASSWORD =>
  6450.         null;
  6451.     end;
  6452.   end if;
  6453.   DIAGRAM.WRAP_UP ( RESULT_OK );
  6454. exception 
  6455.   when USER_QUIT =>
  6456.     COMMON_PROCS.HOME_CLEAR;
  6457.     COMMON_PROCS.MSG_PROC ( "DIAGRAM SESSION STOPPED", ERROR_LINE );
  6458.   when others =>
  6459.     COMMON_PROCS.HANDLE_EXCEPTION ( EXCEPT );
  6460.     VIDEO_DEBUG.PRINT_EXCEPTIONS;
  6461.     if VIDEO_IO.NODE_FILE_OPEN then
  6462.       VIDEO_IO.CLOSE_NODE_FILE ( VIDEO_IO.SAVE_FILE );
  6463.     end if;
  6464.     if DIAGRAM_IO.PRINT_FILE_OPEN then
  6465.       DIAGRAM_IO.DELETE_PRINT_FILE;
  6466.     end if;
  6467. end VIDEO_DIAGRAM;
  6468.  
  6469.