home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-05-03 | 171.0 KB | 3,974 lines |
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --textsete.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
-
- -- TEXT_HANDLER_SUBSET;TEXTSETE.ADA;KJL;04/09/85
-
- -- This package is a subset of the Text Handler package from the LRM. It
- -- contains only the operations needed for the Menu Manager project. The
- -- TEXT type is a dynamic character string type, that is implemented using
- -- access types where the object is really a pointer to a string. The string
- -- can expand dynamicly because the object points to a new string that
- -- includes the text of the previous one and more.
-
- -- This is one of the few non generic library units in the Menu Manager set.
- -- This package must be compiled before others are.
-
- package TEXT_HANDLER_SUBSET is
-
- type TEXT is private;
-
- function VALUE (T: TEXT) return STRING;
- -- Returns the string which the access type points to, or "" if the access
- -- type points to null.
-
- function LENGTH (T: TEXT) return NATURAL;
- -- Returns the Length of the accessed string. 0 if access is null.
-
- function EMPTY (T: TEXT) return BOOLEAN;
- -- Returns true if the accessed string is "", or access is null.
-
-
- function TO_TEXT (STR: STRING) return TEXT;
- -- Creates an access type that points to a string of the value given.
-
- function TO_TEXT (CHR: CHARACTER) return TEXT;
- -- Creates an access type poiting to a string that is the character given.
-
- procedure CLEAR_TEXT (T: in out TEXT);
- -- Resets the given access object to point to a null string.
-
-
- procedure PACK_TEXT (T: in out TEXT);
- -- Takes the leading and trailing blanks off the given accessed string.
-
- procedure UNPACK_TEXT (T: in out TEXT; LEN: in NATURAL;
- NO_ROOM: out BOOLEAN);
- -- Adds trailing blanks to the given accessed string to make it the length
- -- requested in LEN. NO_ROOM is true when the LEN is smaller than the
- -- number of characters in the T accessed string.
-
- function UNPACK_VALUE (T: TEXT; LEN: NATURAL) return STRING;
- -- Returns a string of length LEN from the accessed string T. If T is too
- -- big, returns a string of blanks.
-
- function PACK_TO_TEXT (STR: STRING) return TEXT;
- -- Returns an access type pointing to a string with value STR, but with
- -- no leading or trailing blanks.
-
-
- procedure APPEND (TAIL: TEXT; TO: in out TEXT);
- -- TO will point to a string that is the accessed string TO concated with
- -- the accessed string TAIL.
-
- procedure APPEND (TAIL: STRING; TO: in out TEXT);
- -- TO will point to a string that is the accessed string TO concated with
- -- the string TAIL.
-
- procedure APPEND (TAIL: CHARACTER; TO: in out TEXT);
- -- TO will point to a string that is the accessed string TO concated with
- -- the character TAIL.
-
-
- function GIVE_POS (T: TEXT; POSITION: NATURAL) return CHARACTER;
- -- Returns the character of accessed string T, that is the string index
- -- given in POSITION.
-
-
- private -- Objects of type TEXT point to strings.
- type TEXT is access STRING;
-
-
- end TEXT_HANDLER_SUBSET;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --compgese.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
- -- COMPILER_MESSAGES;COMPGESE.ADA;KJL;04/09/85
-
- -- This package contains the procedures, data structures, and values needed
- -- for displaying messages during the running of the Menu Compiler.
-
- -- All the messages that the Menu Compiler and Menu Handler issue are found in
- -- a file "COMERRS". There are 2 lines for each message:
- -- The first line is a code of severity for the message: NO_ERROR for
- -- information messages that are not related to errors. WARNING_ERROR for
- -- errors that will not stop the compilation or the creation of the Menu Def
- -- Table, DISABLING_ERROR for errors that stop the creation of the Menu Def
- -- Table, but the compiler continues to process the Menu Def File, and
- -- FATAL_ERROR for errors that are severe enough to warrant stopping the
- -- compilation immediately, and no Menu Def Table is created.
- -- The second line in a 236 character line that contains the text of the
- -- the message to be displayed.
- -- Each message has a numeric code associated with it which is the order that
- -- the message entrys appear in the COMERRS file. This numeric code is used
- -- when a message is invoked in other procedures.
-
- -- One procedure of this package reads the COMERRS file into an array kept in
- -- the package. The array is used during the compilation, not the file.
- -- The file is open only when it initially being read, then closed for the
- -- duration of the program run.
-
- with TEXT_HANDLER_SUBSET;
- generic
- -- When this package is instantiated during the execution on the Menu
- -- Compiler, the Screen Width is passed (so that the messages are displayed
- -- correctly), a function returning the current lexical unit and one
- -- returning the current line number of the Menu Def File are passed (the
- -- lex unit and line number will be displayed in the error messages).
- SCREEN_WIDTH: POSITIVE;
- with function CURRENT_LEX_STRING return TEXT_HANDLER_SUBSET.TEXT;
- with function CURRENT_LINE_NUMBER return INTEGER;
- package COMPILER_MESSAGES is
-
- function FATAL_ERROR_STATUS return BOOLEAN;
- -- Returns true if any errors have been found during this compilation
- -- which are of Fatal severity or worse (nothing is worse yet).
-
- function DISABLE_ERROR_STATUS return BOOLEAN;
- -- Returns true if any errors have been found during this compilation
- -- which are of Disabling severity or worse.
-
- function WARNING_ERROR_STATUS return BOOLEAN;
- -- Returns true if any errors have been found during this compilation
- -- which are of Warning severity or worse.
-
- procedure INITIALIZE_MESSAGES;
- -- Procedure reads the information from the COMERRS file to an array kept
- -- in this package.
-
- procedure SEND_SIMPLE_MESSAGE(CODE: in INTEGER);
- -- Procedure is used if only the text of a message is to be displayed on
- -- the screen (the message is identified by the numeric code).
-
- procedure SEND_COMPILE_ERROR(CODE: in INTEGER);
- -- Procedure is used to send a compiler error. The text sent to the display
- -- includes the message number code, the line number, the severity of the
- -- error, the lexical unit, and the text of the message.
-
- procedure SEND_FINAL_MESSAGE;
- -- Sends a final summary message to the screen, includes the total number
- -- of errors, the highest severity of error, and message text.
-
- procedure SEND_RUNTIME_ERROR(CODE: in INTEGER);
- -- This procedure is used to send messages during the Menu Handler. It
- -- shows the numeric code, the message text, and waits for any key to be
- -- typed to return control the calling program.
-
- end COMPILER_MESSAGES;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --continee.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
- -- CONTROLLING_MENU_INFO_LINE;CONTINEE.ADA;KJL;04/16/85
-
- -- This package contains the text for Menu Information Line, and it contains
- -- subprograms for processing this line. The Menu Information Line is a
- -- character string that appears in the second to last line of the menu
- -- display. The line is often blank but will contain the Bad Selection Message
- -- if necessary, or a message telling that a background task has started. If
- -- this software system is expanded, this package can be edited to allow more
- -- messages to appear in the Menu Information Line.
-
- -- The package is instantiated when the Menu Handler is run so the procedures
- -- will work using the proper configuration constants.
- generic
- -- The Screen Width is passed to this package when it is instantiated, so
- -- the string lengths will fit on the display.
- SCREEN_WIDTH: POSITIVE;
- package CONTROLLING_MENU_INFO_LINE is
-
- -- Procedure will set the Bad Selection Message that is kept internally is
- -- this package to the string given.
- procedure RECEIVE_BAD_SELECT_MESSAGE (BAD_SELECT_MSG: in STRING);
-
- -- Procedure will set the Menu Information Line to the text of the Bad
- -- Selection Message.
- procedure SET_BAD_SELECTION;
-
- -- Procedure will set the Menu Information Line to text notifying that a
- -- task has started (tasks are run in background while the menu is
- -- displaying and processing inputs).
- procedure SET_TASK_STARTED (FILE_NAME: in STRING);
-
- -- Function returns a string of size SCREEN_WIDTH that is the Menu
- -- Information Line kept internally.
- function RETURN_INFO_LINE return STRING;
-
-
- end CONTROLLING_MENU_INFO_LINE;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --dispinge.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
- -- DISPLAY_PROCESSING;DISPINGE.ADA;KJL;04/09/85
-
- -- This package contains procedures to handle the menu display. It stores
- -- the display layout in an array of strings. The procedures are used to
- -- process this array of strings, and output the display to a CRT.
- -- The package keeps a Current Read counter, and a Current Write counter. These
- -- value indicate the next display line to be read and written from the display
- -- array. Display lines are read when the display is put to the Menu Def Table
- -- file, they are written when the Menu Def File contains text to be put in
- -- the screen layout, and when the Menu Def Table is read by the Menu Handler.
-
- with TEXT_HANDLER_SUBSET;
- generic
- -- Passed to this package when instantiated is the Screen Width which
- -- determines the length of each display line. The Screen Length
- -- determines the number of display lines within the display array.
- SCREEN_WIDTH: POSITIVE;
- SCREEN_LENGTH: POSITIVE;
- package DISPLAY_PROCESSING is
-
- -- Rename to avoid using DOT notation.
- subtype TEXT is TEXT_HANDLER_SUBSET.TEXT;
-
- function GET_NEXT_SCREEN_LINE return STRING;
- -- Returns the next display line as determined by the Current Read counter.
-
- procedure PUT_NEXT_SCREEN_LINE(DISPLAY_TEXT: in STRING);
- -- Writes the next display line as determined by the Current Write counter.
-
- function END_OF_SCREEN return BOOLEAN;
- -- Returns true if the last display line has been read.
-
- procedure PUT_SCREEN_TEXT(LINE, COLUMN: in INTEGER; DISPLAY_TEXT: in TEXT);
- -- Writes text to the display layout array starting at the display line
- -- given, and the string index of that line given in the Column argument.
-
- procedure CLEAR_SCREEN_LAYOUT;
- -- Puts blanks in all the positions of the display layout array.
-
- procedure PUT_SCREEN_LAYOUT_TO_CRT;
- -- Using Text_Io procedures, each line of the display layout array is
- -- put to the display.
-
-
- end DISPLAY_PROCESSING;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --handntse.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
-
- -- HANDLE_COMPILER_COMPONENTS;HANDNTSE.ADA;KJL;04/13/85
-
- -- This package contains subprograms used to process the Lexical Units found in
- -- the Menu Definition File. The package keeps track or variables used as the
- -- compilation is running, ie, current column and line number for the display
- -- layout, and the Bad Selection message last specified in the Menu Definition.
-
-
- with TEXT_HANDLER_SUBSET;
- -- The package in instantiated at run time so that the subprograms are
- -- executed with the proper configuration values.
- generic
- -- Passed to the package when it is instantiated is:
- -- The types of lexical units, used check syntax (most often a User Literal
- -- must follow an Identifier).
- type LEXICAL_UNIT_TYPES is (<>);
-
- -- Types of action - for processing the Select instruction.
- type ACTION_TYPE is (<>);
-
- -- Valid selection keys - for processing the Select instruction.
- USABLE_SELECT_KEYS: STRING;
-
- -- Screen width and length - for valid Line and Column instructions and to
- -- insure that text for the menu layout will fit on the display.
- SCREEN_WIDTH: POSITIVE;
- SCREEN_LENGTH: POSITIVE;
-
- -- Maximum characters in a command name - checked when the user specifies
- -- a process in a select instruction.
- FILE_STRING_SIZE: POSITIVE;
-
- -- Procedure adds a control item to a dynamic list of control items. A
- -- control item results from a Select instruction, and specifies the
- -- process and its type associated with a menu selection key.
- with procedure ADD_MENU_CONTROL_ITEM (SELECT_KEY: in CHARACTER;
- NEXT_MENU: in TEXT_HANDLER_SUBSET.TEXT;
- FILE_NAME_OF_PRCESS: in TEXT_HANDLER_SUBSET.TEXT;
- TYPE_OF_ACTION: in ACTION_TYPE);
-
- -- Procedure makes the next lexical unit available for analyzing.
- with procedure GET_LEXICAL_UNIT_IF_NEEDED;
-
- -- Signals that a lexical unit was made available and has not been used
- -- yet, so the next request for a lexical unit should not get a new one
- -- from the Menu Definition, but should use the one still available.
- with procedure UNIT_RECEIVED;
-
- -- Returns the type of the lexical unit currently available.
- with function CURRENT_LEX_TYPE return LEXICAL_UNIT_TYPES;
-
- -- Returns the text of the lexical unit currently available.
- with function CURRENT_LEX_STRING return TEXT_HANDLER_SUBSET.TEXT;
-
- -- Puts text to the display layout array.
- with procedure PUT_SCREEN_TEXT (ROW,COLUMN: in POSITIVE;
- DISPLAY_TEXT: in TEXT_HANDLER_SUBSET.TEXT);
-
- -- Send errors messages to user terminal.
- with procedure SEND_COMPILE_ERROR(CODE: in INTEGER);
- package HANDLE_COMPILER_COMPONENTS is
-
- -- Rename Text type to avoid using extended name notation.
- subtype TEXT is TEXT_HANDLER_SUBSET.TEXT;
-
- -- Procedure gets name of Menu Definition Table to be created. This text
- -- string is kept in this package.
- procedure GET_THE_TITLE;
-
- -- Do the necessary logic to process the given Identifiers string.
- procedure PROCESS_IDENTIFIER(LEXICAL_STRING: in TEXT);
-
- -- Put the given text to the menu display layout at the current line and
- -- column position (User Literals not following an identifier as per the
- -- language syntax, are interpreted as text put to the display layout).
- procedure WRITE_SCREEN_LAYOUT_TEXT(LEXICAL_STRING: in TEXT);
-
- -- Returns the text that is the Bad Selection message.
- function THE_BAD_SELECTION_MESSAGE return TEXT;
-
- -- Returns the text that is the name of the Menu Def Table to be created.
- function THE_TITLE_NAME return TEXT;
-
- end HANDLE_COMPILER_COMPONENTS;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --handsese.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
- -- HANDLE_PROCESSES;HANDSESE.ADA;KJL;04/17/85
-
- -- This package contains subprograms used by the Menu Handler that processes
- -- the requests for action, that result from the menu users inputs. This
- -- package will also contain the file name of the Menu Definition Table that
- -- defined the next menu to be displayed.
-
- with TEXT_HANDLER_SUBSET;
- -- The package is instantiated using the following arguments:
- generic
-
- -- The enumeration type set of qualifiers for the action to perform on a
- -- menu selection (M - call a menu, P - CLI command, T - CLI command
- -- performed while the Menu Handler continues, A - call Ada procedure).
- type ACTION_TYPES is (<>);
-
- -- The types of user inputs, a CLI line or a selection key typed.
- type INPUT_TYPES is (<>);
-
- -- This procedure will be used to retrieve the process name to perform, and
- -- its type, given a selection key character. The procedure searches a
- -- Menu Control List kept in another package. If the selection key is not
- -- found in the list, the NOT_FOUND argument will be set.
- with procedure RETRIEVE_CONTROL_ITEM (SELECT_KEY: in CHARACTER;
- NEXT_MENU: out TEXT_HANDLER_SUBSET.TEXT;
- FILE_NAME_OF_PROCESS: out TEXT_HANDLER_SUBSET.TEXT;
- TYPE_OF_ACTION: out ACTION_TYPES;
- NOT_FOUND: out BOOLEAN);
-
- -- This procedure is used to pass a character string to the Command Line
- -- Interpreter of the operating system. A code is sent to specify whether
- -- to wait for the command to complete, or continue immediately with the
- -- Menu Handler.
- with procedure COMMAND_LINE_PROCESSOR (COMMAND_LINE: in STRING;
- CONTINUE_WAIT_CODE: in INTEGER; ERROR_OCCUR: out BOOLEAN);
-
- -- This procedure is used to call an Ada procedure of the name given as a
- -- string argument. The procedure runs until complete and the Menu Handler
- -- returns when the procedure is finished.
- with procedure ADA_PROCEDURE_CALL (ADA_PROCEDURE_NAME: in STRING;
- ERROR_OCCUR: out BOOLEAN);
-
- -- This procedure will display an error while the Menu Handler is running.
- -- The error displays, and on the users command, the Menu Handler cont-
- -- inues. The error displayed is identified by the CODE argument.
- with procedure SEND_RUNTIME_ERROR (CODE: in INTEGER);
-
- -- This procedure sets the Menu Info Line to display the Bad Selection
- -- Message.
- with procedure SET_BAD_SELECTION;
-
- -- This procedure sets the Menu Info Line to display that the task of
- -- name given in the string argument has started.
- with procedure SET_TASK_STARTED (FILE_NAME: in STRING);
-
- package HANDLE_PROCESSES is
-
- -- Rename the TEXT type to avoid using the extended DOT notation.
- subtype TEXT is TEXT_HANDLER_SUBSET.TEXT;
-
-
- -- This procedure is passed the string that is what the user input at the
- -- menu, and the type of input this was. The procedure will perform the
- -- necessary processing based on this users input, including retrieving
- -- the action(s) to perform, updating the name of the next menu to display,
- -- and issuing necessary error messages.
- procedure DO_REQUEST (CURRENT_MENU: in TEXT; REQUEST_STRING: in TEXT;
- TYPE_OF_REQUEST: in INPUT_TYPES);
-
-
- -- This function will return the name of the next menu to be displayed. The
- -- name will be in TEXT dynamic string form with no leading or trailing
- -- blanks around the name.
- function MENU_TO_BE_DISPLAYED return TEXT;
-
-
- end HANDLE_PROCESSES;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --procblee.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
- -- PROCESS_MENU_CONTROL_TABLE;PROCBLEE.ADA;KJL;04/16/85
-
- -- This package contains subprograms necessary to hold and use the Menu Control
- -- List. This list is a dynamic list of Menu Control Items, each item
- -- characterizes a menu selection. Information contained in each item includes:
- -- The selection key that is typed at resulting menu, the type of action that
- -- is performed when this key is typed, and the name or file name involved in
- -- such action. As an example, a Menu Control Item might contain information
- -- defining that when this menu is run, the letter 'A' (selection key) may be
- -- typed to invoke an operating system command 'GOJOB' (name or file name) that
- -- will be performed in background while the menu returns to the screen (type
- -- of action, translating the the TASK type). The Menu Control Item also
- -- contains a Next Menu which specifies the name of a Menu Def Table that will
- -- be the next menu following the action performed.
-
- -- This procedure also contains the subprograms used to write and read the
- -- external file which is the Menu Definition Table. The file is written with
- -- records that match the Menu Control Items. Other information written to the
- -- file; the lines of the Menu Display Layout, and the Bad Selection Message,
- -- are put into the same record structure then written to the file. The same
- -- record structures are read from the file, and the Menu Control List, Menu
- -- Display Layout, and Bad Selection Message is extracted.
-
- with TEXT_HANDLER_SUBSET;
- -- This package is instantiated at when the Menu Compiler or Menu Handler is
- -- running, so that the procedures work correctly for the configuration
- -- specified. The following items are given on instantialing this package.
- generic
-
- -- The enumeration set that is the codes for each type of action that can
- -- be performed on a selection (CLI program, background CLI task, Ada
- -- procedure, call another Menu...);
- type ACTION_TYPE is (<>);
-
- -- The Maximum size of a file name or program name allowed.
- FILE_STRING_SIZE: POSITIVE;
-
- -- The number of characters possible for each line of the screen display.
- SCREEN_STRING_SIZE: POSITIVE;
-
- -- Function that returns the text of a line from the Menu Display Layout.
- -- Each time the function is called the next line is returned in order top
- -- to bottom ("next" is the line right after the last one GOT).
- with function GET_NEXT_SCREEN_LINE return STRING;
-
- -- Returns true if the last display layout line hav been returned using the
- -- GET_NEXT_SCREEN_LINE function.
- with function END_OF_SCREEN return BOOLEAN;
-
- -- Puts the text given to the Menu Display Layout. Lines are put in order
- -- from top to bottom. The line in put to the "next" display layout line,
- -- right after the last line that was PUT.
- with procedure PUT_NEXT_SCREEN_LINE(DISPLAY_TEXT: in STRING);
-
- -- Clears the Menu Display Layout.
- with procedure CLEAR_SCREEN_LAYOUT;
-
- package PROCESS_MENU_CONTROL_TABLE is
-
-
- -- Rename TEXT type to avoid using the extended name notation.
- subtype TEXT is TEXT_HANDLER_SUBSET.TEXT;
-
-
- -- This procedure adds a Menu Control Item to the dynamic Menu Control
- -- List given the information for the item ie, the Selection Key, the
- -- Action Type, the Next Menu and the names or file names involved. The
- -- information is put into the proper data structure. The data structure is
- -- added to the list.
- procedure ADD_MENU_CONTROL_ITEM (SELECT_KEY: in CHARACTER;
- NEXT_MENU: in TEXT;
- FILE_NAME_OF_PROCESS: in TEXT;
- TYPE_OF_ACTION: in ACTION_TYPE);
-
-
- -- The procedure is given a character select key, and the returns the
- -- information from the Control Item corrisonding to that selection key.
- -- This procedure is used in the Menu Handler when a select key is typed.
- procedure RETRIEVE_CONTROL_ITEM (SELECT_KEY: in CHARACTER;
- NEXT_MENU: out TEXT;
- FILE_NAME_OF_PROCESS: out TEXT;
- TYPE_OF_ACTION: out ACTION_TYPE;
- NOT_FOUND: out BOOLEAN);
-
-
- -- This procedure writes the Menu Definition Table. It uses the Menu
- -- Control List kept in this package, but also writes the Bad Selection
- -- Message and the Menu Display layout lines. All items written are put
- -- into the record types used by the Menu Control Items, and the external
- -- file is written using these types of records.
- procedure WRITE_MENU_CONTROL_FILE (FILE_NAME_OF_MENU_DEF_TABLE: in TEXT;
- BAD_SELECTION_MESSAGE: in TEXT;
- ERROR_CODE: out INTEGER);
-
-
- -- This procedure is used by the Menu Handler to read a Menu Definition
- -- Table. The external file read must have been written using the procedure
- -- above since the same structure of records that are written above, is
- -- read here. The procedure will read the file and load the Menu Control
- -- List, it will also return the Bad Selection Message, and load the Menu
- -- Display Layout.
- procedure READ_MENU_CONTROL_FILE (FILE_NAME_OF_MENU_DEF_TABLE: in TEXT;
- BAD_SELECTION_MESSAGE: out TEXT;
- ERROR_CODE: out INTEGER);
-
-
-
- end PROCESS_MENU_CONTROL_TABLE;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --procinge.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
- -- PROCESS_MENU_DEF_STRING;PROCINGE.ADA;KJL;04/17/85
-
- -- This package is used by the Menu Compiler, and contains the subprograms
- -- needed to do some basic processing on the Menu Definition File. The Menu
- -- Def File is written in the Menu Def Language, and is a description of the
- -- Menu display and menu action. The file cna be thought of as a series of
- -- Lexical Units, that are characters of set of characters, that are arranged
- -- in the file and can be sequentially extracted. This package contains sub-
- -- programs to extract and handle these Lexical Units. Analyzing the Lexical
- -- Units for correctness in their content and their order is left to another
- -- Ada package, so no compiler errors regarding the lexical units appear in
- -- this package.
-
- -- The Menu Definition File is an external file that is edited using some
- -- editor and the operations of the particular operating system. One of the
- -- operations performed in this package is to transfer the external file to
- -- a Menu Definition String. This string is a dynamic character string that
- -- will contain all the characters of the file. This string will be kept in
- -- this package, and the string will be processed when lexical units are
- -- extracted. This keeps the external Menu Definition File open for a minimum
- -- amount of time.
-
- with TEXT_IO, TEXT_HANDLER_SUBSET;
- -- The package is instantiated with the following arguments so the procedures
- -- will work with the given configuration:
- generic
-
- -- The enumeration type set of lexical unit names. The names do not affect
- -- the processing, but the type of lexical unit is an argument passed in
- -- some of the subprograms.
- type LEXICAL_UNIT_TYPES is (<>);
-
- -- The maximum size of a line in the Menu Definition File. Used when the
- -- lines form the Menu Def File are read.
- MENU_DEF_FILE_LINE_SIZE: POSITIVE;
-
- -- A string of characters that are the characters signaling separateion of
- -- lexical units within the Menu Def File.
- WORD_SEPARATORS: STRING;
-
- -- Character signaling that the characters following until the end of the
- -- line are comments (can be ignored).
- COMMENT_INDICATOR: CHARACTER;
-
- -- The right and left delimiter character are used to signal User Literal
- -- lexical units. In these lexical units, all characters (whether Comment
- -- Indicator, Word Separateor of whatever...) that are between the delim-
- -- iters are taken as part of the lexical unit.
- RIGHT_DELIMITER: CHARACTER;
- LEFT_DELIMITER: CHARACTER;
-
- package PROCESS_MENU_DEF_STRING is
-
- -- Rename the TEXT type to avoid using the extended dot notation.
- subtype TEXT is TEXT_HANDLER_SUBSET.TEXT;
-
- -- This procedure is given name of file which is the Menu Definition File,
- -- and the file is written to a Menu Definition String. The string is kept
- -- in this package for future lexical unit extractions. An error code is
- -- given if there are problems reading the external file.
- procedure WRITE_MENU_DEF_STRING(FILE_NAME_OF_MENU_DEF_FILE: in TEXT;
- ERROR_CODE: out INTEGER);
-
- -- This procedure makes the next lexical unit in the Menu Def String
- -- available. It extract the text for the next lexical unit from the Menu
- -- Def String, and keeps it available in this package. It also compacts the
- -- Menu Def String, eliminating the text of all previous lexical elements
- -- in the Menu Def String. In this way the Menu Def String is always
- -- shrinking as lexical elements are extracted.
- procedure GET_LEXICAL_UNIT_IF_NEEDED;
-
- -- This procedure signals this package that the last lexical unit extracted
- -- has not been used yet. Therefore when a request is made for a new
- -- lexical unit, no new lexical unit will be extracted from the Menu Def
- -- String, instead the current lexical unit available will remain the
- -- current lexical unit available.
- procedure UNIT_RECEIVED;
-
- -- Returns the lexical unit type of the current lexical unit available.
- function CURRENT_LEX_TYPE return LEXICAL_UNIT_TYPES;
-
- -- Returns the character position of the current Menu Definition File line,
- -- where the next lexical unit will be extracted.
- function CURRENT_POSITION return INTEGER;
-
- -- returns the current Menu Definition File Line where the next lexical
- -- unit will be extracted.
- function CURRENT_LINE_NUMBER return INTEGER;
-
- -- Returns the text of the current lexical unit available, returned in
- -- TEXT type form.
- function CURRENT_LEX_STRING return TEXT;
-
- -- Returns the number of characters in the lexical unit that is currently
- -- available.
- function LEXICAL_STRING_LENGTH return INTEGER;
-
-
-
- end PROCESS_MENU_DEF_STRING;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --procione.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
- -- PROCESS_CONFIGURATION;PROCIONE.ADA;KJL;04/18/85
-
- -- This package contains the user defined items as read from the
- -- configuration file. The objects are kept in the package Spec. so that they
- -- are accessable to the main procedure of the Menu Compiler, and Menu Handler.
- -- The objects are also given default values, so that if errors occur while
- -- reading the file, all objects will still have legal values.
- -- If problems occur when the Configuration file is being read, this is
- -- signaled by displaying "!!" on the screen (this is done because before
- -- reading the config file, the Menu Manager programs do not know how big the
- -- the screen width is, and full text lines may not be displayed correctly). In
- -- any case, the config objects will at least have the legal default values so
- -- the Menu Manager procedures can perform.
-
- with TEXT_IO, TEXT_HANDLER_SUBSET;
- package PROCESS_CONFIGURATION is
-
- -- The default name of configuration file is "MENCON". The maximum
- -- characters per line in this file is 100. These two constants can be
- -- changed if the user desired, but the following steps will have to be
- -- taken to make the Menu Compiler and Menu Handler work:
- -- * Recompile this package.
- -- * Recompile the main procedure for the Menu Compiler
- -- * Recompile the main procedure for the Menu Handler
- -- * Relink the main procedures for the Menu Compiler and Handler.
- CONFIG_FILE_NAME : constant STRING := "MENCON";
- INPUT_LINE_LENGTH : constant := 100;
-
- -- Rename the TEXT type to avoid using DOT notation.
- subtype TEXT is TEXT_HANDLER_SUBSET.TEXT;
-
- -- Configuration ojects, the values are read from the MENCON file.
- MAX_FILE_NAME_LENGTH: POSITIVE := 15;
- MENU_FILE: TEXT := TEXT_HANDLER_SUBSET.TO_TEXT("MENUFILE");
- LENGTH_OF_LINES_IN_MENU_FILE: POSITIVE := 100;
- MENU_TABLE: TEXT := TEXT_HANDLER_SUBSET.TO_TEXT("MENUTABL");
- SCREEN_WIDTH: POSITIVE := 80;
- SCREEN_LENGTH: POSITIVE := 22;
- QUIT_CHARACTER: CHARACTER := '@';
-
-
- -- Other configuration items that are not changable to the user, but are
- -- needed in both Menu Compiler, and Menu Handler.
- type ACTION_TYPES is (X, T, P, A, M);
-
-
- procedure READ_CONFIGURATION_FILE;
- -- Reads the configuration values from the MENCON file.
-
- end PROCESS_CONFIGURATION;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --proctore.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
- -- PROCESS_INITIATOR;PROCTORE.ADA;KJL;04/17/85
-
- -- This package contains two procedures, the bodies of which are completely user
- -- supplied except for a few sample and skeletal statements. These procedures
- -- provide the interface of the Menu Handler with the CLI, and the interface
- -- of the Menu Handler with any Ada procedures that are desired to be linked
- -- to this Menu Handler program. The package spec for this package contains
- -- the procedure specs for the two interface procedures. The procedure specs
- -- should not be changed since this is the linkage between the interface
- -- procedures and the rest of the Menu Handler software. Therefore the user
- -- should supply the statements in the procedure bodies, so that the arguments
- -- of the procedures input and return the desired values.
-
- package PROCESS_INITIATOR is
-
- -- This interface procedure is used to transfer a string passed it the CLI.
- -- The method of doing this is different for different Ada environments,
- -- and may not even exist in a particular environment. There are two
- -- arguments passed to this procedure to be used by the user provided
- -- statements, and one argument passed back to the calling procedure.
- -- The COMMAND_LINE is a string argument that contains a single word,
- -- like a command or an executable file of commands. This string have no
- -- leading of trailing blanks, and this string is to be passed directly to
- -- the Command Line Interpretor.
- -- The CONTINUE_WAIT_CODE is integer code that specifies 0 - to hold the
- -- Menu Handler program while the command is being processed by the CLI,
- -- or 1 - to make the Menu Handler continue immediately once the line or
- -- command has been passed to the CLI. The use of these codes input the
- -- this interface procedure will depend entirely on the capability
- -- available to issue statements the CLI from this Ada program (ie, it
- -- may be possible to issue a command to the CLI from this Ada program,
- -- but it may not be possible to issue the command and have the Ada program
- -- wait for command completion).
- -- The ERROR argument is a boolean parameter returned to the calling
- -- procedure. It is ment to be used to return the status of the CLIs
- -- ability to interpret the line given to it. If the CLI could not read
- -- or understand the string passed to it, then the ERROR argument should
- -- return TRUE. The ERROR argument is not ment to return the status of
- -- the actual command of process started, only the CLIs ability to start it.
- procedure COMMAND_LINE_PROCESSOR (COMMAND_LINE: in STRING;
- CONTINUE_WAIT_CODE: in INTEGER;
- ERROR: out BOOLEAN);
-
-
-
- -- This interface procedure is used to provide a method for starting other
- -- Ada procedures. The procedures will in some way have to be linked to
- -- the Menu Handle procedure for them to be called. This can be done in a
- -- number of ways. There is one argument passed to this procedure, to
- -- be used by the user supplyed statements in the procedure body, and one
- -- argument passed back to the calling program, the statements of the
- -- procedure body must supply a value for this argument.
- -- The ADA_PROCEDURE_NAME argument is a string argument given to the
- -- procedure. This string is ment to be used in a multi-conditional
- -- statement, that will call an Ada procedure by the name corresponding to
- -- the string given. The string passed here will always have no leading or
- -- trailing blanks, other than that, they will be the exact string
- -- specified in the Menu Definition File on a Select ... A [string] in-
- -- struction (see the syntax guide).
- -- The ERROR argument passed back to the calling program is ment to be
- -- set TRUE if the string is not found in the multi-conditional statement,
- -- and therefore no corresponding Ada procedure was started.
- procedure ADA_PROCEDURE_CALL (ADA_PROCEDURE_NAME: in STRING;
- ERROR: out BOOLEAN);
-
-
- end PROCESS_INITIATOR;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --compgesd.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
- -- COMPILER_MESSAGES;COMPGESD.ADA;KJL;04/18/85
-
- -- Package body to handle compiler messages.
-
- -- All the messages that the Menu Compiler and Menu Handler issue are found in
- -- a file "COMERRS". There are 2 lines for each message:
- -- The first line is a code of severity for the message: NO_ERROR for
- -- information messages that are not related to errors. WARNING_ERROR for
- -- errors that will not stop the compilation or the creation of the Menu Def
- -- Table, DISABLING_ERROR for errors that stop the creation of the Menu Def
- -- Table, but the compiler continues to process the Menu Def File, and
- -- FATAL_ERROR for errors that are severe enough to warrant stopping the
- -- compilation immediately, and no Menu Def Table is created.
- -- The second line is a 236 character line that contains the text of the
- -- the message to be displayed.
- -- Each message has a numeric code associated with it which is the order that
- -- the message entrys appear in the COMERRS file. This numeric code is used
- -- when a message is invoked in other procedures.
-
- -- One procedure of this package reads the COMERRS file into an array kept in
- -- the package. The array is used during the compilation, not the file.
- -- The file is open only when it is initially being read, then closed for the
- -- duration of the program run.
-
- with TEXT_IO;
- package body COMPILER_MESSAGES is
-
- MESSAGE_SIZE: constant := 236; -- string size of messages.
- LAST_MESSAGE: constant := 36; -- number of messages in COMERRS file
-
- -- Set of severity codes
- type ERROR_TYPES is (FATAL_ERROR,DISABLING_ERROR,WARNING_ERROR,NO_ERROR);
-
- -- Structure used to store message information from COMERRs file.
- type MESSAGE_INFO is
- record
- ERROR_STATUS: ERROR_TYPES;
- MESSAGE_LINE: STRING(1..MESSAGE_SIZE);
- end record;
-
- type MESSAGE_LIST_TYPE is array (1..LAST_MESSAGE) of MESSAGE_INFO;
-
-
- NUMBER_OF_ERRORS: INTEGER := 0; -- Tally of all types of errors
- MESSAGE_LIST: MESSAGE_LIST_TYPE; -- Message info from COMERRS file
-
- -- The error status will contain the highest severity code as yet received
- -- in a compile error.
- CURRENT_ERROR_STATUS: ERROR_TYPES := NO_ERROR;
-
- -- To allow conversion of integer to string to be displayed
- package INTEGER_IO is new TEXT_IO.INTEGER_IO(INTEGER);
-
-
- procedure PUT_MESSAGE_TO_SCREEN (STR: in STRING) is
- -- This procedure is used to put a string to the display. The string is
- -- split at word breaks so that it will fit on the screen width defined.
-
- START_POS: POSITIVE; -- Index of 1st char for next output line.
- CHAR_COUNT: POSITIVE; -- String index for current character.
- BLANK_POS: NATURAL; -- Index of the last blank found.
-
- function RETURN_STARTING_POSITION (INIT: POSITIVE) return POSITIVE is
- -- Function returns the string index of the first non blank character,
- -- following the string index given in INIT. Operation is done to the
- -- STR string passed to the PUT_MESSAGE_TO_SCREEN procedure.
- begin
- for I in INIT..STR'LAST loop
- if STR(I) /= ' ' then
- return I;
- end if;
- end loop;
- -- if no blanks were found, return value greater than last index.
- return STR'LAST + 1;
- end RETURN_STARTING_POSITION;
-
- procedure PUT_THIS_LINE is
- -- This procedure is used to put a section of the STR string to the
- -- display.
- begin
- -- if no blank is found on the line, put the full set of characters
- -- received.
- if (BLANK_POS = START_POS -1) then
- TEXT_IO.PUT_LINE(STR(START_POS..CHAR_COUNT-1));
- else
- -- put the section of the string from 1st non blank to before the
- -- last blank found. Set current char to just after the blank
- TEXT_IO.PUT_LINE(STR(START_POS..BLANK_POS-1));
- CHAR_COUNT := BLANK_POS+1;
- end if;
- -- Reset start pos for next line to be output (next non blank).
- -- Set current string index to same value, an set blank pos to signal
- -- that no blanks have yet been found.
- START_POS := RETURN_STARTING_POSITION(CHAR_COUNT);
- CHAR_COUNT := START_POS;
- BLANK_POS := START_POS-1;
- end PUT_THIS_LINE;
-
- begin
- -- Main logic of the PUT_MESSAGE_TO_SCREEN procedure. The string passed
- -- is followed character by character, keeping track of the last blank
- -- incountered and the 1st no blank after the previously written line.
- -- When enough words are found to fit in the screen width then the
- -- accumulated string, which is a section of the passed string, will be
- -- written to the display.
- -- Start with the first non blank character found.
- START_POS := RETURN_STARTING_POSITION(STR'FIRST);
- CHAR_COUNT := START_POS;
- BLANK_POS := START_POS - 1;
- while (CHAR_COUNT <= STR'LAST) loop -- Do until the end of the string
- if (STR(CHAR_COUNT) = ' ') then
- BLANK_POS := CHAR_COUNT; -- Keep last found blank index
- end if;
- if (CHAR_COUNT - START_POS + 1 > SCREEN_WIDTH) then
- -- when the accumulated string gets larger than the screen width
- -- put the accumulated string to the display.
- PUT_THIS_LINE;
- end if;
- CHAR_COUNT := CHAR_COUNT + 1;
- end loop; -- Increment through passed string
-
- -- When the end of the string is reached, check if there is text being
- -- accumulated that has not been written, set blank pos so the whole
- -- set will be written to the display (disregard the last blank
- -- encountered), and put this text on the screen.
- if (START_POS <= STR'LAST) then
- BLANK_POS := START_POS - 1;
- PUT_THIS_LINE;
- end if;
-
- end PUT_MESSAGE_TO_SCREEN;
-
-
-
- procedure INITIALIZE_MESSAGES is
- -- This procedure reads the COMERRS file into the array that will be used
- -- while the Menu Compiler and Menu Handler run.
- ERROR_MESSAGE_FILE: TEXT_IO.FILE_TYPE; -- internal file name
- ERROR_TYPE_STRING: STRING(1..MESSAGE_SIZE); -- input string used
- LAST_INDEX: POSITIVE; -- index for input string
- OLD_LINE: TEXT_IO.POSITIVE_COUNT; -- Line number of file
- begin
- -- Open the COMERRS file
- TEXT_IO.OPEN(ERROR_MESSAGE_FILE, TEXT_IO.IN_FILE, "COMERRS");
- for I in 1..LAST_MESSAGE loop
- -- Read for each message: the severity code which is converted from
- -- string type to enumeration type, and read the message text.
- TEXT_IO.GET_LINE(ERROR_MESSAGE_FILE,ERROR_TYPE_STRING,LAST_INDEX);
- MESSAGE_LIST(I).ERROR_STATUS := ERROR_TYPES'VALUE
- (ERROR_TYPE_STRING(1..LAST_INDEX));
-
- OLD_LINE := TEXT_IO.LINE(ERROR_MESSAGE_FILE);
- TEXT_IO.GET_LINE(ERROR_MESSAGE_FILE,ERROR_TYPE_STRING,LAST_INDEX);
- if LAST_INDEX < MESSAGE_SIZE then
- ERROR_TYPE_STRING(LAST_INDEX+1..MESSAGE_SIZE) :=
- (LAST_INDEX+1..MESSAGE_SIZE => ' ');
- end if;
- if INTEGER(TEXT_IO.LINE(ERROR_MESSAGE_FILE)) = INTEGER(OLD_LINE) then
- TEXT_IO.SKIP_LINE(ERROR_MESSAGE_FILE);
- end if;
- MESSAGE_LIST(I).MESSAGE_LINE := ERROR_TYPE_STRING;
- end loop;
- -- Close file after reading all messages, or receiving END_ERROR.
- TEXT_IO.CLOSE(ERROR_MESSAGE_FILE);
- exception
- when CONSTRAINT_ERROR =>
- PUT_MESSAGE_TO_SCREEN(" Error in reading COMERRS file. ");
- when TEXT_IO.DATA_ERROR =>
- PUT_MESSAGE_TO_SCREEN(" Error in reading COMERRS file. ");
- when TEXT_IO.END_ERROR =>
- TEXT_IO.CLOSE(ERROR_MESSAGE_FILE);
- end INITIALIZE_MESSAGES;
-
-
-
-
- procedure SEND_SIMPLE_MESSAGE(CODE: in INTEGER) is
- -- Procedure is used if only the text of a message is to be displayed on
- -- the screen (the message is identified by the numeric code).
- begin
- PUT_MESSAGE_TO_SCREEN(MESSAGE_LIST(CODE).MESSAGE_LINE);
- end SEND_SIMPLE_MESSAGE;
-
-
-
- procedure SEND_COMPILE_ERROR(CODE: in INTEGER) is
- -- Procedure is used to send a compiler error. The text sent to the display
- -- includes the message number code, the line number, the severity of the
- -- error, the lexical unit, and the text of the message.
-
- CODE_STRING : STRING(1..4); -- String that is numeric error code.
- LINE_POSITION : STRING(1..7); -- String that is line number of error.
-
- begin
- -- Convert code and line number to string, put line to display
- -- containing numeric error code, line number, and severity code.
- INTEGER_IO.PUT(CODE_STRING,CODE);
- INTEGER_IO.PUT(LINE_POSITION,CURRENT_LINE_NUMBER);
- TEXT_IO.NEW_LINE;
- TEXT_IO.NEW_LINE;
- PUT_MESSAGE_TO_SCREEN (
- " <= Error Number " & CODE_STRING &
- " Line Position " & LINE_POSITION & " " &
- ERROR_TYPES'IMAGE(MESSAGE_LIST(CODE).ERROR_STATUS) );
-
- -- Put text to display containing current lexical string in Menu Def
- -- File where error was detected.
- TEXT_IO.NEW_LINE;
- PUT_MESSAGE_TO_SCREEN(" < " &
- TEXT_HANDLER_SUBSET.VALUE(CURRENT_LEX_STRING)
- & " >");
-
- -- Put text of the message to the display.
- TEXT_IO.NEW_LINE;
- PUT_MESSAGE_TO_SCREEN(MESSAGE_LIST(CODE).MESSAGE_LINE);
-
- -- Update Current Error Status so that it always contains the highest
- -- error severity code yet found.
- if (MESSAGE_LIST(CODE).ERROR_STATUS < CURRENT_ERROR_STATUS) then
- CURRENT_ERROR_STATUS := MESSAGE_LIST(CODE).ERROR_STATUS;
- end if;
-
- -- Increment total number of errors.
- NUMBER_OF_ERRORS := NUMBER_OF_ERRORS + 1;
-
- end SEND_COMPILE_ERROR;
-
-
-
- procedure SEND_FINAL_MESSAGE is
- -- Sends a final summary message to the screen, includes the total number
- -- of errors, the highest severity of error, and message text.
- NUMBER_ERRORS_STRING: STRING(1..4); -- String that is total errors.
-
- begin
- -- Convert total errors to string, put text to display.
- INTEGER_IO.PUT(NUMBER_ERRORS_STRING,NUMBER_OF_ERRORS);
- TEXT_IO.NEW_LINE;
- TEXT_IO.NEW_LINE;
- PUT_MESSAGE_TO_SCREEN("Menu Compiler EXITING with " &
- NUMBER_ERRORS_STRING & " error(s).");
-
- -- Put text to display depending on the final severity code. The
- -- different messages explain whether or not compilation finished,
- -- and/or Menu Def Table is created.
- TEXT_IO.NEW_LINE;
- case CURRENT_ERROR_STATUS is
- when FATAL_ERROR =>
- PUT_MESSAGE_TO_SCREEN (MESSAGE_LIST(20).MESSAGE_LINE);
-
- when DISABLING_ERROR =>
- PUT_MESSAGE_TO_SCREEN (MESSAGE_LIST(21).MESSAGE_LINE);
-
- when WARNING_ERROR =>
- PUT_MESSAGE_TO_SCREEN (MESSAGE_LIST(22).MESSAGE_LINE);
-
- when NO_ERROR =>
- PUT_MESSAGE_TO_SCREEN (MESSAGE_LIST(23).MESSAGE_LINE);
-
- end case;
-
- end SEND_FINAL_MESSAGE;
-
-
-
- procedure SEND_RUNTIME_ERROR (CODE: in INTEGER) is
- -- This procedure is used to send messages during the Menu Handler. It
- -- shows the numeric code, the message text, and waits for any key to be
- -- typed to return control the calling program.
-
- CODE_STRING: STRING(1..4); -- String that is numeric error code.
- INPUT_CHAR: CHARACTER; -- Character input to exit program.
-
- begin
- -- Convert code to string, put text to display.
- INTEGER_IO.PUT(CODE_STRING,CODE);
- TEXT_IO.NEW_LINE;
- PUT_MESSAGE_TO_SCREEN (
- "<= Run Time Error Number " & CODE_STRING & " " &
- ERROR_TYPES'IMAGE(MESSAGE_LIST(CODE).ERROR_STATUS) );
-
- -- Always keep current error status to the most severe error yet.
- if (MESSAGE_LIST(CODE).ERROR_STATUS < CURRENT_ERROR_STATUS) then
- CURRENT_ERROR_STATUS := MESSAGE_LIST(CODE).ERROR_STATUS;
- end if;
-
- -- Put text corresponding to this error code to the display.
- PUT_MESSAGE_TO_SCREEN (MESSAGE_LIST(CODE).MESSAGE_LINE);
- PUT_MESSAGE_TO_SCREEN (" Type Any Key to continue.");
-
- -- Wait for user to type any key to continue.
- TEXT_IO.GET(INPUT_CHAR);
-
- end SEND_RUNTIME_ERROR;
-
-
-
-
- function FATAL_ERROR_STATUS return BOOLEAN is
- -- Returns true if any errors have been found during this compilation
- -- which are of Fatal severity or worse (nothing is worse yet).
- begin
- return (CURRENT_ERROR_STATUS <= FATAL_ERROR);
- end FATAL_ERROR_STATUS;
-
-
-
- function DISABLE_ERROR_STATUS return BOOLEAN is
- -- Returns true if any errors have been found during this compilation
- -- which are of Disabling severity or worse.
- begin
- return (CURRENT_ERROR_STATUS <= DISABLING_ERROR);
- end DISABLE_ERROR_STATUS;
-
-
-
- function WARNING_ERROR_STATUS return BOOLEAN is
- -- Returns true if any errors have been found during this compilation
- -- which are of Warning severity or worse.
- begin
- return (CURRENT_ERROR_STATUS <= WARNING_ERROR);
- end WARNING_ERROR_STATUS;
-
-
-
- end COMPILER_MESSAGES;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --contined.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
- -- CONTROLLING_MENU_INFO_LINE;CONTINED;KJL;04/16/85
-
- -- Package body used to hold and process the Menu Information Line. This line
- -- appears at the second to last line of the menu display. It gives simple
- -- information to the menu user, when a menu is displayed. The line is usually
- -- blank, but will display the Bad Selection Message if necessary, or a
- -- message that a task was started. This package can be changed to cause the
- -- Menu Information Line to display other information should the system expand.
-
- package body CONTROLLING_MENU_INFO_LINE is
-
- -- A character string that will fit on the display screen.
- subtype SCREEN_STRING is STRING(1..SCREEN_WIDTH);
-
- -- The Menu Information Line. It is initially blank.
- MENU_INFO_LINE: SCREEN_STRING := (1..SCREEN_WIDTH => ' ');
-
- -- This blank line in assigned to the Menu Info Line to clear it.
- BLANK_LINE: SCREEN_STRING := (1..SCREEN_WIDTH => ' ');
-
- -- The Bad Selection Message is received from the Menu Def Table of the
- -- current menu to be displayed.
- BAD_SELECTION_MESSAGE: SCREEN_STRING;
-
-
- -- This procedure assigns the string given to the Bad Selection Message.
- procedure RECEIVE_BAD_SELECT_MESSAGE (BAD_SELECT_MSG: in STRING) is
- begin
- BAD_SELECTION_MESSAGE := BAD_SELECT_MSG;
- end RECEIVE_BAD_SELECT_MESSAGE;
-
-
- -- This procedure will set the Menu Information Line to the Bad Selection
- -- Message. The next time the Info Line is displayed, it will display the
- -- Bad Selection Message.
- procedure SET_BAD_SELECTION is
- begin
- MENU_INFO_LINE := BAD_SELECTION_MESSAGE;
- end SET_BAD_SELECTION;
-
-
- -- This procedure sets the Menu Info Line to tell that a task has started
- -- (a task is a CLI instruction that runs in background while the Menu
- -- Handler continues to display menus and accept inputs). The task name is
- -- passed to the procedure. The string assigned to the Menu Info Line is
- -- first checked to see if it will fit.
- procedure SET_TASK_STARTED (FILE_NAME: in STRING) is
- -- String telling task that started.
- INFO_STRING: constant STRING := " Task " & FILE_NAME & " has started.";
- begin
- if INFO_STRING'LENGTH <= SCREEN_WIDTH then
- MENU_INFO_LINE := BLANK_LINE;
- MENU_INFO_LINE(1..INFO_STRING'LENGTH) := INFO_STRING;
- end if;
- end SET_TASK_STARTED;
-
-
- -- Function returns a string of size SCREEN_WIDTH that is the value of the
- -- Menu Information Line. The Menu Information Line is blanked out before
- -- its value is returned so a temp variable is used.
- function RETURN_INFO_LINE return STRING is
- INFO_STRING: SCREEN_STRING := MENU_INFO_LINE;
- begin
- MENU_INFO_LINE := BLANK_LINE;
- return INFO_STRING;
- end RETURN_INFO_LINE;
-
-
- end CONTROLLING_MENU_INFO_LINE;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --dispingd.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
- -- DISPLAY_PROCESSING;DISPINGD.ADA;KJL;04/09/85
-
- -- This package contains procedures to handle the menu display. It stores
- -- the display layout in an array of strings. The procedures are used to
- -- process this array of strings, and output the display to a CRT.
- -- The package keeps a Current Read counter, and a Current Write counter. These
- -- value indicate the next display line to be read and written from the display
- -- array. Display lines are read when the display is put to the Menu Def Table
- -- file, they are written when the Menu Def File contains text to be put in
- -- the screen layout, and when the Menu Def Table is read by the Menu Handler.
-
-
- with TEXT_IO;
- package body DISPLAY_PROCESSING is
-
- -- The data structure that will be used for the display layout array.
- subtype SCREEN_STRING is STRING (1..SCREEN_WIDTH);
- type SCREEN_TYPE is array (1..SCREEN_LENGTH) of SCREEN_STRING;
-
- SCREEN_LAYOUT: SCREEN_TYPE; -- The display layout array.
-
- -- Current Read and Current Write counters
- CURRENT_LINE_READ, CURRENT_LINE_TO_WRITE: INTEGER;
-
-
- function GET_NEXT_SCREEN_LINE return STRING is
- -- Returns the next display line as determined by the Current Read counter.
- begin
- CURRENT_LINE_READ := CURRENT_LINE_READ + 1;
- return SCREEN_LAYOUT(CURRENT_LINE_READ);
- end GET_NEXT_SCREEN_LINE;
-
-
- function END_OF_SCREEN return BOOLEAN is
- begin
- return (CURRENT_LINE_READ >= SCREEN_LENGTH);
- end END_OF_SCREEN;
-
-
- procedure PUT_NEXT_SCREEN_LINE(DISPLAY_TEXT: in STRING) is
- -- Writes the next display line as determined by the Current Write counter.
- begin
- if CURRENT_LINE_TO_WRITE <= SCREEN_LENGTH then
- SCREEN_LAYOUT(CURRENT_LINE_TO_WRITE) := DISPLAY_TEXT;
- CURRENT_LINE_TO_WRITE := CURRENT_LINE_TO_WRITE + 1;
- end if;
- return;
- end PUT_NEXT_SCREEN_LINE;
-
-
- procedure PUT_SCREEN_TEXT(LINE, COLUMN: in INTEGER; DISPLAY_TEXT: in TEXT) is
- -- Writes text to the display layout array starting at the display line
- -- given, and the string index of that line given in the Column argument.
- begin
- SCREEN_LAYOUT(LINE)
- (COLUMN .. COLUMN + TEXT_HANDLER_SUBSET.LENGTH(DISPLAY_TEXT) - 1) :=
- TEXT_HANDLER_SUBSET.VALUE(DISPLAY_TEXT);
- end PUT_SCREEN_TEXT;
-
-
- procedure CLEAR_SCREEN_LAYOUT is
- -- Puts blanks in all the positions of the display layout array.
- begin
- SCREEN_LAYOUT :=
- (1..SCREEN_LENGTH => (1..SCREEN_WIDTH => ' ') );
- -- Reset Current Read and Current Write counters
- CURRENT_LINE_READ := 0;
- CURRENT_LINE_TO_WRITE := 1;
- end CLEAR_SCREEN_LAYOUT;
-
-
- procedure PUT_SCREEN_LAYOUT_TO_CRT is
- -- Using Text_Io procedures, each line of the display layout array is
- -- put to the display.
- -- The screen is drawn by sequentially writing each display line to the
- -- CRT. The Ada Text_Io package is used to do this. Should a particular
- -- installation contain more features that control the display layout
- -- of the CRT, this procedure could be changed to take advantage of such
- -- features. Currently the menu display will appear as a number of lines
- -- being written to the CRT, each pushing the previous one up the screen.
- begin
- for I in 1..SCREEN_LENGTH loop
- TEXT_IO.PUT_LINE(SCREEN_LAYOUT(I));
- end loop;
- end PUT_SCREEN_LAYOUT_TO_CRT;
-
-
- end DISPLAY_PROCESSING;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --handntsd.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
- -- HANDLE_COMPILER_COMPONENTS;HANDNTSD.ADA;KJL;04/18/85
-
- -- This package contains subprograms used to process the lexical units found
- -- in the Menu Definition File. The package keeps track of variables used as
- -- the compilation is running, ie, current column and line numbers for the
- -- display layout, and the Bad Selection message last specified in the
- -- Menu Def File.
-
- package body HANDLE_COMPILER_COMPONENTS is
-
- -- range of valid values for column and line numbers. Values given in the
- -- Menu Def for column and line will be checked if "in" these sets.
- subtype VALID_COLUMN_NUMBERS is INTEGER
- range 1..SCREEN_WIDTH;
- subtype VALID_LINE_NUMBERS is INTEGER
- range 1..SCREEN_LENGTH;
-
- subtype UPPER_LETTERS is CHARACTER range 'A'..'Z';
- subtype LOWER_LETTERS is CHARACTER range 'a'..'z';
-
- -- Used to determine lex unit type.
- USER_LITERAL: constant := 1;
- IDENTIFIER: constant := 0;
-
- -- Name of Menu Def Table to be created.
- CURRENT_MENU_FILE_NAME: TEXT;
-
- -- Column and line of menu display layout for the next request for text
- -- to be put in the display layout.
- CURRENT_COLUMN_NUMBER: VALID_COLUMN_NUMBERS := 1;
- CURRENT_LINE_NUMBER: VALID_LINE_NUMBERS := 1;
-
- -- Text for bad selection message.
- BAD_SELECTION_MESSAGE: TEXT;
-
-
- -- Procedure is instantiated with an enumeration type, it accepts a
- -- character and gives the element of the enumeration set corresponding to
- -- the character, or it gives an error if no element matches the char.
- generic
- type ENUM_TYPE is (<>);
- procedure CHAR_TO_ENUM_TYPE (CHAR: in CHARACTER;
- RETURNED_CODE: out ENUM_TYPE; INVALID: out BOOLEAN);
- -- Procedure body
- procedure CHAR_TO_ENUM_TYPE (CHAR: in CHARACTER;
- RETURNED_CODE: out ENUM_TYPE; INVALID: out BOOLEAN) is
- CHAR_TO_STRING: STRING(1..1) := (1 => CHAR);
- begin
- -- Initialize arguments passed.
- INVALID := FALSE;
- RETURNED_CODE := ENUM_TYPE'FIRST;
- RETURNED_CODE := ENUM_TYPE'VALUE(CHAR_TO_STRING);
- exception
- -- Exception raised if no correspondence to the character.
- when CONSTRAINT_ERROR =>
- INVALID := TRUE;
- end CHAR_TO_ENUM_TYPE;
-
-
- -- Function returns the upper case of a lower case character. Will return
- -- the character itself if the input character is not a lower case
- -- character.
- function LOWER_TO_UPPER(CHAR: CHARACTER) return CHARACTER is
- type UPPER_LETTERS is new CHARACTER range 'A'..'Z';
- type LOWER_LETTERS is new CHARACTER range 'a'..'z';
- BIG: UPPER_LETTERS;
- LITTLE: LOWER_LETTERS;
- begin
- -- Convert input character to lower case character. If in char is not
- -- lower case, an exception will be raised.
- LITTLE := LOWER_LETTERS(CHAR);
- -- Get the upper case char corresponding to the lower case char.
- BIG := UPPER_LETTERS'VAL(LOWER_LETTERS'POS(LITTLE));
- -- return a value of character type.
- return CHARACTER(BIG);
- exception
- when CONSTRAINT_ERROR =>
- return CHAR;
- end LOWER_TO_UPPER;
-
-
-
- -- Procedure is called when a "Select" identifier is found in the Menu
- -- Definition string. The procedure obtains the other lex units needed for
- -- a full Select instruction. If a correct syntax instruction is found, a
- -- Menu Control Item is added to the Control Item List (kept in another
- -- package).
- procedure PROCESS_SELECT is
-
- -- Used to pack the text (remove trailing and leading blanks).
- TEMP_TEXT: TEXT;
-
- -- The key given to initiate action on the resulting menu.
- SELECT_KEY: CHARACTER;
-
- -- Menu to display following the action performed (defaults to the
- -- current menu def table if no other name is given).
- NEXT_MENU: TEXT;
-
- -- Type of action to perform on this selection in resulting menu
- -- (program, task, Ada procedure, menu..).
- ACTION_CODE: ACTION_TYPE;
-
- -- Used if a Next Menu is specified.
- MENU_ACTION_CODE: ACTION_TYPE;
-
- -- Text of command or name of file or procedure to execute on selection.
- FILE_EXECUTED: TEXT;
-
- -- True if action is only to call another menu.
- MENU_SELECTED: BOOLEAN;
-
- -- Used as error argument of procedures returning errors.
- ERROR: BOOLEAN;
-
- -- Converts character given to Action Type.
- procedure CHAR_TO_ACTION_TYPE is new CHAR_TO_ENUM_TYPE(ACTION_TYPE);
-
- -- Returns true if given character is in the give string.
- function MATCH(CHAR: CHARACTER; STR: STRING) return BOOLEAN is
- FOUND: BOOLEAN := FALSE;
- begin
- -- Compare character to each character in the string until found.
- for I in STR'FIRST..STR'LAST loop
- FOUND := (STR(I) = CHAR);
- exit when FOUND;
- end loop;
- return FOUND;
- end MATCH;
-
-
- -- Start PROCESS_SELECT procedure.
- begin
- -- After the "S..." Identifier, the next lex unit must be a valid
- -- selection key in a user literal. Make the next lexical unit
- -- available, and do the proper checks.
- GET_LEXICAL_UNIT_IF_NEEDED;
- -- Pack the text of the lex unit, to get just the key character and no
- -- blanks.
- TEMP_TEXT := TEXT_HANDLER_SUBSET.PACK_TO_TEXT
- (TEXT_HANDLER_SUBSET.VALUE(CURRENT_LEX_STRING));
-
- -- Lex unit must be a user literal
- if (CURRENT_LEX_TYPE /= LEXICAL_UNIT_TYPES'VAL(USER_LITERAL)) then
- SEND_COMPILE_ERROR(03);
- UNIT_RECEIVED;
- return;
- end if;
-
- -- Length of lex unit must be 1 for single character, or 0 for
- -- space bar.
- if (TEXT_HANDLER_SUBSET.LENGTH(TEMP_TEXT) > 1) or
- (TEXT_HANDLER_SUBSET.LENGTH(TEMP_TEXT) < 0) then
- SEND_COMPILE_ERROR(04);
- return;
- end if;
-
- -- Selection key is a space bar if length is 0,
- if (TEXT_HANDLER_SUBSET.LENGTH(TEMP_TEXT) = 0) then
- SELECT_KEY := ' ';
- -- Selection key must be valid if it is not the space bar.
- elsif not MATCH (TEXT_HANDLER_SUBSET.GIVE_POS(TEMP_TEXT,1),
- USABLE_SELECT_KEYS) then
- SEND_COMPILE_ERROR(05);
- return;
- else
- -- Assign select key if character is valid.
- SELECT_KEY := TEXT_HANDLER_SUBSET.GIVE_POS(TEMP_TEXT,1);
- end if;
- TEXT_HANDLER_SUBSET.CLEAR_TEXT(TEMP_TEXT);
-
- -- Select key is obtained, the next lex unit should be an ACTION
- -- Identifier, specifying the type of action to perform on this menu
- -- selection. Make lex unit available, and do checks too insure the proper
- -- type of Identifier.
- GET_LEXICAL_UNIT_IF_NEEDED;
- -- Lex unit must be an Identifier.
- if (CURRENT_LEX_TYPE /= LEXICAL_UNIT_TYPES'VAL(IDENTIFIER)) then
- SEND_COMPILE_ERROR(06);
- UNIT_RECEIVED;
- return;
- end if;
-
- -- Convert the 1st character of the lex unit to an ACTION Identifier.
- -- Error on covertion is a syntax error.
- CHAR_TO_ACTION_TYPE
- ( LOWER_TO_UPPER(TEXT_HANDLER_SUBSET.GIVE_POS(CURRENT_LEX_STRING,1)),
- ACTION_CODE, ERROR );
- if ERROR then
- SEND_COMPILE_ERROR(07);
- UNIT_RECEIVED;
- return;
- end if;
-
- -- Action Code is obtained from selection instruction. The next lex unit
- -- must be a user literal giving the name of the command, file or
- -- procedure to execute on this menu selection. Make the lex unit
- -- available, and check value.
- GET_LEXICAL_UNIT_IF_NEEDED;
- -- Lex unit must be a User Literal with file/command name.
- if (CURRENT_LEX_TYPE /= LEXICAL_UNIT_TYPES'VAL(USER_LITERAL)) then
- SEND_COMPILE_ERROR(08);
- UNIT_RECEIVED;
- return;
- end if;
-
- -- Pack the user literal to eliminate leading and trailing blanks,
- -- check that text specified is not longer than the maximum file size
- -- for a file name.
- TEMP_TEXT := TEXT_HANDLER_SUBSET.PACK_TO_TEXT
- (TEXT_HANDLER_SUBSET.VALUE(CURRENT_LEX_STRING));
- if (TEXT_HANDLER_SUBSET.LENGTH(TEMP_TEXT) > FILE_STRING_SIZE) then
- SEND_COMPILE_ERROR(26);
- return;
- end if;
-
- FILE_EXECUTED := TEXT_HANDLER_SUBSET.TO_TEXT
- (TEXT_HANDLER_SUBSET.VALUE(TEMP_TEXT));
- TEXT_HANDLER_SUBSET.CLEAR_TEXT(TEMP_TEXT);
-
- -- The file to execute is obtained. Now, if the action to be performed
- -- by this menu selection is to display another menu, then no other
- -- actions can be specified. If some other action was specified, the
- -- select instruction can now contain a specification for a Next Menu.
- -- The following code looks for the "Menu" Action Identifier, and a
- -- Menu Def Table name given in a User Literal. First check if a Menu
- -- Action Identifier was already specified.
- MENU_SELECTED := (ACTION_CODE = ACTION_TYPE'LAST);
-
- -- Use a Quit Construct to branch to the bottom of this logic since even
- -- on errors, the select info already obtained should be added to the
- -- Menu Control List.
- if MENU_SELECTED then
- -- The Next Menu info to be added to the Menu Control list will
- -- contain the name of the Menu Def Table specified in this selection
- -- instruction. If no Next Menu is specified, or errors occur while
- -- trying to find the "next menu", then the name of the Menu Def
- -- Table currently being defined will be the Next Menu.
- NEXT_MENU := FILE_EXECUTED;
- goto CONTINUE;
- end if;
-
- -- Possible that a Next Menu might be specified. Make the next lex unit
- -- available, and test if it is a "Menu" Identifier. If not, no error
- -- is displayed, since the next "Menu" specification in a selection
- -- instruction is optional.
- GET_LEXICAL_UNIT_IF_NEEDED;
- if (CURRENT_LEX_TYPE /= LEXICAL_UNIT_TYPES'VAL(IDENTIFIER)) then
- UNIT_RECEIVED;
- -- Menu displayed following this menu selection is the current menu.
- NEXT_MENU := CURRENT_MENU_FILE_NAME;
- goto CONTINUE;
- end if;
-
- -- See if the Identifier found is an Action Identifier. If not, no error
- -- is displayed, sice again, this is not required.
- CHAR_TO_ACTION_TYPE
- ( LOWER_TO_UPPER(TEXT_HANDLER_SUBSET.GIVE_POS(CURRENT_LEX_STRING,1)),
- MENU_ACTION_CODE, ERROR );
- if ERROR then
- UNIT_RECEIVED;
- NEXT_MENU := CURRENT_MENU_FILE_NAME;
- goto CONTINUE;
- end if;
- -- If an Action Identifier is found, it better be a "Menu", since only
- -- on command/program/procedure... is allowed on a selection. The
- -- Selection instruction is not thrown out on an error, the current menu
- -- is set as the next menu, and the first action found is still entered
- -- in the Menu Control List.
- if (MENU_ACTION_CODE /= ACTION_TYPE'LAST) then
- SEND_COMPILE_ERROR(09);
- NEXT_MENU := CURRENT_MENU_FILE_NAME;
- goto CONTINUE;
- end if;
-
- -- At this point the Selection instruction contains a Menu Action
- -- Identifier, and the next lex unit must be a user literal giving the
- -- name of the Menu Def Table to be used for the menu following the
- -- selection action. If errors occur in finding this user literal, they
- -- will be displayed to the user.
- GET_LEXICAL_UNIT_IF_NEEDED;
- if (CURRENT_LEX_TYPE /= LEXICAL_UNIT_TYPES'VAL(USER_LITERAL)) then
- SEND_COMPILE_ERROR(10);
- UNIT_RECEIVED;
- NEXT_MENU := CURRENT_MENU_FILE_NAME;
- goto CONTINUE;
- end if;
-
- -- Pack the text that is the Menu Def Table name, check that text is
- -- within legal size.
- TEMP_TEXT := TEXT_HANDLER_SUBSET.PACK_TO_TEXT
- (TEXT_HANDLER_SUBSET.VALUE(CURRENT_LEX_STRING));
- if TEXT_HANDLER_SUBSET.LENGTH(TEMP_TEXT) > FILE_STRING_SIZE then
- SEND_COMPILE_ERROR(26); -- File name is to long
- NEXT_MENU := CURRENT_MENU_FILE_NAME;
- else
- -- User Literal is the name of the Menu Def Table that is the next
- -- menu displayed following this selection action.
- NEXT_MENU := TEXT_HANDLER_SUBSET.TO_TEXT
- (TEXT_HANDLER_SUBSET.VALUE(TEMP_TEXT));
- end if;
- TEXT_HANDLER_SUBSET.CLEAR_TEXT(TEMP_TEXT);
- <<CONTINUE>>
-
- -- Add all the information found from this selection instruction to the
- -- Menu Control List. The procedure put the information in the form
- -- needed for the list, and adds it. The list is in another package.
- ADD_MENU_CONTROL_ITEM(SELECT_KEY,NEXT_MENU,FILE_EXECUTED,ACTION_CODE);
-
- end PROCESS_SELECT;
-
-
-
- -- Procedure is used when a "Column" Identifier is found in the code. The
- -- procedure looks for a User Literal containing a valid column number, and
- -- updates the Current Column Number for placing text in the display layout
- procedure LOAD_COLUMN_NUMBER is
- -- Used to get an integer for the Column number.
- TEMP_COLUMN: VALID_COLUMN_NUMBERS;
- -- Used to pack the User Literal Text.
- TEMP_TEXT: TEXT;
- begin
- -- The next lex unit must be a User Literal containing the Column number
- GET_LEXICAL_UNIT_IF_NEEDED;
- if (CURRENT_LEX_TYPE /= LEXICAL_UNIT_TYPES'VAL(USER_LITERAL)) then
- SEND_COMPILE_ERROR(11);
- UNIT_RECEIVED;
- else
- -- Pack User Literal, and assign value of string to the object
- -- constrained to the valid column numbers. If the value is outside
- -- the valid column number values, a CONSTRAINT_ERROR will result.
- TEMP_TEXT := TEXT_HANDLER_SUBSET.PACK_TO_TEXT
- (TEXT_HANDLER_SUBSET.VALUE(CURRENT_LEX_STRING));
- TEMP_COLUMN := VALID_COLUMN_NUMBERS'VALUE
- (TEXT_HANDLER_SUBSET.VALUE(TEMP_TEXT));
- CURRENT_COLUMN_NUMBER := TEMP_COLUMN;
- end if;
- return;
- exception
- when CONSTRAINT_ERROR =>
- -- Exception raised when assignment of a value outside the legal
- -- column numbers is attempted to a constrained object.
- SEND_COMPILE_ERROR(12);
- end LOAD_COLUMN_NUMBER;
-
-
-
- -- Procedure is used when a "Line" Identifier is found in the code. The
- -- procedure looks for a User Literal containing a valid line number, and
- -- updates the Current Line Number for placing text in the display layout
- procedure LOAD_LINE_NUMBER is
- -- Used to get an integer for the Line number.
- TEMP_LINE: VALID_LINE_NUMBERS;
- -- Used to pack the User Literal Text.
- TEMP_TEXT: TEXT;
- begin
- -- The next lex unit must be a User Literal containing the Line number
- GET_LEXICAL_UNIT_IF_NEEDED;
- if (CURRENT_LEX_TYPE /= LEXICAL_UNIT_TYPES'VAL(USER_LITERAL)) then
- SEND_COMPILE_ERROR(13);
- UNIT_RECEIVED;
- else
- -- Pack User Literal, and assign value of string to the object
- -- constrained to the valid line numbers. If the value is outside
- -- the valid line number values, a CONSTRAINT_ERROR will result.
- TEMP_TEXT := TEXT_HANDLER_SUBSET.PACK_TO_TEXT
- (TEXT_HANDLER_SUBSET.VALUE(CURRENT_LEX_STRING));
- TEMP_LINE := VALID_LINE_NUMBERS'VALUE
- (TEXT_HANDLER_SUBSET.VALUE(TEMP_TEXT));
- CURRENT_LINE_NUMBER := TEMP_LINE;
- end if;
- return;
- exception
- when CONSTRAINT_ERROR =>
- -- Exception raised when assignment of a value outside the legal
- -- line numbers is attempted to a constrained object.
- SEND_COMPILE_ERROR(14);
- end LOAD_LINE_NUMBER;
-
-
-
- -- Procedure is used when an "Error.." Identifier is found in the code. It
- -- will look for a User Literal containing the Bad Selection Message. The
- -- message must fit on the screen width, so this check is made.
- procedure LOAD_BAD_SELECTION_MESSAGE is
- begin
- -- User Literal containing Bad Selection Message must be found.
- GET_LEXICAL_UNIT_IF_NEEDED;
- if (CURRENT_LEX_TYPE /= LEXICAL_UNIT_TYPES'VAL(USER_LITERAL)) then
- SEND_COMPILE_ERROR(15);
- UNIT_RECEIVED;
-
- -- The Message must fit in the screen width.
- elsif (TEXT_HANDLER_SUBSET.LENGTH(CURRENT_LEX_STRING) > SCREEN_WIDTH) then
- SEND_COMPILE_ERROR(16);
- else
- -- Set Bad Selection Message.
- BAD_SELECTION_MESSAGE := TEXT_HANDLER_SUBSET.TO_TEXT
- (TEXT_HANDLER_SUBSET.VALUE(CURRENT_LEX_STRING));
- end if;
- return;
- end LOAD_BAD_SELECTION_MESSAGE;
-
-
-
- -- The first non-comment lex unit of the Menu Def Table must be a User
- -- Literal that specifys the name of the Menu Def Table that will be
- -- created by this Menu Definition. This procedure gets this User Literal,
- -- and sets the Current Menu File Name.
- procedure GET_THE_TITLE is
- -- Used to pack the user literal text.
- TEMP_TEXT: TEXT;
- begin
- -- Make lexical unit available, and check if it is a User Literal
- GET_LEXICAL_UNIT_IF_NEEDED;
- if (CURRENT_LEX_TYPE /= LEXICAL_UNIT_TYPES'VAL(USER_LITERAL)) then
- SEND_COMPILE_ERROR(17);
- -- On error, the current menu file name is a null string.
- TEXT_HANDLER_SUBSET.CLEAR_TEXT(CURRENT_MENU_FILE_NAME);
- UNIT_RECEIVED;
- else
- CURRENT_MENU_FILE_NAME := TEXT_HANDLER_SUBSET.PACK_TO_TEXT
- (TEXT_HANDLER_SUBSET.VALUE(CURRENT_LEX_STRING));
- end if;
- end GET_THE_TITLE;
-
-
-
- -- Procedure is used to process an identifier found in the Menu Definition.
- -- The Identifier is converted to an identifier code, and the proper
- -- procedure is called to handle each type of identifier.
- procedure PROCESS_IDENTIFIER(LEXICAL_STRING: in TEXT) is
-
- -- Legal Identifier codes. One of these letters must be the first letter
- -- of each Control Identifier.
- -- S - Select... E - Error... L - Line... C - Column....
- type CONTROL_TYPE is (S,E,L,C);
-
- -- Code from conversion of character string to Control Identifier.
- IDENTIFIER_CODE: CONTROL_TYPE;
-
- -- Used as an error argument in procedures requiring it.
- ERROR: BOOLEAN;
-
- -- Procedure to convert a character string to an element within the
- -- Control Identifier set.
- procedure CHAR_TO_CONTROL_TYPE is new CHAR_TO_ENUM_TYPE(CONTROL_TYPE);
-
-
- begin
- -- Get the Control Identifier referenced by the Lexical String. If the
- -- string does not correspond to a Control Identifier, an error is sent
- -- to the user display.
- CHAR_TO_CONTROL_TYPE
- ( LOWER_TO_UPPER(TEXT_HANDLER_SUBSET.GIVE_POS(LEXICAL_STRING,1)),
- IDENTIFIER_CODE, ERROR );
- if (not ERROR) then
- -- Call the necessary procedure for what ever type of Control
- -- Identifier has been found.
- case IDENTIFIER_CODE is
- when S =>
- PROCESS_SELECT;
- when L =>
- LOAD_LINE_NUMBER;
- when C =>
- LOAD_COLUMN_NUMBER;
- when E =>
- LOAD_BAD_SELECTION_MESSAGE;
- end case;
- else
- -- Send error if invalid Control Identifier.
- SEND_COMPILE_ERROR(18);
- end if;
-
- end PROCESS_IDENTIFIER;
-
-
-
- -- This procedure is used when an unqualifiered User Literal is found in
- -- the Menu Definition, that is, a User Literal that does not follow any
- -- Identifiers, or is not expected as qualifying something. The text of
- -- the User Literal found will be placed in the Menu Display Layout at the
- -- current line and column position.
- procedure WRITE_SCREEN_LAYOUT_TEXT(LEXICAL_STRING: in TEXT) is
- -- Used to determine if the text will fit on the screen.
- X_COLUMN: INTEGER;
-
- begin
- -- First, determine whether or not the text of the user literal will fit
- -- on the display layout, given the current column number.
- X_COLUMN := TEXT_HANDLER_SUBSET.LENGTH(LEXICAL_STRING) + CURRENT_COLUMN_NUMBER - 1;
- -- Send error if text will not fit.
- if (X_COLUMN > SCREEN_WIDTH) then
- SEND_COMPILE_ERROR(19);
- else
- -- Put text to display layout.
- PUT_SCREEN_TEXT(CURRENT_LINE_NUMBER, CURRENT_COLUMN_NUMBER,
- LEXICAL_STRING);
- end if;
- end WRITE_SCREEN_LAYOUT_TEXT;
-
-
-
- -- Returns the text that is the Bad Selection Message.
- function THE_BAD_SELECTION_MESSAGE return TEXT is
- begin
- return BAD_SELECTION_MESSAGE;
- end THE_BAD_SELECTION_MESSAGE;
-
-
-
- -- Returns the text that is the name or the Menu Def Table being created.
- function THE_TITLE_NAME return TEXT is
- begin
- return CURRENT_MENU_FILE_NAME;
- end THE_TITLE_NAME;
-
-
-
-
- end HANDLE_COMPILER_COMPONENTS;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --handsesd.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
- -- HANDLE_PROCESSES;HANDSESD;KJL;04/17/85
-
- -- This package contains subprograms used by the Menu Handler that processes
- -- the requests for action, that result from the menu users inputs. This
- -- package will also contain the file name of the Menu Definition Table that
- -- defined the next menu to be displayed.
-
- package body HANDLE_PROCESSES is
-
- -- The name of the next menu to be displayed.
- MENU_TO_DISPLAY: TEXT;
-
-
-
- -- This procedure is passed the string that is what the user input at the
- -- menu, and the type of input this was. The procedure will perform the
- -- necessary processing based on this users input, including retrieving
- -- the action(s) to perform, updating the name of the next menu to display,
- -- and issuing necessary error messages.
- procedure DO_REQUEST (CURRENT_MENU: in TEXT; REQUEST_STRING: in TEXT;
- TYPE_OF_REQUEST: in INPUT_TYPES) is
-
- -- Constants used to specify Wait or Dont Wait code when issuing a CLI
- -- command of file name.
- WAIT: constant := 0;
- DONT_WAIT: constant := 1;
-
- -- Constant codes to identify types of user inputs.
- CLI_COMMAND: constant := 0;
- SELECTION: constant := 1;
-
- -- Constant codes to identify Action Codes retrieved from the Menu
- -- Control List.
- X: constant := 0; T: constant := 1; P: constant := 2;
- A: constant := 3; M: constant := 4;
-
- -- The name or file name received from the Menu Control List that
- -- corresponds to a given selection key.
- PROCESS_TO_PERFORM: TEXT;
-
- -- The type of action received from the Menu Control List, corresponding
- -- to the action received above.
- ACTION_OF_PROCESS: ACTION_TYPES;
-
- -- The name of the next menu to be displayed as retrieved from the
- -- Menu Control List.
- MENU_FILE: TEXT;
-
- -- Error code used for procedures that return an error code.
- ERROR_CODE: BOOLEAN := TRUE;
-
-
- -- Begin the DO_REQUEST procedure.
- begin
- -- Clear the TEXT object holding the menu to be displayed, and set it
- -- equal to the Current Menu passed as an argument.
- TEXT_HANDLER_SUBSET.CLEAR_TEXT(MENU_TO_DISPLAY);
- MENU_TO_DISPLAY := CURRENT_MENU;
-
- -- Handle the types of user inputs
- if TYPE_OF_REQUEST = INPUT_TYPES'VAL(CLI_COMMAND) then
- -- On a CLI line input at the menu, the text of the line is
- -- coverted to a character string with no leading or trailing
- -- blanks, and the line is sent and a command line with a code
- -- for the Menu Handle to wait until the command is completed.
- COMMAND_LINE_PROCESSOR (TEXT_HANDLER_SUBSET.VALUE(REQUEST_STRING),
- DONT_WAIT, ERROR_CODE);
- -- Error returned means the CLI could not process the line.
- if ERROR_CODE then
- SEND_RUNTIME_ERROR(33);
- end if;
- return;
- end if;
-
- if TYPE_OF_REQUEST = INPUT_TYPES'VAL(SELECTION) then
- -- On a selection input from menu user, first try to retrieve the
- -- Menu Control information from the Menu Control List, given the
- -- character select key the user input.
- RETRIEVE_CONTROL_ITEM (TEXT_HANDLER_SUBSET.GIVE_POS(REQUEST_STRING,
- 1), MENU_FILE, PROCESS_TO_PERFORM,
- ACTION_OF_PROCESS, ERROR_CODE);
- -- An error means a Bad Selection was made, set the Menu Info Line
- -- to display the Bad Selection Message.
- if ERROR_CODE then
- SET_BAD_SELECTION;
- return;
- end if;
- -- Clear the Menu to be displayed, and assign it the value
- -- retrieved from the Menu Control List.
- TEXT_HANDLER_SUBSET.CLEAR_TEXT(MENU_TO_DISPLAY);
- MENU_TO_DISPLAY := MENU_FILE;
-
- -- Process the type of action to perform. The names passed to the
- -- procedures below will be converted form packed TEXT dynamic
- -- string types, to regular character strings.
- if ACTION_OF_PROCESS = ACTION_TYPES'VAL(X) then
- -- Null action, do nothing.
- null;
-
- elsif ACTION_OF_PROCESS = ACTION_TYPES'VAL(T) then
- -- The action is a TASK, send the file name/ name to the CLI
- -- with the code to continue the Menu Handler immediately.
- COMMAND_LINE_PROCESSOR (TEXT_HANDLER_SUBSET.VALUE
- (PROCESS_TO_PERFORM), DONT_WAIT, ERROR_CODE);
- -- Error returned from issuing the CLI command indicates the
- -- CLI could not process that command of or command file. If
- -- the string was processed successfully by the CLI, set the
- -- Menu Info Line to tell that the task was started.
- if ERROR_CODE then
- SEND_RUNTIME_ERROR (34);
- else
- SET_TASK_STARTED (TEXT_HANDLER_SUBSET.VALUE
- (PROCESS_TO_PERFORM) );
- end if;
-
- elsif ACTION_OF_PROCESS = ACTION_TYPES'VAL(P) then
- -- A PROGRAM action means the send the command name retrieved
- -- to the CLI with a code for the Menu Handler to wait until
- -- the the command is completed.
- COMMAND_LINE_PROCESSOR (TEXT_HANDLER_SUBSET.VALUE
- (PROCESS_TO_PERFORM), WAIT, ERROR_CODE);
- -- An error returned will signal that the CLI could not
- -- process the command of command file name given.
- if ERROR_CODE then
- SEND_RUNTIME_ERROR (35);
- end if;
-
- elsif ACTION_OF_PROCESS = ACTION_TYPES'VAL(A) then
- -- The A for Ada PROCEDURE CALL action causes the name
- -- retrieved to be passed the the procedure that starts Ada
- -- procedures. The Ada procedure called will execute to
- -- completion before the Menu Handler returns.
- ADA_PROCEDURE_CALL (TEXT_HANDLER_SUBSET.VALUE
- (PROCESS_TO_PERFORM), ERROR_CODE);
- -- The Error returned here means that the Ada procedure was
- -- not found. The procedure must be linked to this program
- -- for it to run.
- if ERROR_CODE then
- SEND_RUNTIME_ERROR(36);
- end if;
-
- elsif ACTION_TYPES'VAL(M) = ACTION_TYPES'VAL(M) then
- -- A MENU type action is just to do no action and set the
- -- next menu the be displayed to the name retrieved. This was
- -- done at the beginning of this condition statement.
- null;
- else
- null;
- end if;
- return;
-
- end if; -- Input Type is SELECTION.
-
- end DO_REQUEST;
-
-
-
- -- This function will return the name of the next menu to be displayed. The
- -- name will be in TEXT dynamic string form with no leading or trailing
- -- blanks around the name.
- function MENU_TO_BE_DISPLAYED return TEXT is
- begin
- return MENU_TO_DISPLAY;
- end MENU_TO_BE_DISPLAYED;
-
-
-
- end HANDLE_PROCESSES;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --procbled.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
- -- PROCESS_MENU_CONTROL_TABLE;PROCBLED.ADA;KJL;04/16/85
-
- -- This package contains subprograms necessary to hold and use the Menu Control
- -- List. This list is a dynamic list of Menu Control Items, each item
- -- characterizes a menu selection. Information contained in each item includes:
- -- The selection key that is typed at resulting menu, the type of action that
- -- is performed when this key is typed, and the name or file name involved in
- -- such action. As an example, a Menu Control Item might contain information
- -- defining that when this menu is run, the letter 'A' (selection key) may be
- -- typed to invoke an operating system command 'GOJOB' (name or file name) that
- -- will be performed in background while the menu returns to the screen (type
- -- of action, translating the the TASK type). The Menu Control Item also
- -- contains a Next Menu which specifies the name of a Menu Def Table that will
- -- be the next menu following the action performed.
-
- -- This procedure also contains the subprograms used to write and read the
- -- external file which is the Menu Definition Table. The file is written with
- -- records that match the Menu Control Items. Other information written to the
- -- file; the lines of the Menu Display Layout, and the Bad Selection Message,
- -- are put into the same record structure then written to the file. The same
- -- record structures are read from the file, and the Menu Control List, Menu
- -- Display Layout, and Bad Selection Message is extracted.
-
- with SEQUENTIAL_IO, TEXT_IO, UNCHECKED_DEALLOCATION;
- package body PROCESS_MENU_CONTROL_TABLE is
-
- -- Character string that will hold the names and file names for processes
- -- invoked. The STRING type is used so the values can be written to file.
- subtype FILE_STRING_TYPE is STRING(1..FILE_STRING_SIZE);
-
- -- Character string that will hold Display Layout lines. The String type
- -- is used so the values can be written to file.
- subtype SCREEN_STRING_TYPE is STRING(1..SCREEN_STRING_SIZE);
-
- -- This record is used to hold a process name (file name, Menu Def Table
- -- name, Ada procedure name...), and the type of process of action.
- type PROCESS_DESCRIPTION is
- record
- ACTION_CODE: ACTION_TYPE;
- FILE_EXECUTED: FILE_STRING_TYPE;
- end record;
-
-
- -- This record is the information for the Menu Control Item. The NUMBER is
- -- the number of Menu Control Item in the list, SELECT_KEY is the character
- -- key to activate the action at the menu, NEXT_MENU is the Menu Def Table
- -- file name of the next menu to be displayed, PROCESSES specifies the
- -- action to perform, and MISC_INFO is used to hold other information when
- -- needed (such as the Display Layout line, and Bad Selection Message).
- type MENU_CONTROL_ITEM_TYPE is
- record
- NUMBER: INTEGER;
- SELECT_KEY: CHARACTER;
- NEXT_MENU: FILE_STRING_TYPE;
- PROCESSES: PROCESS_DESCRIPTION;
- MISC_INFO: SCREEN_STRING_TYPE;
- end record;
-
-
- -- The data structure used for the list of Menu Control Items is a dynamic
- -- array structure. The object that is the list will be an access type
- -- that points to an array of Menu Control Items. When a Control Item is
- -- added to the list, a new access object will point to a new array of
- -- Menu Control Items that is identical to the old one but one bigger.
-
- -- The array is unbounded so the access object can point to different
- -- arrays of different sizes.
- type CONTROL_ARRAY is array (POSITIVE range <>) of MENU_CONTROL_ITEM_TYPE;
-
- -- The access type that points to the unbounded array.
- type MENU_CONTROL_LIST_TYPE is access CONTROL_ARRAY;
-
-
- -- Blank line for file name and screen line strings. Used to clear the
- -- elements of the Menu Control Items.
- BLANK_FILE_STRING: FILE_STRING_TYPE :=
- (FILE_STRING_TYPE'FIRST..FILE_STRING_TYPE'LAST => ' ');
- BLANK_SCREEN_STRING: SCREEN_STRING_TYPE :=
- (SCREEN_STRING_TYPE'FIRST..SCREEN_STRING_TYPE'LAST => ' ');
-
-
- -- The following variables are all of the menu control item structure. They
- -- aree used to hold information in the proper structure, so that it can be
- -- written to the Menu Def Table file.
-
- -- The MISC_INFO element holds the Bad Selection Message.
- BAD_SELECTION_MESSAGE_ITEM: MENU_CONTROL_ITEM_TYPE;
-
- -- The NUMBER element holds the number of Menu Control Items written to the
- -- Menu Def Table file. Tells READ procedure when to look for "other" info.
- NUMBER_OF_CONTROL_ITEMS: MENU_CONTROL_ITEM_TYPE;
-
- -- The MISC_INFO element of this object will hold a line for the
- -- Menu Display Layout.
- SCREEN_LAYOUT_ITEM: MENU_CONTROL_ITEM_TYPE;
-
- -- This object will hold actual Menu Control Items as they are added to the
- -- Menu Control List, and as they are written to the Menu Def Table file.
- MENU_CONTROL_ITEM: MENU_CONTROL_ITEM_TYPE;
-
- -- The NUMBER element of this object will hold the critical cofiguration
- -- items (screen width, and file name size), and these will be written to
- -- the Menu Def Table first. If these values are not concistent between
- -- writting in the Menu Compiler, and reading in the Menu Handler, then
- -- the reading will not complete successfully. An exception will be raised
- -- by the read procedure if the config info read is not the same as the
- -- current config info FILE_STRING_SIZE, and SCREEN_STRING_SIZE.
- CONFIG_INFO_ITEM: MENU_CONTROL_ITEM_TYPE;
-
-
- -- List of Menu Control Items. Really is a pointer to an array, since
- -- initially there are no elements, set the pointer to null.
- MENU_CONTROL_LIST: MENU_CONTROL_LIST_TYPE := null;
-
- -- Number of Menu Control Elements added to the list.
- CONTROL_LIST_COUNT: INTEGER := 0;
-
-
- -- This procedure is used to deallocate the space pointed to by old
- -- access object. Before a pointer is assigned to point to a new array of
- -- Menu Control Items, the old array must be deallocated.
- procedure FREE is new UNCHECKED_DEALLOCATION(CONTROL_ARRAY,
- MENU_CONTROL_LIST_TYPE);
-
-
- -- Input/Output package that will input and output items of the Menu
- -- Control Item data structure.
- package MENU_CONTROL_ITEM_IO is new SEQUENTIAL_IO (MENU_CONTROL_ITEM_TYPE);
-
-
-
- -- Function returns an array of Menu Control Items that include all the
- -- items of the array argument, and one more which is the Menu Control
- -- Item argument.
- function CONCAT (CONTROL_ARRAY_PARAM: CONTROL_ARRAY;
- CONTROL_ITEM_PARAM: MENU_CONTROL_ITEM_TYPE) return CONTROL_ARRAY is
-
- -- Will hold the array that is one bigger than CONTROL_ARRAY_PARAM.
- TEMP_ARRAY: CONTROL_ARRAY
- (CONTROL_ARRAY_PARAM'FIRST..CONTROL_ARRAY_PARAM'LAST+1);
-
- begin
- -- Assign the elements of TEMP_ARRAY. The first elements are those of
- -- CONTROL_ARRAY_PARAM, the last element is the CONTROL_ITEM_PARAM.
- TEMP_ARRAY(CONTROL_ARRAY_PARAM'FIRST..CONTROL_ARRAY_PARAM'LAST) :=
- CONTROL_ARRAY_PARAM(CONTROL_ARRAY_PARAM'FIRST..CONTROL_ARRAY_PARAM'LAST);
- TEMP_ARRAY(CONTROL_ARRAY_PARAM'LAST+1) := CONTROL_ITEM_PARAM;
- -- Return the full array.
- return TEMP_ARRAY;
-
- end CONCAT;
-
-
-
- -- This procedure is used to add a new Menu Control Item to the Menu
- -- Control List. The procedure always adds the object MENU_CONTROL_ITEM
- -- to the object MENU_CONTROL_LIST.
- procedure ADD_ITEM_TO_LIST is
- -- Temp access object, used to free up allocated space.
- TEMP: MENU_CONTROL_LIST_TYPE;
- begin
- if MENU_CONTROL_LIST = null then
- -- This is the first entry in the list, so make the access object
- -- point too an array where the 1st element is the Menu Control Item
- MENU_CONTROL_LIST := new CONTROL_ARRAY'((1 => MENU_CONTROL_ITEM));
- else
- -- To add an item to an existing list, first make an access object
- -- that points to an array with identical elements as the array that
- -- Menu Control List points to. Then free up the space pointed to by
- -- the Menu Control List pointer.
- TEMP := new CONTROL_ARRAY'(MENU_CONTROL_LIST.all);
- FREE(MENU_CONTROL_LIST);
- -- Make the Menu Control List a new pointer that points to an array
- -- that is the concatination of the old array elements (which is
- -- what the temp pointer points too), and the Menu Control Item. Then
- -- free up the space that the temp pointer is pointing to.
- MENU_CONTROL_LIST := new CONTROL_ARRAY'
- (CONCAT(TEMP.all,MENU_CONTROL_ITEM));
- FREE(TEMP);
- end if;
- end ADD_ITEM_TO_LIST;
-
-
-
- -- This procedure is used to add the information for a Menu Control Item
- -- to the Menu Control List. The information passed is: the selection key
- -- typed to initiate action on the menu, the name and type of action
- -- initiated, and the next menu to be displayed when control returns to
- -- the Menu Handler. The procedure puts the information in the data
- -- stucture of a Menu Contol Item then adds the Item to the Control List.
- procedure ADD_MENU_CONTROL_ITEM (SELECT_KEY: in CHARACTER;
- NEXT_MENU: in TEXT;
- FILE_NAME_OF_PROCESS: in TEXT;
- TYPE_OF_ACTION: in ACTION_TYPE) is
- begin
- -- Set up the information in a Menu Control Item data structure, blank
- -- all unneeded fields. The text strings are passed in TEXT format so
- -- convert the text to string fields of the proper size.
- MENU_CONTROL_ITEM :=
- (NUMBER => CONTROL_LIST_COUNT,
- SELECT_KEY => SELECT_KEY,
- NEXT_MENU => TEXT_HANDLER_SUBSET.UNPACK_VALUE
- (NEXT_MENU,FILE_STRING_SIZE),
- PROCESSES =>
- (ACTION_CODE => TYPE_OF_ACTION,
- FILE_EXECUTED => TEXT_HANDLER_SUBSET.UNPACK_VALUE
- (FILE_NAME_OF_PROCESS,FILE_STRING_SIZE)),
- MISC_INFO => BLANK_SCREEN_STRING );
-
- -- Add the Menu Control Item to the Control list, and increment the
- -- number of items in the list.
- ADD_ITEM_TO_LIST;
- CONTROL_LIST_COUNT := CONTROL_LIST_COUNT + 1;
-
- end ADD_MENU_CONTROL_ITEM;
-
-
-
- -- This procedure looks through the Menu Control List, and finds a Menu
- -- Control Item with a Select Key that matches the character given. If no
- -- match exists, an flag for not found is set. The information returned
- -- is: the name and type of the process to be performed, and the next menu
- -- to be displayed by the Menu Handler. The names are return in TEXT format
- -- so the character strings received from the Menu Control List are packed
- -- to TEXT form (blanks taken away, and put in TEXT form).
- procedure RETRIEVE_CONTROL_ITEM (SELECT_KEY: in CHARACTER;
- NEXT_MENU: out TEXT;
- FILE_NAME_OF_PROCESS: out TEXT;
- TYPE_OF_ACTION: out ACTION_TYPE;
- NOT_FOUND: out BOOLEAN) is
- begin
- -- Assume the item is not found, and loop through the number of Menu
- -- Control Items in the Menu Control List.
- NOT_FOUND := TRUE;
- for I in 1..CONTROL_LIST_COUNT loop
- if MENU_CONTROL_LIST.all(I).SELECT_KEY = SELECT_KEY then
- -- When the Select Key of a Menu Control Item matches the given
- -- select key, the item is found, set the return arguments,
- -- set NOT FOUND to false, and exit the loop.
- NEXT_MENU := TEXT_HANDLER_SUBSET.PACK_TO_TEXT
- (MENU_CONTROL_LIST.all(I).NEXT_MENU);
- FILE_NAME_OF_PROCESS := TEXT_HANDLER_SUBSET.PACK_TO_TEXT
- (MENU_CONTROL_LIST.all(I).PROCESSES.FILE_EXECUTED);
- TYPE_OF_ACTION := MENU_CONTROL_LIST.all(I).
- PROCESSES.ACTION_CODE;
- NOT_FOUND := FALSE;
- exit;
- end if;
- end loop;
- -- If the Select Key is not found in all the Menu Control Items of the
- -- Menu Control List, then the Not Found flag will still be true when
- -- the loop runs out, and this status is returned.
- return;
- end RETRIEVE_CONTROL_ITEM;
-
-
-
-
- -- Procedure is used to write the Menu Definition File. The Menu Control
- -- List that is updated by this package, the Display Layout, and the Bad
- -- Selection Message are written to this file. The text of the Bad
- -- Selection Message is passed as an actual argument, but the lines of
- -- the Menu Display Layout are obtained by using the functions provided in
- -- the instantiation of this package. All information is put into the
- -- record structure the Menu Control Items, and these records are written
- -- to the file. The name of the file to created is passed as an argument.
- -- The name is passed in TEXT format and is packed (no leading or trailing
- -- blanks). An error code is returned by this procedure reflecting problems
- -- in creating the Menu Def Table file.
- procedure WRITE_MENU_CONTROL_FILE (FILE_NAME_OF_MENU_DEF_TABLE: in TEXT;
- BAD_SELECTION_MESSAGE: in TEXT;
- ERROR_CODE: out INTEGER) is
-
- -- Internal file name for the Menu Def Table. This name is used by the
- -- I/O fuctions.
- TABLE_FILE: MENU_CONTROL_ITEM_IO.FILE_TYPE;
-
- begin
- -- Assume no Errors, and open the file using the External file name
- -- passed to the procedure. The file name must not contain trailing or
- -- leading blanks. The CREATE operation will create a file with the
- -- name of the exact string. A packed file name in TEXT form is assumed.
- ERROR_CODE := 0;
- MENU_CONTROL_ITEM_IO.CREATE(TABLE_FILE,MENU_CONTROL_ITEM_IO.OUT_FILE,
- TEXT_HANDLER_SUBSET.VALUE(FILE_NAME_OF_MENU_DEF_TABLE));
-
- -- Put screen width and file name size into Menu Control Item type
- -- records, and write these to the Menu Def Table file. The integer
- -- values are put in the NUMBER field of the record.
- CONFIG_INFO_ITEM :=
- (NUMBER => FILE_STRING_SIZE,
- SELECT_KEY => ' ',
- NEXT_MENU => BLANK_FILE_STRING,
- PROCESSES =>
- (ACTION_CODE => ACTION_TYPE'FIRST,
- FILE_EXECUTED => BLANK_FILE_STRING),
- MISC_INFO => BLANK_SCREEN_STRING);
- MENU_CONTROL_ITEM_IO.WRITE(TABLE_FILE, CONFIG_INFO_ITEM);
-
- CONFIG_INFO_ITEM.NUMBER := SCREEN_STRING_SIZE;
- MENU_CONTROL_ITEM_IO.WRITE(TABLE_FILE, CONFIG_INFO_ITEM);
-
-
- -- Put the Bad Selection Message in a Menu Control Item type record
- -- (the string is put into the MISC_INFO field), and write the record
- -- to the file.
- BAD_SELECTION_MESSAGE_ITEM :=
- (NUMBER => 0,
- SELECT_KEY => ' ',
- NEXT_MENU => BLANK_FILE_STRING,
- PROCESSES =>
- (ACTION_CODE => ACTION_TYPE'FIRST,
- FILE_EXECUTED => BLANK_FILE_STRING),
- MISC_INFO => TEXT_HANDLER_SUBSET.UNPACK_VALUE
- (BAD_SELECTION_MESSAGE,SCREEN_STRING_SIZE) );
- MENU_CONTROL_ITEM_IO.WRITE(TABLE_FILE, BAD_SELECTION_MESSAGE_ITEM);
-
- -- Put the number of Menu Control Items in the Menu Control List into a
- -- Menu Control Item type record (put the integer into the NUMBER field
- -- and blank the other fields or the record). Write this record.
- NUMBER_OF_CONTROL_ITEMS :=
- (NUMBER => CONTROL_LIST_COUNT,
- SELECT_KEY => ' ',
- NEXT_MENU => BLANK_FILE_STRING,
- PROCESSES =>
- (ACTION_CODE => ACTION_TYPE'FIRST,
- FILE_EXECUTED => BLANK_FILE_STRING),
- MISC_INFO => BLANK_SCREEN_STRING );
- MENU_CONTROL_ITEM_IO.WRITE(TABLE_FILE, NUMBER_OF_CONTROL_ITEMS);
-
-
- -- For each Menu Control Item in the Menu Control List, write the item
- -- to the file. The Menu Control List points to an array with all the
- -- items in it, so referencing an item is done by referencing the
- -- element of the array that is pointed to by Menu Control List.
- for I in 1..CONTROL_LIST_COUNT loop
- MENU_CONTROL_ITEM_IO.WRITE (TABLE_FILE, MENU_CONTROL_LIST.all(I));
- end loop;
-
-
- -- Now, for each line in the Menu Display Layout (from top to bottom)
- -- retrieve the text of the line and put it into a Menu Control Item
- -- type record (put it in the MISC_INFO field). The string retrieved
- -- is a character string of length SCREEN_STRING_SIZE, so the string
- -- is put directly into the record w/o converting it to another form.
- -- Write a record in the file for each line retrieved.
- while (not END_OF_SCREEN) loop
- SCREEN_LAYOUT_ITEM :=
- (NUMBER => 0,
- SELECT_KEY => ' ',
- NEXT_MENU => BLANK_FILE_STRING,
- PROCESSES =>
- (ACTION_CODE => ACTION_TYPE'FIRST,
- FILE_EXECUTED => BLANK_FILE_STRING),
- MISC_INFO => GET_NEXT_SCREEN_LINE );
- MENU_CONTROL_ITEM_IO.WRITE(TABLE_FILE, SCREEN_LAYOUT_ITEM);
- end loop;
-
-
- -- The config information, Menu Control List, Menu Display Layout, and
- -- Bad Selection Message has been written to the file. Close the Menu
- -- Def Table file.
- MENU_CONTROL_ITEM_IO.CLOSE(TABLE_FILE);
-
- exception
- when MENU_CONTROL_ITEM_IO.NAME_ERROR =>
- -- exception will occur if the file name given to the procedure is
- -- not legal in the current operating system.
- ERROR_CODE := 1;
-
- end WRITE_MENU_CONTROL_FILE;
-
-
-
- -- This procedure is used by the Menu Handler to read a Menu Def Table
- -- file. The name of the file is passed to the procedure. The file must
- -- have been written using the WRITE_MENU_CONTROL_FILE procedure above.
- -- This procedure will attempt to load the Menu Control List kept in this
- -- package, and, using the procedures suplied in the instantiation, it will
- -- attempt to load the Menu Display Layout kept in another Ada package.
- -- The procedure will return the Bad Selection Message, and an Error Code
- -- specifying ant problems with reading the file.
- procedure READ_MENU_CONTROL_FILE (FILE_NAME_OF_MENU_DEF_TABLE: in TEXT;
- BAD_SELECTION_MESSAGE: out TEXT;
- ERROR_CODE: out INTEGER) is
-
- -- This exception will be raised if the config information in the file
- -- read does not match the cofiguration currently running.
- WRONG_DATA_STRUCTURE: exception;
-
- -- Internal file name for Menu Def Table being read. This name is used
- -- in the I/O operations.
- TABLE_FILE: MENU_CONTROL_ITEM_IO.FILE_TYPE;
-
- begin
- -- Assume no errors to start with and try to open the file of the name
- -- passed to this procedure. The name is passed in TEXT format so
- -- covert this to a character string.
- ERROR_CODE := 0;
- MENU_CONTROL_ITEM_IO.OPEN( TABLE_FILE,MENU_CONTROL_ITEM_IO.IN_FILE,
- TEXT_HANDLER_SUBSET.VALUE(FILE_NAME_OF_MENU_DEF_TABLE ));
-
-
- -- Read the config information from the first two records of the file.
- -- If either the screen width or the file name size are not the same
- -- as the values used in this instantiation of the package, then the
- -- records will not be read successfully, therefore raise an exception.
- MENU_CONTROL_ITEM_IO.READ(TABLE_FILE,CONFIG_INFO_ITEM);
- if CONFIG_INFO_ITEM.NUMBER /= FILE_STRING_SIZE then
- raise WRONG_DATA_STRUCTURE;
- end if;
-
- MENU_CONTROL_ITEM_IO.READ(TABLE_FILE,CONFIG_INFO_ITEM);
- if CONFIG_INFO_ITEM.NUMBER /= SCREEN_STRING_SIZE then
- raise WRONG_DATA_STRUCTURE;
- end if;
-
-
- -- Read the record containing the Bad Selection Message next. Extract
- -- the message from the MISC_INFO field, and convert it to TEXT format
- -- so it can be passed as a retured argument.
- MENU_CONTROL_ITEM_IO.READ(TABLE_FILE,BAD_SELECTION_MESSAGE_ITEM);
- BAD_SELECTION_MESSAGE := TEXT_HANDLER_SUBSET.TO_TEXT
- (BAD_SELECTION_MESSAGE_ITEM.MISC_INFO);
-
- -- Read the number of Menu Control Items that will be found in this
- -- file. This value is in the NUMBER field of the next record.
- MENU_CONTROL_ITEM_IO.READ(TABLE_FILE,NUMBER_OF_CONTROL_ITEMS);
- CONTROL_LIST_COUNT := NUMBER_OF_CONTROL_ITEMS.NUMBER;
-
- -- Initialize the Menu Control List to point to no array of items. Build
- -- the Menu Control List by reading each Menu Control Item from the file
- -- and adding each to the Menu Control List (the number of reads/adds
- -- done is the number of Menu Control Items read above).
- MENU_CONTROL_LIST := null;
- for I in 1..CONTROL_LIST_COUNT loop
- MENU_CONTROL_ITEM_IO.READ(TABLE_FILE,MENU_CONTROL_ITEM);
- ADD_ITEM_TO_LIST;
- end loop;
-
-
- -- Next build the Menu Display Layout by reading each record up to the
- -- end of the file, and sequentially putting the display line (found in
- -- the MISC_INFO field of each record) to the Menu Display Layout using
- -- the procedure provided.
- CLEAR_SCREEN_LAYOUT;
- while (not MENU_CONTROL_ITEM_IO.END_OF_FILE(TABLE_FILE)) loop
- MENU_CONTROL_ITEM_IO.READ(TABLE_FILE,SCREEN_LAYOUT_ITEM);
- PUT_NEXT_SCREEN_LINE(SCREEN_LAYOUT_ITEM.MISC_INFO);
- end loop;
-
-
- -- The full Menu Def Table file has been read, close the file.
- MENU_CONTROL_ITEM_IO.CLOSE(TABLE_FILE);
-
- exception
- when MENU_CONTROL_ITEM_IO.NAME_ERROR =>
- -- Exception occurs when the file named cannot be opened. It could
- -- be an invalid file name for this operating system, or the file
- -- may not exist.
- ERROR_CODE := 1;
- when WRONG_DATA_STRUCTURE =>
- -- Exception will occur when the file read was written with another
- -- configuraion.
- MENU_CONTROL_ITEM_IO.CLOSE(TABLE_FILE);
- ERROR_CODE := 2;
-
- end READ_MENU_CONTROL_FILE;
-
-
-
-
- end PROCESS_MENU_CONTROL_TABLE;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --procingd.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
- -- PROCESS_MENU_DEF_STRING;PROCINGD.ADA;KJL;04/17/85
-
- -- This package is used by the Menu Compiler, and contains the subprograms
- -- needed to do some basic processing on the Menu Definition File. The Menu
- -- Def File is written in the Menu Def Language, and is a description of the
- -- Menu display and menu action. The file cna be thought of as a series of
- -- Lexical Units, that are characters of set of characters, that are arranged
- -- in the file and can be sequentially extracted. This package contains sub-
- -- programs to extract and handle these Lexical Units. Analyzing the Lexical
- -- Units for correctness in their content and their order is left to another
- -- Ada package, so no compiler errors regarding the lexical units appear in
- -- this package.
-
- -- The Menu Definition File is an external file that is edited using some
- -- editor and the operations of the particular operating system. One of the
- -- operations performed in this package is to transfer the external file to
- -- a Menu Definition String. This string is a dynamic character string that
- -- will contain all the characters of the file. This string will be kept in
- -- this package, and the string will be processed when lexical units are
- -- extracted. This keeps the external Menu Definition File open for a minimum
- -- amount of time.
-
- package body PROCESS_MENU_DEF_STRING is
-
- -- The dynamic string that is the currently available Lexical Unit.
- LEXICAL_STRING: TEXT;
-
- -- The dynamic string that is the Menu Definition String. The Menu
- -- Definition File will be written to this string.
- MENU_DEF_STRING: TEXT;
-
- -- The character index of the Menu Def String character that will be
- -- analyzed. The parser will get each character in the Menu Def String, and
- -- process it to form the lexical units.
- STRING_POSITION: NATURAL := 1;
-
- -- The current line of the Menu Def File where the character analyzing is
- -- happening.
- LINE_NUMBER: NATURAL := 1;
-
- -- This will contain the STRING_POSITION value at the beginning of each
- -- line in the Menu Def String. This will be used to determine the current
- -- character of the current line where the character is being analyzed.
- LINE_POSITION: NATURAL := 1;
-
- -- The line number where the current lexical unit starts.
- LEX_UNIT_LINE_NUMBER: NATURAL := 0;
- -- The character of the line where the current lexical unit starts.
- LEX_UNIT_POSITION: NATURAL := 0;
-
- -- Will hold the Type of the currently available lexical unit.
- LEXICAL_TYPE: LEXICAL_UNIT_TYPES := LEXICAL_UNIT_TYPES'LAST;
-
- -- If TRUE, this will signal that a new lexical unit should not be
- -- extracted from the Menu Def String on the next request for a new lexical
- -- unit. Instead, the currently available lexical unit should remain
- -- the currently available lexical unit, and no parsing is done on the Menu
- -- Def String.
- LEXICAL_UNIT_ALREADY_RECEIVED: BOOLEAN := FALSE;
-
- -- Constants used to identify the types of lexical units:
- IDENTIFIER: constant := 0;
- USER_LITERAL: constant := 1;
- NO_MORE: constant := 2;
-
-
-
- -- This procedure extracts a Lexical Unit from the Menu Definition String.
- -- The text of the lexical unit is TEXT type and always put into the
- -- LEXICAL_STRING object. The type of the lexical unit is always put into
- -- the LEXICAL_TYPE object. When called this procedure uses and updates the
- -- Menu Def String character index as it analyzes characters within the
- -- Menu Def String to extract the next lexical unit.
- procedure GENERATE_NEW_LEXICAL_UNIT is
-
- -- As the Menu Def String is parsed, different modes are used to giving
- -- characters different significance. For example, in Comment Mode,
- -- only the CR character has significance as the end of the comment.
- type MODE_TYPE is (INITIAL_MODE, WORD_SEP_MODE,
- COMMENT_MODE, USER_LITERAL_MODE);
-
- -- Holds the current mode of the parser.
- MODE: MODE_TYPE := INITIAL_MODE;
-
- -- The current character being analyzed.
- PARSED_CHARACTER: CHARACTER;
-
-
- -- Function will return a substring of string argument given. The new
- -- string will be characters from the INDEX position to the end.
- function CHOP_STRING(STR: STRING; INDEX: POSITIVE) return STRING is
- begin
- return STR(INDEX..STR'LAST);
- end CHOP_STRING;
-
-
- -- This procedure is used to shrink the Menu Def String, so that all
- -- characters of previously extracted lexical units are eliminated. In
- -- this way, as a lexical unit is extracted, the Menu Def String is
- -- stripped of already extracted characters.
- procedure GARBAGE_COLLECTION is
-
- -- A temporary TEXT object to hold the new shortened Menu Def String.
- TEMP_MENU_DEF_STRING: TEXT;
-
- begin
- -- Make a new TEXT type string that is the Menu Def String with the
- -- characters that have already been extracted stripped off.
- TEMP_MENU_DEF_STRING := TEXT_HANDLER_SUBSET.TO_TEXT
- (CHOP_STRING(TEXT_HANDLER_SUBSET.VALUE(MENU_DEF_STRING), STRING_POSITION) );
- -- Free up the space allocated for the Menu Def String.
- TEXT_HANDLER_SUBSET.CLEAR_TEXT(MENU_DEF_STRING);
- -- Set the Menu Def String equal the characters of the shorter string.
- MENU_DEF_STRING := TEXT_HANDLER_SUBSET.PACK_TO_TEXT
- (TEXT_HANDLER_SUBSET.VALUE(TEMP_MENU_DEF_STRING) );
- -- Free up the space allocated for the temp TEXT string.
- TEXT_HANDLER_SUBSET.CLEAR_TEXT(TEMP_MENU_DEF_STRING);
- -- The string index for the ne Menu Def String now starts at 1.
- STRING_POSITION := 1;
-
- end GARBAGE_COLLECTION;
-
-
- -- Function returns the character in the Menu Def String at the string
- -- index. The Text Handler Subset operation is used.
- function RETURN_NEXT_CHAR return CHARACTER is
- begin
- return TEXT_HANDLER_SUBSET.GIVE_POS(MENU_DEF_STRING,STRING_POSITION);
- end RETURN_NEXT_CHAR;
-
-
- -- Function returns TRUE if the character argument is found in the
- -- string argument.
- function MATCH(CHAR: CHARACTER; STR: STRING) return BOOLEAN is
- FOUND: BOOLEAN := FALSE;
- begin
- -- Check each character in the string until CHAR is found. If CHAR is
- -- not found, the initial FALSE value is returned.
- for I in STR'FIRST..STR'LAST loop
- FOUND := (STR(I) = CHAR);
- exit when FOUND;
- end loop;
- return FOUND;
- end MATCH;
-
-
- -- Procedure sets the line number where a Lexical Unit starts.
- procedure MARK_START_OF_LEX_UNIT is
- begin
- LEX_UNIT_LINE_NUMBER := LINE_NUMBER;
- end MARK_START_OF_LEX_UNIT;
-
-
- -- Using the Text Handler Subset operation, this procedure adds the
- -- character argument to the LEXICAL_STRING object.
- procedure ADD_CHARACTER_TO_LEXICAL_STRING
- (PARSED_CHARACTER: in CHARACTER) is
- begin
- TEXT_HANDLER_SUBSET.APPEND (PARSED_CHARACTER,LEXICAL_STRING);
- end ADD_CHARACTER_TO_LEXICAL_STRING;
-
-
- -- Begin the GENERATE_NEW_LEXICAL_UNIT procedure.
- begin
- -- Start by clearing and deallocating the old Lexical Unit, and clean
- -- the Menu Def String so it contains no characters from previously
- -- extracted lexical units.
- TEXT_HANDLER_SUBSET.CLEAR_TEXT(LEXICAL_STRING);
- GARBAGE_COLLECTION;
-
- -- The loop will go character by character through the Menu Def String
- -- analyzing the characters. The procedure is exited when a lexical
- -- unit is found. The loop is exited if no more characters exist in the
- -- Menu Def String (in which case there are no more lexical units).
- loop
- exit when (STRING_POSITION > TEXT_HANDLER_SUBSET.LENGTH(MENU_DEF_STRING));
-
- -- Get the next character in the Menu Def String. If CR, then update
- -- the line number, and save the string position line break.
- PARSED_CHARACTER := RETURN_NEXT_CHAR;
- if PARSED_CHARACTER = ASCII.CR then
- LINE_NUMBER := LINE_NUMBER + 1;
- end if;
-
- -- The different modes of the parser cause the characters to have
- -- different significances:
- case MODE is
-
- when INITIAL_MODE =>
- -- In the Initial Mode, the parser is looking for characters
- -- other than Word Separators. A left delimiter signals the
- -- beginning of a User Literal type lexical unit, the mode
- -- is switched. A Comment indicator signals the beginning of
- -- a comment, the mode is switched. On other characters, the
- -- beginning of an Identifier type lex unit is signaled, the
- -- character is added to the new lex unit, and nmode switched.
- if MATCH(PARSED_CHARACTER, WORD_SEPARATORS) then
- null;
- elsif PARSED_CHARACTER = LEFT_DELIMITER then
- MODE := USER_LITERAL_MODE;
- MARK_START_OF_LEX_UNIT;
- elsif PARSED_CHARACTER = COMMENT_INDICATOR then
- MODE := COMMENT_MODE;
- else
- ADD_CHARACTER_TO_LEXICAL_STRING(PARSED_CHARACTER);
- MODE := WORD_SEP_MODE;
- MARK_START_OF_LEX_UNIT;
- end if;
-
- when WORD_SEP_MODE =>
- -- In Word Sep mode, the parser continues to put characters
- -- into the lex unit until a Word Separator, Comment indicator
- -- or left delimiter is found. At that the lex unit is a
- -- complete Identifier type, and the procedure is exited.
- if ((MATCH(PARSED_CHARACTER, WORD_SEPARATORS)) or
- (PARSED_CHARACTER = LEFT_DELIMITER) or
- (PARSED_CHARACTER = COMMENT_INDICATOR)) then
- LEXICAL_TYPE := LEXICAL_UNIT_TYPES'VAL(IDENTIFIER);
- return;
- else
- ADD_CHARACTER_TO_LEXICAL_STRING(PARSED_CHARACTER);
- end if;
-
- when COMMENT_MODE =>
- -- In Comment mode, the parser is looking for a CR character.
- -- When found, the comment is over, but this is like nothing
- -- was found so which the mode back to the Initial Mode.
- if PARSED_CHARACTER = ASCII.CR then
- MODE := INITIAL_MODE;
- end if;
-
- when USER_LITERAL_MODE =>
- -- In User Literal mode the parser is adding every character
- -- analyzed from the Menu Def String until a right delimiter
- -- is found. At that, the User Literal type lex unit is
- -- complete, Lex Type is set to USER_LITERAL, and the
- -- procedure exited.
- if PARSED_CHARACTER = RIGHT_DELIMITER then
- -- Now, two consecutive right delimiters are interpreted as
- -- one right delimiter character still within the User
- -- Literal. Therefore when a right delimiter is found, make
- -- sure the next character is not a right delimiter before
- -- completing the lexical unit.
- STRING_POSITION := STRING_POSITION + 1;
- PARSED_CHARACTER := RETURN_NEXT_CHAR;
- if PARSED_CHARACTER /= RIGHT_DELIMITER then
- LEXICAL_TYPE := LEXICAL_UNIT_TYPES'VAL(USER_LITERAL);
- return;
- end if;
- end if;
- ADD_CHARACTER_TO_LEXICAL_STRING(PARSED_CHARACTER);
-
- end case;
- -- Set the string index to analyze the next character in the Menu Def
- -- String.
- STRING_POSITION := STRING_POSITION + 1;
- end loop;
-
- -- If the loop has exited w/o the procedure exiting, then the end of the
- -- Menu Def String has been reached. Set the current lex type to NO_MORE
- LEXICAL_TYPE := LEXICAL_UNIT_TYPES'VAL(NO_MORE);
-
- end GENERATE_NEW_LEXICAL_UNIT;
-
-
-
-
- -- This procedure is given name of file which is the Menu Definition File,
- -- and the file is written to a Menu Definition String. The string is kept
- -- in this package for future lexical unit extractions. An error code is
- -- given if there are problems reading the external file.
- procedure WRITE_MENU_DEF_STRING
- (FILE_NAME_OF_MENU_DEF_FILE: in TEXT;
- ERROR_CODE: out INTEGER) is
-
- -- The type of character string line read from the Menu Def File.
- subtype MENU_DEF_LINE_TYPE is STRING(1..MENU_DEF_FILE_LINE_SIZE);
-
- -- The string read from the Menu Def File.
- INPUT_STRING: MENU_DEF_LINE_TYPE;
- -- The character index of the last character read in each line.
- LAST_INDEX: INTEGER;
- -- The internal file name given to the Menu Def File. This name will be
- -- used in the I/O operations.
- DEFINITION_FILE: TEXT_IO.FILE_TYPE;
-
- begin
- -- Initially there are no errors in reading the file. Try to open the
- -- file whose file name was given as an argument (the argument is in
- -- the TEXT form so the file name must be converted to a character
- -- string, also the TEXT file name is assumed to have no leading and
- -- trailing blanks).
- ERROR_CODE := 0;
- TEXT_IO.OPEN(DEFINITION_FILE, TEXT_IO.IN_FILE,
- TEXT_HANDLER_SUBSET.VALUE(FILE_NAME_OF_MENU_DEF_FILE));
-
- -- For each line in the Menu Def File, read the line into a character
- -- string and append the string to the dynamic Menu Def String using
- -- the Text Handler Subset operation. At each line put a CR character
- -- in the Menu Def String.
- loop
- TEXT_IO.GET_LINE(DEFINITION_FILE,INPUT_STRING,LAST_INDEX);
- TEXT_HANDLER_SUBSET.APPEND((INPUT_STRING(1..LAST_INDEX) & ASCII.CR),MENU_DEF_STRING);
- end loop;
-
- exception
- when TEXT_IO.NAME_ERROR =>
- -- This exception occurs when the file name passed to the procedure
- -- is invalid for this operating system, of the file doesn't exist.
- ERROR_CODE := 1;
- when TEXT_IO.END_ERROR =>
- -- This exception occurs when the end of the file is reached.
- TEXT_IO.CLOSE(DEFINITION_FILE);
-
- end WRITE_MENU_DEF_STRING;
-
-
-
-
- -- This procedure makes the next lexical unit in the Menu Def String
- -- available. It extract the text for the next lexical unit from the Menu
- -- Def String, and keeps it available in this package. It also compacts the
- -- Menu Def String, eliminating the text of all previous lexical elements
- -- in the Menu Def String. In this way the Menu Def String is always
- -- shrinking as lexical elements are extracted.
- procedure GET_LEXICAL_UNIT_IF_NEEDED is
- begin
- -- Check if it is necessary to extract another lex unit from the Menu
- -- Def String. If not keep the current lex unit, and reset the Already
- -- Received flag.
- if (LEXICAL_UNIT_ALREADY_RECEIVED) then
- LEXICAL_UNIT_ALREADY_RECEIVED := FALSE;
- else
- GENERATE_NEW_LEXICAL_UNIT;
- end if;
- end GET_LEXICAL_UNIT_IF_NEEDED;
-
-
-
-
- -- This procedure signals this package that the last lexical unit extracted
- -- has not been used yet. Therefore when a request is made for a new
- -- lexical unit, no new lexical unit will be extracted from the Menu Def
- -- String, instead the current lexical unit available will remain the
- -- current lexical unit available.
- procedure UNIT_RECEIVED is
- begin
- LEXICAL_UNIT_ALREADY_RECEIVED := TRUE;
- end UNIT_RECEIVED;
-
-
-
-
- -- Returns the lexical unit type of the current lexical unit available.
- function CURRENT_LEX_TYPE return LEXICAL_UNIT_TYPES is
- begin
- return LEXICAL_TYPE;
- end CURRENT_LEX_TYPE;
-
-
- -- Returns the character position of the current Menu Definition File line,
- -- where the next lexical unit will be extracted.
- function CURRENT_POSITION return INTEGER is
- begin
- -- Currently this procedure is not used, and will always return 0.
- return LEX_UNIT_POSITION;
- end CURRENT_POSITION;
-
-
-
-
- -- Returns the current Menu Definition File Line where the next lexical
- -- unit will be extracted.
- function CURRENT_LINE_NUMBER return INTEGER is
- begin
- return LEX_UNIT_LINE_NUMBER;
- end;
-
-
-
-
- -- Returns the text of the current lexical unit available, returned in
- -- TEXT type form.
- function CURRENT_LEX_STRING return TEXT is
- begin
- return LEXICAL_STRING;
- end CURRENT_LEX_STRING;
-
-
-
-
- -- Returns the number of characters in the lexical unit that is currently
- -- available.
- function LEXICAL_STRING_LENGTH return INTEGER is
- begin
- return TEXT_HANDLER_SUBSET.LENGTH(LEXICAL_STRING);
- end LEXICAL_STRING_LENGTH;
-
-
-
-
- end PROCESS_MENU_DEF_STRING;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --prociond.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
- -- PROCESS_CONFIGURATION;PROCIOND.ADA;KJL;04/18/85
-
- -- This package contains the user defined items as read from the
- -- configuration file. The objects are kept in the package Spec. so that they
- -- are accessable to the main procedure of the Menu Compiler, and Menu Handler.
- -- The objects are also given default values, so that if errors occur while
- -- reading the file, all objects will still have legal values.
- -- If problems occur when the Configuration file is being read, this is
- -- signaled by displaying "!!" on the screen (this is done because before
- -- reading the config file, the Menu Manager programs do not know how big the
- -- the screen width is, and full text lines may not be displayed correctly). In
- -- any case, the config objects will at least have the legal default values so
- -- the Menu Manager procedures can perform.
-
- package body PROCESS_CONFIGURATION is
-
- -- Constants containing the configuration value defaults. When the value
- -- for each object is read, the default is assigned if there is any
- -- trouble. The TEXT objects use string constants as defaults.
- MAX_FILE_NAME_LENGTH_DEFAULT : constant := 15;
- MENU_FILE_DEFAULT : constant STRING := "MENUFILE ";
- LENGTH_OF_FILE_LINES_DEFAULT : constant := 100;
- MENU_TABLE_DEFAULT : constant STRING := "MENUTABL ";
- SCREEN_WIDTH_DEFAULT : constant := 80;
- SCREEN_LENGTH_DEFAULT : constant := 22;
- QUIT_CHARACTER_DEFAULT : constant CHARACTER := '@';
-
- CONFIG_FILE: TEXT_IO.FILE_TYPE; -- Internal file name for MENCON file.
-
- -- Used to read positive numeric values from the file.
- package INTEGER_IO is new TEXT_IO.INTEGER_IO(POSITIVE);
-
-
- procedure GET_NUMBER (NUMBER_DEFAULT: in POSITIVE; NUMBER: out POSITIVE) is
- -- Procedure reads a numeric value fron the MENCON file.
- begin
- INTEGER_IO.GET(CONFIG_FILE,NUMBER);
- TEXT_IO.SKIP_LINE(CONFIG_FILE);
- return;
- exception
- when TEXT_IO.DATA_ERROR =>
- -- Bad type of value found where a number is expected, display the error
- -- signal, and assign the default.
- TEXT_IO.PUT_LINE("!!");
- NUMBER := NUMBER_DEFAULT;
- when TEXT_IO.END_ERROR =>
- -- End of file reached, close file, all subsequent configuration objects
- -- will contain the default values, or whatever value they had previously.
- TEXT_IO.CLOSE(CONFIG_FILE);
- when others =>
- -- Other exceptions could occur if the file is already closed.
- null;
- end GET_NUMBER;
-
-
- procedure GET_FILE_NAME (NAME_DEFAULT: in STRING; NAME: out TEXT) is
- -- This procedure is used to read a string file name from the MENCON file.
- -- The resulting string read is put in an object type TEXT.
- INPUT_STRING: STRING(1..INPUT_LINE_LENGTH); -- Line read from file.
- LAST_INDEX: POSITIVE; -- Last string index in INPUT_STRING that
- -- contains a character.
- TX: TEXT; -- Temp TEXT used as (in out) arguement for PACK_TO_TEXT
-
- begin
- -- Read line from file, and convert to TEXT with no trailing or leading
- -- blanks.
- TEXT_IO.GET_LINE(CONFIG_FILE,INPUT_STRING,LAST_INDEX);
- TX := TEXT_HANDLER_SUBSET.PACK_TO_TEXT(INPUT_STRING(1..LAST_INDEX));
- -- Make sure file name read from file is not to many characters.
- if TEXT_HANDLER_SUBSET.LENGTH(TX) > MAX_FILE_NAME_LENGTH then
- TEXT_IO.PUT_LINE("!!");
- NAME := TEXT_HANDLER_SUBSET.PACK_TO_TEXT(NAME_DEFAULT);
- else
- NAME := TX;
- end if;
- return;
-
- exception
- when TEXT_IO.END_ERROR =>
- -- End of File reached. Close file, subsequent objects will contain
- -- default values or previously assigned value.
- TEXT_IO.CLOSE(CONFIG_FILE);
- when TEXT_IO.DATA_ERROR =>
- -- Value read from file was not string. Signal error, and assign default
- TEXT_IO.PUT_LINE("!!");
- NAME := TEXT_HANDLER_SUBSET.PACK_TO_TEXT(NAME_DEFAULT);
- when others =>
- -- Other exception could occur if the file is already closed.
- null;
-
- end GET_FILE_NAME;
-
-
- procedure GET_CHAR_ELEM (CHAR_DEFAULT: in CHARACTER;
- CHAR_ELEM: out CHARACTER) is
- -- Procedure reads a character from the MENCON file.
- begin
- TEXT_IO.GET(CONFIG_FILE,CHAR_ELEM);
- TEXT_IO.SKIP_LINE(CONFIG_FILE);
- return;
- exception
- when TEXT_IO.DATA_ERROR =>
- -- Some other type input was found instead of a character. Signal error
- -- and use default value.
- TEXT_IO.PUT_LINE("!!");
- CHAR_ELEM := CHAR_DEFAULT;
- when TEXT_IO.END_ERROR =>
- -- End of file reached, close file, all subsequent config object will
- -- contain default of proviously assigned value.
- TEXT_IO.CLOSE(CONFIG_FILE);
- when others =>
- -- Other exceptions could occur if the file is already closed.
- null;
- end GET_CHAR_ELEM;
-
-
-
- procedure READ_CONFIGURATION_FILE is
- -- Procedure opens MENCON configuration file, and reads the configuration
- -- values. Lines are skipped where neccessary to skip the instruction lines
- -- of the file.
- begin
- TEXT_IO.OPEN(CONFIG_FILE,TEXT_IO.IN_FILE,CONFIG_FILE_NAME);
- TEXT_IO.SKIP_LINE(CONFIG_FILE,2);
- GET_NUMBER(MAX_FILE_NAME_LENGTH_DEFAULT,MAX_FILE_NAME_LENGTH);
- TEXT_IO.SKIP_LINE(CONFIG_FILE);
- GET_FILE_NAME(MENU_FILE_DEFAULT,MENU_FILE);
- TEXT_IO.SKIP_LINE(CONFIG_FILE);
- GET_NUMBER(LENGTH_OF_FILE_LINES_DEFAULT,LENGTH_OF_LINES_IN_MENU_FILE);
- TEXT_IO.SKIP_LINE(CONFIG_FILE);
- GET_FILE_NAME(MENU_TABLE_DEFAULT, MENU_TABLE);
- TEXT_IO.SKIP_LINE(CONFIG_FILE);
- GET_NUMBER(SCREEN_WIDTH_DEFAULT, SCREEN_WIDTH);
- TEXT_IO.SKIP_LINE(CONFIG_FILE);
- GET_NUMBER(SCREEN_LENGTH_DEFAULT, SCREEN_LENGTH);
- TEXT_IO.SKIP_LINE(CONFIG_FILE);
- GET_CHAR_ELEM(QUIT_CHARACTER_DEFAULT ,QUIT_CHARACTER);
- TEXT_IO.CLOSE(CONFIG_FILE);
- return;
- exception
- when TEXT_IO.NAME_ERROR =>
- -- MENCON file is not found. Signal error and use defaults.
- TEXT_IO.PUT_LINE ("!!");
- when TEXT_IO.END_ERROR =>
- -- End of file reached. Close file, use defaults for remaining objects
- TEXT_IO.CLOSE(CONFIG_FILE);
- when others =>
- -- Other exception could occur if file is already closed.
- null;
- end READ_CONFIGURATION_FILE;
-
-
- end PROCESS_CONFIGURATION;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --proctord.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
-
- -- PROCESS_INITIATOR;PROCTORD.ADA;KJL;04/17/85
-
- -- This package contains two procedures, the bodies of which are completely user
- -- supplied except for a few sample and skeletal statements. These procedures
- -- provide the interface of the Menu Handler with the CLI, and the interface
- -- of the Menu Handler with any Ada procedures that are desired to be linked
- -- to this Menu Handler program. The package spec for this package contains
- -- the procedure specs for the two interface procedures. The procedure specs
- -- should not be changed since this is the linkage between the interface
- -- procedures and the rest of the Menu Handler software. Therefore the user
- -- should supply the statements in the procedure bodies, so that the arguments
- -- of the procedures input and return the desired values.
-
- with TEXT_IO; -- And any packages needed for procedures run...
- package body PROCESS_INITIATOR is
-
- -- The installer of the Menu Manager software can make the Menu Handler
- -- call other Ada procedures in three ways:
- -- 1) Include the code for the procedure is another package, and put that
- -- package unit name in the "with" clause above this package body. If
- -- this is done, the other package must be compiled, then this package
- -- body must be compiled, then the main procedure MENUSHOW must be
- -- re-compiled and re-linked.
- -- 2) An external procedure can be written using the "separate" clause
- -- before its "procedure" statement. The unit name given in that
- -- procedures "separate" clause will be this unit, "PROCESS_INITIATOR".
- -- Then in this procedure, a procedure statement is put into the code
- -- declaring the procedure as separate, ie:
- -- procedure XYZ is separate;
- -- If this is done, the other procedure must be compiled, then this
- -- package body must be compiled, then the main procedure MENUSHOW must
- -- be re-compiled and re-linked.
- -- 3) The code for the procedure can be put directly within this package.
- -- This is what is done for the sample procedure, since no other files
- -- are involved in this method. In this case, this package body will
- -- have to be compiled, and the main procedure MENUSHOW must be re-
- -- compiled and re-linked.
-
- -- This SAMPLE_1 procedure shows the third method of including Ada
- -- procedures to be run by the Menu Handler. The procedure outputs a line
- -- and waits for user to input a character.
- procedure SAMPLE_1 is
- INPUT_CHAR: CHARACTER;
- begin
- TEXT_IO.PUT_LINE(" SAMPLE_1 procedure has started... ");
- TEXT_IO.GET (INPUT_CHAR);
- end SAMPLE_1;
-
-
-
-
- -- This interface procedure is used to provide a method for starting other
- -- Ada procedures. The procedures will in some way have to be linked to
- -- the Menu Handle procedure for them to be called. This can be done in a
- -- number of ways. There is one argument passed to this procedure, to
- -- be used by the user supplyed statements in the procedure body, and one
- -- argument passed back to the calling program, the statements of the
- -- procedure body must supply a value for this argument.
- -- The ADA_PROCEDURE_NAME argument is a string argument given to the
- -- procedure. This string is ment to be used in a multi-conditional
- -- statement, that will call an Ada procedure by the name corresponding to
- -- the string given. The string passed here will always have no leading or
- -- trailing blanks, other than that, they will be the exact string
- -- specified in the Menu Definition File on a Select ... A [string] in-
- -- struction (see the syntax guide).
- -- The ERROR argument passed back to the calling program is ment to be
- -- set TRUE if the string is not found in the multi-conditional statement,
- -- and therefore no corresponding Ada procedure was started.
- procedure ADA_PROCEDURE_CALL (ADA_PROCEDURE_NAME: in STRING;
- ERROR: out BOOLEAN) is
- begin
- -- This interface procedure must be edited by the user to make Ada
- -- procedure calls possible. The procedure consists of a multi-
- -- conditional statement, that test for different character strings
- -- entering the procedure, and starts corresponding procedures.
- ERROR := FALSE;
- if ADA_PROCEDURE_NAME = "SAMPLE_1" then
- SAMPLE_1;
-
- -- Continue the condition for any procedure available to be called, for
- -- example the follow condition could added to call a procedure in the
- -- package "SAMPLE_PROCS". "SAMPLE_PROCS" would have been included in
- -- the "with" clause above this package body.
- -- elsif ADA_PROCEDURE_NAME = "SAMPLE_2" then
- -- SAMPLE_PROCS.SAMPLE_2;
-
- else
- -- Set error if string is not matched by a procedure call.
- ERROR := TRUE;
- end if;
-
- -- Note that the result of the above statement is a list the valid
- -- strings that can specified in the Select instruction of the Menu
- -- Definition File ie, from the above conditional statement, the Select
- -- instruction:
- -- Select [x] Ada [SAMPLE_1]
- -- will result in a legal process when 'x' is typed at the menu.
-
- end ADA_PROCEDURE_CALL;
-
-
-
-
- -- This interface procedure is used to transfer a string passed it the CLI.
- -- The method of doing this is different for different Ada environments,
- -- and may not even exist in a particular environment. There are two
- -- arguments passed to this procedure to be used by the user provided
- -- statements, and one argument passed back to the calling procedure.
- -- The COMMAND_LINE is a string argument that contains a single word,
- -- like a command or an executable file of commands. This string have no
- -- leading of trailing blanks, and this string is to be passed directly to
- -- the Command Line Interpretor.
- -- The CONTINUE_WAIT_CODE is integer code that specifies 0 - to hold the
- -- Menu Handler program while the command is being processed by the CLI,
- -- or 1 - to make the Menu Handler continue immediately once the line or
- -- command has been passed to the CLI. The use of these codes input the
- -- this interface procedure will depend entirely on the capability
- -- available to issue statements the CLI from this Ada program (ie, it
- -- may be possible to issue a command to the CLI from this Ada program,
- -- but it may not be possible to issue the command and have the Ada program
- -- wait for command completion).
- -- The ERROR argument is a boolean parameter returned to the calling
- -- procedure. It is ment to be used to return the status of the CLIs
- -- ability to interpret the line given to it. If the CLI could not read
- -- or understand the string passed to it, then the ERROR argument should
- -- return TRUE. The ERROR argument is not ment to return the status of
- -- the actual command of process started, only the CLIs ability to start it.
- procedure COMMAND_LINE_PROCESSOR (COMMAND_LINE: in STRING;
- CONTINUE_WAIT_CODE: in INTEGER;
- ERROR: out BOOLEAN) is
-
- -- All of the code lines in this package should be replaced with user
- -- supplied code. The code existing here now is used only for test
- -- purposes, and to give an example of how this procedure is called from
- -- another procedure outside the package. The code supplied by the
- -- user for this procedure should the necessary Ada procedure/package(s)
- -- that enable string to be passed to the Command Line Interpretor,
- -- in Wait, or Don't Wait mode. Refer to the Ada environment manual
- -- for the particular system running to see if such procedures exist,
- -- and how they are called in an Ada program.
-
- begin
-
- SHOW_PROCEDURE_CALL:
- -- This code will simply show that the procedure is called, and accepts
- -- the string passed it. The code should be replaced by the uses.
- declare
- INPUT_CHAR: CHARACTER;
- WAIT: constant := 0;
- begin
- TEXT_IO.PUT_LINE(" Issue command " & COMMAND_LINE & " to the CLI.");
- TEXT_IO.GET(INPUT_CHAR);
- -- The ERROR is set is the WAIT signal was given. This again is just
- -- test code to show how an ERROR would be processed.
- ERROR := (CONTINUE_WAIT_CODE = WAIT);
- end SHOW_PROCEDURE_CALL;
-
-
- end COMMAND_LINE_PROCESSOR;
-
-
-
-
- end PROCESS_INITIATOR;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --textsetd.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
- -- TEXT_HANDLER_SUBSET;TEXTSETD.ADA;KJL;04/18/85
-
- -- This package is a subset of the Text Handler package from the LRM. It
- -- contains only the operations needed for the Menu Manager project. The
- -- TEXT type is a dynamic character string type, that is implemented using
- -- access types where the object is really a pointer to a string. The string
- -- can expand dynamicly because the object points to a new string that
- -- includes the text of the previous one and more.
-
- -- This is one of the few non generic library units in the Menu Manager set.
- -- This package must be compiled before others are.
-
- with UNCHECKED_DEALLOCATION;
- package body TEXT_HANDLER_SUBSET is
-
- procedure FREE is new UNCHECKED_DEALLOCATION (STRING, TEXT);
- -- procedure to free addresses being pointed to by a TEXT object.
-
-
- function STRNG (C: CHARACTER) return STRING is
- -- Returns a string of one character that is the given C.
- TEMP: STRING(1..1) := (1 => C);
- begin
- return TEMP;
- end STRNG;
-
-
- procedure INITIALIZE_TEXT (T: in out TEXT) is
- -- This procedure is used to initialize a TEXT object to point to a null
- -- string. This avoids CONSTRAINT_ERRORS ocurring when the accessed string
- -- of a TEXT object is processed when the object in fact points to null.
- begin
- if T = null then
- FREE (T);
- T := new STRING'("");
- end if;
- return;
- end INITIALIZE_TEXT;
-
-
-
- function LENGTH (T: TEXT) return NATURAL is
- -- Returns the Length of the accessed string. 0 if access is null.
- begin
- return T.all'LENGTH;
- exception
- when CONSTRAINT_ERROR =>
- return 0;
- end LENGTH;
-
-
- function VALUE (T: TEXT) return STRING is
- -- Returns the string which the access type points to, or "" if the access
- -- type points to null.
- begin
- return T.all;
- exception
- when CONSTRAINT_ERROR =>
- return "";
- end VALUE;
-
-
- function EMPTY (T: TEXT) return BOOLEAN is
- -- Returns true if the accessed string is "", or access is null.
- begin
- return (T.all = "");
- exception
- when CONSTRAINT_ERROR =>
- return TRUE;
- end EMPTY;
-
-
- function TO_TEXT (STR: STRING) return TEXT is
- -- Creates an access type that points to a string of the value given.
- begin
- return new STRING'(STR);
- end TO_TEXT;
-
-
- function TO_TEXT (CHR: CHARACTER) return TEXT is
- -- Creates an access type pointing to a string that is the character given.
- begin
- return new STRING'(STRNG(CHR));
- end TO_TEXT;
-
-
- procedure CLEAR_TEXT (T: in out TEXT) is
- -- Resets the given access object to point to a null string.
- begin
- FREE (T);
- T := new STRING'("");
- end CLEAR_TEXT;
-
-
- procedure PACK_TEXT (T: in out TEXT) is
- -- Takes the leading and trailing blanks off the given accessed string.
- TEMP: TEXT; -- Used so old addresses can be freed.
- FRONT, BACK: POSITIVE; -- 1st and last string idex of new string.
- begin
- INITIALIZE_TEXT (T); -- if T is null, make it point to null string.
- if EMPTY(T) then
- return;
- else
- -- Start at begining of string and move to the right looking for a
- -- character other than blank.
- FRONT := T.all'FIRST;
- BACK := T.all'LAST;
- while (T.all(FRONT) = ' ') loop
- FRONT := FRONT + 1;
- if FRONT > BACK then
- -- The String contains all blanks, return access to a null string.
- FREE(T);
- T := new STRING'("");
- return;
- end if;
- end loop;
-
- -- The starting string index has been found, now move from the last
- -- string index to the left until a character other than blank is
- -- found, this will be the ending string index.
- while (T.all(BACK) = ' ') loop
- BACK := BACK - 1;
- end loop;
-
- -- A new string is created so the index will begin at 1.
- MAKE_NEW_STRING:
- declare
- NEW_STRING: STRING(1..BACK-FRONT+1) := T.all(FRONT..BACK);
- begin
- TEMP := new STRING'(NEW_STRING);
- end MAKE_NEW_STRING;
-
- -- Free the address currently pointed to by T, make T point to a new
- -- string, and free the address pointing to the temporary new string.
- FREE (T);
- T := new STRING'(TEMP.all);
- FREE (TEMP);
- return;
- end if;
-
- end PACK_TEXT;
-
-
- procedure UNPACK_TEXT (T: in out TEXT; LEN: in NATURAL;
- NO_ROOM: out BOOLEAN) is
- -- Adds trailing blanks to the given accessed string to make it the length
- -- requested in LEN. NO_ROOM is true when the LEN is smaller than the
- -- number of characters in the T accessed string.
- BLANK_AREA, TEMP: TEXT; -- Blank area is TEXT object of blanks.
- NUMBER_OF_BLANKS: INTEGER; -- Number of trailing blanks needed.
-
- begin
- INITIALIZE_TEXT (T); -- Make T point to null string if T is null.
- if LENGTH(T) > LEN then
- -- Accessed string is to big.
- NO_ROOM := TRUE;
- return;
- elsif LENGTH(T) = LEN then
- -- Accessed string is the same size as desired string. Keep T the
- -- same and return.
- NO_ROOM := FALSE;
- return;
- else
- -- The accessed string will have to be padded with trailing blanks.
- -- Find out how many blanks are needed, and make a TEXT object pointing
- -- to a string of that many blanks. Then make a temp TEXT object point
- -- to the concat of the original text and the blank string.
- NUMBER_OF_BLANKS := LEN - LENGTH(T);
- BLANK_AREA := new STRING'(1..NUMBER_OF_BLANKS => ' ');
- TEMP := new STRING'(T.all & BLANK_AREA.all);
- -- Free T blank string address, T address. Make T point to a string
- -- of the new longer value, an free the temp address.
- FREE (BLANK_AREA);
- FREE (T);
- T := new STRING'(TEMP.all);
- FREE (TEMP);
- NO_ROOM := FALSE;
- return;
- end if;
-
- end UNPACK_TEXT;
-
-
- function UNPACK_VALUE (T: TEXT; LEN: NATURAL) return STRING is
- -- Returns a string of length LEN from the accessed string T. If T is too
- -- big, returns a string of blanks.
- NO_ROOM: BOOLEAN;
- TEMP_TEXT: TEXT := T; -- Temp TEXT used as an (in out) parameter in
- -- UNPACKED_TEXT call.
- BLANK_STRING: STRING(1..LEN) := (1..LEN => ' '); -- Blank line passed if
- -- T is too big.
- begin
- UNPACK_TEXT(TEMP_TEXT,LEN,NO_ROOM);
- if NO_ROOM then
- return BLANK_STRING;
- else
- return VALUE(TEMP_TEXT);
- end if;
-
- end UNPACK_VALUE;
-
-
- function PACK_TO_TEXT (STR: STRING) return TEXT is
- -- Returns an access type pointing to a string with value STR, but with
- -- no leading or trailing blanks.
- TEMP_TEXT: TEXT;
- begin
- -- Convert string to TEXT, pack the TEXT oobject, and return the
- -- resulting object.
- TEMP_TEXT := TO_TEXT(STR);
- PACK_TEXT(TEMP_TEXT);
- return TEMP_TEXT;
- end PACK_TO_TEXT;
-
-
- procedure APPEND (TAIL: TEXT; TO: in out TEXT) is
- -- TO will point to a string that is the accessed string TO concated with
- -- the accessed string TAIL.
- TEMP,TAIL1: TEXT;
-
- -- In this procedure a new object TAIL1 will point to the accessed string
- -- to be concatinated. This makes sure that the 2 concat objects do in
- -- fact point to strings and are not null pointers.
- begin
- -- Make sure TAIL1 points to a string.
- if TAIL = null then
- TAIL1 := new STRING'("");
- else
- TAIL1 := TAIL;
- end if;
-
- -- Make sure TO points to a string.
- INITIALIZE_TEXT (TO);
-
- -- if TO is empty, the new string is TAIL, otherwise free the old T
- -- address and make T point to a new string that is the concat of the
- -- two strings.
- if EMPTY(TO) then
- TO := new STRING'(TAIL1.all);
- else
- TEMP := new STRING'(TO.all);
- FREE (TO);
- TO := new STRING'(TEMP.all & TAIL1.all);
- FREE (TEMP);
- end if;
-
- end APPEND;
-
-
- procedure APPEND (TAIL: STRING; TO: in out TEXT) is
- -- TO will point to a string that is the accessed string TO concated with
- -- the string TAIL.
- TEMP: TEXT;
- begin
- -- Make sure T points to a string.
- INITIALIZE_TEXT (TO);
-
- -- if TO is empty, the new string is TAIL, otherwise free the old T
- -- address and make T point to a new string that is the concat of the
- -- two strings.
- if EMPTY(TO) then
- TO := new STRING'(TAIL);
- else
- TEMP := new STRING'(TO.all);
- FREE (TO);
- TO := new STRING'(TEMP.all & TAIL);
- FREE (TEMP);
- end if;
-
- end APPEND;
-
-
- procedure APPEND (TAIL: CHARACTER; TO: in out TEXT) is
- -- TO will point to a string that is the accessed string TO concated with
- -- the character TAIL.
- TEMP: TEXT;
-
- begin
- -- Make sure T points to a string.
- INITIALIZE_TEXT (TO);
-
- -- if TO is empty, the new string is TAIL, otherwise free the old T
- -- address and make T point to a new string that is the concat of the
- -- accessed string and the character given.
- if EMPTY(TO) then
- TO := new STRING'(STRNG(TAIL));
- else
- TEMP := new STRING'(TO.all);
- FREE (TO);
- TO := new STRING'(TEMP.all & STRNG(TAIL));
- FREE (TEMP);
- end if;
-
- end APPEND;
-
-
- function GIVE_POS (T: TEXT; POSITION: NATURAL) return CHARACTER is
- -- Returns the character of accessed string T, that is the string index
- -- given in POSITION.
- begin
- return T.all(POSITION);
- exception
- when CONSTRAINT_ERROR =>
- return ' ';
- end GIVE_POS;
-
-
-
- end TEXT_HANDLER_SUBSET;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --menuread.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
-
- -- MENUREAD;MENUREAD.ADA;KJL;04/11/85
-
- -- This procedure is the main program executed when the Menu Compiler is run.
- -- The procedure will first read a configuration file, named "MENCON" (this is
- -- always the name of the configuration file). Using the values in the
- -- configuration file, the procedure instantiates packages need, reads the
- -- input Menu Definition File (the name of the Menu Definition File is given
- -- in the configuration file), and processes the Menu Definition file to create
- -- a Menu Definition Table used by the Menu Handler.
-
- -- These packages contain the subprograms used by this program. The names
- -- listing are package UNIT names, and do not necessarily corrispond to file
- -- names when the packages are found.
- with TEXT_IO, HANDLE_COMPILER_COMPONENTS, DISPLAY_PROCESSING,
- PROCESS_MENU_CONTROL_TABLE, PROCESS_MENU_DEF_STRING,
- COMPILER_MESSAGES, PROCESS_CONFIGURATION, TEXT_HANDLER_SUBSET;
- procedure MENUREAD is
-
- -- Rename type to avoid using extended name.
- subtype TEXT is TEXT_HANDLER_SUBSET.TEXT;
-
- -- The Menu Definition File is comprised of Lexical Units. The types of
- -- lexical units are: Identifier - like an instuction for the menu
- -- processing, and User Literals - literal information like display text
- -- or line numbers. Identifiers usually perform on User Literals. The
- -- No More unit type signals there is no more lexical units, ie end of
- -- Menu Definition.
- type LEXICAL_UNIT_TYPES is (IDENTIFIER, USER_LITERAL, NO_MORE);
-
- -- Legal characters used to signal the separation of lex units.
- WORD_SEPARATORS : constant STRING := ":, ;"
- & ASCII.VT & ASCII.HT & ASCII.LF & ASCII.CR;
-
- -- Valid characters the user can use as "select keys" typed at the final
- -- menu to perform a desired action (all defined in the Menu Def File).
- USABLE_SELECT_KEYS : constant STRING := "ABCDEFGHIJKLMNOPQRSTUVWXYZ" &
- "abcdefghijklmnopqrstuvwxyz" & "1234567890" & "!@#$%^&*()_-+=<,>.?/";
-
- -- Characters used as left and right delimiters for the User Literals in
- -- the Menu Def File, characters are currently '[' and ']'. If some other
- -- characters are desired (say quote marks "") the program can de changed
- -- here. Remeber the characters cannot in the User Select Keys or Word
- -- Separators, as this would confuse the parsing, and the compiler will
- -- not work correctly.
- LEFT_DELIMITER : constant CHARACTER := ASCII.L_BRACKET;
- RIGHT_DELIMITER : constant CHARACTER := ASCII.R_BRACKET;
-
- -- Character used to indicate that what follows is a comment. The character
- -- can also be changed as long as it is not a delimiter, or Word Separator.
- COMMENT_INDICATOR : constant CHARACTER := '*';
-
-
-
- MENU_DEF_FILE: TEXT_HANDLER_SUBSET.TEXT;
- -- Name of the file used as input to the Menu Compiler.
-
- FILE_ERROR: INTEGER;
- -- Used to determine errors in reading and writting the files. The
- -- procedures used to read and write will return an integer file error.
-
- MORE: BOOLEAN := TRUE;
- -- True if there are more Lexical Units to process.
-
-
- -- The processing first reads the configuration file, then starts a block
- -- statement that does runtime instantiation of the needed generic packages.
- -- At that point the procedures needed exist (with the proper configuration
- -- constants) within the new packages.
- begin
- PROCESS_CONFIGURATION.READ_CONFIGURATION_FILE;
- DO_MAIN_PROCESSING:
- declare
-
- -- Will contain subprograms to handle the Menu Def String
- package THIS_DEF_STRING is new PROCESS_MENU_DEF_STRING
- (LEXICAL_UNIT_TYPES,
- PROCESS_CONFIGURATION.LENGTH_OF_LINES_IN_MENU_FILE,
- WORD_SEPARATORS,
- COMMENT_INDICATOR,
- RIGHT_DELIMITER,
- LEFT_DELIMITER);
-
- -- Will contain subprograms to handle building the menu display.
- package THIS_DISPLAY is new DISPLAY_PROCESSING
- (PROCESS_CONFIGURATION.SCREEN_WIDTH,
- PROCESS_CONFIGURATION.SCREEN_LENGTH);
-
- -- Will contain subprograms to handle the list of "control items" being
- -- built (control items, ie what select key corrisponds to what type and
- -- name of program to initiate...).
- package THIS_MENU_CON_PROCESS is new PROCESS_MENU_CONTROL_TABLE
- (PROCESS_CONFIGURATION.ACTION_TYPES,
- PROCESS_CONFIGURATION.MAX_FILE_NAME_LENGTH,
- PROCESS_CONFIGURATION.SCREEN_WIDTH,
- THIS_DISPLAY.GET_NEXT_SCREEN_LINE,
- THIS_DISPLAY.END_OF_SCREEN, THIS_DISPLAY.PUT_NEXT_SCREEN_LINE,
- THIS_DISPLAY.CLEAR_SCREEN_LAYOUT);
-
- -- Will contain subprograms to puting message to the dsiplay during
- -- compilation.
- package THESE_COMPILER_MSGS is new COMPILER_MESSAGES
- (PROCESS_CONFIGURATION.SCREEN_WIDTH,
- THIS_DEF_STRING.CURRENT_LEX_STRING,
- THIS_DEF_STRING.CURRENT_LINE_NUMBER);
-
- -- Will contain subprograms to evaluate the lexical units as received
- -- from the Menu Definition.
- package THIS_HANDLER is new HANDLE_COMPILER_COMPONENTS
- (LEXICAL_UNIT_TYPES,
- PROCESS_CONFIGURATION.ACTION_TYPES,
- USABLE_SELECT_KEYS,
- PROCESS_CONFIGURATION.SCREEN_WIDTH,
- PROCESS_CONFIGURATION.SCREEN_LENGTH,
- PROCESS_CONFIGURATION.MAX_FILE_NAME_LENGTH,
- THIS_MENU_CON_PROCESS.ADD_MENU_CONTROL_ITEM, THIS_DEF_STRING.
- GET_LEXICAL_UNIT_IF_NEEDED, THIS_DEF_STRING.UNIT_RECEIVED,
- THIS_DEF_STRING.CURRENT_LEX_TYPE, THIS_DEF_STRING.CURRENT_LEX_STRING,
- THIS_DISPLAY.PUT_SCREEN_TEXT, THESE_COMPILER_MSGS.SEND_COMPILE_ERROR);
-
-
- -- Once the packages are instantiates, the subprograms within them can be
- -- used in a logical sequence to do the menu compilation.
- begin
-
- -- Read all messages so that they are available for output.
- THESE_COMPILER_MSGS.INITIALIZE_MESSAGES;
-
- -- Initialize the screen layout array with all blanks (this array will
- -- contain the display layout as it is defined in the menu Definition).
- -- Write this blank page to the display.
- THIS_DISPLAY.CLEAR_SCREEN_LAYOUT;
- THIS_DISPLAY.PUT_SCREEN_LAYOUT_TO_CRT;
-
- -- The file used as the input Menu Definition File is the name given in
- -- the configuration file.
- MENU_DEF_FILE := PROCESS_CONFIGURATION.MENU_FILE;
-
- -- The input Menu Definition File is used to write a Menu Definition
- -- string which is simply a dynamic array of the whole Menu Def File.
- -- The external Menu Def File is closed imediately after the string
- -- is produced, and the Menu Def String is used for the remainder of the
- -- compilation in parsing and analyzing its lexical units. Error codes
- -- are returned if there were problems reading the Menu Def File, and
- -- compiler messages are displayed.
- THIS_DEF_STRING.WRITE_MENU_DEF_STRING(MENU_DEF_FILE, FILE_ERROR);
- if FILE_ERROR /= 0 then
- THESE_COMPILER_MSGS.SEND_COMPILE_ERROR(01);
- end if;
-
- -- The first lexical element to be found in the Menu Definition is a
- -- title. The title will be the name of the Menu Def Table created.
- if not THESE_COMPILER_MSGS.FATAL_ERROR_STATUS then
- THIS_HANDLER.GET_THE_TITLE;
- end if;
-
- -- For the rest of the Menu Definition, get each lexical unit, and use
- -- the subprograms to process them, according to their type.
- while (MORE) and (not THESE_COMPILER_MSGS.FATAL_ERROR_STATUS) loop
- -- Subprogram makes available the next lexical unit to be analyzed.
- -- The actual text of the lexical unit is returned with another
- -- function, however the text in not needed here.
- THIS_DEF_STRING.GET_LEXICAL_UNIT_IF_NEEDED;
- -- The type of lexical unit is returned in a function.
- case THIS_DEF_STRING.CURRENT_LEX_TYPE is
- when USER_LITERAL =>
- -- A User Literal by itself is text to be put in the display
- -- layout. A subprogram is called to do this. The position in
- -- the display layout is determined by variables within the
- -- THIS_HANDLER package, and those values are not needed here.
- THIS_HANDLER.WRITE_SCREEN_LAYOUT_TEXT
- (THIS_DEF_STRING.CURRENT_LEX_STRING);
-
- when IDENTIFIER =>
- -- Identifiers are handled by a subprogram that analyzes what to
- -- do in the case of each identifier.
- THIS_HANDLER.PROCESS_IDENTIFIER
- (THIS_DEF_STRING.CURRENT_LEX_STRING);
-
- when NO_MORE =>
- -- End of Menu Definition (Menu Definition String)
- MORE := FALSE;
- end case;
-
- end loop;
-
- -- Write a Menu Def Table (if no error has prevented it), from the list
- -- of control items built, and from the menu display layout built. Also
- -- include some configuration information in the file, and the Bad
- -- Selection Message.
- if (not THESE_COMPILER_MSGS.DISABLE_ERROR_STATUS) then
- THIS_MENU_CON_PROCESS.WRITE_MENU_CONTROL_FILE
- (THIS_HANDLER.THE_TITLE_NAME,
- THIS_HANDLER.THE_BAD_SELECTION_MESSAGE, FILE_ERROR);
- -- Errors can occur when an attempt is made to write a file. Issue
- -- the appropriate message to the user.
- if FILE_ERROR /= 0 then
- THESE_COMPILER_MSGS.SEND_COMPILE_ERROR(02);
- end if;
- end if;
-
- -- Issue a final summary message, number of errors, severity, and
- -- whether or not Menu Def Table was created.
- THESE_COMPILER_MSGS.SEND_FINAL_MESSAGE;
-
- -- End the block statement, end the compiler.
- end DO_MAIN_PROCESSING;
-
- end MENUREAD;
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- --menushow.ada
- --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
-
- -- MENUSHOW;MENUSHOW.ADA;KJL;04/15/85;
-
- -- This procedure is the main program executed when the Menu Handler is run.
- -- The procedure will read the configuration file, MENCON (this is always the
- -- name of the configuration file). Using the values read from the config file,
- -- the program will instantiate packages to create procedures that work for
- -- this particular configuration. The program will read a Menu Definition Table
- -- (the name of the file is given in the MENCON config file), and will display
- -- the proper menu layout, and do the proper processing on the users inputs.
-
- -- These packages listed contain the subprograms used by this procedure. The
- -- names are library UNIT names and do not necessarily corrispond to the
- -- file names where the packages are found.
- with TEXT_IO, DISPLAY_PROCESSING, PROCESS_MENU_CONTROL_TABLE,
- COMPILER_MESSAGES, PROCESS_CONFIGURATION, TEXT_HANDLER_SUBSET,
- CONTROLLING_MENU_INFO_LINE, HANDLE_PROCESSES, PROCESS_INITIATOR;
- procedure MENUSHOW is
-
- -- Rename the TEXT type to avoid using the extended dot notation.
- subtype TEXT is TEXT_HANDLER_SUBSET.TEXT;
-
- -- Inputs from the user are either command lines, or a selection key. Each
- -- input will be given one of these types.
- type INPUT_TYPES is (CLI_COMMAND, SELECTION);
-
- -- The user inputs a "!" which causes the menu processing to then allow a
- -- line to be typed and passed to the CLI. If a different character is
- -- desired for this "escape" character, then this constant can be changed.
- CLI_INDICATOR: constant CHARACTER := '!';
-
- -- The name of the Menu Definition Table that is being used for the
- -- current Menu Processing. The Menu Def Table contains the layout for the
- -- menu display, and the selections available, and the corrisponding
- -- actions.
- MENU_TABLE_FILE: TEXT;
-
- -- Text for the Bad Selection Message used for the current menu being
- -- processed. This text is read from the Menu Def Table.
- BAD_SELECTION_MSG: TEXT;
-
- -- Used to determine errors when reading the Menu Def Tables.
- FILE_ERROR: INTEGER;
- CANNOT_OPEN: constant := 1;
- IMPROPER_CONFIG: constant := 2;
-
- -- Text of the users input to the menu processor.
- USER_INPUT: TEXT;
- -- Type of input from the user to the menu processor.
- USER_INPUT_TYPE: INPUT_TYPES;
-
- -- Dummy function used in instantiation of packages. The Menu Handler will
- -- not need a function to return Lex Units, it is not parsing any files.
- function DUMMY_RETURN_LEX_STRING return TEXT is
- begin
- return TEXT_HANDLER_SUBSET.TO_TEXT("No Function");
- end DUMMY_RETURN_LEX_STRING;
-
- -- Dummy function needed to instantiate the error messages package. No
- -- Line number is needed for runtime errors.
- function DUMMY_RETURN_LINE_NUMBER return INTEGER is
- begin
- return 0;
- end DUMMY_RETURN_LINE_NUMBER;
-
-
- -- Start MENUSHOW procedure. Read the configuration file and start a block
- -- statement that will do runtime instantiations of the packages needed.
- begin
-
- PROCESS_CONFIGURATION.READ_CONFIGURATION_FILE;
- DO_MENU_HANDLER:
- declare
-
- -- Package will contain subprograms needed to read the Menu Display
- -- layout from the Menu Def Table, and put the layout to menu display.
- package THIS_DISPLAY is new DISPLAY_PROCESSING
- (PROCESS_CONFIGURATION.SCREEN_WIDTH,
- PROCESS_CONFIGURATION.SCREEN_LENGTH);
-
- -- Package will contain subprograms to read the Menu Def Table into
- -- a list of control items (accessed from menu selections), and into
- -- the display layout kept in the THIS_DISPLAY package.
- package THIS_MENU_CON_PROCESS is new PROCESS_MENU_CONTROL_TABLE
- (PROCESS_CONFIGURATION.ACTION_TYPES, PROCESS_CONFIGURATION.MAX_FILE_NAME_LENGTH,
- PROCESS_CONFIGURATION.SCREEN_WIDTH,
- THIS_DISPLAY.GET_NEXT_SCREEN_LINE, THIS_DISPLAY.END_OF_SCREEN,
- THIS_DISPLAY.PUT_NEXT_SCREEN_LINE,
- THIS_DISPLAY.CLEAR_SCREEN_LAYOUT);
-
- -- Package will contain the subprograms to output messages to the user
- -- durring the running of the Menu Handler.
- package THESE_PROGRAM_MSGS is new COMPILER_MESSAGES
- (PROCESS_CONFIGURATION.SCREEN_WIDTH,
- DUMMY_RETURN_LEX_STRING, DUMMY_RETURN_LINE_NUMBER);
-
- -- Package will contain the Menu Info Line that appears at the bottom
- -- of the screen. The subprograms will set the line to certain values,
- -- and return the text of the line to be displayed with the menu layout.
- package THIS_INFO_LINE is new CONTROLLING_MENU_INFO_LINE
- (PROCESS_CONFIGURATION.SCREEN_WIDTH);
-
- -- Package will contain subprograms to handle the inputs from the menu
- -- user once they are received from the terminal.
- package THESE_PROCESSES is new HANDLE_PROCESSES
- (PROCESS_CONFIGURATION.ACTION_TYPES, INPUT_TYPES,
- THIS_MENU_CON_PROCESS.RETRIEVE_CONTROL_ITEM,
- PROCESS_INITIATOR.COMMAND_LINE_PROCESSOR,
- PROCESS_INITIATOR.ADA_PROCEDURE_CALL,
- THESE_PROGRAM_MSGS.SEND_RUNTIME_ERROR,
- THIS_INFO_LINE.SET_BAD_SELECTION,
- THIS_INFO_LINE.SET_TASK_STARTED);
-
- -- This local procedure accepts inputs from the terminal. Only a
- -- single character is accepted unless that character is the "escape"
- -- character '!', in which case a full line is then accepted from the
- -- terminal. The output of this procedure is the text of the users input
- -- and the type of input; Selection character or CLI line.
- procedure ACCEPT_INPUT (SELECT_OR_STRING: out INPUT_TYPES;
- USERS_INPUT: out TEXT) is
- -- Used as first character received.
- INPUT_CHAR: CHARACTER;
- -- Character string input when user enters a CLI line after '!'.
- INPUT_STRING: STRING(1..PROCESS_CONFIGURATION.SCREEN_WIDTH);
- -- Index of last character in the string input.
- LAST_INDEX: POSITIVE;
-
- begin
- -- Get the first character.
- TEXT_IO.GET(INPUT_CHAR);
- if INPUT_CHAR = CLI_INDICATOR then
- -- Accept a CLI line, set the type of input to CLI command.
- TEXT_IO.GET_LINE(INPUT_STRING,LAST_INDEX);
- SELECT_OR_STRING := CLI_COMMAND;
- USERS_INPUT := TEXT_HANDLER_SUBSET.PACK_TO_TEXT
- (INPUT_STRING(1..LAST_INDEX));
- else
- -- Accept no more characters, set type of input to Selection.
- SELECT_OR_STRING := SELECTION;
- USERS_INPUT := TEXT_HANDLER_SUBSET.TO_TEXT(INPUT_CHAR);
- end if;
- return;
- end ACCEPT_INPUT;
-
-
- -- This local procedure is used to set up the user display. It will
- -- start a new line, put the Menu Display Layout to the screen, and
- -- put the Menu Info Line to the screen. If the screen width is big
- -- enough, the prompt line will be put to the screen and the cursor
- -- will wait following this prompt for user inputs.
- procedure PUT_MENU_DISPLAY is
- PROMPT_STRING: constant STRING := "==>>";
- begin
- TEXT_IO.NEW_LINE;
- -- Current Menu Display Layout to the screen.
- THIS_DISPLAY.PUT_SCREEN_LAYOUT_TO_CRT;
- -- Current Menu Info Line to the screen.
- TEXT_IO.PUT_LINE(THIS_INFO_LINE.RETURN_INFO_LINE);
- -- Prompt line to screen if room.
- if PROCESS_CONFIGURATION.SCREEN_WIDTH > PROMPT_STRING'LENGTH then
- TEXT_IO.PUT(PROMPT_STRING);
- end if;
- end PUT_MENU_DISPLAY;
-
-
- -- Begin the DO_MENU_HANDLER block which is the logic for the Menu Handler.
- -- Following the initialization steps, the Menu Handler performs a loop
- -- until a QUIT character is entered. The loop will:
- -- Put the full menu display on the screen.
- -- Accept user input, receive text and the type of input.
- -- (Exit loop if the input is a QUIT character).
- -- Pass the text and type input to a processor, that will do all
- -- processing necessary for the given input.
- -- Test if the next menu to be displayed is different from the
- -- current menu. If so, read the corrisponding Menu Def Table
- -- for that menu, so that the Display Layout and a Control
- -- List of selections is made available.
- -- When the loop exits, the program exits.
- begin
-
- -- Do initialization first. Make the system messages available to be
- -- output on command. Clear the screen display.
- THESE_PROGRAM_MSGS.INITIALIZE_MESSAGES;
- THIS_DISPLAY.CLEAR_SCREEN_LAYOUT;
- THIS_DISPLAY.PUT_SCREEN_LAYOUT_TO_CRT;
-
- -- The program may use a number of Menu Def Tables throughout the course
- -- of the run. The first Menu Def Table used it receives from the file
- -- name specified in the MENCON config file. The program will try to
- -- read from a file with this name first, and if an error occurs, the
- -- Menu Handler will abort. A successful read of a Menu Def Table will
- -- cause the loop to start.
- MENU_TABLE_FILE := PROCESS_CONFIGURATION.MENU_TABLE;
- THIS_MENU_CON_PROCESS.READ_MENU_CONTROL_FILE
- (MENU_TABLE_FILE, BAD_SELECTION_MSG, FILE_ERROR);
- if FILE_ERROR = CANNOT_OPEN then
- -- The external file could not be opened. The program always trys to
- -- open the file of the name given in the config file. The user has
- -- to copy other Menu Def Tables into that file name if they want to
- -- use different Menu Def Tables.
- THESE_PROGRAM_MSGS.SEND_RUNTIME_ERROR(29);
-
- elsif FILE_ERROR = IMPROPER_CONFIG then
- -- The Menu Def Table read was created with a different config than
- -- what is currently running. This is illegal since foramted records
- -- have to be read from the file, and the wrong string lengths
- -- defined would result in improper reading of the records.
- THESE_PROGRAM_MSGS.SEND_RUNTIME_ERROR(30);
- else
-
- -- The initial file was read correctly. Set up the Bad Selection
- -- Message and start the loop.
- THIS_INFO_LINE.RECEIVE_BAD_SELECT_MESSAGE
- (TEXT_HANDLER_SUBSET.VALUE(BAD_SELECTION_MSG));
- loop
- -- Display to screen, accept and process inputs.
- PUT_MENU_DISPLAY;
- ACCEPT_INPUT(USER_INPUT_TYPE, USER_INPUT);
- exit when (TEXT_HANDLER_SUBSET.GIVE_POS(USER_INPUT,1) =
- PROCESS_CONFIGURATION.QUIT_CHARACTER);
- THESE_PROCESSES.DO_REQUEST(MENU_TABLE_FILE, USER_INPUT,
- USER_INPUT_TYPE);
-
- -- From the processing performed on the input, the next menu to
- -- be displayed may be different from the current menu. Test this
- -- and read a new Menu Def Table external file if a new menu is
- -- to be displayed.
- if TEXT_HANDLER_SUBSET.VALUE(THESE_PROCESSES.MENU_TO_BE_DISPLAYED) /=
- TEXT_HANDLER_SUBSET.VALUE(MENU_TABLE_FILE) then
- THIS_MENU_CON_PROCESS.READ_MENU_CONTROL_FILE
- (THESE_PROCESSES.MENU_TO_BE_DISPLAYED, BAD_SELECTION_MSG,
- FILE_ERROR);
- -- On errors in reading a new Menu Def Table, the old menu
- -- is still used for display and selections.
- if FILE_ERROR = CANNOT_OPEN then
- -- The new menus Menu Def Table cannot be opened. Could be
- -- the file is missing, of the wrong name given in the Menu
- -- Def File. At this point the Menu Handler no longer uses
- -- the file name found in the MENCON file. The file name
- -- for all further menus to be displayed are those specified
- -- in the the Select instructions of the Menu Def Files.
- THESE_PROGRAM_MSGS.SEND_RUNTIME_ERROR(31);
-
- elsif FILE_ERROR = 2 then
- -- The Menu Def Table read was compiled with a different
- -- configuration than what is currently running. The Menu
- -- Def Table cannot be used.
- THESE_PROGRAM_MSGS.SEND_RUNTIME_ERROR(32);
-
- else
- -- The Menu Def Table can be used for the next menu to be
- -- displayed. Set the name of the current menu to the new
- -- menu, and reset the Bad Selection Message.
- TEXT_HANDLER_SUBSET.CLEAR_TEXT(MENU_TABLE_FILE);
- MENU_TABLE_FILE := THESE_PROCESSES.MENU_TO_BE_DISPLAYED;
- THIS_INFO_LINE.RECEIVE_BAD_SELECT_MESSAGE
- (TEXT_HANDLER_SUBSET.VALUE(BAD_SELECTION_MSG));
- end if; -- Test for file errors.
-
- end if; -- Test for new menu specified.
-
- end loop; -- Main loop for Menu Handler.
- end if; -- File errors in reading initial Menu Def Table.
-
- end DO_MENU_HANDLER;
-
-
- end MENUSHOW;
-
-