LOCATE Statement ---------------------------------------------------------------------------- Action Moves the cursor to the specified position on the screen. Syntax LOCATE row% , column% , cursor% , start% , stop% Remarks The LOCATE statement uses the following arguments. ----------------------------------------------------------------------------- Argument Description ---------------------------------------------------------------------------- row% The number of a row on the screen; row% is a numeric expression returning an integer. If row% is not specified, the row location of the cursor does not change. column% The number of a column on the screen; column% is a numeric Argument Description ---------------------------------------------------------------------------- screen; column% is a numeric expression returning an integer. If column% is not specified, the column location of the cursor does not change. cursor% A Boolean value indicating whether the cursor is visible or not. A value of 0 indicates cursor off; a value of 1 indicates cursor on. start%, stop% The starting and ending raster scan lines of the cursor on the screen. The arguments start% and stop% redefine the cursor size and must be numeric expressions returning an integer between 0 and 31, inclusive. Argument Description ---------------------------------------------------------------------------- You can omit any argument from the statement except that if stop% is specified, start% also must be specified. When you omit row% or column%, LOCATE leaves the cursor at the row or column where it was moved by the most recently executed input or output statement (such as LOCATE, PRINT, or INPUT). When you omit other arguments, BASIC assumes the previous value for the argument. Note that the start% and stop% lines are the CRT scan lines that specify which pixels on the screen are lit. A wider range between the start% and stop% lines produces a taller cursor, such as one that occupies an entire character block. In OS-2 real mode and under DOS, LOCATE assumes there are eight lines (numbered 0 to 7) in the cursor. In OS-2 protected mode there are 16 lines (numbered 0 to 15). When start% is greater than stop%, LOCATE produces a two-part cursor. If the start% line is given but the stop% line is omitted, stop% assumes the same value as start%. A value of 8 for both start% and stop% produces the underline cursor. The maximum cursor size is determined by the character block size of the screen mode in use. Setting start% greater than stop% displays a full-height cursor on VGA-equipped systems. For screen mode information, see the entry for the SCREEN statement. The last line on the screen is reserved for the soft-key display and is not accessible to the cursor unless the soft-key display is off ( KEY OFF) and LOCATE is used with PRINT to write on the line. See Also CSRLIN, POS Examples The first example shows the effects on the cursor of different LOCATE statements. CLS' Clear screen. LOCATE 5,5 ' Moves cursor to row 5, column 5. PRINT "C" DO LOOP WHILE INKEY$ = "" LOCATE 1,1 ' Moves cursor to upper-left corner of the screen. PRINT "C" DO LOOP WHILE INKEY$ = "" LOCATE , ,1' Makes cursor visible; position remains unchanged. PRINT "C" DO LOOP WHILE INKEY$ = "" LOCATE , , ,7 ' Position and cursor visibility remain unchanged; ' sets the cursor to display at the bottom of the ' character box starting and ending on scan line 7. PRINT "C" DO LOOP WHILE INKEY$ = "" LOCATE 5,1,1,0,7 ' Moves the cursor to line 5, column 1; ' turns cursor on; cursor covers entire ' character cell starting at scan line ' 0 and ending on scan line 7. PRINT "C" DO LOOP WHILE INKEY$ = "" END The following example prints a menu on the screen, then waits for input in the allowable range (1-4). If a number outside that range is entered, the program continues to prompt for a selection. Note that this program is incomplete. CONST FALSE = 0, TRUE = NOT FALSE DO CLS PRINT "MAIN MENU". PRINT PRINT "1) Add Records" PRINT "2) Display-Update-Delete a Record" PRINT "3) Print Out List of People Staying at Hotel" PRINT "4) End Program" ' Change cursor to a block. LOCATE , , 1, 1, 12 LOCATE 12, 1 PRINT "What is your selection?"; DO CH$ = INPUT$(1) LOOP WHILE (CH$ < "1" OR CH$ > "4") PRINT CH$ ' Call the appropriate SUB procedure. SELECT CASE VAL(CH$) CASE 1 CALL Add CASE 2 CALL Search CASE 3 CALL Hotel CASE 4 CALL Quit END SELECT LOOP WHILE NOT ENDPROG . . . END