Category : BASIC Source Code
Archive   : QLIB56.ZIP
Filename : SYSTEM.DOC

 
Output of file : SYSTEM.DOC contained in archive : QLIB56.ZIP
QLIB's SYSTEM routines detect the presence or status of PC hardware
or software. Monitor type, co-processor presence, CPU speed and keyboard
toggles may be determined, CPU speed toggle and keyboard toggles may be
set. CTRL, ALT and SHIFT key status may also be monitored, and the
software enviornment may be determined.



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutines: CapsOFF, CapsON
object file: kbd2.obj

Simplified controls to toggle the CapsLock key. See also
GetKBDToggle and SetKBDToggle.

Example:
CALL CapsON ' this turns Caps Lock on



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Function: oops% = DOSError
object file: q$error.obj

DOSError returns an error flag resulting from the most recent QLIB
subroutine which updates the DOS error flag (see FLoad in DISK.DOC).
NOTE: not all QLIB subroutines update DOSError!!

common MS-DOS error codes are:

2 = file not found
3 = path not found
4 = too many open files
5 = access denied (file may be read-only or a subdirectory
or subdirectory not empty)
8 = insufficient memory
19= disk is write-protected

Example:
REM $INCLUDE: '\qb4\qlib.bi'
filename$ = "\ramfont\italics.fnt"
iseg% = fload (filename$)
IF DOSError THEN
.
.
. ; error handling code

°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutine: EGAinfo(crt%, memory%)
object file: egainfo.obj

EGAinfo determines the type of monitor and amount of memory
installed on an EGA card. Crt% = 0 if a monochrome monitor is
attached to the EGA card, -1 if an RGB color monitor, and crt% = 1
if the monitor is an Enhanced or Mutli-scan monitor. Memory% returns
the kbytes installed on the card. If no EGA is installed, memory% = 0.

Example:
CALL EGAinfo(crt%, memory%)



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Function: a$ = EXEName$()
object files: exename.obj (strncpy.obj)

requires DOS version 3.0 or later

EXEName$ returns the full drive and path name of the currently
executing program. When developing programs within the QB or QBX
development enviornment, EXEName$ returns something like:

C:\QB4\QB.EXE

Example:
REM $INCLUDE: 'qb4\lib\qlib.bi'
PRINT EXEName$ ' prints name of program


°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutine: FindMONO(crt%)
object files: findmono.obj (find6845.obj, egainfo.obj, q$herc.obj)

FindMONO determines if a monochrome monitor is installed.
GetCRT (below) determines the default monitor; FindMONO will
find an MDA or HGC monitor in single- or dual-monitor setups
whether the monochrome monitor is default or not. Crt% = 0 if
MDA, 128 or greater if HGC or compatible, and -1 if no monochrome
installed.

Example:
CALL FindMONO(crt%)



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Function: Floppies
object file: floppies.obj

FLOPPIES determines the number of floppy drives installed in the
computer.

Example:
REM $INCLUDE: 'qlib.bi'
fdrives = floppies ' get number of floppy drives


°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Function: FloppyType(d%)
object file: floptype.obj

Determines the type of floppy disk drive installed. Drive number
d% is the BIOS drive number corresponding to the physical drives
installed: for drive A, d% = 0, and for drive B, d% = 1.

Returns: 0 if drive not installed
1 if drive is 360 k
2 if drive is 1.2 M
3 if drive is 720 k
4 if drive is 1.44M
Example:
REM $INCLUDE: 'qlib.bi'
' drive a:
d% = 0
drivetype = FloppyType(d%)



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Function: GetCMD$(a%)
object files: getcmd.obj (strndup.obj)

GetCMD$ isolates and returns command-line parameters without
converting the parameter to upper case. GetCMD$ acts like an array
of strings; GetCMD$(0) returns the first parameter, while GetCMD$(n%)
returns the (n+1)th parameter. GetCMD$ returns a NUL string if there
are no more parameters.

Note: in the QuickBASIC development enviornment, GetCMD returns QB's
parameters (including /L and QLIB), while when your program is run
from the command line, GetCMD$ returns your program's parameters.

