!! !! Module Name : EVE_SORT !! !! Original Request Number : !! System Designation : Sorts a range or buffer. Select ascending !! Module Description : or descending order by relationship of !! : beginning and ending of a range. !! : !! Original Programmer : UCS_KAS@SHSU.BITNET !! !! Date Approved : 14-MAY-1989 !! !! Files open for Input : !! Files open for Output : !! Modules Referenced : !! procedure eve_sort local sort_array, sort_index, next_index, range_sort, end_select, reverse_order, top_Sel, bottom_sel; on_error [OTHERWISE]: endon_error; sort_array := create_array; range_sort := EVE$X_SELECT_POSITION <> 0; if range_sort then reverse_order := EVE$X_SELECT_POSITION > mark(free_cursor); else reverse_order := 0; endif; if range_sort then if reverse_order then top_sel := mark(none); ! mark top position(eve$x_select_position); ! goto bottom bottom_Sel := mark(none); ! mark bottom position(top_sel); ! goto top eve$x_select_position := 0; ! clear select eve$x_select_position := select(reverse); ! select from top position(bottom_sel); ! goto bottom endif; end_select := mark(none); position(EVE$X_SELECT_POSITION); position(line_begin); else position(beginning_of(current_buffer)); endif; loop if range_sort then exitif mark(none) >= end_select; else exitif mark(none) >= end_of(current_buffer); endif; next_index := sort_array{current_line}; if next_index = tpu$k_unspecified then sort_array{current_line} := 1; else sort_array{current_line} := next_index + 1; endif; move_vertical(1); endloop; if range_sort then erase(select_range); else erase(current_buffer); endif; if reverse_order then sort_index := get_info(sort_array,"last"); else sort_index := get_info(sort_array,"first"); endif; loop exitif sort_index = tpu$k_unspecified; loop exitif sort_array{sort_index} = 0; copy_text(sort_index); split_line; sort_array{sort_index} := sort_array{sort_index} - 1; endloop; if reverse_order then sort_index := get_info(sort_array,"previous"); else sort_index := get_info(sort_array,"next"); endif; endloop; erase_line; if range_sort then EVE$X_SELECT_POSITION := 0; endif; endprocedure