 !++ H !  The following procedure is used when defining a key or LSE command toF !  position to a particular line.  This procedure prompts for the line !  number to be used.  !--  PROCEDURE lsi_goto_line  LOCAL line_num_str;   - line_num_str := READ_LINE ('_Line number: '); % lsi_goto_line_dispatch (line_num_str)  ENDPROCEDURE ! !++ H !  This procedure is the 'callable interface' to the goto-line function. !-- / PROCEDURE lsi_goto_line_dispatch (line_num_arg) 3 LOCAL line_num,	     ! integer value of line number 4       max_line_num,  ! largest line number in buffer6       this_line,     ! line number of the current line?       displacement,  ! distance between target and current line 2       lines_to_move, ! number of lines to traverse%       curr_wdw,	     ! current window %       curr_buf,	     ! current buffer >       top_offset,    ! line offset for scrolling top of windowA       bottom_offset, ! line offset for scrolling bottom of window 7       scroll_amt;    ! number of lines to scroll window     curr_buf := CURRENT_BUFFER;  curr_wdw := CURRENT_WINDOW;  !++ 2 !  Convert the input argument to an integer value. !-- + IF GET_INFO (line_num_arg, 'type') = STRING  THEN!    line_num := INT (line_num_arg)  ELSE    line_num := line_num_arg  ENDIF; !++  !  Error check the input.  !-- 4 max_line_num := GET_INFO (curr_buf, 'record_count');/ IF (line_num <= 0) OR (line_num > max_line_num)  THEN    !++*    !  Requested line is not in the buffer..    !  If it was too low, go to the buffer top./    !  If it was too high, go to the buffer end.     !--=    MESSAGE (FAO ('Line number !UL not in buffer', line_num));     IF line_num <= 0     THEN (       POSITION (BEGINNING_OF (curr_buf))    ELSE "       POSITION (END_OF (curr_buf))	    ENDIF;     ABORT ENDIF; !++  !  Determine how far to go.  !-- ' this_line := lsi_determine_line_number; % displacement := line_num - this_line; 4 !MESSAGE (FAO ('Displacement = !SL', displacement)); !++ 9 !  Turn off screen updating (to avoid lots of scrolling).  !--  SET (SCREEN_UPDATE, OFF); 0 top_offset := GET_INFO (curr_wdw, 'scroll_top');6 bottom_offset := GET_INFO (curr_wdw, 'scroll_bottom');3 scroll_amt := GET_INFO (curr_wdw, 'scroll_amount'); ( SET (SCROLLING, curr_wdw, OFF, 0, 0, 0); IF displacement < 0  THEN    !++8    !  Target is between current position and buffer top.    !--     IF line_num < -1*displacement    THEN 	       !++ A       !  Target is closer to buffer top than to current position. *       !	 Start from the top and work down.	       !-- )       POSITION (BEGINNING_OF (curr_buf)); #       lines_to_move := line_num - 1     ELSE 	       !++ >       !  Target is closer to current position than buffer top.1       !	 Start from current position and work up. 	       !-- #       lines_to_move := displacement     ENDIF ELSE    !++8    !  Target is between current position and buffer end.    !--,    IF displacement < max_line_num - line_num    THEN 	       !++ >       !  Target is closer to current position than buffer end.3       !	 Start from current position and work down. 	       !-- #       lines_to_move := displacement     ELSE 	       !++ >       !  Target is closer to buffer end than current position.+       !	 Start from buffer end and work up. 	       !-- #       POSITION (END_OF (curr_buf)); 	       !++ A       !  Compute the number of lines to move from the buffer end. B       !	 This number is negative, because the cursor must move up,J       !	 and is the difference between the target line number and the lastO       !	 line's number, plus one because the end of the buffer is one line past        !	 the last line. 	       !-- 5       lines_to_move := -(max_line_num - line_num + 1)     ENDIF ENDIF;6 !MESSAGE (FAO ('Lines to move = !SL', lines_to_move)); !++  !  Move to the target line.  !--  MOVE_VERTICAL (lines_to_move); !++  !  Restore the screen updating.  !--  SET (SCREEN_UPDATE, ON);E SET (SCROLLING, curr_wdw, ON, top_offset, bottom_offset, scroll_amt);  ENDPROCEDURE ! lsi_goto_line