Example:
REM $INCLUDE: 'qlib.bi'
' print command line parameters, starting with the first one
a% = 0


10: c$ = GetCMD$(a%)
IF c$ <> "" THEN PRINT c$: GO TO 10



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutine: GetCPU(cpu%)
object file: getcpu.obj

Determines the processor in the computer system. Returns cpu% = 0
if 8086 or 8088, cpu% = 1 if 80186 or 80188, cpu% = 2 if 286, cpu% = 3
if 386 or 386sx, and cpu% = 4 if 486.

Example:
DIM cpu$(4)
FOR i = 0 to 4: READ cpu$(i): NEXT i
DATA "8086 or 8088","80186 or 80188","286","386","486"
CALL GetCPU(cpu%)
PRINT cpu$(cpu%)


°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutine: GetCRT(crt%)
object files: getcrt.obj (q$herc.obj, egainfo.obj)

GetCRT tells you what kind of display is being used. The returned
value will be zero if it's MDA or EGA with a monochrome monitor, -1 if
CGA, 1 if EGA with a color or enhanced color monitor, 2 if MCGA, and if
VGA, crt% will be 3. With Hercules or Hercules clones, crt% will be 128
or greater. The Hercules Graphics Card Plus returns 144, and the
Hercules InColor card returns 208. See also IsSEVGA, EGAinfo, and
FindMONO.

Example:
REM $INCLUDE: 'qlib.bi'
CALL GetCRT(crt%)
SELECT CASE crt%
CASE -1
PRINT "CGA Color"
CASE 0
PRINT "Monochrome Display Adapter"
CASE 1
PRINT "EGA"
CASE 2
PRINT "MCGA"
CASE 3
PRINT "VGA"
CASE 128 TO 208
PRINT "Hercules"
END SELECT


°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutine: GetDOSVer(maj%, min%)
object file: dosver.obj

GetDOSVer returns the major and minor version numbers of the DOS
installed. Maj% is the major version number, i.e., maj% = 3 if DOS 3.xx
is installed. Min% is the minor version number, i.e., min% = 21 if DOS
x.21 is installed.

Example:
CALL GetDOSVer(maj%,min%)
REM if maj% < 3 then SHELL may not be reliable


°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutine: GetKBDToggle(kbd%)
object file: kbd.obj

Returns the status of the keyboard toggles and whether the CTRL, ALT
or SHIFT keys are pressed. The code returned by GetKBDToggle is a copy of
the BIOS keyboard status byte, which must be ANDed to determine which key
toggles are set. See also SetKBDToggle.

Example:
rshift% = 1
lshift% = 2
shiftkey% = 3
ctrl% = 4
alt% = 8
scroll% = 16
numb% = 32
caps% = 64
insert% = 128

CALL GetKBDToggle(kbd%)
IF (kbd% AND rshift%) THEN PRINT "Right Shift pressed"
IF (kbd% AND lshift%) THEN PRINT "Left Shift pressed"
IF (kbd% AND shiftkey%) THEN PRINT "Shift Key pressed"
IF (kbd% AND ctrl%) THEN PRINT "Ctrl Key pressed"
IF (kbd% AND alt%) THEN PRINT "Alt Key pressed"
IF (kbd% AND scroll%) THEN PRINT "ScrollLOCK ON"
IF (kbd% AND numb%) THEN PRINT "NumLOCK ON"
IF (kbd% AND caps%) THEN PRINT "CapsLOCK ON"
IF (kbd% AND insert%) THEN PRINT "INSERT ON"



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutine: GetSpeed(speed%)
object file: speed.obj

Determines whether the system is in "turbo" mode. Returns 0 if
CPU is operating at normal speed, 1 if operating at faster CPU speed.
See also SetSpeed.

Example:
CALL GetSpeed(speed%)


°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Function: IsATT
object files: isatt.obj ($6845.obj, egainfo.obj)

IsATT determines if the program is running on an ATT 6300 or similar
computer (such as Olivetti). If a Hercules is also installed in
the computer it may be switched to HALF mode (see Use32k, Use64k in
GRAPHICS.DOC).

