Q(uick)BASIC Function: CSRLIN
Quick View
CSRLIN
A device I/O function that returns the current line (row) position of the cursor
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- LOCATE [row%] [,[column%] [,[cursor%] [,start% [,stop%]]]]
- CSRLIN
- POS(expression)
Description/Parameter(s)
row% and column% | The number of the row and column to which the cursor moves. |
cursor% | Specifies whether the cursor is visible: 0 = invisible, 1 = visible |
start% and stop% | Integer expressions in the range 0 through 31 that specify the first and last cursor scan lines. You can change the cursor size by changing the cursor scan lines. |
expression | Any expression. |
Example
CLS
LOCATE 5, 5
MyRow% = CSRLIN
MyCol% = POS(0)
PRINT "Position 1 (Press any key)"
DO
LOOP WHILE INKEY$ = ""
LOCATE (MyRow% + 2), (MyCol% + 2)
PRINT "Position 2"
Syntax
- CSRLIN
Description/Parameter(s)
To return the current column position, use the POS function.
Example
CSR_EX.BAS is a program file in the subdirectory ADVR_EX that illustrates the CSRLIN function. To look at the program in the View window and, optionally, to run it, load CSR_EX.BAS using the File menu Open Program command.
The program uses a SUB that prints a message on the screen without disturbing the current cursor position.
See also:
Syntax
- CSRLIN
Description/Parameter(s)
Returns | The current line (row) position of the cursor. To return the current column position, use the POS function. |
Example
This example uses the CSRLIN function to maintain the current cursor position with a SUB procedure that prints a message on the screen.
'Move cursor to center of screen, then print message.
'Cursor returned to center of screen.
LOCATE 12, 40
CALL MsgNoMove("A message not to be missed.", 9, 35)
INPUT "Enter anything to end: ", A$
'Print a message without disturbing current
'cursor position.
SUB MsgNoMove (Msg$, Row%, Col%) STATIC
'Save the current line.
CurRow% = CSRLIN
'Save the current column.
CurCol% = POS(0)
'Print the message at the given position.
LOCATE Row%, Col%: PRINT Msg$;
'Move the cursor back to original position.
LOCATE CurRow%, CurCol%
END SUB
See also: