procedure eve_keep(pattern_string) ! Keep all lines containing pattern string local the_arg, lowercase_arg, ! All lowercase version of pattern_string how_exact, ! Controls exact/no_exact search first_flag; ! Flag to check if first search fails ! Code to handle null parameter and prompt for it the_arg := pattern_string; first_flag := 1; if (the_arg = '') then the_arg := read_line('Keep lines containing: '); endif; if the_arg = '' then message("Nothing specified to keep"); return; endif; lowercase_arg := the_arg; change_case(lowercase_arg,lower); ! If arg is all lowercase, do NO_EXACT search ! If arg has any uppercase, do EXACT search ! If arg enclosed in ~~ then do exact search regardless of case how_exact := EXACT; if the_arg = lowercase_arg then how_exact := NO_EXACT; endif; if substr(the_arg,1,1) = '~' then how_exact := EXACT; ! Remove trailing, leading ~ characters the_arg := substr(the_arg, 1, length(the_arg)-1); the_arg := substr(the_arg, 2, length(the_arg)-1); endif; position(beginning_of(current_buffer)); loop; exitif mark(none) = end_of(current_buffer); a_loc := search(the_arg,FORWARD,how_exact); if a_loc = 0 then if first_flag then message("Nothing to keep; command ignored."); exitif 1; else ! delete rest of buffer if string not found eve$x_select_position := select(none); position(end_of(current_buffer)); erase(select_range); eve$x_select_position := 0; exitif 1 ; endif; else first_flag := 0; endif; eve$x_select_position := select(none); position(beginning_of(a_loc)); move_horizontal(-current_offset); if eve$x_select_position = mark(none) then move_vertical(1); ! Current line contains keep string, move on eve$x_select_position := 0; ! Cancel last select else erase(select_range); eve$x_select_position := 0; endif; endloop; position(beginning_of(current_buffer)); eve$x_select_position := 0; if not first_flag then message('Keep completed.'); endif; endprocedure; procedure tpu$local_init ! Initialization eve$arg1_keep := eve$arg1_buffer; endprocedure;