Example:
REM $INCLUDE: 'qlib.bi'
REM look for ATT 6300 so I can use graph mode &H40
REM which is twice the resolution of CGA 2-color mode

modenumber% = 6 ' assume CGA
IF IsATT THEN modenumber% = &H40
CALL ScreenMode(modenumber%) ' see GRAPHICS.DOC


°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Function: IsMSHERC
object file: ismsherc.obj

IsMSHERC determines if the MSHERC.COM resident Hercules driver
has been installed. (MSHERC.COM is called QBHERC.COM in early
versions of QB 4.x). MSHERC.COM is required to use BASIC's
SCREEN 3 function. MSHERC is not required for QLIB's Hercules
graphics subroutines.

IsMSHERC returns 0 if MSHERC has not been loaded, or returns -1
if MSHERC has been loaded.

Example:
REM $INCLUDE: 'qlib.bi'
IF IsMSHERC THEN ... ' use either QLIB or BASIC Hercules stuff



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Function: IsSEVGA
object file: issevga.obj

IsSEVGA determines if a Super EGA or Super VGA graphics
card is installed. Systems detected are:

Everex Micro Enhancer EGA
Paradise EGA 480
Oak VGA
Paradise Plus 16 VGA
Tseng VGA
Western Digital VGA

Note that IsSEVGA does not determine what kind of monitor is
connected to the card. Many Super EGA/VGA cards require a
multi-frequency monitor to take advantage of the card's extended
capabilities.

IsSEVGA returns 0 if no supported system is detected. If a
Super EGA/VGA is detected, IsSEVGA returns:

Super EGA: 256+1 if Paradise EGA 480
256+2 if Everex Micro Enhancer

Super VGA: 768+1 if Paradise Plus 16
768+3 if Tseng VGA
768+4 if Oak VGA
768+5 if Western Digital VGA

Example:
REM $INCLUDE: 'qlib.bi'
evga% = IsSEVGA
if evga% THEN ... 'ask user if he/she has a multi-frequency
' monitor attached to the computer


°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutines: InsertOFF, InsertON
object file: kbd2.obj

Simplified controls to toggle the Insert key. See also
GetKBDToggle and SetKBDToggle.

Example:
CALL InsertON ' this turns Insert key on



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Function: KBDType
object file: kbd1.obj

Detects enhanced (101-key) keyboards. Returns 1 if 101-key
keyboard present and supported, 0 if not. NOTE: KBDType returns 1
only if the enhanced keyboard is present AND is supported by the
computer's BIOS.

Example:
REM $INCLUDE: 'qlib.bi'
IF KBDType THEN PRINT "Enhanced keyboard attached to system"



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutine: KeyRate(delay%, repeat%)
object file: keyrate.obj

KeyRate changes the keyboard's "typematic" delay and repeat rate
on PS/2 and most AT computers. Delay% (0 - 3) sets the delay time for
the start of the typematic action. Repeat% (0 - 31) sets the number
of repeats per second. For both delay% and repeat%, 0 gives the fastest
keyboard action, and the maximum value (delay% = 3, repeat% = 31) gives
you an unbearably slow keyboard.

Example:
REM don't slow me down!!
delay% = 0: repeat% = 0
CALL KeyRate(delay%, repeat%)




°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Function: a% = MathChip
object file: mathchip.obj

Detects the presence of a math coprocessor in the system.
Value returned = 0 if not installed, 1 if 8087, 2 if 80287, 3 if 80387.
DECLARE FUNCTION MathChip%() before using MathChip. The INCLUDE
file QLIB.BI does this for you.

Thanks to Marty Borgen for his help debugging MathChip on PS/2 computers.

Example:
REM $INCLUDE: 'qlib.bi'
msg$ = "No math coprocessor"
IF MathChip THEN msg$ = "math coprocessor installed"
PRINT msg$



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutine: MouseLimit(x0%, y0%, x1%, y1%)
object file: mouse.obj

MouseLimit confines the mouse's motion to an area limited by
x0, y0, x1, y1. Note that the x-dimension is horizontal and the
y-dimension is vertical, and that both x and y are PIXELS, whether
the video system is in graphics mode or text mode.

