Microsoft KB Archive/69853

= Cannot Change Basic's Cursor Position with CALL INTERRUPT =

Article ID: 69853

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1
 * Microsoft QuickBasic 3.0
 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 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 &quot;set cursor position&quot;. 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.

Additional query words: QuickBas BasicCom

Keywords: KB69853

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.