The Sleep routine without parameters waits for a keypress, then release the control to your program. Some computer, after some SLEEPs, generates a beep every time the instruction is used, that's because the buffer is full… If you simply need to wait until a key is pressed, you can use the keyboard interrupt. Try this code: (load QB with the /L parameter)
'$include:'qb.bi'
DIM Regs as RegType 'Registers
for the Interrupt function
Regs.AX = 00
'Interrupt service 00: return a character
Interruput &H16,Regs,Regs 'Call the Interrupt 16h, handled
by the Keyboard bios
The function 00 returns in AX the Ascii value and the keyboard code of the key pressed. Here's a small file ASM for the ASM Sleep routine that you can use (Related file: SMSleep.obj,ASMSleep.ASM,ASMSleep.QLB)
.MODEL MEDIUM,BASIC ;QuickBasic uses the Medium model
.STACK 200h ;Define
our small stack
.CODE
ASMSleep proc FAR ;The SUB ASMSleep
Public ASMSleep ;Make it pubblic to QB
MOV AX,00
;Interrupt 16h service 0
INT 16h
;Call the INTerrupt
RET
;Return to Basic
ENDP ASMSleep ;End of the sub
END
;End of the file
The File included (OBJ) can be linked with the command:
LINK /QU ASMSleep.OBJ,,,BQLB45.LIB
QB /LASMSleep.QLB
If you want to run the file without link:
QB /LASMSleep.QLB
See the QuickLibraires section for more information
For use the ASM code in QB use this code:
Declare sub ASMSleep ()
Print "Please Press a Key"
ASMSleep
Print "You've Pressed a key!"
END