----------------------- CodeFAQ Part 6 of 11 --------------------
SUB InterruptX (IntNo AS INTEGER, Inreg AS RegTypeX, OutReg AS_
RegTypeX) STATIC
'---------------------------------------------------------------
' Interrupt procedure. Works in the same way as its QB 4.5
' counterpart.
'---------------------------------------------------------------
IF NOT MachineCode% THEN
' First time dimension string array to hold machine code
RESTORE InterruptXASM
READ nASMBYTES%
REDIM ASMBuffer(0 TO nASMBYTES% - 1) AS STRING * 1
END IF
' Get address of machine code
DEF SEG = VARSEG(ASMBuffer(0))
Offset% = VARPTR(ASMBuffer(0))
IF NOT MachineCode% THEN
' First time load string array with machine code
FOR i% = 0 TO nASMBYTES% - 1
READ Code$
POKE Offset% + i%, VAL("&H" + Code$)
NEXT i%
' Indicate availability of machine code
MachineCode% = TRUE
END IF
' Call interrupt.
' The first Offset% parameter is used by the machine code
' modifying it self, so don't leave it out.
CALL ABSOLUTE(IntNo%, Inreg, OutReg, Offset%, Offset%)
DEF SEG
END SUB
[end]
6) HOW DO I USE THE MOUSE IN QB?
The most common (and most universal) approach is through
INTERRUPTs. Using INTERRUPT 33h, the following code will allow
you to use a mouse in your programs. Code by David Aukerman
with the idea for limited mouse movement by Dave Shea. Public
domain; use at your own risk!
[begin]
'$INCLUDE: 'qb.bi' 'these three lines go at the
DEFINT A-Z 'beginning of your program..
DIM SHARED HMin, HMax, VMin, VMax 'horiz. and vert. limits
SUB Mouse (cx, dx, bx)
DIM reg AS RegType
reg.ax = 3 'get coordinates
INTERRUPT &H33, reg, reg
bx = reg.bx '1=left button; 2=right; 3=both
'(on a two button mouse)
cx = reg.dx 'horizontal coordinate in *pixels*
dx = reg.cx 'vertical coordinate in *pixels*
END SUB
SUB MouseCtrl (x)
DIM reg AS RegType
reg.ax = x '0 = initialize/reset mouse
'1 = show cursor
'2 = hide cursor
'3 = get current coordinates
'7 = set horizontal coordinates
'8 = set vertical coordinates
IF x = 7 THEN
reg.cx = HMin: reg.dx = HMax
ELSEIF x = 8 THEN
reg.cx = VMin: reg.dx = VMax
END IF
INTERRUPT &H33, reg, reg
END SUB
[end]
Usage:
MouseCtrl 0 'initialize mouse..must be done first!
MouseCtrl 1 'make mouse visible
Mouse cx, dx, bx 'get mouse status
HMin = 0: HMax = 100: MouseCtrl 7 'set horiz. PIXEL limits
7) HOW CAN I CHECK FOR THE EXISTENCE OF A CERTAIN FILE?
There are many ways to do this; this FAQ will cover two of
them. One method is to use the error-trapping features of
QB (code by David Aukerman):
---------- CodeFAQ ends Part 6 of 11 ----------------------------
Robert (Bob) Kohl Rio Rancho, New Mexico
Home Page: http://www.geocities.com/SiliconValley/Way/7854
http://members.tripod.com/~Bob_Kohl/index.html
Internet: bobakohl@abq.com bobakohl1@juno.com barbarianh@aol.com
--- Blue Wave/DOS v2.30
(1:301/45)
---------------
* Origin: * Binary illusions BBS * Albuquerque, NM * 505.897.8282 *
|