Example:
REM keep the mouse out of the right side of the screen
REM assume SCREEN 12, 640 x 480 graphics
x0% = 0: y0% = 0
x1% = 600: y1% = 479
CALL MouseLimit(x0%, y0%, x1%, y1%)



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutine: MousePos(x%, y%)
object file: mouse.obj

Positions the mouse cursor at (x,y). Note that the x-dimension
is horizontal and the y-dimension is vertical, and that both x and y
are PIXELS, whether the video system is in graphics mode or text mode.

Example:
REM put the mouse cursor in the upper left corner of the screen
x% = 0:y% = 0
CALL MousePos(x%, y%)

°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Function: buttons% = MouseReady
object file: mouse.obj

MouseReady determines if the Mouse driver software is loaded,
and returns the number of mouse buttons if so.

Example:
REM $INCLUDE: 'qlib.bi'
buttons% = MouseReady
IF buttons% THEN PRINT buttons% + " button mouse installed"



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Function: a$ = Path$(n%)
object files: path.obj (strlen.obj, strncpy.obj)

requires: DOS 3.xx or greater

Path$() is a pseudo array which returns a path from the program's
enviornment block. If the length of the string returned by Path$
is zero, there are no more paths in the enviornment block.

Example:
REM the PATH statement in my AUTOEXEC.BAT file looks like this:
REM PATH=C:\;C:\MASM;C:\DOS;C:\F77L3;C:\OS386

REM $INCLUDE 'qlib.bi' ' tell BASIC about the function
a$ = " ": n% = 0 ' initial conditions for WHILE/WEND
WHILE LEN(a$) <> 0
a$ = path$(n%)
PRINT a$
n% = n% + 1
WEND

REM this prints:

REM C:\
REM C:\MASM
REM C:\DOS
REM C:\F77L3
REM C:\OS386




°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutines: NumOFF, NumON
object file: kbd2.obj

Simplified controls to toggle the NumLock key. See also
GetKBDToggle and SetKBDToggle.

Example:
CALL NumON ' this turns NumLock on



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Function: PrinterError
object file: prnerror.obj

Determines whether the printer is ready. PrinterError returns 0 if
no error is detected. If the printer is not turned on, or if it is out
of paper, PrinterError returns -1. On some printers, -1 is returned if
the power is on but the printer is not on-line.

Example:
REM $INCLUDE 'qlib.bi'
IF PrinterError THEN PRINT "Printer not ready or out of paper"



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutine: PrnScreenOFF
Subroutine: PrnScreenON
object file: prnscrn.obj

These subroutines enable or disable the Print Screen key.

Example:
REM disable Print Screen
CALL PrnScreenOFF

REM turn it back on before ending the program
CALL PrnScreenON




°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutines: ScrollOFF, ScrollON
object file: kbd2.obj

Simplified controls to toggle the Scroll Lock key. See also
GetKBDToggle and SetKBDToggle.

Example:
CALL ScrollON ' this turns Scroll Lock on




°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutine: SetKBDToggle(kbd%)
object file: kbd.obj

Sets the NumLOCK, CapsLOCK, ScrollLOCK and INSERT keyboard toggles.
See GetKBDToggle.

Example:
REM let's be sure the NumLOCK toggle is ON and CapsLOCK is off
REM use the constants in GetKBDToggle

CALL GetKBDToggle(kbd%) ' get present toggles
kbd% = (kbd% OR numb%) ' this will set NumLOCK ON
kbd% = (kbd% AND (NOT caps%)) ' clears CapsLOCK bit
CALL SetKBDToggle(kbd%)



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

Subroutine: SetSpeed(speed%)
object file: speed.obj

Sets speed toggle of most "turbo" clone computers. Speed% = 0 will
set normal CPU speed, any other value for speed% will set "turbo" speed.
Should not affect non-turbo computers (such as IBM PC, AT, etc.). Good
style suggests that before using this function for the first time, you
should get the initial speed with GetSpeed and save it. You should
then restore the CPU to that original state before exiting the program.

Example:
CALL SetSpeed(speed%)


  3 Responses to “Category : BASIC Source Code
Archive   : QLIB56.ZIP
Filename : SYSTEM.DOC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/