Similar to the Top of File routine, this procedure will move the cursor to the last line of the file. Again, checking is done to determine whether scrolling is required or not. An error will occur if this function is attempted when Cursor 1 is on the last line of the file. The routine's parameters are shown below; the PDL structure of this procedure is given in Fig.4.22.
BOT_OF_FILE (VAR HS_CUR_POS$ INTEGER; VAR MS_TOP_LINE: INTEGER;
FILE_ BOT_ LINE: INTEGER; KCT.SIZE: INTEGER) Procedure Bottom of File
If (Scrolling is not required)
If (Cursor 1 is already at the bottom of file) *Put out error message -- Bottom of file* *Turn old cursor OFF*
*Set MS_CUR_POS to new value* *Turn new cursor ON*
*Move File Linked List pointer to end of list* else:
**(ie. scrolling is required)** ♦Rewrite the entire Main Screen* ♦Turn new cursor ON*
End Procedure:
Fig.4,22: The PDL for the Bottom of File routine
This function allows the u: cr to choose a line number to which Cursor 1 is to be moved. Thv line number is entered in the Window Screen via the Line Edit"r, An illegal line number is not accepted and an error messegc. is displayed in the Prompt Screen. Only an integer number of it: u.- digits or less which is between 1 and FILB_BOT_LINE will be acr.-o^ad.
If the line number requeue: appears in the present Screen 1 display, the cursor is iu ;< •/ moved to this line. If the line number is not on Screen 1, icrolling occurs, with all attempts being made to place the cursor with the required line in the centre of the screen. In this routine, the centre of the screen is taken as the (MS_SIZE / 2)th line. The procedure is defined as shown below, with Fig.4.23 giving the structure of the Cursor-to- line routine in PDL.
CUILTO.LINB (VAR MS_CUIL.POS: INTEGER; .» VAR MS_TOP_LINE: INTEGER;
FILE_BOT_LINE: INTEGER; KCT_SIZE: INTEGER)
Procedure Cursor to Line Begin:
*Prompt user for input line* *Set inputs for Line Bdito. * *Set WSP to start of line* *Set all function key flags to FALSE*
*Set length of editor to allow only a 4 digit number* Call LINE EDITOR
Call WS_CLEAR Call PS_CLEAR
If (Input line number is not valid) *Put out an error*
**(ie. line number is valid)** If (Scrolling is not required)
*Move pointer to correct value on Main Screen* *Turn old cursor OFF*
*Set MS_CUILPOS to new value* **(ie. scrolling is required)**
If (Requested line too near top of file to be placed in centre of screen)
*Move file pointer to requested line number* MS_TOP_LINE := 1
*Set HS_CUILPOS to value indicated by line number* If (Requested line too near bottom of file to be
placed in centre of screen* *Move pointer to line number*
*Set MS„TOP_LINE so that file bottom line is at end of Main Screen*
*Set MS_CUR_POS to value indicated by line number*
**(ie. Requested line can be located at centre of Main Screen)**
*Move file pointer to line number*
*Set MS_TOP_LINE such that line number is in centre of Main Screen*
*Sat MS_CUR_POS to half of the Main Screen
♦Rewrite entire llain Screen* *Turn new cursor ON*
End Procedure:
Fig.4.23: The PDL for the Cursor To Line routine
It will be noted that the Line Editor package is used initially. The length of the line is set so as to restrict the user to a maximum of four digits. The highlighted prompt which is displayed
Page 64
in the Window Screen ("Line number =") is not editable. Also worth noting is the task involved in displaying the error message "Line Number .... it, out of range. Acceptable range = 1 to FILE_BOT_LING." with the FILB_BOT_LINE and the being replaced by their appropriate values. Clearly, integer to string conversions and string concatenation facilities are needed to assemble this type of message in the form of a single string.
This function allows the user to pick any line from the file with Cursor 1 and edit it, if possible, with the Line Editor in the Window Screen. Any line containing a key word only will not be editable and an error message will be output in the Prompt Screen. The user is able to edit the user-entered text or a placeholder in the Window Screen, without affecting the system generated highlighted keywords. The accepted modified line is ENTERed and will replace the old line in Screen 1. If the ESC key is used, the line will remain as before and the Line Editor exit. As no modification to the Screen 1 cursor position is performed in this routine, the editor routine is invoked by the statement:-
EDIT_LINE
Procedure Edit Line
♦Read File Linked List at current pointer position*
♦Read the Key Code Table using the first key code obtained from above*
If (Editing is allowed) then:
♦Initialize settings for the Line Editor* Call LINE.BDITOR
If (The new line differs from the old line)
♦Write the new text line in place of the old text line in the File Linked List*
Call FORMATTER Call MS.WRITE
♦Turn the cursor back ON*
♦Put out an error message — line not editable*
End Procedure:
Fig.4.24: The PDL for the Edit Line routine
Fig.4.24 shows a PDL structure of the procedure. This routine is virtually self explanatory, but the Line Editor inputs can perhaps be elaborated on. The user is given 40 columns of line to edit (Inclusive of the key word). Only the first key word will be
Page 65
displayed. The key word is obtained by reading the Key Code Table, while the editable text line is taken directly from the Pile Lin1' List. All function key flags are set to FALSE so that only the ENTER and ESC keys will exit the Line Editor.