Cannot Change Basic's Cursor Position with CALL INTERRUPT (69853)
The information in this article applies to:
- Microsoft Basic Professional Development System for MS-DOS 7.0
- Microsoft Basic Professional Development System for MS-DOS 7.1
- Microsoft QuickBASIC 3.0
- Microsoft QuickBASIC 4.0
- Microsoft QuickBASIC 4.0b
- Microsoft QuickBASIC 4.5
- Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
- Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
This article was previously published under Q69853 SUMMARY
In a Basic program, you can position Basic's cursor with the LOCATE
statement, but not with an INTERRUPT call to the hardware. (For
example, you can't call BIOS interrupt 10 hex with service 02 hex to
change Basic's cursor position).
This information applies to Microsoft Basic Compiler versions 6.00 and
6.00b, to Microsoft Basic Professional Development System (PDS)
versions 7.00 and 7.01, and to Microsoft QuickBasic versions 3.00,
4.00, 4.00b, and 4.50.
MORE INFORMATION
A call to BIOS interrupt 10 hex, with service 02 hex, is ignored in a
Microsoft Basic program.
Although the system has recorded a new cursor position, Basic does not
check with the system, and maintains the previous cursor position
unless a LOCATE statement changes the cursor position. This is the
expected behavior because Basic accesses the video memory directly,
bypassing most of the BIOS routines.
This can be demonstrated using the CALL INTERRUPT statement.
To tell the system to change the position of the cursor, use Interrupt
10 hex with the following settings:
AX = &H0200 'Sets the service number for "set cursor position".
BX = &H0 'This sets the display page.
DX = &H0A0A 'Position for cursor goes into DX register as follows:
' DH = &H0A and DL = &H0A for row and column position,
' respectively (DH is high byte, DL low byte of DX).
This interrupt service has no return value.
To read the position of the cursor from the system, use Interrupt 10
hex with service number 3 as follows:
AX = &H0300 'This sets the service call to read cursor position.
BX = &H0 'This sets the display page to read from.
The return values are in the DX register with the DH (high byte) and
DL (low byte) contain the row and column position, respectively.
Program Example
' Use 'QBX.BI' (instead of 'QB.BI') in Basic PDS 7.00 or 7.10:
'$INCLUDE: 'QB.BI'
DECLARE SUB INTERRUPT(intnum AS INTEGER, inreg AS INTEGER,_
outreg AS INTEGER)
DIM inreg AS regtype
DIM outreg AS regtype
inreg.AX = &H0200
inreg.BX = &H0
inreg.DX = &H0A0A 'set position to 10,10
CLS 'clear screen and set cursor to 1,1
CALL INTERRUPT(&H10, inreg, outreg) 'attempt to position cursor
inreg.AX = &H0300
CALL INTERRUPT(&H10, inreg, outreg) 'this will read cursor position
PRINT outreg.DX 'This prints decimal value 2570, but not at row
'10, column 10.
Although the output is decimal 2570, which means that the system has
set the cursor to row 10 column 10, Basic still prints the value at
row 1 column 1 as if the interrupt call was never made.
You must use the LOCATE statement to position the cursor; the
interrupt 10 with service 3 will then report the change in cursor
position.
Modification Type: | Minor | Last Reviewed: | 8/16/2005 |
---|
Keywords: | KB69853 |
---|
|