! EXECUTE_EVE.TPU -- EVE "command procedure" utilities ! This file can be incorporated using EVEplus. ! Written by Valerie H. Matthews (SUPER::MATTHEWS) -- comments welcome ! These commands execute a file or buffer containing a set of EVE commands: ! you can write command procedures in EVE, one command per line. ! EXECUTE EVE FILE reads in the specified file and executes the EVE ! commands it contains. To use a file of EVE commands as an initialization ! procedure, place in your TPU initialization command procedure or your ! TPU$LOCAL_INIT a statement like the following (in which EVEINIT.EVE is ! the file containing EVE commands): ! eve_execute_eve_file ("eveinit.eve"); ! EXECUTE EVE BUFFER executes the EVE commands in the buffer with ! the specified name. EXECUTE EVE BUFFER might be useful for debugging an EVE ! command procedure before you set it up to be an initialization procedure. ! By default, EXECUTE EVE BUFFER displays each command just before executing ! it and EXECUTE EVE FILE does not. The global variables ! eveplus_x_execute_buffer_verify and eveplus_x_execute_file_verify, ! respectively, control whether verification is on or off. ! Edit History ! ! Which When Who What ! ! X00-01 23-Oct-1985 vhm New procedure ! ! Procedure to get file and execute it as EVE command procedure. procedure eve_execute_eve_file (file_name) local buffer_to_execute, temp_file_name; ! read specified file into buffer. eve$create_buffer maps window to new ! buffer, so to remain in original buffer we have to map window back to ! it after creating new buffer save_buffer := current_buffer; eve_get_file (file_name); buffer_to_execute := current_buffer; map (current_window, save_buffer); eve$set_status_line (current_window); ! now execute the new buffer (if one was created) as EVE command procedure if buffer_to_execute <> current_buffer then eveplus_execute_eve (buffer_to_execute, eveplus_x_exec_file_vfy); endif; endprocedure; !Procedure to execute named buffer as EVE command procedure. procedure eve_execute_eve_buffer (buffer_parameter) local buffer_to_execute, ! Buffer to pass to eveplus_execute_eve buffer_name, ! local copy of buffer_parameter loop_buffer, ! Current buffer being checked in loop loop_buffer_name, ! String containing name of loop_buffer found_a_buffer, ! True if buffer found with same exact name possible_buffer_name, ! Most recent string entered in possible_names possible_buffer, ! Buffer whose name is possible_buffer_names how_many_buffers; ! Number of buffers listed in possible_names ! buffer name-to-variable conversion lifted from EVE_BUFFER buffer_name := buffer_parameter; if eve$check_bad_window then message ("Cursor has been moved to a text window; try command again"); return; endif; if not (eve$prompt_string (buffer_parameter, buffer_name, "Buffer name: ", "Buffer not executed")) then return; endif; eve$cleanse_string (buffer_name); loop_buffer := get_info (buffers, "first"); change_case (buffer_name, upper); ! buffer names are uppercase erase (eve$choice_buffer); loop exitif loop_buffer = 0; loop_buffer_name := get_info (loop_buffer, "name"); if buffer_name = loop_buffer_name then found_a_buffer := 1; how_many_buffers := 1; exitif 1; else if buffer_name = substr (loop_buffer_name, 1, length (buffer_name)) then eve$add_choice (loop_buffer_name); possible_buffer := loop_buffer; possible_buffer_name := loop_buffer_name; how_many_buffers := how_many_buffers + 1; endif; endif; loop_buffer := get_info (buffers, "next"); endloop; change_case (buffer_name, lower); ! for messages if found_a_buffer then buffer_to_execute := loop_buffer else buffer_to_execute := 0; if get_info (eve$choice_buffer, "record_count") > 0 then if how_many_buffers = 1 then buffer_to_execute := possible_buffer else change_case (buffer_name, lower); eve$display_choices (fao ("Ambiguous buffer name: !AS", buffer_name)); endif; else message (fao ("No such buffer: !AS", buffer_name)); endif; endif; ! After all that, we have the buffer with the given name. Execute it as ! an EVE command procedure. if buffer_to_execute <> 0 then eveplus_execute_eve (buffer_to_execute, eveplus_x_exec_buffer_vfy); endif; endprocedure; ! Procedure to parse and execute all the EVE commands in the buffer specified ! by command_buffer. If verify is true, each command is displayed in message ! window before execution. procedure eveplus_execute_eve (command_buffer, verify) local save_position, command_position, current_command; ! save current position for restoring later; go to top of command procedure save_position := mark(none); position (beginning_of (command_buffer)); if mark(none) <> end_of(current_buffer) then ! read current line, process as EVE command, go to next line loop current_command := current_line; if verify then message (current_command); endif; ! restore position in original buffer, then process line as EVE command command_position := mark(none); position (save_position); eve$process_command (current_command); ! go back to command buffer, move to next line; ! at end of buffer, get out of loop save_position := mark(none); position (command_position); move_vertical(1); exitif mark(none) = end_of(current_buffer); endloop; endif; ! and go back to original buffer position (save_position); endprocedure; procedure tpu$local_init; eveplus_x_exec_buffer_vfy := 1; ! verification on for buffer eveplus_x_exec_file_vfy := 0; ! verification off for file eve$arg1_execute_eve_file := "string"; eve$arg1_execute_eve_buffer := "string"; endprocedure;