home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hall of Fame
/
HallofFameCDROM.cdr
/
qb
/
qb4bas46.lzh
/
QB4BAS.DOC
< prev
next >
Wrap
Text File
|
1989-11-29
|
193KB
|
7,921 lines
QB4BAS.LIB -- Version 4.6
November 29, 1989
Harold Thomson
7437 Burnway Drive
Orlando, Fl. 32819
407-351-3737
PREFACE
There has been a major enhancement to this release of QB4BAS.LIB. Many
of the routines that required pre-allocated strings to be passed in
the call no longer require this and will now return their output as a
string. Many of the subroutines have been converted to functions to
accomodate this new functionality. This is another step towards making
these routines appear as if they are a part of QuickBASIC.
QB4BAS.LIB is a collection of subroutines and functions which are
designed for use with Microsoft QuickBASIC 4.0 thru 4.5. In addition
they will also work with the new Microsoft BASCOM 6.0 compiler. They
are not compatable with previous versions of QuickBASIC or BASCOM and
no attempts should be made to use them with other versions.
As noted above, this library contains both subroutines and functions.
The difference is that subroutines will perform the assigned task and
exit where as a function will perform an assigned task and return a
value which can be used to assign a value to a variable (ie variable
= function) or be part of an expression ( IF function = 0 THEN). As
you can see, this makes QB4BAS.LIB much more powerful and easier to
use than its predecessor, QuickBas.LIB. I would like to take credit
for this improvement but the thanks belongs to Microsoft for creating
a powerful and impressive compiler.
These routines are for whomever wants to use them. I am not charging
anything as long as they are used for personal use or freeware
programs. If any of these routines are to be used in any packages
that are to be sold to the public, I feel it is only fair that I be
informed of this use. I also feel that it would be appropriate in
this case to send me a small donation. I am not in this to make money
but if someone else is going to make money from my work, I should get
at least a little something from it.
As you may have noticed, I did not include the source code for these
routines. The reason for this is to protect these routines from any
changes which may cause them to no longer function the way they are
documented. I am willing to accept any comments or suggestions for
changes but I will have the final say on what happens. I do not
intend to make changes which would cause these routine not to function
as originally documented unless it is felt that these changes will
only improve the routines. Of course if this happens, I will make note
of it so please read the #@!%$& documentation. (I know, I hate to
read documentation almost as much as I hate writing it.)
I do have one thing that I would like to ask of anyone who might
decide to use any or all of these routines, let me know what you think
of them. I like praise but I can also take criticism. You can send
me a note at the address on the front cover.
QB4BAS.LIB -- Version 4.6 ii
ACKNOWLEDGEMENTS
While developing the original QuickBas.LIB routines, Charlie Wooster
and Terry Shockley where very helpful in testing the routines as well
as suggesting several of the routines that were in the library. I
would also like to extend thanks to Charlie who spent a lot of time
correcting problems encountered in QMENU as well as extending its
capabilities by writing QMENUS. Thanks to both of you.
QB4BAS.LIB -- Version 4.6 iii
Many of the new routines in version 2.0 were written for Clint
Labarth, Sysop of the Black Hole BBS in Orlando, for inclusion in his
new release of DoorPch routines which are used with PCBoard for
writing doors. Thanks for the suggestions, Clint.
I have also received several suggestions and comments from different
people who have taken the time to try these routines. It is good to
see that these routines are finally starting to be noticed. To all
who have written or called, thanks.
Many of the routines contained in the QB4BAS.LIB were derived from
routines in Leo J. Scanlons "Assembly Language Subroutines for MS-DOS
Computers". This is a very handy book and if you don't have a copy
and like to write assembly programs, I would recommend it. Another of
his books that I use quite often is "8086/88 Assembly Language
Programming". Page 100 is used quite often.
The QINPUT routine included in the library was developed from the
article "The Finishing Strokes" by Hardin Brothers in the September
1987 (#6) issue of PCResource magazine. Hardin has been writing good
articles for some time now, I remember some from 80 MICRO, and he has
several good ones in PCResource. I find this a very good magazine
with a good amount of information on Quick Basic programming.
The QCLOCK routine supplied is based upon the CLOCK.ASM program by
Robert J. Karp in the October 13, 1987 issue (Vol 7, Number 17) of PC
Magazine.
QB4BAS.LIB -- Version 4.6 iv
TABLE OF CONTENTS
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . iii
Summary of Amendments . . . . . . . . . . . . . . . . . . . . . . 1
Version 4.6 - Released 11/29/89 . . . . . . . . . . . . . . . . . 1
Version 4.5 - Released 10/10/89 . . . . . . . . . . . . . . . . . 2
Version 4.2 - Released 07/17/89 . . . . . . . . . . . . . . . . . 3
Version 4.1 - Released 05/08/89 . . . . . . . . . . . . . . . . . 3
Version 4.0 - Released 04/15/89 . . . . . . . . . . . . . . . . . 3
Version 3.0 - Released 11/20/88 . . . . . . . . . . . . . . . . . 5
Version 2.0 - Released 03/15/88 . . . . . . . . . . . . . . . . . 5
Version 1.0 - Released 01/17/88 . . . . . . . . . . . . . . . . . 6
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
QDATE -- FUNCTION . . . . . . . . . . . . . . . . . . . . . . 9
QDATECVT -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 10
QDATEIN -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 11
QDATE2INT -- FUNCTION . . . . . . . . . . . . . . . . . . . . 12
QINT2DATE -- FUNCTION . . . . . . . . . . . . . . . . . . . . 12
QJULCALC -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 13
Disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
QCNTFILE -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 14
QDISKSTAT -- SUB . . . . . . . . . . . . . . . . . . . . . . . 14
QDISKTYP -- SUB . . . . . . . . . . . . . . . . . . . . . . . 15
QDRVSPACE -- FUNCTION . . . . . . . . . . . . . . . . . . . . 15
QGETDRV -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 16
QGETVOL -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 16
QSETDRV -- SUB . . . . . . . . . . . . . . . . . . . . . . . 16
QSETVOL -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 17
File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
QCOPYFIL -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 18
QDELETE -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 18
QEXIST -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 19
QFATTR -- SUB . . . . . . . . . . . . . . . . . . . . . . . 19
QFCLOSE -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 20
QFCREATE -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 21
QFDATE -- SUB . . . . . . . . . . . . . . . . . . . . . . . 22
QFINDFIRST -- FUNCTION . . . . . . . . . . . . . . . . . . . . 23
QFINDNEXT -- FUNCTION . . . . . . . . . . . . . . . . . . . . 24
QFINDF -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 25
QFINDN -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 25
QFLOF -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 26
QFNAME -- SUB . . . . . . . . . . . . . . . . . . . . . . . 26
QFOPEN -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 27
QB4BAS.LIB -- Version 4.6 v
QFREAD -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 28
QFSETEND -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 29
QFSETREC QFSETRECL-- FUNCTION . . . . . . . . . . . . . . . . 29
QFSIZE -- SUB . . . . . . . . . . . . . . . . . . . . . . . 30
QFSTAMP -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 30
QFTIME -- SUB . . . . . . . . . . . . . . . . . . . . . . . 31
QFWRITE -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 32
QMOVEFIL -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 33
QPARSEF -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 34
QRENAME -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 35
QTREAD -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 36
QTWRITE -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 37
Keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
QALTKEY -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 39
QCAPSKEY -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 39
QCTRLKEY -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 40
QGETKEY -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 40
QINKEY -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 41
QINPUT -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 42
QINPUTM -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 44
QKEYFLAG -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 45
QKEYSTAT -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 45
QPOPMENU -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 46
QMENU -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 49
QMENUS -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 52
QNUMKEY -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 55
QSCRLKEY -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 55
QYESNO -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 56
Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . 57
QALARM -- SUB . . . . . . . . . . . . . . . . . . . . . . . 57
QARGC QARGV -- FUNCTION . . . . . . . . . . . . . . . . . . . 57
QBSRCHT -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 58
QCAPSOFF QCAPSON -- SUB . . . . . . . . . . . . . . . . . . . 59
QCLOCK -- SUB . . . . . . . . . . . . . . . . . . . . . . . 59
QCMDLEN -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 60
QCMDLINE -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 60
QCRCCHK QCRCSET -- FUNCTION . . . . . . . . . . . . . . . . . 61
QDOSVER -- SUB . . . . . . . . . . . . . . . . . . . . . . . 61
QEMSSIZE -- SUB . . . . . . . . . . . . . . . . . . . . . . . 62
QEMSEXIST -- FUNCTION . . . . . . . . . . . . . . . . . . . . 62
QEQUIPMENT -- SUB . . . . . . . . . . . . . . . . . . . . . . 63
QEXIT -- SUB . . . . . . . . . . . . . . . . . . . . . . . 63
QEXEC -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 64
QINPORT -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 66
QMININT QMAXINT -- FUNCTION . . . . . . . . . . . . . . . . . 66
QMINLONG QMAXLONG -- FUNCTION . . . . . . . . . . . . . . . . 67
QNUMLOCKOFF QNUMLOCKON -- SUB . . . . . . . . . . . . . . . . 67
QPRINTER -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 68
QPRTSCRN -- SUB . . . . . . . . . . . . . . . . . . . . . . . 68
QPRTSCRNOFF QPRTSCRNON -- SUB . . . . . . . . . . . . . . . . 69
QPAUSE -- SUB . . . . . . . . . . . . . . . . . . . . . . . 69
QPAUSE18 -- SUB . . . . . . . . . . . . . . . . . . . . . . . 70
QREBOOT -- SUB . . . . . . . . . . . . . . . . . . . . . . . 70
QB4BAS.LIB -- Version 4.6 vi
QSHIFTIL QSHIFTIR -- FUNCTION . . . . . . . . . . . . . . . . 71
QSHIFTLL QSHIFTLR -- FUNCTION . . . . . . . . . . . . . . . . 71
QSCROLLOFF QSCROLLON -- SUB . . . . . . . . . . . . . . . . . 72
QSHARE -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 72
QTIME -- SUB . . . . . . . . . . . . . . . . . . . . . . . 73
QTEMPC -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 73
QTEMPF -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 74
QVERIFY -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 74
QVERIFYOFF QVERIFYON -- SUB . . . . . . . . . . . . . . . . . 75
Q8087 -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 75
Mouse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
QMHIDE -- SUB . . . . . . . . . . . . . . . . . . . . . . . 76
QMLOC -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 76
QMPRESS -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 77
QMSET -- SUB . . . . . . . . . . . . . . . . . . . . . . . 77
QMSHOW -- SUB . . . . . . . . . . . . . . . . . . . . . . . 78
QMSTATUS -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 78
String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
QCAPIT -- SUB . . . . . . . . . . . . . . . . . . . . . . . 79
QCENTER -- SUB . . . . . . . . . . . . . . . . . . . . . . . 79
QCHARTYP -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 80
QDELIM -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 80
QEXTRACT -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 81
QFORMAT -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 81
QHIGHBIT -- SUB . . . . . . . . . . . . . . . . . . . . . . . 82
QINSTR -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 82
QLEN -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 83
QMID -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 83
QMOVREC -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 84
QMOVSTR -- SUB . . . . . . . . . . . . . . . . . . . . . . . 84
QREPLACE -- SUB . . . . . . . . . . . . . . . . . . . . . . . 85
QREVERSE -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 85
QRINSTR -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 86
QSTRIP -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 86
QSTRPCHR -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 87
QSUBSTR -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 87
QWORD -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 88
QWORDS -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 88
Sub-Directory . . . . . . . . . . . . . . . . . . . . . . . . . 89
QCHDIR -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 89
QCHKDIR -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 89
QGETDIR -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 90
QMKDIR -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 90
QRMDIR -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 90
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
QANSIPRT -- SUB . . . . . . . . . . . . . . . . . . . . . . . 91
QATTR -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 91
QBPRT -- SUB . . . . . . . . . . . . . . . . . . . . . . . 92
QBMPRT -- SUB . . . . . . . . . . . . . . . . . . . . . . . 93
QCRTMODE -- SUB . . . . . . . . . . . . . . . . . . . . . . . 94
QCLREOL -- SUB . . . . . . . . . . . . . . . . . . . . . . . 94
QB4BAS.LIB -- Version 4.6 vii
QGETATTR -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 96
QGETCURS -- SUB . . . . . . . . . . . . . . . . . . . . . . . 96
QGETMODE -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 97
QMPRT -- SUB . . . . . . . . . . . . . . . . . . . . . . . 98
QPAINT -- SUB . . . . . . . . . . . . . . . . . . . . . . . 99
QPRT -- SUB . . . . . . . . . . . . . . . . . . . . . . . 100
QPRTANSI -- SUB . . . . . . . . . . . . . . . . . . . . . . . 101
QRESTSCR -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 102
QSAVESCR -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 103
QSCROLL -- SUB . . . . . . . . . . . . . . . . . . . . . . . 104
QSCROLLB -- SUB . . . . . . . . . . . . . . . . . . . . . . . 104
QSCRREST -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 105
QSCRSAVE -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 106
QSETMODE -- SUB . . . . . . . . . . . . . . . . . . . . . . . 107
QWINDOW -- SUB . . . . . . . . . . . . . . . . . . . . . . . 108
QWINDOWH -- SUB . . . . . . . . . . . . . . . . . . . . . . . 109
QWINDOWV -- SUB . . . . . . . . . . . . . . . . . . . . . . . 110
QWINDOWX -- SUB . . . . . . . . . . . . . . . . . . . . . . . 111
QVIDREST -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 112
QVIDSAVE -- FUNCTION . . . . . . . . . . . . . . . . . . . . . 112
QB4BAS.LIB -- Version 4.6 viii
SUMMARY OF AMENDMENTS
VERSION 4.6 - RELEASED 11/29/89
NEW ROUTINES
Miscellaneous QEXEC QSHARE
Mouse QMHIDE QMLOC QMPRESS QMSET QMSHOW QMSTATUS
ROUTINES CORRECTED
QCOPYFIL Corrected documentation
QINSTR QRINSTR Returning incorrect results
QMOVEFIL Occasional incorrect results
QREVERSE Corrected documentation
QSTRIP Errors processing null strings
Summary of Amendments 1
VERSION 4.5 - RELEASED 10/10/89
NEW ROUTINES
File QFSETRECL
Miscellaneous QARGC QARGV
String QREVERSE
ROUTINES CORRECTED
QWINDOWX Correct documentation for DECLARE
QINPUT QINPUTM Would not accept 2 as valid number of keys
QCHARTYP Returning wrong results
ROUTINES REVISED
QCMDLINE Now returns a string variable
QDATE Now returns a string variable
QDATECVT Now returns a string variable
QDATEIN Now returns a string variable
QDELIM Now returns a string variable
QEXIST Can now also check for existance of directorys
QEXTRACT Now returns a string variable
QGETDIR Now returns a string variable
QGETDRV Now returns a string variable
QGETVOL Now returns a string variable
QINT2DTE Now returns a string variable
QMOVREC Now returns a string variable
QREVERSE Now returns a string variable
QSTRIP Now returns a string variable
QSTRPCHR Now returns a string variable
QSUBSTR Now returns a string variable
QWORD Now returns a string variable
Summary of Amendments 2
VERSION 4.2 - RELEASED 07/17/89
NEW ROUTINES
File QFLOF QPARSEF
Keyboard QINPUTM
Miscellaneous QCMDLEN QREBOOT (Really)
String QMID QSTRIP QSTRPCHR QSUBSTR
ROUTINES CORRECTED
QFSETREC Now can select first record.
QCRTMODE Support added to test for VGA monitor.
VERSION 4.1 - RELEASED 05/08/89
NEW ROUTINES
Disk QSETVOL
Keyboard QALTKEY QCAPSKEY QCAPSON QCAPSOFF QCNTLKEY QNUMKEY
QSCRLKEY QSCROLLON QSCROLLOFF QYESNO
Miscellaneous QTEMPC QTEMPF Q8087
String QHIGHBIT QLEN
VERSION 4.0 - RELEASED 04/15/89
NEW ROUTINES
Disk QDISKTYP
File QFSTAMP QTREAD QTWRITE
Miscellaneous QMAXINT QMININT QMAXLONG QMINLONG QSHIFTIL QSHIFTIR
QSHIFTLL QSHIFTLR QVERIFY QVERIFYON QVERIFYOFF
QEMSEXIST
String QCAPIT QCENTER QCHARTYP
Video QCLREOL QGETMODE QPAINT QRESTSCR QSAVESCR QSETMODE
ROUTINES CORRECTED
Summary of Amendments 3
QCOPYFIL Increased copy buffer from 1K to 2K.
QMOVEFIL Increased move buffer from 1K to 2K.
Summary of Amendments 4
VERSION 3.0 - RELEASED 11/20/88
NEW ROUTINES
Disk QCNTFILE QGETVOL
File QFINDFIRST QFINDNEXT
Keyboard QPOPMENU
Miscellaneous QBYTES
String QMOVREC QMOVSTR
Video QWINDOWX
ROUTINES CORRECTED
QINPUT No longer hangs certain systens on exit.
QSCROLL No longer hangs certain systems on exit.
QSCROLLB No longer hangs certain systems on exit.
QSCRREST Now works with monochrome monitors.
QSCRSAVE Now works with monochrome monitors.
VERSION 2.0 - RELEASED 03/15/88
NEW ROUTINES
Date QDATE2INT QINT2DATE
Disk QDSKSTAT QDRVSPC
Keyboard QGETKEY QINKEY QKEYSTAT
Miscellaneous QINPORT QTIMER
Video QCRTMODE QGETATTR QGETCURS QPRTANSI
ROUTINES CORRECTED
QEXIT Now resets either Mono or CGA cursor.
QWORDS Now returns 0 for null strings.
Summary of Amendments 5
VERSION 1.0 - RELEASED 01/17/88
CONVERTED ROUTINES from QuickBas.LIB Version 3.0
Date QDATE QDATECVT QDATEIN QJULCALC
Disk QGETDRV QSETDRV
File QCOPYFIL QDELETE QEXIST QFATTR QFCLOSE QFCREATE
QFOPEN QFREAD QFSETEND QFSETREC QFWRITE QFDATE QFINDF
QFINDN QFNAME QFSIZE QFTIME QMOVEFIL QRENAME
KeyBoard QINPUT QMENU QMENUS
Miscellaneous QALARM QCLOCK QCMDLINE QCRCCHK QCRCSET QDOSVER
QEMSSIZE QEQUIPMENT QEXIT QNUMLOCKOFF QNUMLOCKON
QPRINTER QPRTSCRN QPRTSCRNOFF QPRTSCRNON QPAUSE
QPAUSE18
String QDELIM QEXTRACT QREPLACE QWORD QWORDS
Sub-Directory QCHDIR QCHKDIR QGETDIR QMKDIR QRMDIR
Video QANSIPRT QATTR QBPRT QPRT QBMPRT QMPRT QSCROLL
QSCROLLB QSCRREST QSCRSAVE QWINDOW QWINDOWH QWINDOWV
VIDREST VIDSAVE
DELETED ROUTINES from QuickBas.LIB Version 3.0
String QLOWER QUPPER
Summary of Amendments 6
INTRODUCTION
QB4BAS is a collection of subroutine and functions written in
Assembler for the Microsoft QuickBASIC 4.0 thru 4.5 compilers. The
routines will also work with the Microsoft BASIC 6.0 compiler. Many of
the routines are functionally the same as routines found in other
Basic Library packages. In addition, I have added several routines
that were not available and which I find to be very helpful. I have
tested all of the routines and they have worked for me on my AT&T
PC6300. I am sure that they will work on any AT&T compatible machine.
The files included in QB4BAS45.ZIP are as follows:
QB4BAS.DOC The QB4BAS library DOC.
QB4BAS.LIB The QB4BAS library.
QB4BAS.QLB The QB4BAS quick library.
QB4BAS.BI Include file containing the necessary DECLAREs.
QB4OBJ.ZIP The individual OBJ files to create a LIB.
QB4BAS.RSP The response file used to create the .LIB file.
QB4QLB.RSP The response file used to create the .QLB file.
REQUIREMENTS
In order to use the functions or routines in QB4BAS.LIB, you must
either add the DECLARE statements in the examples or include QB4BAS.BI
using the $INCLUDE metacommand.
Most of the routines in this library require that either a string
variable or a numeric variable be passed with the call. Whenever a
routine requires a numeric variable, the variable must be defined as
an integer by either using the DEFINT statement or by using the
percent sign at the end of the variable name.
Some routines require that when a string variable is used, it be set
to a minimum size. This is due to the limitations placed upon me by
BASIC when using assembly language routines. Always check the routine
format before using it.
Whenever an array is used in a call, double check the example to be
sure that the proper calling format is used. Failure to do so may
cause some of these routines fail or hang up your machine.
I have received some correspondence regarding linking programs with
the routines in the .LIB to create an .EXE file. According to the
information from MicroSoft, only stand alone .EXE files can be creates
using these routines, do not try to create an .EXE from within the QB
environment, you must compile the program using the BC compiler. In
addition, when using the BC compiler, you must use the /O option to
indicate that BCOM45.LIB will be used to link the program.
Introduction 7
The proper format is:
BC mypgm /O;
The format of the link command is as follows:
LINK /E mypgm+NOCOM, , ,BCOM45+QB4BAS;
I hope that this clears up any problems that anyone has been having
with the routines.
Introduction 8
DATES
QDATE -- FUNCTION
Returns a variety of date information based upon the current date. The
routine returns a string which contains the requested information. It
is no longer necessary to pre-allocate the return string. By using a
variety of function codes, this function will return the alpha weekday
(Sunday), the number of days so far this year (ddd), the Julian date
(yyddd), the alpha month (June), the default date format (dd MMM
yyyy), the USA date (mm/dd/yy), The European date (dd/mm/yy), the
ordered date (yy/mm/dd) and the sorted date (yyyymmdd). If an error
is encountered, a null string will be returned.
The format of the call is as follows:
Buffer$ = QDATE(FuncCode$)
The following are the valid Function Codes:
D - Day of the year : ddd
E - European date : dd/mm/yy
J - Julian date : yyddd
M - Month : name of month, RC = length
N - Normal : dd MMM yyyy (30 Sep 1987)
O - Ordered date : yy/mm/dd
S - Sorted date : yyyymmdd
U - USA date : mm/dd/yy
W - Weekday : day of the week, RC = length
Example:
DEFINT A-Z
DECLARE FUNCTION QDATE$ (FunCode AS STRING)
.
REM Print the day of the week
FuncCode$ = "W"
Buffer$ = QDATE(FuncCode$)
IF Buffer$ <> "" THEN
PRINT "Today is " Buffer$
END IF
.
REM Print the normal date
FuncCode$ = "N"
Buffer$ = QDATE(FuncCode$)
IF Buffer$ <> "" THEN
PRINT "Today is " Buffer$
END IF
Dates 9
QDATECVT -- FUNCTION
Converts either a gregorian date to julian (IN = mm/dd/yy OUT = yyddd)
or a julian date to gregorian date (IN = yyddd OUT = mm/dd/yy). The
conversion is based upon a function code which is passed with the
call. If an error is encountered, a null string will returned.
The format of the call is as follows:
OutDate$ = QDATECVT(Indate$, FuncCode$)
The following are the valid Function Codes:
J - Converts gregorian to julian
G - Converts julian to gregorian
Example:
DEFINT A-Z
DECLARE FUNCTION QDATECVT$ (InDate AS STRING, _
FunCode AS STRING)
.
REM Convert to julian
InDate$ = "05/29/87"
FuncCode$ = "J"
OutDate$ = QDATECVT(InDate$, FuncCode$)
IF OutDate$ <> "" THEN
PRINT "The julian date is " OutDate$
END IF
.
REM Convert to gregorian
InDate$ = "87149"
FuncCode$ = "G"
OutDate$ = QDATECVT(InDate$, FuncCode$)
IF OutDate$ <> "" THEN
PRINT "The gregorian date is " OutDate$
END IF
Dates 10
QDATEIN -- FUNCTION
Returns a variety of date information based upon a date which is
included in the call. The date in is in the format of MM/DD/YY or
MM/DD/YYYY. If the year is YY then 1900 is assumed. By supplying a
function code, this routine returns a string which contains either the
alpha weekday (Sunday), the number of days so far this year (ddd), the
Julian date (yyddd), the alpha month (June), the default date format
(dd MMM yyyy), the USA date (mm/dd/yy), The European date (dd/mm/yy),
the ordered date (yy/mm/dd) and the sorted date (yyyymmdd). If an
error is, a null string is returned.
The format of the call is as follows:
Buffer$ = QDATEIN(InDate$, FuncCode$)
The following are the valid Function Codes:
D - Day of the year : ddd
E - European date : dd/mm/yy
J - Julian date : yyddd
M - Month : name of month, RC = length
N - Normal : dd MMM yyyy (30 Sep 1987)
O - Ordered date : yy/mm/dd
S - Sorted date : yyyymmdd
U - USA date : mm/dd/yy
W - Weekday : day of the week, RC = length
Example:
DEFINT A-Z
DECLARE FUNCTION QDATEIN$ (InDate AS STRING, _
FunCode AS STRING)
.
REM Print the day of the week
InDate$ = "10-18-1987"
FuncCode$ = "W"
Buffer$ = QDATEIN(InDate$, FuncCode$)
IF Buffer$ <> "" THEN
PRINT "Today is " Buffer$
END IF
.
REM Print the normal date
FuncCode$ = "N"
Buffer$ = QDATEIN(InDate$, FuncCode$)
IF Buffer$ <> "" THEN
PRINT "Today is " Buffer$
END IF
Dates 11
QDATE2INT -- FUNCTION
Compress an 8 byte string date (XX/XX/XX) into a 2 byte integer. This
function can be used to compress a date to be written to a file to
save 6 bytes per date written.
The format of the call is as follows:
HoldDate = QDATE2INT(InDate$)
Example:
DEFINT A-Z
DECLARE FUNCTION QDATE2INT% (InDate AS STRING)
.
InDate$ = "05/29/48"
HoldDate = QDATE2INT(InDate$)
QINT2DATE -- FUNCTION
Uncompress a 2 byte integer date which has been compressed using
QDATE2INT back into an 8 byte string date (XX/XX/XX).
The format of the call is as follows:
OutDate$ = QINT2DATE(InDate)
Example:
DEFINT A-Z
DECLARE FUNCTION QDATE2INT% (InDate AS STRING)
DECLARE FUNCTION QINT2DATE$ (BYVAL InDate AS INTEGER)
.
InDate$ = "05/29/48"
HoldDate = QDATE2INT(InDate$)
OutDate$ = QINT2DATE(HoldDate)
PRINT "The date is " OutDate$
Dates 12
QJULCALC -- FUNCTION
Either adds or subtracts from a julian date. The julian date must be
passed as a string and the amount to add or subtract must be an
integer. This function allows for leap years. If there is an error
encountered, the RC will be set to -1.
The format of the call is as follows:
RC = QJULCALC(Calcdate$, Amount)
Example:
DEFINT A-Z
DECLARE FUNCTION QJULCALC% (CalcDate AS STRING, _
BYVAL Amount AS INTEGER)
.
REM Add 25 days to "87214"
CalcDate$ = "87214"
Amount = 25
IF QJULCALC(CalcDate$, Amount) = 0 THEN
PRINT "The new julian date is " CalcDate$
END IF
.
REM Subtract 25 days from "87214"
CalcDate$ = "87214"
Amount = -25
IF QJULCALC(CalcDate$, Amount) = 0 THEN
PRINT "The new julian date is " CalcDate$
END IF
Dates 13
DISK
QCNTFILE -- FUNCTION
Retrieves the number of files in the requested path that match the
search string.
The format of the call is as follows:
FileCnt = QCNTFILE(InFileName AS STRING)
Example:
DEFINT A-Z
DECLARE FUNCTION QCNTFILE% (InFileName AS STRING) _
BYVAL Attr AS INTEGER)
InFileName$ = "C:\TESTPATH" + CHR$(0)
Attr = 32
Cnt = QCNTFILE(InFileName$, Attr)
PRINT "Number of files is " + STR$(Cnt)
QDISKSTAT -- SUB
Retrieves information on the requested disk drive. The information
returned is the free clusters, total clusters, bytes per sector and
the number of sectors per cluster
The format of the call is as follows:
QDISKSTAT Drv$, FClusters, TotClusters, BytesSector, SectorsCluster
Example:
DEFINT A-Z
DECLARE SUB QDISKSTAT (DrvName AS STRING, _
FreeClusters AS INTEGER, _
TotClusters AS INTEGER, _
BytesSector AS INTEGER, _
SectorsCluster AS INTEGER)
Drv$="C:\"
QDISKSTAT Drv$, FClusters, TotClusters, BytesSector, SectorsCluster
PRINT "Drive "+Drv$+" has "+STR$(SectorsCluster)+" Clusters/Sector."
Disk 14
QDISKTYP -- SUB
Returns a return code which indicates the type of disk for the current
logged drive. A return code of 0 indicates the it is a hard drive, a
1 indicates a floppy disk and a -1 indicates that the type of disk
could not be determined.
The format of the call is as follows:
RC = QDISKTYP()
Example:
DEFINT A-Z
DECLARE FUNCTION QDISKTYP% ()
RC = QDISKTYP()
IF RC = 0 THEN
PRINT "The current logged disk is a hard disk"
ELSEIF RC = 1 THEN
PRINT "The current logged disk is a floppy disk"
ELSE
PRINT "The current logged disk type cannot be determined"
END IF
QDRVSPACE -- FUNCTION
Retrieves the total amount of free disk space on the requested disk
drive.
The format of the call is as follows:
FreeSpace = QDRVSPACE(DrvStr$)
Example:
DEFINT A-Z
DECLARE FUNCTION QDRVSPACE& (DrvName AS STRING)
DrvStr$="C:\"
FreeSpace = QDRVSPACE(DrvStr$)
PRINT "Drive "+DrvStr$+" has "+STR$(FreeSpace)+" bytes."
Disk 15
QGETDRV -- FUNCTION
Get the current logged disk drive. It is no longer necessary to
pre-allocate the return string.
The format of the call is as follows:
DrvStr$ = QGETDRV
Example:
DEFINT A-Z
DECLARE FUNCTION QGETDRV$ ()
DrvStr$ = QGETDRV
PRINT "The current disk is " DrvStr$
QGETVOL -- FUNCTION
Get the volume label of the requested disk drive. It is not necessary
to pre-allocate the return string.
The format of the call is as follows:
VolId$ = QGETVOL
Example:
DEFINT A-Z
DECLARE FUNCTION QGETVOL$ ()
VolId$ = QGETVOL
PRINT "The current disk label is " VolId$
QSETDRV -- SUB
Change the current logged disk drive.
The format of the call is as follows:
QSETDRV NewDrv$
Example:
DEFINT A-Z
DECLARE SUB QSETDRV (DrvName AS STRING)
NewDrv$="C:"
QSETDRV NewDrv$
Disk 16
QSETVOL -- FUNCTION
This function will set, change or delete the volume label of the
requested disk drive. In order to set or change the vol label, the
string that is passed must be 11 characters long. A null string can
be used to delete the current vol label.
The format of the call is as follows:
RC = QSETVOL(VolId$)
Example:
DEFINT A-Z
DECLARE FUNCTION QSETVOL% (VolId AS STRING)
VolId$ = "HAROLDSDISK"
IF QSETVOL(VolId$) = 0 THEN
PRINT "The Vol label has been set to " VolId$
END IF
.
REM The following will delete the current Vol label
VolId$ = ""
IF QSETVOL(VolId$) = 0 THEN
PRINT "The Vol label has been deleted"
END IF
Disk 17
FILE
QCOPYFIL -- FUNCTION
Copies a file. This is a better way of copying a file because it does
not require the SHELL command. This routine will replace the file on
the destination device, use QEXIST to check if the file already
exists. Requires an ASCIIZ filename. The return code will be set if
any errors are encountered.
The format of the call is as follows:
RC = QCOPYFIL(OldFile$, NewFile$)
Example:
DEFINT A-Z
DECLARE FUNCTION QCOPYFIL% (InFileName AS STRING, _
OutFileName AS STRING)
OldFile$ = "TESTFILE.OLD"+CHR$(0)
NewFile$ = "TESTFILE.NEW"+CHR$(0)
IF QCOPYFIL(OldFile$, NewFile$) = 0 THEN
PRINT "File copied"
ELSE
PRINT "File not copied"
END IF
QDELETE -- FUNCTION
Deletes a file. Requires an ASCIIZ filename without wildcards. Upon
exit, a return code is set to indicate if the file was deleted or not.
The format of the call is as follows:
RC = QDELETE(DelFile$)
Example:
DEFINT A-Z
DECLARE FUNCTION QDELETE% (FileName AS STRING)
.
DelFile$="QUICKBAS.LIB"+CHR$(0)
IF QDELETE(DelFile$) = 0 THEN
PRINT "File deleted"
ELSE
PRINT "File not deleted"
END IF
File 18
QEXIST -- FUNCTION
Tells you if the requested file or sub-directory already exists.
Returns zero if it does, or a -1 if it doesn't. Requires an ASCIIZ
name without wildcards.
The format of the call is as follows:
RC = QEXIST(ChkFile$)
Example:
DEFINT A-Z
DECLARE FUNCTION QEXIST% (FileName AS STRING)
REM For a sub-directory use ==> ChkFile$ = "\QB4\WORK" + CHR$(0)
ChkFile$ = "FINDFILE.TXT" + CHR$(0)
IF QEXIST(ChkFile$) = 0 THEN
PRINT "File exists"
ELSE
PRINT "File not found"
END IF
QFATTR -- SUB
Returns the file attribute of a file that has been located by either
QFINDF or subsequent calls to QFINDN. See the information on these
two calls before using this routine.
The format of the call is as follows:
QFATTR Attr
The file attributes are as follows:
Normal - 00h A normal file.
Read-Only - 01h File cannot be erased or rewritten.
Hidden - 02h File info not displayed by DIR command.
System - 04h Like hidden but for system (DOS,BIOS) files.
Vol Label - 08h A disk's vol label.
Directory - 10h A subdirectory.
Archive - 20h Set after most backup programs run.
Combinations of file attributes can be used. An example is IBMDOS.COM
which is usually a hidden, system, read-only, archive file.
Example:
DEFINT A-Z
DECLARE SUB QFATTR (Attr AS INTEGER)
QFATTR Attr
PRINT "The file attribute is " Attr
File 19
QFCLOSE -- FUNCTION
This function is used to close a file which was created by the
QFCREATE routine or opened by the QFOPEN routine. This function must
be called after the QFCREATE or QFOPEN routines to close the created
or opened file.
The function is called by passing the file "handle" which was returned
by the QFCREATE or QFOPEN routine. Upon return, the RC will either be
zero indicating the file was closed or will be 6 indicating an invalid
handle was specified.
The format of the call is as follows:
RC = QFCLOSE(FHandle)
Example:
DEFINT A-Z
DECLARE FUNCTION QFCLOSE% (Handle AS INTEGER)
.
REM You must issue either a call to QFCREATE or QFOPEN first
.
IF QFCLOSE(FHandle) = 0 THEN
Print "File Closed"
ELSE
Print "Invalid Handle, File Not Closed"
END IF
File 20
QFCREATE -- FUNCTION
This function is used to either create a 0 length file in the
specified or defaulted path or to initialize a file which will be
written to using QFWRITE. The QFCLOSE function must be used to close
the file.
The function is called by passing a file name which may include the
drive and path). The file name must end with a binary "0" as the
routine requires ASCIIZ names. In addition, the file attribute must
be passed in the call, see QFATTR for information on file attributes.
Upon return, the RC will either be zero indicating the file was
created or non-zero indicating an error. If the RC is 0 the file
"handle" will be in the integer variable specified as the 3rd
parameter. If the RC is 3 the specified path was not found. If the
RC is 4 a file "handle" was not available. If the RC is 5 access was
denied.
The format of the call is as follows:
RC = QFCREATE(FileName$, Fattr, FHandle)
Example:
DEFINT A-Z
DECLARE FUNCTION QFCREATE% (FileName AS STRING, _
FAttr AS INTEGER, _
Handle AS INTEGER)
.
FileName$ = "C:\DEMO\TEST.DAT"+CHR$(0)
Fattr = 0
RC = QFCREATE(FileName$, Fattr, FHandle)
IF RC = 0 THEN
Print "File Created"
ELSE
Print "File Not Created";RC
END IF
.
RC = QFCLOSE(FHandle)
File 21
QFDATE -- SUB
Returns the date that the file was created or updated. The file must
first located by a call to either QFINDF or subsequent calls to
QFINDN. See the information on these two calls before using this
routine.
The format of the call is as follows:
QFDATE Month, Day, Year
Example:
DEFINT A-Z
DECLARE SUB QFDATE (Month AS INTEGER, _
Day AS INTEGER, _
Year AS INTEGER)
.
QFDATE Month, Day, Year
.
PRINT "The file date is " Month Day Year
File 22
QFINDFIRST -- FUNCTION
This new function works much like the QFINDF function but, unlike
QFINDF, it does not require additional calls to other routines to
retrieve the information that you really wanted in the beginning. The
file information is returned in a record which must be defined with
the TYPE command. The necessary record TYPE is supplied in QB4BAS.BI.
See below for an example on how to use it. This function will locate
the first file in the specified or default path which matches the
specified file name. The file name may contain wildcards (* and ?).
Additional matching files may be found using the QFINDNEXT function.
The function is called by passing a pointer to the record where the
file information is to be placed. A file name (which can contain
wildcards "*" or "?" as well as the drive and path) which must end
with a binary "0" as the routine requires ASCIIZ names. In addition,
the file attribute must be passed in the call, see QFATTR for
information on file attributes. Upon return, the RC will either be
zero, indicating that a file was found, or non-zero indicating an
error. If the RC is -1 there was an error in the call. If the RC is
a 2 the specified path is invalid. If the RC is 18 there is no
matching file.
The format of the call is as follows:
RC = QFINDFIRST(RecAddr, ChkFile$, Fattr)
Example:
DEFINT A-Z
DECLARE FUNCTION QFINDFIRST% (BYVAL RecPtr AS INTEGER, _
FileName AS STRING, _
BYVAL Attr AS INTEGER)
TYPE FileType
Fname AS STRING * 12
Fdate AS STRING * 8
Ftime AS STRING * 5
Fsize AS LONG
Fattr AS INTEGER
Month AS INTEGER
Day AS INTEGER
Year AS INTEGER
Hour AS INTEGER
Minute AS INTEGER
END TYPE
.
DIM Qfile AS FileType
Fptr = VARPTR(Qfile)
ChkFile$="C:\DEMO\*.EXE"+CHR$(0)
IF QFINDFIRST(Fptr, ChkFile$, 0) = 0 THEN
Print Qfile.Fname, Qfile.Fdate, Qfile.Ftime, Qfile.Fsize
END IF
File 23
QFINDNEXT -- FUNCTION
This new function works much like the QFINDN function but, unlike
QFINDN, it does not require additional calls to other routines to
retrieve the information that you really wanted in the beginning. The
file information is returned in a record which must be defined with
the TYPE command. The necessary record TYPE is supplied in QB4BAS.BI.
See below for an example on how to use it. This function will locate
additional files after a successful call to QFINDFIRST.
The function is called by passing a pointer to the record where the
file information is to be placed. Upon return, the RC will either be
zero indicating that a file was found or 18 indicating there are no
more matching files.
The format of the call is as follows:
RC = QFINDNEXT(RecAddr)
Example:
DEFINT A-Z
DECLARE FUNCTION QFINDNEXT% (BYVAL RecPtr AS INTEGER)
.
TYPE FileType
Fname AS STRING * 12
Fdate AS STRING * 8
Ftime AS STRING * 5
Fsize AS LONG
Fattr AS INTEGER
Month AS INTEGER
Day AS INTEGER
Year AS INTEGER
Hour AS INTEGER
Minute AS INTEGER
END TYPE
.
DIM Qfile AS FileType
Fptr = VARPTR(Qfile)
ChkFile$="C:\DEMO\*.EXE"+CHR$(0)
IF QFINDFIRST(Fptr, ChkFile$, 0) = 0 THEN
Print Qfile.Fname, Qfile.Fdate, Qfile.Ftime, Qfile.Fsize
WHILE QFINDNEXT(Fptr) = 0
Print Qfile.Fname, Qfile.Fdate, Qfile.Ftime, Qfile.Fsize
WEND
END IF
File 24
QFINDF -- FUNCTION
This function is used to locate the first file in the specified or
default path which matches the specified file name. The file name may
contain wildcards (* and ?). Additional matching files may be found
using the QFINDN function. This function must be called before calls
to QFATTR, QFDATE, QFINDN, QFNAME, QFSIZE and QFTIME.
The function is called by passing a file name (which can contain
wildcards "*" or "?" as well as the drive and path). The file name
must end with a binary "0" as the routine requires ASCIIZ names. In
addition, the file attribute must be passed in the call, see QFATTR
for information on file attributes. Upon return, the RC will either
be zero, indicating that a file was found, or non-zero indicating an
error. If the RC is -1 there was an error in the call, a 2 indicates
the specified path is invalid, an 18 indicates there is no matching
file.
The format of the call is as follows:
RC = QFINDF(ChkFile$, Fattr)
Example:
DEFINT A-Z
DECLARE FUNCTION QFINDF% (FileName AS STRING, BYVAL Attr AS INTEGER)
RC = QFINDF("C:\DEMO\*.EXE"+CHR$(0), 0)
IF RC < 0 THEN
Print "Error in call."
ELSEIF RC > 0 THEN
Print "File not found."
END IF
QFINDN -- FUNCTION
This function is used to locate additional files beyond the file found
by the QFINDF function. The QFINDN function reuses the parameters
passed to the QFINDF function to locate any additional files. The RC
will zero if a file was found or 18 if there are no more matching
files.
The format of the call is as follows:
RC = QFINDN
Example:
DEFINT A-Z
DECLARE FUNCTION QFINDN% ()
IF QFINDN > 0 THEN PRINT "No more files."
File 25
QFLOF -- FUNCTION
This function is used to return the file size of an open file that was
opened with either QFOPEN or QFCREATE. It will return the file size
whether it has been just opened or if it has been added to with
QFWRITE. Be careful to make sure that a long integer is used to
return the file size to.
The format of the call is as follows:
Fsize& = QFLOF(FHandle)
Example:
DEFINT A-Z
DECLARE FUNCTION QFLOF& (Handle AS INTEGER)
REM Open file for reading
FileName$ = "C:\DEMO\TEST.DAT"+CHR$(0)
Faccess = 1
RC = QFOPEN(FileName$, Faccess, FHandle)
Fsize& = QFLOF(FHandle)
RC = QFCLOSE(FHandle)
QFNAME -- SUB
Returns the name of the file that was located by either QFINDF or
subsequent calls to QFINDN. It also returns the length of the file
name less trailing spaces. See the information on these two calls
before using this routine.
The format of the call is as follows:
QFNAME File$
Example:
DEFINT A-Z
DECLARE SUB QFNAME (FileName AS STRING)
.
REM You must issue a call to either QFINDF or QFINDN first
.
File$ = Space$(12)
QFNAME File$
PRINT "The file name is " RTRIM$(File$)
.
File 26
QFOPEN -- FUNCTION
This function is used to open an existing file. The file can then be
read by using QFREAD or written to by QFWRITE. The QFCLOSE function
must be used to close the file.
The function is called by passing a file name which may include the
drive and path). The file name must end with a binary "0" as the
routine requires ASCIIZ names. In addition, the file access must be
passed in the call, 0 to open for reading, 1 to open for writing or 2
to open for both reading and writing. Upon return, the RC will either
be zero indicating the file was opened or non-zero indicating an
error. If the RC is 0 the file "handle" will be in the integer
variable specified as the 3rd parameter. If the RC is 2 the specified
path was not found. If the RC is 4, then too many files open. If the
RC is 5, then access was denied. If the RC is 12, then an invalid
access number was passed.
The format of the call is as follows:
RC = QFOPEN(FileName$, Faccess, FHandle)
Example:
DEFINT A-Z
DECLARE FUNCTION QFOPEN% (FileName AS STRING, _
Access AS INTEGER, _
Handle AS INTEGER)
.
REM Open file for reading
FileName$ = "C:\DEMO\TEST.DAT"+CHR$(0)
Faccess = 0
RC = QFOPEN(FileName$, Faccess, FHandle)
IF RC = 0 THEN
Print "File Opened"
ELSE
Print "File Not Opened";RC
END IF
.
REM Open file for writing
FileName$ = "C:\DEMO\TEST.DAT"+CHR$(0)
Faccess = 1
RC = QFOPEN(FileName$, Faccess, FHandle)
IF RC = 0 THEN
Print "File Opened"
ELSE
Print "File Not Opened";RC
END IF
.
RC = QFCLOSE(FHandle)
File 27
QFREAD -- FUNCTION
This function is used to read a file which has been opened by QFOPEN.
The calling sequence requires that a string buffer be passed which
will contain the requested record upon return. In addition, the
length of the record to read must be passed so that the routine will
know how many bytes to read. Upon return, the string will contain the
requested record and the actual number of bytes read will be returned.
In addition, the RC will either be zero indicating that the read was
successful or non-zero indicating an error. If the RC is -1, there
was an error in one of the parameters. If the RC is greater than
zero, DOS encountered an error reading the file.
A useful feature of this function is that block reads can be done. A
block read is reading multiple records at a time. If the record
length is 50, by setting a buffer length to 500 will cause the routine
to attempt to read 10 records. The bytes read count can then be used
to determine exactly how many records were read. The buffer can be
split using the MID$ function to extract each record.
The format of the call is as follows:
RC = QFREAD(FHandle, FBuffer$, ReadLen, BytesRead)
Example:
DEFINT A-Z
DECLARE FUNCTION QFREAD% (Handle AS INTEGER, _
Buffer AS STRING, _
ReadLen AS INTEGER, _
BytesRead AS INTEGER)
.
REM Open file for reading
FileName$ = "C:\DEMO\TEST.DAT"+CHR$(0)
Faccess = 0
RC = QFOPEN(FileName$, Faccess, FHandle)
.
FBuffer$ = Space$(50)
ReadLen = 50
RC = QFREAD(FHandle, FBuffer$, ReadLen, BytesRead)
IF RC <> 0 THEN
PRINT "Error reading file"
END
ELSEIF BytesRead = 0 THEN
PRINT "End of File"
ELSE
PRINT FBuffer$
END IF
.
RC = QFCLOSE(FHandle)
File 28
QFSETEND -- FUNCTION
This function is used to set the file pointer to the end of the file.
The file must have been opened using QFOPEN. This function is useful
to add new records to the end of an existing file. Upon return, the
RC will either be zero indicating success or non-zero indicating an
error.
The format of the call is as follows:
RC = QFSETEND(FHandle)
Example:
DEFINT A-Z
DECLARE FUNCTION QFSETEND% (Handle AS INTEGER)
FileName$ = "C:\DEMO\TEST.DAT"+CHR$(0)
Faccess = 1
RC = QFOPEN(FileName$, Faccess, FHandle)
RC = QFSETEND(FHandle)
REM New records can now be added.
RC = QFCLOSE(FHandle)
QFSETREC QFSETRECL-- FUNCTION
These functions are used to set the file pointer for random reading or
writing to a file that has been opened using QFOPEN. The calling
sequence requires that the record length and the record number to set
be passed in the call. Upon return, the RC will either be zero
indicating success or non-zero indicating an error.
The format of the call is as follows:
RC = QFSETREC(FHandle, RecLen, RecNum)
RC = QFSETRECL(FHandle, RecLen, RecNum)
Example:
DEFINT A-Z
DECLARE FUNCTION QFSETREC% (BYVAL Handle AS INTEGER, _
BYVAL RecLen AS INTEGER, _
BYVAL RecNum AS INTEGER)
DECLARE FUNCTION QFSETRECL% (BYVAL Handle AS INTEGER, _
BYVAL RecLen AS INTEGER, _
BYVAL RecNum AS LONG)
FileName$ = "C:\DEMO\TEST.DAT"+CHR$(0): Faccess = 0
RC = QFOPEN(FileName$, Faccess, FHandle)
RecLen = 50: RecNum& = 70000
RC = QFSETRECL(FHandle, RecLen, RecNum&)
REM Record 70000 can now be read.
RC = QFCLOSE(FHandle)
File 29
QFSIZE -- SUB
Returns the size of the file that was located by either QFINDF or
subsequent calls to QFINDN. See the information on these two calls
before using this routine. This routine returns the size of the file
as a long integer, make sure you ues the correct type declaration.
The format of the call is as follows:
QFSIZE SizeFile&
Example:
DEFINT A-Z
DECLARE SUB QFSIZE (Size AS LONG)
.
REM You must issue a call to either QFINDF or QFINDN first
QFSIZE SizeFile&
Print "File size is " SizeFile&
QFSTAMP -- FUNCTION
This function is used to change the date and time that a file was last
updated. It returns a zero if the request completed successfully. If
there was and error in the information passed to the function, then a
-1 is return. If there were any DOS error encountered, then a
positive number will be returned.
The format of the call is as follows:
RC = QFSTAMP(Qname$, Qtime$, Qdate$)
Example:
DEFINT A-Z
DECLARE FUNCTION QFSTAMP (Qname AS STRING, _
Qtime AS STRING, _
Qdate AS STRING)
.
Qname$ = "TEST.TST" + CHR$(0)
Qtime$ = "13:10:00"
Qdate$ = "12/12/88"
.
XX = QFSTAMP(Qname$, Qtime$, Qdate$)
.
END
File 30
QFTIME -- SUB
Returns the time that the file was created or updated. The file must
first located by a call to either QFINDF or subsequent calls to
QFINDN. See the information on these two calls before using this
routine.
The format of the call is as follows:
QFTIME Hrs, Min
Example:
DEFINT A-Z
DECLARE SUB QFTIME (Hrs AS INTEGER, _
Min AS INTEGER)
.
REM You must issue a call to either QFINDF or QFINDN first
QFTIME Hrs, Min
PRINT "The file time is " Hrs Min
File 31
QFWRITE -- FUNCTION
This function is used to Write a file which has been opened by QFOPEN.
The calling sequence requires that a string buffer be passed which
will contain the data to be written. In addition, the length of the
record to write must be passed so that the routine will know how many
bytes to write. Upon return, then actual number of bytes written will
be returned. In addition, the RC will either be zero indicating that
the write was successful or non-zero indicating an error. If the RC
is -1, there was an error in one of the parameters. If the RC is
greater than zero, DOS encountered an error writing to the file.
The format of the call is as follows:
RC = QFWRITE(FHandle, FBuffer$, WriteLen, BytesWritten)
Example:
DEFINT A-Z
DECLARE FUNCTION QFWRITE% (Handle AS INTEGER, _
Buffer AS STRING, _
WriteLen AS INTEGER, _
BytesWritten AS INTEGER)
.
REM Open file for writing
FileName$ = "C:\DEMO\TEST.DAT"+CHR$(0)
Faccess = 1
RC = QFOPEN(FileName$, Faccess, FHandle)
.
FBuffer$ = "This is a record that will be written to the file."
ReadLen = LEN(FBuffer$)
RC = QFWRITE(FHandle, FBuffer$, WriteLen, BytesWritten)
IF RC <> 0 THEN
PRINT "Error writing file"
END
ELSEIF BytesWritten <> WriteLen THEN
PRINT "Error writing file"
ELSE
PRINT "Write successful"
END IF
.
RC = QFCLOSE(FHandle)
File 32
QMOVEFIL -- FUNCTION
Moves a file. It functions the same way as QCOPYFIL but the original
file will be deleted after the copy is completed. If the file is to
be moved to a different directory on the same device, it will move
just the directory entry which will make the move much faster. If an
error is encountered, the RC will be set to -1. See QCOPYFIL for
additional information.
The format of the call is as follows:
RC = QMOVEFIL(OldFile$, NewFile$)
Example:
DEFINT A-Z
DECLARE FUNCTION QMOVEFIL% (InFileName AS STRING, _
OutFileName AS STRING)
.
REM Move a file from the A drive to the C drive
OldFile$="A:TESTFILE.TXT"+CHR$(0)
NewFile$="C:\TESTSUB\TESTFILE.TXT"+CHR$(0)
IF QMOVEFIL(OldFile$, NewFile$) = 0 THEN
PRINT "File moved"
ELSE
PRINT "File not moved"
END IF
.
.
REM Move a file to a different directory on the C drive
OldFile$="TESTFILE.TXT"+CHR$(0)
NewFile$="\TESTSUB\TESTFILE.TXT"+CHR$(0)
IF QMOVEFIL(OldFile$, NewFile$) = 0 THEN
PRINT "File moved"
ELSE
PRINT "File not moved"
END IF
File 33
QPARSEF -- FUNCTION
This function will parse a string which can contain a drive specifier,
a path, a file name and a file extention into individule pieces which
will be returned in a defined type record. This function will return
a -1 if the file name is longer than 8 characters.
The TYPE description below is contained in QB4BAS.BI and if it is
included into the program using the $INCLUDE meta command it will be
available to the program. You will still have to DIM the record using
whichever name that you wish to use.
The format of the call is as follows:
RC = PARSEF(Pstring$, Pseg, Pptr)
Example:
DEFINT A-Z
DECLARE FUNCTION QPARSEF% (Pstring AS STRING, _
BYVAL Pseg AS INTEGER, _
BYVAL Pptr AS INTEGER)
TYPE ParseType
Pdrive AS STRING * 2
Ppath AS STRING * 64
Pname AS STRING * 8
Pext AS STRING * 3
END TYPE
DIM FileRec AS ParseType
Pseg = VARSEG(FileRec)
Pptr = VARPTR(FileRec)
Pstring$ = "D:\PATH1\PATH2\THISTEST.DAT"
IF QPARSEF(Pstring$, Pseg, Pptr) = 0 THEN
PRINT "1 " + FileRec.Pdrive
PRINT "2 " + FileRec.Ppath
PRINT "3 " + FileRec.Pname
PRINT "4 " + FileRec.Pext
END IF
END
File 34
QRENAME -- FUNCTION
Rename an existing file. Can also be used to move a file from one
sub-directory to another. Requires an ASCIIZ filename without
wildcards for both files. If an error is encountered, the RC will be
set to -1.
The format of the call is as follows:
RC = QRENAME(OldFile$, NewFile$)
Example:
DEFINT A-Z
DECLARE FUNCTION QRENAME% (InFileName AS STRING, _
OutFileName AS STRING)
.
REM Rename a file
OldFile$="\FIRSTDIR\MYFILE.TXT"+CHR$(0)
NewFile$="MYFILE.DOC"+CHR$(0)
IF QRENAME(OldFile$, NewFile$) = 0 THEN
PRINT "File renamed"
ELSE
PRINT "File not renamed"
END IF
.
.
REM Move a file
OldFile$="\FIRSTDIR\MYFILE.TXT"+CHR$(0)
NewFile$="\SECONDDIR\MYFILE.TXT"+CHR$(0)
IF QRENAME(OldFile$, NewFile$) = 0 THEN
PRINT "File renamed"
ELSE
PRINT "File not renamed"
END IF
File 35
QTREAD -- FUNCTION
This function is similar to QFREAD except instead of placing the
record into a string buffer it will place the record into a user
defined record type. This allows records to be placed directly
into the type of record needed and, in addition, multiple records
can be read directly into an array of defined records.
This function requires that the file be opened with QFOPEN and
closed with QFCLOSE. The file handle returned by QFOPEN is used
to read the records. Also required by the call is the segment
address of the file buffer, the offset of the file buffer and the
number of bytes to read which is usually the length of the record
type. Upon return, the record will contain the requested record
and the actual number of bytes read. The RC will either be zero
indicating that the read was successful or non-zero indicating an
error. If the RC is -1, there was an error in one of the
parameters. If the RC is greater than zero, DOS encountered an
error reading the file.
A useful feature of this function is that block reads can be done.
A block read is reading multiple records at a time. If the record
length is 50, by setting a buffer length to 500 will cause the
routine to attempt to read 10 records. The bytes read count can
then be used to determine exactly how many records were read.
The format of the call is as follows:
RC = QTREAD(FHandle, BufSeg, BufPtr, ReadLen, BytesRead)
Example:
DEFINT A-Z
DECLARE FUNCTION QTREAD% (BYVAL Handle AS INTEGER, _
BYVAL BufSeg AS INTEGER, _
BYVAL BufPtr AS INTEGER, _
BYVAL ReadLen AS INTEGER, _
BytesRead AS INTEGER)
.
TYPE TestType
TstCode AS STRING * 2
TstName AS STRING * 34
Balance AS LONG
END TYPE
.
DIM TestRec(1 TO 100) AS TestType
.
REM Open file for reading
FileName$ = "C:\DEMO\TEST.DAT"+CHR$(0)
Faccess = 0
RC = QFOPEN(FileName$, Faccess, FHandle)
VSeg = VARSEG(TestRec(1))
VPtr = VARPTR(TestRec(1))
Rlen = LEN(TestRec(1))
File 36
Olen = 0
FOR x = 1 TO 100
RC = QTREAD(Fhandle, VSeg, VPtr, Rlen, Olen)
IF RC <> 0 THEN
PRINT "Error reading record number ", x
PRINT "Error code returned is ", RC
END
ELSEIF Olen = 0 THEN
EXIT FOR
END IF
VPtr = VPtr + Rlen
NEXT x
.
RC = QFCLOSE(FHandle)
QTWRITE -- FUNCTION
This function is similar to QFWRITE except instead of wrinting the
record into a string buffer it will write the record from a user
defined record type. This allows records to be written directly
from the type of record needed and, in addition, multiple records
can be written directly from an array of defined records.
This function requires that the file be opened with QFOPEN and
closed with QFCLOSE. The file handle returned by QFOPEN is used
to write the records. Also required by the call is the segment
address of the file buffer, the offset of the file buffer and the
number of bytes to write which is usually the length of the record
type. Upon return, the actual number of bytes written will be
returned. The RC will either be zero indicating that the write was
successful or non-zero indicating an error. If the RC is -1,
there was an error in one of the parameters. If the RC is greater
than zero, DOS encountered an error writing the file.
A useful feature of this function is that block writes can be
done. A block write is writing multiple records at a time. If the
record length is 50, by setting a buffer length to 500 will cause
the routine to attempt to write 10 records. The bytes written
count can then be used to determine exactly how many records were
written.
The format of the call is as follows:
RC = QTWRITE(FHandle, BufSeg, BufPtr, WriteLen, BytesWritten)
Example:
DEFINT A-Z
DECLARE FUNCTION QTWRITE% (BYVAL Handle AS INTEGER, _
BYVAL BufSeg AS INTEGER, _
BYVAL BufPtr AS INTEGER,
BYVAL WriteLen AS INTEGER, _
File 37
BytesWritten AS INTEGER)
.
TYPE TestType
TstCode AS STRING * 2
TstName AS STRING * 34
Balance AS LONG
END TYPE
.
DIM TestRec(1 TO 100) AS TestType
.
REM Open file for reading
FileName$ = "C:\DEMO\TEST.DAT"+CHR$(0)
Faccess = 0
RC = QFOPEN(FileName$, Faccess, FHandle)
VSeg = VARSEG(TestRec(1))
Wlen = LEN(TestRec(1))
Olen = 0
FOR x = 1 TO RecCounter
VPtr = VARPTR(TestRec(x))
RC = QTWRITE(Fhandle, VSeg, VPtr, Wlen, Olen)
IF RC <> 0 THEN
PRINT "Error writing record number ", x
PRINT "Error code returned is ", RC
END
END IF
NEXT x
.
RC = QFCLOSE(FHandle)
File 38
KEYBOARD
QALTKEY -- FUNCTION
Returns a zero to indicate that the ALT key is pressed, otherwise it
returns a -1 to indicate that the ALT key is not pressed.
The format of the call is as follows:
RC = QALTKEY()
Example:
DEFINT A-Z
DECLARE FUNCTION QALTKEY% ()
WHILE INKEY$ = ""
SELECT CASE QALTKEY
CASE -1
LOCATE 5, 2: PRINT "ALT not pressed"
CASE 0
LOCATE 5, 2: PRINT "ALT is pressed "
END SELECT
WEND
END
QCAPSKEY -- FUNCTION
Returns a zero to indicate that the CAPS LOCK key is pressed,
otherwise it returns a -1 to indicate that the CAPS LOCK key is not
pressed.
The format of the call is as follows:
RC = QCAPSKEY()
Example:
DEFINT A-Z
DECLARE FUNCTION QCAPSKEY% ()
WHILE INKEY$ = ""
SELECT CASE QCAPSKEY
CASE -1
LOCATE 5, 2: PRINT "CAPS not pressed"
CASE 0
LOCATE 5, 2: PRINT "CAPS is pressed "
END SELECT
WEND
END
Keyboard 39
QCTRLKEY -- FUNCTION
Returns a zero to indicate that the CTRL key is pressed, otherwise
it returns a -1 to indicate that the CTRL key is not pressed.
The format of the call is as follows:
RC = QCTRLKEY()
Example:
DEFINT A-Z
DECLARE FUNCTION QCTRLKEY% ()
WHILE INKEY$ = ""
SELECT CASE QCTRLKEY
CASE -1
LOCATE 7, 2: PRINT "CTRL not pressed"
CASE 0
LOCATE 7, 2: PRINT "CTRL is pressed "
END SELECT
WEND
END
QGETKEY -- FUNCTION
Returns a key which is waiting in the keyboard buffer. If the RC is
zero then the key returned is a normal ASCII key. If the RC is -1
the the key returned is an extended code. The meanings of these
codes can be found in the BASIC reference manual.
The format of the call is as follows:
RC = QGETKEY(Char$)
Example:
DEFINT A-Z
DECLARE FUNCTION QGETKEY% (Char AS STRING)
Char$ = SPACE$(1)
IF QGETKEY(Char$) = 0 THEN
PRINT "Normal key "; Char$
ELSE
PRINT "Extended code "; Char$
END IF
Keyboard 40
QINKEY -- FUNCTION
This function is a combination of both QGETKEY and QKEYSTAT. It
will set a RC to indicate if a key is waiting and what type of key
was pressed. This function works very well with SELECT CASE logic.
The format of the call is as follows:
RC = QINKEY(Char$)
Example:
DEFINT A-Z
DECLARE FUNCTION QINKEY% (Char AS STRING)
Char$ = SPACE$(1)
SELECT CASE QINKEY(CHAR$)
CASE 0
PRINT "No key waiting."
CASE 1
PRINT "Normal key "; Char$
CASE -1
PRINT "Extended code "; VAL(Char$)
CASE ELSE
PRINT "Error detected."
END SELECT
Keyboard 41
QINPUT -- FUNCTION
A keyboard input function that has full editing capabilities. By
passing a verification string, each key stroke is validated as it is
entered. It also returns a RETURN CODE which indicates which key
was pressed to exit the input routine. The input string can either
be all spaces or it can contain existing data to be updated. It
should be noted here, because of the restrictions BASIC forces on
called ASSEMBLER programs, the size of the string must be set before
calling the function. The Keys variable must be initialized with a
number from 0 to 50 which is used to set which return keys will be
used. The keys with an RC equal to or less than the passed number
will be the active return keys. See the next page for the valid
return keys. The color attribute used by the program is the Aattr
variable. The program will reverse the color attribute that is set,
which usually means that the input field will highlighted.
The format of the call is as follows:
RC = QINPUT(Ver$,InBuff$,Row,Col,Aattr,Page,Keys)
Where:
RC the return code or key that was pressed to exit.
Ver$ the string containing that valid characters.
InBuff$ the input buffer which can be pre-populated.
Row the screen row to display the buffer.
Column the screen column to display the buffer.
Aattr the action video color attribute.
Page the video display page (Valid pages are 0-3).
Keys a number from 0 to 50 to indicate the valid return keys.
Example:
DEFINT A-Z
DECLARE FUNCTION QINPUT% (VerStr AS STRING, _
Buffer AS STRING, _
BYVAL Row AS INTEGER, _
BYVAL Col AS INTEGER, _
BYVAL Attr AS INTEGER, _
BYVAL Page AS INTEGER, _
BYVAL Keys AS INTEGER)
Fgrd = 7
Bkgrd = 1
Aattr = QATTR(Fgrd,Bkgrd)
REM Only accept alpha-numeric input
Ver$ = "0123456789abcdefghijklmnopqrstuvwxyz"
Ver$ = Ver$+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
InBuff$ = SPACE$(20)
Row = 10 : Col = 20 : Page = 0 : Keys = 8
IF QINPUT(Ver$,InBuff$,Row,Col,Aattr,Page,Keys) > 0 THEN
InBuff$ = RTRIM$(InBuff$)
END IF
Keyboard 42
The following are the valid editing keys:
INSERT Toggles the insert mode and over-type mode.
DELETE Delete character at cursor.
BACKSPACE Destructive backspace.
LEFT ARROW Move the cursor to the left.
RIGHT ARROW Move the cursor to the right.
HOME Move the cursor to the beginning of the field.
END Move the cursor to the end of the field.
CTL-HOME Move cursor to the start and erase the field.
CTL-END Erase from the cursor to the end of the field.
CTL-BkSpace Erase from the cursor to the start of the field.
The following are the return codes returned upon exit:
RC - Key pressed RC - Key pressed
00 - ESC 09 - ALT HOME
01 - RETURN 10 - ALT-END
02 - CTL-RETURN 11-20 - F1 thru F10
03 - TAB 21-30 - SHIFT-F1 thru SHIFT-F10
04 - SHIFT-TAB 31-40 - CTL-F1 thru CTL-F10
05 - UP ARROW 41-50 - ALT-F1 thru ALT-F10
06 - DOWN ARROW
07 - PAGE UP
08 - PAGE DOWN
Keyboard 43
QINPUTM -- FUNCTION
This function works just like QINPUT but has the added feature of
allowing you to supply an edit mask which makes entering information
such as dates or social security numbers look much more
professional. The cursor will automatically skip over any mask
characters, the user will not have to press the tab or arrow keys.
The mask characters will not be returned in the buffer. See QINPUT
for further information on using the editing functions, it works
just the same.
The format of the call is as follows:
RC = QINPUTM(Ver$,InBuff$,Mask$,Row,Col,Aattr,Page,Keys)
Where:
RC the return code or key that was pressed to exit.
Ver$ the string containing that valid characters.
InBuff$ the input buffer which can be pre-populated.
Mask$ the edit mask to be displayed.
Row the screen row to display the buffer.
Column the screen column to display the buffer.
Aattr the action video color attribute.
Page the video display page (Valid pages are 0-3).
Keys a number from 0 to 50 to indicate the valid return keys.
Example:
DEFINT A-Z
DECLARE FUNCTION QINPUTM% (VerStr AS STRING, _
Buffer AS STRING, _
Mask AS STRING, _
BYVAL Row AS INTEGER, _
BYVAL Col AS INTEGER, _
BYVAL Attr AS INTEGER, _
BYVAL Page AS INTEGER, _
BYVAL Keys AS INTEGER)
Fgrd = 7
Bkgrd = 1
Aattr = QATTR(Fgrd,Bkgrd)
REM Only accept numeric input
VerStr$ = "0123456789"
Buffer$ = "4075551212"
BuffMask$ = "( ) - "
Row = 10 : Col = 20 : Page = 0 : Keys = 8
RC = QINPUTM(VerStr$, Buffer$, BuffMask$, Row, Col, Aattr, Page, Keys)
END
Keyboard 44
QKEYFLAG -- FUNCTION
This function returns an RC to indicate if either the ALT, CTRL,
LEFT SHIFT or the RIGHT SHIFT is pressed. By adding the various key
values together, you can check various combinations. The key values
are NO KEY-0, RIGHT SHIFT-1, LEFT SHIFT-2, CTRL-4 and ALT-8.
The format of the call is as follows:
RC = QKEYFLAG
Example:
DEFINT A-Z
DECLARE FUNCTION QKEYFLAG% ()
CLS
WHILE INKEY$ = ""
SELECT CASE QKEYFLAG
CASE 1
LOCATE 5, 2: PRINT "RIGHT SHIFT "
CASE 15
LOCATE 5, 2: PRINT "R L CTRL ALT "
END SELECT
WEND
END
QKEYSTAT -- FUNCTION
This function returns an RC to indicate if a key is waiting in the
keyboard buffer. A zero indicates no key, anything else indicates
that a key is waiting.
The format of the call is as follows:
RC = QKEYSTAT
Example:
DEFINT A-Z
DECLARE FUNCTION QKEYSTAT% ()
.
Char$ = SPACE$(1)
IF QKEYSTAT = 0 THEN
PRINT "No key waiting."
ELSE
IF QGETKEY(Char$) = 0 THEN
PRINT "Normal key "; Char$
ELSE
PRINT "Extended code "; Char$
END IF
END IF
Keyboard 45
QPOPMENU -- FUNCTION
The QPOPMENU function displays a menu within a window or frame and
obtains a selection from the user and passes back an indicator of
the users selection. The function accepts as input the screen
location where the window should be displayed allowing the menu to
be placed in a window which is a subset of the screen. The menu may
be created allowing selection by moving a selection bar, optionally
each menu entry may have an action indicator which provides a faster
selection mechanism.
The QPOPMENU function is specified as follows:
Slct=QPOPMENU(Cnt,VARSEG(Menu$(1)),VARPTR(Menu$(1)), _
Row,Col,NAttr,AAttr,HAttr,Page)
The Slct variable will contain the results of the QPOPMENU function
when control is returned to your program. This will be the number of
the menu array entry selected or, depending on the key pressed, zero
if the Esc key was depressed, -1 if the left arrow was pressed or -2
if the right arrow was pressed.
The contents of the variables passed are as follows:
Cnt The number of entries contained in the menu array which are
to be included in the menu.
VARSEG(Menu$(1)) A string array (Menu$) passed to QPOPMENU using the
VARSEG/VARPTR functions. The number (1) indicates the array
element where the menu entries begin.
VARPTR(Menu$(1)) A string array (Menu$) passed to QPOPMENU using the
VARSEG/VARPTR functions. The number (1) indicates the array
element where the menu entries begin.
Row The screen row where the menu window is to start.
Col The screen Column where the menu window is to start.
NAttr The color attribute to be used to display normal text. It
is also used for the color attribute of the window frame.
AAttr The color attribute to be used to display the action
character. Use 0,0 (black on black) if action characters are
not desired.
HAttr The color attribute to be used to display the highlighted
menu entry. When a black background is specified the
attribute will be reversed by the routine.
Page The video display page (valid pages are 0-3) to be used.
Rules:
1. No error checking is performed on the input parameters. Errors
in the input parameters will have unpredictable results.
2. The QPOPMENU routine requires the Color Graphics Adapter with a
color or monochrome (shades of gray) monitor.
3. Text placed on the screen before this function is called which
is outside of the bounds of the menu itself is left undisturbed.
Keyboard 46
4. The menu is displayed starting at the row and column specified
and extends down the screen using as many screen rows as there
are menu entries.
5. When the action attribute specified is not 0,0 (black on black)
the first character of each entry will be highlighted with the
action attribute if there are 36 or fewer menu selection
entries.
6. The highlight attribute is checked for a background other than
black. When the background is black the highlight attribute is
reversed to create a reverse video highlight bar. If the
background is not black the highlight attribute is not changed.
7. The following keys will be active for the indicated purpose
while the menu is displayed.
Esc Exit the menu without a selection, 0 is returned as
the function result.
Left Arrow Exit the menu without a selection, -1 is returned as
the function result.
Right Arrow Exit the menu without a selection, -2 is returned as
the function result.
Enter Selects highlighted item.
Up Move the highlight bar up 1 menu entry. Rolls to
the last entry if the highlight bar is already on
the first entry.
Down Move the highlight bar down 1 menu entry. Rolls to
the first entry if the highlight bar is already on
the last entry.
Home Move the highlight bar to the first menu entry.
End Move the highlight bar to the last menu entry.
x When the action attribute is specified other than
0,0 (black on black) the keys corresponding to the
characters highlighted by the action attribute may
be used to select the menu entry.
8. By checking the value returned by QPOPMENU for a -1 or -2,
programs can use this function to create pull down menus similar
to the menus that are found in the QuickBASIC 4 environment.
See the example below for a suggested way of accomplishing this.
Keyboard 47
Example:
DEFINT A-Z
DECLARE FUNCTION QPOPMENU% (BYVAL Count AS INTEGER, _
BYVAL MenuSeg AS INTEGER, _
BYVAL MenuOff AS INTEGER, _
BYVAL Row AS INTEGER, _
BYVAL Col AS INTEGER, _
BYVAL Norm AS INTEGER, _
BYVAL Actn AS INTEGER, _
BYVAL High AS INTEGER, _
BYVAL Page AS INTEGER)
OPTION BASE 1
DIM Menu$(5)
...
NAttr=QATTR(3,0)
AAttr=QATTR(4,0)
HAttr=QATTR(7,0)
...
Menu$(1)= "A - Goto Routine One"
Menu$(2)= "B - Goto Routine Two"
Menu$(3)= "C - Goto Routine Three"
Menu$(4)= "D - Goto Routine Four"
Menu$(5)= "E - Goto Routine Five"
Cnt = 5: Row = 3: Col = 3: Page = 0
RC = QPOPMENU(Cnt,VARSEG(Menu$(1)),VARPTR(Menu$(1)), _
Row,Col,NAttr,AAttr,HAttr,Page)
SELECT CASE RC
CASE -2
GOTO NextMenu
CASE -1
GOTO PrevMenu
CASE 0
GOTO GetOut
CASE 1
GOTO Rtn1
CASE 2
GOTO Rtn2
CASE 3
GOTO Rtn3
CASE 4
GOTO Rtn4
CASE 5
GOTO Rtn5
CASE ELSE
GOTO ErrorRtn
END SELECT
...
END
Keyboard 48
QMENU -- FUNCTION
The QMENU function displays a menu and obtains a selection from the
user and passes back an indicator of the users selection. The
function accepts as input the screen location where the menu should
be displayed allowing the menu to be placed in a window which is a
subset of the screen. The menu may be created allowing selection by
moving a selection bar, optionally each menu entry may have an
action indicator which provides a faster selection mechanism.
The QMENU function is specified as follows:
Slct=QMENU(Cnt,VARSEG(Menu$(1)),VARPTR(Menu$(1)), _
Row,Col,NAttr,AAttr,HAttr,Page)
The Slct variable will contain the results of the QMENU function
when control is returned to your program, the number of the menu
array entry selected or zero if the Esc key was depressed.
The contents of the variables passed are as follows:
Cnt The number of entries contained in the menu array which are
to be included in the menu.
VARSEG(Menu$(1)) A string array (Menu$) passed to QMENU using the
VARSEG/VARPTR functions. The number (1) indicates the array
element where the menu entries begin.
VARPTR(Menu$(1)) A string array (Menu$) passed to QMENU using the
VARSEG/VARPTR functions. The number (1) indicates the array
element where the menu entries begin.
Row The screen row where the menu display is to start.
Col The screen Column where the menu display is to start.
NAttr The color attribute to be used to display normal text.
AAttr The color attribute to be used to display the action
character. Use 0,0 (black on black) if action characters are
not desired.
HAttr The color attribute to be used to display the highlighted
menu entry. When a black background is specified the
attribute will be reversed by the routine.
Page The video display page (valid pages are 0-3) to be used.
Rules:
1. No error checking is performed on the input parameters. Errors
in the input parameters will have unpredictable results.
2. The QMENU routine requires the Color Graphics Adapter with a
color or monochrome (shades of gray) monitor.
3. Text placed on the screen before this function is called which
is outside of the bounds of the menu itself is left undisturbed.
As an example the QWINDOW subroutine can be used to create a
window before calling this function.
Keyboard 49
4. The menu is displayed starting at the row and column specified
and extends down the screen using as many screen rows as there
are menu entries.
5. When the action attribute specified is not 0,0 (black on black)
the first character of each entry will be highlighted with the
action attribute if there are 36 or fewer menu selection
entries.
6. The highlight attribute is checked for a background other than
black. When the background is black the highlight attribute is
reversed to create a reverse video highlight bar. If the
background is not black the highlight attribute is not changed.
7. The following keys will be active for the indicated purpose
while the menu is displayed.
Esc Exit the menu without a selection, 0 is returned as the
function result.
Enter Selects highlighted item.
Up Move the highlight bar up 1 menu entry.
Down Move the highlight bar down 1 menu entry.
Home Move the highlight bar to the first menu entry.
End Move the highlight bar to the last menu entry.
x When the action attribute is specified other than 0,0
(black on black) the keys corresponding to the
characters highlighted by the action attribute may be
used to select the menu entry.
Example:
DEFINT A-Z
DECLARE FUNCTION QMENU% (BYVAL Count AS INTEGER, _
BYVAL MenuSeg AS INTEGER, _
BYVAL MenuOff AS INTEGER, _
BYVAL Row AS INTEGER, _
BYVAL Col AS INTEGER, _
BYVAL Norm AS INTEGER, _
BYVAL Actn AS INTEGER, _
BYVAL High AS INTEGER, _
BYVAL Page AS INTEGER)
OPTION BASE 1
DIM Menu$(3)
...
NAttr=QATTR(3,0)
AAttr=QATTR(4,0)
HAttr=QATTR(7,0)
Menu$(1)= "A - Goto Routine One"
Menu$(2)= "B - Goto Routine Two"
Menu$(3)= "C - Goto Routine Three"
Cnt = 4: Row = 3: Col = 58: Page = 0
RC = QMENU(Cnt,VARSEG(Menu$(1)),VARPTR(Menu$(1)), _
Row,Col,NAttr,AAttr,HAttr,Page)
ON RC GOTO Rtn1,Rtn2,Rtn3
...
Keyboard 50
END
Keyboard 51
QMENUS -- FUNCTION
The QMENUS function displays a menu and obtains a selection from the
user and passes back an indicator of the users selection. Unlike the
QMENU function this function assumes the entire screen is used for
the menu display. The function accepts as input the screen row where
the menu is to start, the screen column is computed based on the
longest menu selection entry assuming an 80 character screen. The
displayed menu extends from the specified screen row through row 22,
rows 23 and 24 are not used and the 25th row is used as a status
line where the valid cursor movement keys are displayed. The menu
allows selection by moving a selection bar, optionally each menu
entry may have an action indicator which provides a faster selection
mechanism.
A unique feature of the QMENUS function allows a maximum of 32,767
menu selection entries to be displayed. Yes, that's right 32,767
menu selection entries. What is displayed on the screen is a subset
of the menu. The cursor movement keys allow the menu to be scrolled
in both directions, move to the next or previous screen and move to
the first or last screen.
The QMENUS function is specified as follows:
Slct=QMENUS(Cnt,VARSEG(Menu$(1)),VARPTR(Menu$(1)), _
Row,Col,NAttr,AAttr,HAttr,Page)
The Slct variable will contain the results of the QMENUS function
when control is returned to your program, the number of the menu
array entry selected or zero if the Esc key was depressed.
The contents of the variables passed are as follows:
Cnt The number of entries contained in the menu array which are
to be included in the menu. This number may range from 1 to
32,767.
VARSEG(Menu$(1)) A string array (Menu$) passed to QMENUS using the
VARSEG/VARPTR functions. The number (1) indicates the array
element where the menu entries begin.
VARPTR(Menu$(1)) A string array (Menu$) passed to QMENUS using the
VARSEG/VARPTR functions. The number (1) indicates the array
element where the menu entries begin.
Row The screen row where the menu display is to start.
NAttr The color attribute to be used to display normal text.
AAttr The color attribute to be used to display the action
character. Use 0,0 (black on black) if action characters are
not desired.
HAttr The color attribute to be used to display the highlighted
menu entry. When a black background is specified the
attribute will be reversed by the routine.
Page The video display page (valid pages are 0-3) to be used.
Keyboard 52
Rules:
1. No error checking is performed on the input parameters. Errors
in the input parameters will have unpredictable results.
2. The QMENUS function requires the Color Graphics Adapter with a
color or monochrome (shades of gray) monitor. An 80x25 screen
size is assumed.
3. Text placed on the screen before this function is called which
is outside of the bounds of the menu itself and the status line
is left undisturbed. As an example the QWINDOW subroutine can be
used to frame the screen before calling this function, however,
this frame may not use the 25th row.
4. The menu is displayed starting at the row specified and extends
down the screen to row 22. Row 25 is used as a status line to
indicate the valid cursor movement keys.
5. When the action attribute specified is not 0,0 (black on black)
the first character of each entry will be highlighted with the
action attribute if there are 36 or fewer menu selection
entries.
6. The highlight attribute is checked for a background other than
black. When the background is black the highlight attribute is
reversed to create a reverse video highlight bar. If the
background is not black the highlight attribute is not changed.
7. The following keys will be active for the indicated purpose
while the menu is displayed.
Esc Exit the menu without a selection, 0 is returned as the
function result.
Enter Selects highlighted item.
Up Move the highlight bar up 1 menu entry.
Down Move the highlight bar down 1 menu entry.
PgUp Move up 1 screen.
PgDn Move down 1 screen.
Home Move the highlight bar to the first menu entry.
End Move the highlight bar to the last menu entry.
x When the action attribute is specified other than 0,0
(black on black) the keys corresponding to the
characters highlighted by the action attribute may be
used to select the menu entry.
Keyboard 53
Example:
DEFINT A-Z
DECLARE FUNCTION QMENUS% (BYVAL Count AS INTEGER, _
BYVAL MenuSeg AS INTEGER, _
BYVAL MenuOff AS INTEGER, _
BYVAL Row AS INTEGER, _
BYVAL Norm AS INTEGER, _
BYVAL Actn AS INTEGER, _
BYVAL High AS INTEGER, _
BYVAL Page AS INTEGER)
OPTION BASE 1
DIM Menu$(5)
...
NAttr=QATTR(3,0)
AAttr=QATTR(4,0)
HAttr=QATTR(7,0)
Menu$(1)= "Apples to Oranges"
Menu$(2)= "Books to Comics"
...
Menu$(25)= "Yet Another Entry"
Menu$(26)= "Zebras to Horses"
Cnt = 26
Row = 3
Page = 0
RC = QMENUS(Cnt,VARSEG(Menu$(1)),VARPTR(Menu$(1)), _
Row,NAttr,AAttr,HAttr,Page)
SELECT CASE RC
CASE 1
...
CASE 2
...
CASE 26
...
END SELECT
END
Keyboard 54
QNUMKEY -- FUNCTION
Returns a zero to indicate that the NUM LOCK key is on, otherwise it
returns a -1 to indicate that the NUM LOCK key is not on.
The format of the call is as follows:
RC = QNUMKEY()
Example:
DEFINT A-Z
DECLARE FUNCTION QNUMKEY% ()
CLS
WHILE INKEY$ = ""
SELECT CASE QNUMKEY
CASE -1
LOCATE 5, 2: PRINT "NUM LOCK not on"
CASE 0
LOCATE 5, 2: PRINT "NUM LOCK is on "
END SELECT
WEND
END
QSCRLKEY -- FUNCTION
Returns a zero to indicate that the SCROLL LOCK key is on, otherwise
it returns a -1 to indicate that the SCROLL LOCK key is not on.
The format of the call is as follows:
RC = QSCRLKEY()
Example:
DEFINT A-Z
DECLARE FUNCTION QSCRLKEY% ()
CLS
WHILE INKEY$ = ""
SELECT CASE QSCRLKEY
CASE -1
LOCATE 5, 2: PRINT "SCROLL LOCK not on"
CASE 0
LOCATE 5, 2: PRINT "SCROLL LOCK is on "
END SELECT
WEND
END
Keyboard 55
QYESNO -- FUNCTION
Returns a value to indicate if the "Y" or "N" or the "ESC" key has
has been pressed. It will not return to the main program until one
of the above keys has been pressed. It will accept both upper and
lower case characters. The values returned are -1 for ESC, 0 for Y
and 1 for N.
The format of the call is as follows:
RC = QYESNO()
Example:
DEFINT A-Z
DECLARE FUNCTION QYESNO% ()
CLS
PRINT "Press (Y)es or (N)o --> ";
SELECT CASE QYESNO
CASE -1
PRINT "ESC was pressed"
CASE 0
PRINT "Y was pressed"
CASE 1
PRINT "N was pressed"
END SELECT
END
Keyboard 56
MISCELLANEOUS
QALARM -- SUB
Produces a pulsating alarm tone.
The format of the call is as follows:
QALARM
Example:
DEFINT A-Z
DECLARE SUB QALARM ()
QALARM
QARGC QARGV -- FUNCTION
QARGC returns the number of command line parameters used to envoke
the program. This value can be tested to determine if any
parameters were passed to the program. This routines has been
optimized for multiple executions.
QARGV returns the space delimited parameters used to invoke the
program. The parameters are placed into individual elements much
like a BASIC array. The zero element, QARGV(0), returns the fully
qualified program name, including the drive letter, of the executing
program in version 3.x of DOS. Prior versions return a null string.
Use QARGC to determine the number of command line parameters.
The format of the calls are as follows:
Parms = QARGC
Parm$ = QARGV(Parms)
Example:
DEFINT A-Z
DECLARE FUNCTION QARGC% ()
DECLARE FUNCTION QARGV$ (ParmNumber AS INTEGER)
IF QARGC > 0 THEN
FOR X = 1 TO QARGC
PRINT QARGV(X)
NEXT X
END IF
Miscellaneous 57
QBSRCHT -- FUNCTION
This function is a BINARY search routine that will search through an
array of records defined using the TYPE statement. This function
requires that the KEY being searched for is the first element of the
record and it must be in string format. It is also necessary that
the records be in sorted, ascending order. If these rules are
followed, this routine should find the KEY you are looking for in
seven or less tests of the array. This is done by constantly
spliting the search group in half. When the KEY is found, the
function will return the element number of the record. If the KEY
is not found, then a -1 is returned. All of this searching is done
in memory so the KEY will be found very quickly.
The format of the calls are as follows:
Index = QBSRCHT(Aseg, Aptr, Lrecl, RecCnt, SearchKey$)
Example:
DEFINT A-Z
TYPE DataType
DataKey AS STRING * 6
DataField1 AS STRING * 10
DataField2 AS INTEGER
DataField3 AS STRING * 5
DataField4 AS INTEGER
DataField5 AS INTEGER
END TYPE
DIM DataRec(1 TO 2000) AS DataType
.
REM Do whatever is necessary to load the DataRec array
.
DataSeg = VARSEG(DataRec(1))
DataPtr = VARPTR(DataRec(1))
DataLen = LEN(DataRec(1))
DataCnt = 2000
DataKey$ = "ABC123"
DataSub = QBSRCHT(DataSeg, DataPtr, DataLen, DataCnt, DataKey$)
IF DataSub = -1 THEN
PRINT "Key not found ==> " + DataKey$
ELSE
PRINT DataRec(DataSub).DataKey
PRINT DataRec(DataSub).DataField1
PRINT DataRec(DataSub).DataField2
PRINT DataRec(DataSub).DataField3
PRINT DataRec(DataSub).DataField4
PRINT DataRec(DataSub).DataField5
END IF
END
Miscellaneous 58
QCAPSOFF QCAPSON -- SUB
This routine will enable or disable the CAPS LOCK key on the
keyboard. This will force all input to be in upper case without
having to press the shift key. The normal functions can still be
used by pressing the shift key and then the appropriate key.
The format of the call is as follows:
QCAPSOFF
QCAPSON
Example:
DEFINT A-Z
DECLARE SUB QCAPSOFF ()
DECLARE SUB QCAPSON ()
QCAPSON
.
QCAPSOFF
QCLOCK -- SUB
Display a running clock on the screen. This is a very nice touch on
menu and update screens. The clock can be turned on and off by
flipping the "switch" (1 = on, 0 = off). The routine can also be
called again to move the location of the clock without having to
first turn it off.
The format of the call is as follows:
QCLOCK Row, Col, NAttr, Page, Switch
Example:
DEFINT A-Z
DECLARE SUB QCLOCK (BYVAL Row AS INTEGER, BYVAL Col AS INTEGER, _
BYVAL NAttr AS INTEGER, BYVAL Page AS INTEGER, _
BYVAL Switch AS INTEGER)
REM Turn the clock on
Fgrd=5 : Bkgrd=7
NAttr = QATTR(Fgrd,Bkgrd)
Row = 2: Col = 70
Switch = 1: Page = 0
QCLOCK Row, Col, NAttr, Page, Switch
.
REM Turn the clock off
Switch = 0
QCLOCK Row, Col, NAttr, Page, Switch
Miscellaneous 59
QCMDLEN -- FUNCTION
Returns the length of the command line used to envoke the program.
This function is helpful in setting the length of the string
variable needed when using QCMDLINE. If there is no command line
information, then zero is returned.
The format of the call is as follows:
RC = QCMDLEN
Example:
DEFINT A-Z
DECLARE FUNCTION QCMDLEN% ()
DECLARE FUNCTION QCMDLINE% (CmdLine AS STRING)
IF QCMDLEN = 0 THEN
PRINT "No command line parameters."
ELSE
CmdLine$ = Space$(QCMDLEN)
RC = QCMDLINE(CmdLine$)
PRINT "Command line is " CmdLine$
END IF
QCMDLINE -- FUNCTION
Returns the command line used to invoke the program. This function
works like the COMMAND$ function except it does not convert all
letters to uppercase. You do not have to pre-set the return string,
one of the correct size will be returned. A null string will be
returned it there aren't any characters passed. This function does
not work in the editor environment because it will return the
command line used to invoke QuickBasic.
The format of the call is as follows:
CmdLine$ = QCMDLINE
Example:
DEFINT A-Z
DECLARE FUNCTION QCMDLEN% ()
DECLARE FUNCTION QCMDLINE$ ()
IF QCMDLEN = 0 THEN
PRINT "No command line parameters."
ELSE
CmdLine$ = QCMDLINE
PRINT "Command line is " CmdLine$
END IF
Miscellaneous 60
QCRCCHK QCRCSET -- FUNCTION
These functions will either calculate and set the cyclical
redundancy check (CRC) value for a record or check the validity if a
record with the CRC already set. These functions will return a RC
which will be zero if OK or -1 on an error.
The format of the call is as follows:
RC = QCRCCHK(Rec$)
RC = QCRCSET(Rec$)
Example:
DEFINT A-Z
DECLARE FUNCTION QCRCCHK% (Record AS STRING)
DECLARE FUNCTION QCRCSET% (Record AS STRING)
REM Sending a record
Rec$ = Rec$+STRING$(2,0)
IF QCRCSET(Rec$) = 0 THEN
Send the record
ELSE
Error computing the CRC
END IF
.
REM Receiving a record
IF QCRCCHK(Rec$) = 0 THEN
Rec$ = LEFT$(Rec$,LEN(Rec$)-2)
ELSE
Error in CRC, request a resend
END IF
QDOSVER -- SUB
Retrieve the MS-DOS version. The major version is returned in the
first parm and the minor version in the second parm.
The format of the call is as follows:
QDOSVER Lparm, Rparm
Example:
DEFINT A-Z
DECLARE SUB QDOSVER (Major AS INTEGER, _
Minor AS INTEGER)
QDOSVER Lparm, Rparm
PRINT Lparm, Rparm
Miscellaneous 61
QEMSSIZE -- SUB
Returns both the total and free amounts of memory in kilobytes that
is available on an EMS board. If no board is installed or the EMS
driver is not loaded, it will return -1 for both.
The format of the call is as follows:
QEMSSIZE Total, Free
Example:
DEFINT A-Z
DECLARE SUB QEMSSIZE (Total AS INTEGER, _
Free AS INTEGER)
QEMSSIZE Total, Free
IF Total > 0 THEN
PRINT "Total is" Total " Free is" Free
ELSE
PRINT "EMS is not available."
END IF
QEMSEXIST -- FUNCTION
Returns a return code indicating if an EMS board and driver is
installed. If either is unavailable it will return -1 otherwise it
returns a zero.
The format of the call is as follows:
RC = QEMSEXIST()
Example:
DEFINT A-Z
DECLARE FUNCTION QEMSSIZE% ()
IF QEMSEXIST() = 0 THEN
PRINT "EMS is available"
ELSE
PRINT "EMS is not available."
END IF
Miscellaneous 62
QEQUIPMENT -- SUB
Returns information on the hardware configuration of the computer.
The information returned is the memory installed in kilobytes, the
number of parallel ports (0-3), the number of serial ports (0-7) and
the number of game ports (0-1).
The format of the call is as follows:
QEQUIPMENT Memory, Parallel, Serial, Game
Example:
DEFINT A-Z
DECLARE SUB QEQUIPMENT (Memory AS INTEGER, _
Parallel AS INTEGER, _
Serial AS INTEGER, _
Game AS INTEGER)
QEQUIPMENT Memory, Parallel, Serial, Game
PRINT Memory, Parallel, Serial, Game
QEXIT -- SUB
This routine provides a method of letting you set the DOS errorlevel
and exiting your program. There may be cases where it may cause
some problems so use it with care. This routine is used instead of
the BASIC commands "END" or "SYSTEM". The errorlevel can be set to
any value between 0 and 255. You must also be sure that any open
files are closed before calling this routine because it does not
return, it jumps straight to DOS. This routine can now be called
from the programming environment, it basically will perform a nop,
you should include a BASIC "END" or "SYSTEM" on the next line.
The format of the call is as follows:
QEXIT ErrorLevel
Example:
DEFINT A-Z
DECLARE SUB QEXIT (ErrorLevel AS INTEGER)
.
ErrorExit:
CLOSE
ErrorLevel = 16
QEXIT ErrorLevel
END
Miscellaneous 63
QEXEC -- FUNCTION
This function is used to execute another program without leaving the
the current program. This function will in effect, put the current
program on hold, shrink the memory that is being used to a minimum,
run the requested program, return a return code or errorlevel if the
executed program returns one and then return the memory usage back
to the way it was in the beginning of the routine.
When this function is executed it must be passed a string which
contains the full file name, with extention (.EXE or .COM). In
addition, command line parameters can be included in the string,
just leave one space after the file name. There are special rules
if you want to run a .BAT file, see the example below.
There are a few error codes that can be returned by the routine that
may need special attention. The first error is issued if QEXEC
finds an error, the remaining error codes are returned if DOS
encounters an error. Any error code greater than zero can be
assumed to be returned by the program that was executed.
-1 An error was encountered in the passed string.
-255 Invalid function
-254 File not found
-248 Not enough memory
-246 Bad environment
-245 Bad format
A little explanation should be given to the following routine as it
contains some routines from this library. The first routine,
QREPLACE changes all occurances of one character to another
character. This is used to change all occurances of ";" to a space
that I can then parse to the PATH string using QWORD and QWORDS in a
FOR loop, concatinating it to the file name and then using QEXIST to
see if the file exists. If it does, I break out of the FOR loop and
then invoke QEXEC. The resulting return code will be printed to the
screen. If the file is not found, then the routine just exits.
Miscellaneous 64
The format of the call is as follows:
RC = QEXEC (PgmStr$)
Example:
DEFINT A-Z
' $INCLUDE: 'QB4BAS.BI'
DECLARE FUNCTION QEXEC% (PgmStr AS STRING)
Tmp$ = "SDIR.COM"
Work$ = ENVIRON$("PATH")
QREPLACE Work$, ";", " "
FOR X = 1 TO QWORDS(Work$)
Work2$ = QWORD(Work$, X) + "\" + Tmp$
IF QEXIST(Work2$ + CHR$(0)) = 0 THEN
EXIT FOR
ELSE
Work2$ = ""
END IF
NEXT X
IF Work2$ <> "" THEN
PRINT QEXEC(Work2$)
END IF
END
This second example shows the necessary format to execute a .BAT
program. This requires that another copy of COMMAND.COM be first
loaded using the /C option and then the .BAT file name is passed in
the command tail.
DEFINT A-Z
DECLARE FUNCTION QEXEC% (PgmStr AS STRING)
Work1$ = ENVIRON$("COMSPEC")
Work2$ = " /C THISTEST.BAT"
Work$ = Work1$ + Work2$
RC = QEXEC(Work$)
END
Miscellaneous 65
QINPORT -- FUNCTION
This function works just like the BASIC INP function except it is
slightly faster. The port must be a number between 0 and 65,535 and
can be either and integer or in BASIC HEX notation. The function
will return the value that was read from the port requested.
The format of the call is as follows:
PortVal = QINPORT(&H6A)
Example:
DEFINT A-Z
DECLARE FUNCTION QINPORT% (BYVAL Port AS INTEGER)
.
.
PortVal = QINPORT(&H6A)
PRINT PortVal
QMININT QMAXINT -- FUNCTION
These functions will return either the smaller of two integers for
QMININT or the larger of two integers for QMAXINT. This will allow
numbers to be selected with a minimum of code.
The format of the call is as follows:
NewMin = QMININT(Number1, Number2)
NewMax = QMAXINT(Number1, Number2)
Example:
DEFINT A-Z
DECLARE FUNCTION QMININT% (BYVAL NUM1 AS INTEGER, BYVAL NUM1 AS INTEGER)
DECLARE FUNCTION QMAXINT% (BYVAL NUM1 AS INTEGER, BYVAL NUM1 AS INTEGER)
.
NewMin = QMININT(600, 682)
NewMax = QMAXINT(600, 682)
PRINT "The smaller number is " NewMin
PRINT "The larger number is " NewMax
END
Miscellaneous 66
QMINLONG QMAXLONG -- FUNCTION
These functions will return either the smaller of two long integers
for QMININT or the larger of two long integers for QMAXINT. This
will allow numbers to be selected with a minimum of code.
The format of the call is as follows:
NewMin = QMINLONG(Number1, Number2)
NewMax = QMAXLONG(Number1, Number2)
Example:
DEFLONG A-Z
DECLARE FUNCTION QMINLONG& (BYVAL NUM1 AS LONG, BYVAL NUM1 AS LONG)
DECLARE FUNCTION QMAXLONG& (BYVAL NUM1 AS LONG, BYVAL NUM1 AS LONG)
.
NewMin = QMININT(600000, 682000)
NewMax = QMAXINT(600000, 682000)
PRINT "The smaller number is " NewMin
PRINT "The larger number is " NewMax
END
QNUMLOCKOFF QNUMLOCKON -- SUB
This routine will enable or disable the NUMLOCK key on the keyboard.
This will allow the numeric keypad to be used without having to
press the shift key. The normal functions can still be used by
pressing the shift key and then the appropriate key.
The format of the call is as follows:
QNUMLOCKOFF
QNUMLOCKON
Example:
DEFINT A-Z
DECLARE SUB QNUMLOCKOFF ()
DECLARE SUB QNUMLOCKON ()
QNUMLOCKON
.
QNUMLOCKOFF
Miscellaneous 67
QPRINTER -- FUNCTION
Check to see if the first printer device is active or on. The RC
will be 0 if it is online or -1 if it is not. Care must be taken
when using this function because some print spoolers may return 0
when the printer is actually offline.
The format of the call is as follows:
RC = QPRINTER
Example:
DEFINT A-Z
DECLARE FUNCTION QPRINTER% ()
.
IF QPRINTER = 0 THEN
PRINT "Printer is online"
ELSE
PRINT "Printer is offline"
END IF
QPRTSCRN -- SUB
Prints the current screen display to the current printer device.
This routine functions exactly the same as pressing the Shift-PrtSc
keys from the keyboard.
The format of the call is as follows:
QPRTSCRN
Example:
DEFINT A-Z
DECLARE SUB QPRTSCRN ()
QPRTSCRN
Miscellaneous 68
QPRTSCRNOFF QPRTSCRNON -- SUB
These routines will enable or disable the PRTSCRN key on the
keyboard. This will prevent anyone from accidently pressing the
wrong key while the program is executing.
The format of the call is as follows:
QPRTSCRNOFF
QPRTSCRNON
Example:
DECLARE SUB QPRTSCRNOFF ()
DECLARE SUB QPRTSCRNON ()
QPRTSCRNOFF
.
QPRTSCRNON
QPAUSE -- SUB
Pause for a given number of seconds. It uses the system clock and
will pause for the same amount of time regardless of the CPU used.
The format of the call is as follows:
QPAUSE Seconds
Example:
DEFINT A-Z
DECLARE SUB QPAUSE (BYVAL Seconds AS INTEGER)
Seconds = 15
QPAUSE Seconds
Miscellaneous 69
QPAUSE18 -- SUB
Pause for a given number of eighteenths of a second. The actual
amount may vary depending on the PC that you are using.
The format of the call is as follows:
QPAUSE18 Count
Example:
DEFINT A-Z
DECLARE SUB QPAUSE18 (BYVAL Count AS INTEGER)
REM Pause for 1/2 second.
Count = 9
QPAUSE18 Count
QREBOOT -- SUB
Forces the system to do an immediate reboot. This program can be
useful in programs that change the CONFIG.SYS file which requires
that the system be rebooted to take effect.
The format of the call is as follows:
QREBOOT
Example:
DEFINT A-Z
DECLARE SUB QREBOOT ()
REM Replace the config.sys file
RC = QCOPYFIL("CONFIG.NEW" + CHR$(0), "CONFIG.SYS + CHR$(0))
QREBOOT
Miscellaneous 70
QSHIFTIL QSHIFTIR -- FUNCTION
These functions will take an integer and shift the bits the
requested number of bits either left or right and return the new
number. This will increase or decrease the number by the power of
two.
The format of the call is as follows:
Num1 = QSHIFTIL(Number, 1)
Num2 = QSHIFTIR(Number, 1)
Example:
DEFINT A-Z
DECLARE FUNCTION QSHIFTIL% (BYVAL Number AS INTEGER, _
BYVAL Shift AS INTEGER)
DECLARE FUNCTION QSHIFTIR% (BYVAL Number AS INTEGER, _
BYVAL Shift AS INTEGER)
.
Num1 = QSHIFTIL(5,1)
Num2 = QSHIFTIL(10,1)
PRINT Num1, Num2
QSHIFTLL QSHIFTLR -- FUNCTION
These functions will take a long integer and shift the bits the
requested number of bits either left or right and return the new
number. This will increase or decrease the number by the power of
two.
The format of the call is as follows:
Num1 = QSHIFTLL(Number, 1)
Num2 = QSHIFTLR(Number, 1)
Example:
DEFLONG A-Z
DECLARE FUNCTION QSHIFTIL& (BYVAL Number AS LONG, _
BYVAL Shift AS INTEGER)
DECLARE FUNCTION QSHIFTIR& (BYVAL Number AS LONG, _
BYVAL Shift AS INTEGER)
.
Num1 = QSHIFTLL(65536,1)
Num2 = QSHIFTLL(262144,1)
PRINT Num1, Num2
Miscellaneous 71
QSCROLLOFF QSCROLLON -- SUB
This routine will enable or disable the SCROLL LOCK key on the
keyboard.
The format of the call is as follows:
QSCROLLOFF
QSCROLLON
Example:
DEFINT A-Z
DECLARE SUB QSCROLLOFF ()
DECLARE SUB QSCROLLON ()
QSCROLLON
.
QSCROLLOFF
QSHARE -- FUNCTION
This function returns a return code which indicates if the program
SHARE has been loaded or not. The following are the return codes
that will be returned, -1 indicates a version of DOS less than
3.10. If a zero is returned, then SHARE has been loaded, otherwise
a one is returned to indicate that SHARE is not present.
The format of the call is as follows:
RC = QSHARE
Example:
DEFINT A-Z
DECLARE FUNCTION QSHARE ()
.
PRINT QSHARE
Miscellaneous 72
QTIME -- SUB
Returns 4 integers which contain the current hours, minutes and
seconds of the day as well as the total number of seconds since
midnight.
The format of the call is as follows:
QTIME Hours, Minutes, Seconds, TotSeconds
Example:
DEFINT A-Z
DECLARE SUB QTIME (Hours AS INTEGER, _
Minutes AS INTEGER, _
Seconds AS INTEGER, _
TotSeconds AS LONG)
.
QTIME Hours, Minutes, Seconds, TotSeconds
QTEMPC -- FUNCTION
This function will convert the inputed fahrenheit temperature and
convert it into centigrade.
The format of the call is as follows:
TempC = QTEMPC(TempF);
Example:
DEFINT A-Z
DECLARE FUNCTION QTEMPC% (BYVAL Fahrenheit AS INTEGER)
FOR N1 = 32 TO 212
PRINT QTEMPC(N1);
NEXT N1
END
Miscellaneous 73
QTEMPF -- FUNCTION
This function will convert the inputed centigrade temperature and
convert it into fahrenheit.
The format of the call is as follows:
TempF = QTEMPF(TempC);
Example:
DEFINT A-Z
DECLARE FUNCTION QTEMPF% (BYVAL Fahrenheit AS INTEGER)
FOR N1 = 0 TO 100
PRINT QTEMPF(N1);
NEXT N1
END
QVERIFY -- FUNCTION
Returns an integer which indicates if the DOS write verify flag is
on or off. If the value is zero then the verify flag is turned off.
If the value is one then the flag is turned on.
The format of the call is as follows:
Flag = QVERIFY
Example:
DEFINT A-Z
DECLARE FUNCTION QVERIFY% ()
.
PRINT "The write verify flag is ";
IF QVERIFY = 0 THEN
PRINT "OFF"
ELSE
PRINT "ON"
END IF
Miscellaneous 74
QVERIFYOFF QVERIFYON -- SUB
These subroutines will either turn the verify flag on or off. If the
verify flag is turned on, writing to files will take longer.
The format of the call is as follows:
QVERIFYOFF
QVERIFYON
Example:
DEFINT A-Z
DECLARE SUB QVERIFYOFF()
DECLARE SUB QVERIFYON()
DECLARE FUNCTION QVERIFY% ()
.
CLS
PRINT QVERIFY
QVERIFYON
PRINT QVERIFY
QVERIFYOFF
PRINT QVERIFY
END
Q8087 -- FUNCTION
Returns an integer which indicates if an 80x87 math coprocessor is
present. If the value is zero then a coprocessor is present. A
value of -1 is returned if a coprocessor is not present.
The format of the call is as follows:
Flag = Q8087
Example:
DEFINT A-Z
DECLARE FUNCTION Q8087% ()
IF Q8087 = 0 THEN
PRINT "Co-processor is present"
ELSE
PRINT "Co-processor is not present"
END IF
END
Miscellaneous 75
MOUSE
QMHIDE -- SUB
Removes the mouse pointer from the screen. The mouse driver continues
to track the mouse position.
The format of the call is as follows:
QMHIDE
Example:
DEFINT A-Z
DECLARE SUB QMHIDE ()
Buttons = QMSTATUS
QMSHOW
..
REM Do what you want with the MOUSE
..
..
QMHIDE
END
QMLOC -- FUNCTION
Returns the current mouse button status and the X/Y pointer
positon. This function will always return the current location,
If you need to know what the location was when a key was pressed,
use QMPRESS.
The format of the call is as follows:
Buttons = QMLOC(Xloc, Yloc)
Example:
DEFINT A-Z
DECLARE FUNCTION QMLOC% (Xloc AS INTEGER, Yloc AS INTEGER)
Buttons = QMSTATUS
QMSHOW
..
Buttons = QMLOC(Xloc, Yloc)
PRINT Buttons, Xloc, Yloc
..
QMHIDE
Mouse 76
QMPRESS -- FUNCTION
Returns the current status of all mouse buttons, and the number of
presses and position of the last press for a specified mouse
button. The press counter for the button is reset to zero.
The format of the call is as follows:
Button = QMPRESS(MouseKey, PushCounter, Xloc, Yloc)
Example:
DEFINT A-Z
DECLARE FUNCTION QMPRESS% (BYVAL Mkey AS INTEGER, Ctr AS INTEGER,
Xloc AS INTEGER, Yloc AS INTEGER)
Buttons = QMSTATUS
QMSHOW
..
MouseKey = 1
Button1 = QMPRESS(MouseKey, PushCounter1, Xloc1, Yloc1)
MouseKey = 2
Button2 = QMPRESS(MouseKey, PushCounter2, Xloc2, Yloc2)
PRINT Button1, PushCounter1, Xloc1, Yloc1
PRINT Button2, PushCounter2, Xloc2, Yloc2
..
QMHIDE
QMSET -- SUB
Sets the position of the mouse pointer. The pointer is displayed
at the new position unless it has been hidden with QMHIDE.
The format of the call is as follows:
QMSET Xloc, Yloc
Example:
DEFINT A-Z
DECLARE SUB QMSET (Xloc, Yloc)
Buttons = QMSTATUS
QMSHOW
..
Xloc = 50
Yloc = 70
QMSET Xloc, Yloc
..
QMHIDE
Mouse 77
QMSHOW -- SUB
Displays the mouse pointer on the screen provided the mouse driver
is running.
The format of the call is as follows:
QMSHOW
Example:
DEFINT A-Z
DECLARE SUB QMSHOW ()
Buttons = QMSTATUS
QMSHOW
..
REM Do what you want with the MOUSE
..
..
QMHIDE
END
QMSTATUS -- FUNCTION
Initializes the mouse driver and returns the driver status. If
the status code returned is -1 then the mouse driver is not
available, otherwise the number of mouse buttons are returned.
The format of the call is as follows:
Buttons = QMSTATUS
Example:
DEFINT A-Z
DECLARE FUNCTION QMSTATUS% ()
Buttons = QMSTATUS
QMSHOW
..
REM Do what you want with the MOUSE
..
..
QMHIDE
END
Mouse 78
STRING
QCAPIT -- SUB
This routine will take an input string and change the first
character to upper case and the remainder of the string will be
changed to lower case. If the second character of the string is
an apostrophe ('), then the third character will also be converted
to an upper case character.
The format of the call is as follows:
QCAPIT TstStr$
Example:
DEFINT A-Z
DECLARE SUB QCAPIT (StringName AS STRING)
TstStr$="harold"
QCAPIT TstStr$
PRINT TstStr$
.
TstStr$="o'brian"
QCAPIT TstStr$
PRINT TstStr$
END
QCENTER -- SUB
This routine will take an input string that has been padded with
spaces and center the test. It does not matter if the padding is
on the left or the right of the text and the text can have
multiple words. The way that this routine works is to first left
justify all text and then to center the text.
The format of the call is as follows:
QCENTER TstStr$
Example:
DEFINT A-Z
DECLARE SUB QCENTER (StringName AS STRING)
TstStr$ = "Harold Thomson" + SPACE$(30)
QCENTER TstStr$
PRINT TstStr$
END
String 79
QCHARTYP -- FUNCTION
This function is used to determine if an input string contains
valid characters which are inputed to the function via a string of
valid characters. If the inputed characters are valid, a zero (0)
is returned otherwise the position of the first invalid characters
is returned. If either string is null ("") then a -1 is returned.
The format of the call is as follows:
RC = QCHARTYP(TstStr$, ValStr$)
Example:
DEFINT A-Z
DECLARE FUNCTION QCHARTYP% (TstStr AS STRING, ValStr AS STRING)
TstStr$="abbc2254621"
ValStr$="abcdefgABCDEFG12345"
IF QCHARTYP(TstStr$, ValStr$) = 0 THEN
PRINT "The string is valid"
ELSE
PRINT "The string is invalid"
END
QDELIM -- FUNCTION
Returns the n'th word in a comma delimited string. If the
requested word is null (,,) then a null string is returned.
The format of the call is as follows:
NewStr$ = QDELIM(TstStr$, Index)
Example:
DEFINT A-Z
DECLARE FUNCTION QDELIM$ (StringName AS STRING,
BYVAL Indx AS INTEGER)
TstStr$="This,,string,contains,five,words"
Index = 5
NewStr$ = QDELIM(TstStr$, Indx)
IF NewStr$ <> "" THEN
PRINT "The fifth word of the string is " NewStr$
ELSE
PRINT "Error in QDELIM"
END
String 80
QEXTRACT -- FUNCTION
Returns the n'th word from a string based upon a delimiter which
is passed in the call. A null string is returned if an error is
encountered.
The format of the call is as follows:
NewString$ = QEXTRACT(TstStr$, Delim$, Index)
Example:
DEFINT A-Z
DECLARE FUNCTION QEXTRACT$ (StringName AS STRING, Delim AS STRING, _
BYVAL Index AS INTEGER)
TstStr$="This@string@contains@five@words"
Index = 4: Delim$ = "@"
NewStr$ = QEXTRACT(TstStr$, Delim$, Index)
IF NewStr$ <> "" THEN
PRINT "The fourth word of the string is " NewStr$
ELSE
PRINT "Error in QEXTRACT"
END
QFORMAT -- FUNCTION
This function will return a formatted string using two input
strings. The first string is the unformatted input string and the
second string is the format mask string. This routine can be used
to print such things as a SSN (social security number), telephone
numbers and money amounts that are in a string format. The
important thing to remember is that the spaces in the mask string
are where the data from the input string will be printed. If you
want a space in the formatted string, what I have done is include
an ASCII 255 in the mask string, QFORMAT will not print in this
location.
The format of the call is as follows:
NewString$ = QFORMAT(TstStr$, Mask$)
Example:
DEFINT A-Z
DECLARE FUNCTION QFORMAT$ (StringName AS STRING, Mask AS STRING)
TstStr$="4073513737"
Mask$ = "( ) - "
NewStr$ = QFORMAT(TstStr$, Mask$)
PRINT NewStr$ ' Should print (407)351-3737
END
String 81
QHIGHBIT -- SUB
This subroutine will turn off the high order or leftmost bit of
every character in a string. This may be useful when reading some
files which have been created by some word processing programs
such as Wordstar.
The format of the call is as follows:
QHIGHBIT TstStr$
Example:
DEFINT A-Z
DECLARE SUB QHIGHBIT (TstStr AS STRING)
TstStr$="ÇàÄÜ"
QHIGHBIT TstStr$
PRINT "This string now reads " TstStr$
END
QINSTR -- FUNCTION
Returns the position of a character in a string based upon a
supplied character which is passed in the call. In addition, the
desired number of the character occurence is passed. Returns a -1
if an error is encountered or the character is not found.
The format of the call is as follows:
RC = QINSTR(TstStr$, Delim$, Index)
Example:
DEFINT A-Z
DECLARE FUNCTION QINSTR% (TstStr AS STRING, _
Delim AS STRING, _
BYVAL Index AS INTEGER)
TstStr$="aaa( ( ( ) ) )aaa"
Index = 2
Delim$ = "("
IF QINSTR(TstStr$, Delim$, Index) > 0 THEN
PRINT "The character position is " Index
ELSE
PRINT "Error in QINSTR Call"
END IF
END
String 82
QLEN -- FUNCTION
Returns the length of a string. This routine works just like the
BASIC LEN() function but is somewhat faster. This functions works
with variable length strings as well as fixed length strings. It
also works with strings defined with the BASIC TYPE statement.
The format of the call is as follows:
StrLen = QLEN(TstStr$)
Example:
DEFINT A-Z
DECLARE FUNCTION QLEN% (TstStr AS STRING)
TstStr$="1234567890"
PRINT "The length of the string is " QLEN(TstStr$)
QMID -- FUNCTION
Overlays the contents of string 2 with the contents of string 1
starting at the character pointed to by start. This function
returns a zero if it is successful, if start if beyond the string
2 length or the length of string 1 extends beyond string 2 a -1 is
returned.
The format of the call is as follows:
RC = QMID(Str1$, Str2$, Start)
Example:
DEFINT A-Z
DECLARE FUNCTION QMID% (Str1 AS STRING, _
Str2 AS STRING, _
BYVAL Start AS INTEGER)
Str1$ = "zzzzzzzzzz": Str2$ = "aaaXxxxxxxxxxxXaaa"
Start = 5
XX = QMID(Str1$, Str2$, Start)
PRINT Str2$
END
String 83
QMOVREC -- FUNCTION
Move a record defined with the TYPE function to a BASIC string
variable. Currently, only individule fields can be moved to a
string.
The format of the call is as follows:
OutString$ = QMOVREC(PtrR, LenR)
Example:
DEFINT A-Z
DECLARE FUNCTION QMOVREC$ (BYVAL PtrR AS INTEGER, _
BYVAL LenR AS INTEGER)
TYPE TestType
Fld1 AS STRING * 5
Fld2 AS STRING * 10
END TYPE
DIM TestRec AS TestType
TestRec.Fld1 = "AAAAA": TestRec.Fld2 = "0123456789"
PtrR = VARPTR(TestRec): LenR = LEN(TestRec)
Buffer$ = QMOVREC(PrtR, LenR)
PRINT Buffer$
QMOVSTR -- SUB
Moves a BASIC string variable to a record defined with the TYPE
function. Currently, strings can only be moved to individule
fields.
The format of the call is as follows:
QMOVSTR PtrR, LenR, OutString$
Example:
DEFINT A-Z
DECLARE SUB QMOVSTR (BYVAL PtrR AS INTEGER, BYVAL LenR AS INTEGER, _
Buffer AS STRING)
TYPE TestType
Fld1 AS STRING * 5
Fld2 AS STRING * 10
END TYPE
DIM TestRec AS TestType
PtrR = VARPTR(TestRec): LenR = LEN(TestRec)
Buffer$ = "AAAAA0123456789"
QMOVSTR PrtR, LenR, Buffer$
PRINT TestRec.Fld1, TestRec.Fld2
String 84
QREPLACE -- SUB
Replace the character specified by OLD$ with the character
specified by NEW$. These two characters must be only one
character long or the routine returns without changing the string.
The format of the call is as follows:
QREPLACE TstStr$, Old$, New$
Example:
DEFINT A-Z
DECLARE SUB QREPLACE (StringName AS STRING, _
OldStr AS STRING, _
NewStr AS STRING)
TstStr$="05-29-87"
Old$ = "-"
New$ = "/"
QREPLACE TstStr$, Old$, New$
PRINT TstStr$
QREVERSE -- FUNCTION
This function returns a new string with all characters of the
input string reversed. In other words, "ABCD" becomes "DCBA". It
is not necessary to supply an output string.
The format of the call is as follows:
NewStr$ = QREVERSE(OldStr$)
Example:
DEFINT A-Z
DECLARE FUNCTION QREVERSE$ (StringName AS STRING)
TstStr$ = "This is a test string"
NewStr$ = QREVERSE(TstStr$)
PRINT NewStr$
REM The results are ==> "gnirts tset a si sihT"
String 85
QRINSTR -- FUNCTION
This routine is simular to QINSTR except it starts the search from
the end of the string and searches towards the beginning. It will
return the position of a character in a string based upon a
supplied character which is passed in the call. In addition, the
desired number of the character occurence is passed. Returns a -1
if an error is encountered or the character is not found.
The format of the call is as follows:
RC = QRINSTR(TstStr$, Delim$, Index)
Example:
DEFINT A-Z
DECLARE FUNCTION QRINSTR% (TstStr AS STRING, _
Delim AS STRING, _
BYVAL Index AS INTEGER)
TstStr$="aaa( ( ( ) ) )aaa"
Index = 2
Delim$ = ")"
IF QRINSTR(TstStr$, Delim$, Index) > 0 THEN
PRINT "The character position is " Index
ELSE
PRINT "Error in QRINSTR Call"
END
QSTRIP -- FUNCTION
This routine removes all occurances of blanks or spaces from a
string and returns a new string.
The format of the call is as follows:
NewString$ = QSTRIP(StringName$)
Example:
DEFINT A-Z
DECLARE FUNCTION QSTRIP$ (StringName AS STRING)
StringName$ = "This is a test string for QSTRIP"
NewString$ = QSTRIP(StringName$)
PRINT NewString$
String 86
QSTRPCHR -- FUNCTION
This routine removes all of the occurances of the requested
character from a string and return it in a new string.
The format of the call is as follows:
NewString$ = QSTRPCHR(StringName$, StripChr$)
Example:
DEFINT A-Z
DECLARE FUNCTION QSTRPCHR$ (StringName AS STRING, _
StripChr AS STRING)
StringName$ = "This#is#a#test#string#for#QSTRPCHR"
StripChr$ = "#"
NewString$ = QSTRPCHR(StringName$, StripChr$)
PRINT NewString$
QSUBSTR -- FUNCTION
This function copies a portion of FromStr starting at the Start
position for Length number of characters and places it in ToStr$.
A null string is returned if it was unsuccessful.
The format of the call is as follows:
ToStr$ = QSUBSTR(FromStr$, Start, Length)
Example:
DEFINT A-Z
DECLARE FUNCTION QSUBSTR$ (FromStr AS STRING, _
BYVAL Start AS INTEGER, _
BYVAL Length AS INTEGER)
.
FromStr$ = "aaaXxxxxxxxxxxXaaa"
Start = 4
Length = 10
ToStr$ = QSUBSTR(FromStr$, Start, Length)
PRINT ToStr$
END
String 87
QWORD -- FUNCTION
Returns a string which contains the n'th space delimited word from
a string. Returns a null string if an error is encountered.
The format of the call is as follows:
Found$ = QWORD(TstStr$, Index)
Example:
DEFINT A-Z
DECLARE FUNCTION QWORD$ (StringName AS STRING, _
BYVAL Index AS INTEGER)
TstStr$="This string contains five words"
Index = 4
Found$ = QWORD(TstStr$, Index)
IF Found$ <> "" THEN
PRINT "The fourth word of the string is " Found$
ELSE
PRINT "Error in QWORD"
END
QWORDS -- FUNCTION
Returns the number of space delimited words in a string. If the
string is null or all spaces, it will return zero.
The format of the call is as follows:
Number.Of.Words = QWORDS(TstStr$)
Example:
DEFINT A-Z
DECLARE FUNCTION QWORDS% (StringName AS STRING)
TstStr$="This string contains five words"
IF QWORDS(TstStr$) > 0 THEN
PRINT "The number of words in this string is " QWORDS(TstStr$)
ELSE
PRINT "Error in QWORDS"
END
String 88
SUB-DIRECTORY
QCHDIR -- FUNCTION
Change the current sub-directory. Works the same as the DOS CHDIR
command except a return code is set to zero (0) if successful.
The format of the call is as follows:
RC = QCHDIR(ChFile$)
Example:
DEFINT A-Z
DECLARE FUNCTION QCHDIR% (DirName AS STRING)
ChFile$="C:\NEWSUB\DIR"+CHR$(0)
IF QCHDIR(ChFile$) = 0 THEN
PRINT "New directory set"
ELSE
PRINT "New directory not selected"
END IF
QCHKDIR -- FUNCTION
Checks to see if the requested sub-directory exists. The return
code is set to -1 if the directory doesn't exist.
The format of the call is as follows:
RC = QCHKDIR(ChkFile$)
Example:
DEFINT A-Z
DECLARE FUNCTION QCHKDIR% (DirName AS STRING)
ChkFile$="C:\CHKSUB\DIR"+CHR$(0)
IF QCHKDIR(ChkFile$) = 0 THEN
PRINT "Sub-directory exists"
ELSE
PRINT "The requested sub-directory doesn't exist"
END IF
Sub-Directory 89
QGETDIR -- FUNCTION
Returns the current sub-directory. It is no longer necessary to
pre-allocate the return string.
The format of the call is as follows:
DirStr$ = QGETDIR
Example:
DEFINT A-Z
DECLARE FUNCTION QGETDIR$ ()
DirStr$ = QGETDIR
PRINT "The current directory is " DirStr$
QMKDIR -- FUNCTION
Create a new sub-directory. Works the same as the DOS MKDIR
command except a return code is set to -1 if the directory wasn't
created.
The format of the call is as follows:
RC = QMKDIR(MkFile$)
Example:
DEFINT A-Z
DECLARE FUNCTION QMKDIR% (DirName AS STRING)
MkFile$ = "NEWSUBDIR"+CHR$(0)
IF QMKDIR(MkFile$) = 0 THEN PRINT "Sub-directory created."
QRMDIR -- FUNCTION
Deletes an existing sub-directory. Same as the DOS RMDIR command
except the RC will be set to -1 if the directory not found.
The format of the call is as follows:
RC = QRMDIR(RmFile$)
Example:
DEFINT A-Z
DECLARE FUNCTION QRMDIR% (DirName AS STRING)
RmFile$ = "OLDSUBDIR"+CHR$(0)
IF QRMDIR(RmFile$) = 0 THEN PRINT "Sub-directory deleted."
Sub-Directory 90
VIDEO
QANSIPRT -- SUB
Print a string to the screen including any ANSI escape characters
sequences. The BASIC LOCATE command must be used before the call
to set the line and column before printing. This routine uses DOS
calls so it will print slower than QPRT or QBPRT.
The format of the call is as follows:
QANSIPRT CharString$
Example:
DEFINT A-Z
DECLARE SUB QANSIPRT (PrtString AS STRING)
LOCATE 3,2
QANSIPRT CharString$
QATTR -- FUNCTION
Calculates the color attribute for routines such as QPRT, QWINDOW,
etc. It also allows use of the "blink" attribute.
The format of the call is as follows:
NAttr = QATTR(Fgrd, Bkgrd)
Example:
DEFINT A-Z
DECLARE FUNCTION QATTR% (BYVAL Fore AS INTEGER, _
BYVAL Back AS INTEGER)
Fgrd = 7 : Bkgrd = 0
NAttr = QATTR(Fgrd, Bkgrd)
Video 91
QBPRT -- SUB
Print a string at the specified location on the screen. The Color
attribute must be computed prior to the call and included with the
call. It also allows the string to be printed on any of the 4
video pages. This routine uses BIOS calls to print the string so
it will be compatible with most versions of DOS.
The format of the call is as follows:
QBPRT Prt$, Row, Col, NAttr, Page
The parameters that are used by QBPRT are as follow:
Prt$ The string to be printed.
Row The row to print.
Col The column to print.
Attr The video color attribute to use.
Page The video page to print on.
Example:
DEFINT A-Z
DECLARE SUB QBPRT (PrtLine AS STRING, _
BYVAL Row AS INTEGER, _
BYVAL Col AS INTEGER, _
BYVAL Attr AS INTEGER, _
BYVAL Page AS INTEGER)
.
.
Prt$="This is the string to be printed."
Fgrd = 7 : Bkgrd = 0
NAttr = QATTR(Fgrd, Bkgrd)
Row=5 : Col=10 : Page=0
QBPRT Prt$, Row, Col, NAttr, Page
Video 92
QBMPRT -- SUB
Print a string array at the specified location on the screen. The
color attribute must be calculated before the call and passed with
the call. It also allows the string to be printed on any of the 4
video pages. This routine uses BIOS calls to print the strings so
it will be compatible with most versions of DOS.
The format of the call is as follows:
QBMPRT Elements, VARSEG(Prt$(0)), VARPTR(Prt$(0)), Row, Col, AAttr, Page
The parameters that are used by QMPRT are as follows:
Elements The number of occurrences of the array.
VARSEG(Prt$(0)) The VARSEG segment address of the first array
element.
VARPTR(Prt$(0)) The VARPTR address of the first array element.
Row The row to start printing.
Col The column to start in.
Attr The video color attribute to use.
Page The video page to print on.
Example:
OPTION BASE 0
DEFINT A-Z
DECLARE SUB QBMPRT (BYVAL Elements AS INTEGER, _
BYVAL VSeg AS INTEGER, _
BYVAL VOff AS INTEGER, _
BYVAL Row AS INTEGER, _
BYVAL Col AS INTEGER, _
BYVAL Attr AS INTEGER, _
BYVAL Page AS INTEGER)
DIM Prt$(4)
.
Prt$(0)="This is the first string to be printed."
Prt$(1)="This is the second string to be printed."
Prt$(2)="This is the third string to be printed."
Prt$(3)="This is the fourth string to be printed."
Fgrd = 1 : Bkgrd = 7
AAttr = QATTR(Fgrd, Bkgrd)
Row=5 : Col=10 : Page=0
Elements=4
QBMPRT Elements, VARSEG(Prt$(0)), VARPTR(Prt$(0)), Row, Col, AAttr, Page
Video 93
QCRTMODE -- SUB
This routine will return a value between 0 and 3 to indicate the
type of monitor that is installed. In addition it will return the
current number of columns that the screen is set too. Care must
be taken on some systems such as the AT&T PC6300 because it will
return a 1 indicationg CGA even though a mono screen is being
used. This is due to the fact that a CGA video controller card is
being used.
The format of the call is as follows:
QCRTMODE CType, CCols
Example:
DEFINT A-Z
DECLARE SUB QCRTMODE (CrtType AS INTEGER, _
CrtCols AS INTEGER)
REM CrtType ==> 0 = MDA, 1 = CGA, 2 = EGA, 3 = VGA
QCRTMODE CType, CCols
SELECT CASE CType
CASE 0
PRINT "Monitor type is MDA with"+STR$(CCols)+" Columns."
CASE 1
PRINT "Monitor type is CGA with"+STR$(CCols)+" Columns."
CASE 2
PRINT "Monitor type is EGA with"+STR$(CCols)+" Columns."
CASE 3
PRINT "Monitor type is VGA with"+STR$(CCols)+" Columns."
CASE ELSE
PRINT "Unknown monitor type."
END SELECT
END
QCLREOL -- SUB
This routine will print spaces from the current cursor location to
the end of the line. The cursor can be places anywhere on the
screen using the LOCATE statement.
The format of the call is as follows:
QCLREOL
Example:
DEFINT A-Z
DECLARE SUB QCLREOL ()
.
LOCATE 5, 15
Video 94
QCLREOL
.
END
Video 95
QGETATTR -- FUNCTION
This function will return an integer containing the current video
attribute at the requested row and column. This can be useful in
determinine the color attribute being used before print with QPRT
or the other print routines in this library.
The format of the call is as follows:
Attr = QGETATTR (Row, Col)
Example:
DEFINT A-Z
DECLARE FUNCTION QGETATTR% (BYVAL Row AS INTEGER, _
BYVAL Col AS INTEGER)
PRINT "The color attribute at row 24, column 1 is "; QGETATTR(24,1)
END
QGETCURS -- SUB
This routine will return integer values containing the current
cursor row and column for the requested video page. This requires
only one call instead of 2 using the BASIC funtions CSRLIN and
POS(0).
The format of the call is as follows:
QGETCURS Row, Col, Page
Example:
DEFINT A-Z
DECLARE SUB QGETCURS (Row AS INTEGER, _
Col AS INTEGER, _
Page AS INTEGER)
QGETCURS Row, Col, Page
PRINT "The cursor is at Row/Column": Row, Col
END
Video 96
QGETMODE -- FUNCTION
This function will return an integer value which contains the
current video mode returned by the BIOS. This value can then be
used to reset the video mode after it has been changed with
QSETMODE.
The format of the call is as follows:
HoldMode = QGETMODE
Example:
DEFINT A-Z
DECLARE FUNCTION QGETMODE% ()
HoldMode = QGETMODE
QSETMODE HoldMode - 2
.
.
QSETMODE HoldMode
.
END
Video 97
QMPRT -- SUB
Print a string array at the specified location on the screen. The
color attribute must be calculated before the call and passed with
the call. It also allows the string to be printed on any of the 4
video pages. This routine writes to video ram directly and may
not be compatible with some versions of DOS.
The format of the call is as follows:
QMPRT Elements, VARSEG(Prt$(0)), VARPTR(Prt$(0)), Row, Col, AAttr, Page
The parameters that are used by QMPRT are as follows:
Elements The number of occurrences of the array.
VARSEG(Prt$(0)) The VARSEG segment address of the first array
element.
VARPTR(Prt$(0)) The VARPTR address of the first array element.
Row The row to start printing.
Col The column to start in.
Attr The video color attribute to use.
Page The video page to print on.
Example:
OPTION BASE 0
DEFINT A-Z
DECLARE SUB QMPRT (BYVAL Elements AS INTEGER, _
BYVAL VSeg AS INTEGER, _
BYVAL VOff AS INTEGER, _
BYVAL Row AS INTEGER, _
BYVAL Col AS INTEGER, _
BYVAL Attr AS INTEGER, _
BYVAL Page AS INTEGER)
DIM Prt$(4)
.
Prt$(0)="This is the first string to be printed."
Prt$(1)="This is the second string to be printed."
Prt$(2)="This is the third string to be printed."
Prt$(3)="This is the fourth string to be printed."
Fgrd = 1 : Bkgrd = 7
AAttr = QATTR(Fgrd, Bkgrd)
Row=5 : Col=10 : Page=0
Elements=4
QMPRT Elements, VARSEG(Prt$(0)), VARPTR(Prt$(0)), Row, Col, AAttr, Page
Video 98
QPAINT -- SUB
This subroutine will change the current foreground and background
colors of an area of the screen as defined by the supplied screen
locations. Any text that exists in this area will remain. Only
the colors will change.
The format of the call is as follows:
QPAINT TRow, LCol, BRow, RCol, Attr, Page
The parameters that are used by QPAINT are as follows:
TR The top row location.
LC The left column location.
BR The bottom row location.
RC The right column location.
Attr The video color attribute to use.
Page The video page to print on.
Example:
DEFINT A-Z
DECLARE SUB QPAINT (BYVAL TR AS INTEGER, _
BYVAL LC AS INTEGER, _
BYVAL BR AS INTEGER, _
BYVAL RC AS INTEGER, _
BYVAL ATTR AS INTEGER, _
BYVAL PAGE AS INTEGER)
.
.
TRow = 5: LCol = 10: BRow = 15: RCol = 70: Page = 0
Attr = QATTR(3, 0)
QPAINT TRow, LCol, BRow, RCol, Attr, Page
.
END
Video 99
QPRT -- SUB
Print a string at the specified location on the screen. The color
attribute must be calculated prior to the call and passed with the
call. It also allows the string to be printed on any of the 4
video pages. This routine writes to video ram directly and may
not be compatible with some versions of DOS.
The format of the call is as follows:
QPRT Prt$, Row, Col, NAttr, Page
The parameters that are used by QPRT are as follows:
Prt$ The string to be printed.
Row The row to print.
Col The column to print.
Attr The video color attribute to use.
Page The video page to print on.
Example:
DEFINT A-Z
DECLARE SUB QPRT (PrtLine AS STRING, _
BYVAL Row AS INTEGER, _
BYVAL Col AS INTEGER, _
BYVAL Attr AS INTEGER, _
BYVAL Page AS INTEGER)
.
.
Prt$="This is the string to be printed."
Fgrd = 7 : Bkgrd = 0
NAttr = QATTR(Fgrd, Bkgrd)
Row=5 : Col=10 : Page=0
QPRT Prt$, Row, Col, NAttr, Page
Video 100
QPRTANSI -- SUB
Print a string to the screen including any ANSI escape characters
sequences. The unlike the QANSIPRT sub, this routine has a built
in locate function. In addition, this subroutine can be passed a
number which is the last line of a window that the routine will
print to. If this number will be exceeded, the subroutine will
scroll the screen up one before printing the next line. In this
case, the row and column parameters will be ignored. If this
value is zero, then the window parameter is ignored and the row
and column specified will be used. This routine uses DOS calls so
it will print slower than QPRT or QBPRT.
The format of the call is as follows:
QPRTANSI CharString$, Row, Col, Awindow
Example:
DEFINT A-Z
DECLARE SUB QPRTANSI (PrtString AS STRING, _
BYVAL Row AS INTEGER, _
BYVAL Col AS INTEGER, _
BYVAL Awindow AS INTEGER)
.
REM Print string at row and column specified
CharString$ = "This is a string to be printed"
Row=5 : Col=10 : Awindow = 0
QPRTANSI CharString$, Row, Col, Awindow
.
.
REM Print string at next row if the row is less than the window
CharString$ = "This is a string to be printed" + CHR$(13) + CHR$(10)
Row=0 : Col=0 : Awindow = 22
QPRTANSI CharString$, Row, Col, Awindow
Video 101
QRESTSCR -- FUNCTION
Restore the portion of the screen from an array that had been
saved with QSAVESCR. It will restore the screen to any of the 4
video pages. The screen does not have to be restored to the same
location that it was saved from. The array that is used must be
large enough to hold the saved screen area. The way to calculate
the size array needed is with the following ((BottomRow - TopRow)
+ 1) * (RightCol - LeftCol) + 1).
The format of the call is as follows:
QRESTSCR TRow, LCol, BRow, RCol, Page, VARSEG(Array(0)), VARPTR(Array(0))
The parameters that are used by QRESTSCR are as follows:
TR The top row location.
LC The left column location.
BR The bottom row location.
RC The right column location.
Page The video page to save from.
VARSEG(A(0)) The array segment address.
VARPTR(A(0)) The array pointer address.
Example:
DEFINT A-Z
DECLARE SUB QRESTSCR (BYVAL TR AS INTEGER, _
BYVAL LC AS INTEGER, _
BYVAL BR AS INTEGER, _
BYVAL RC AS INTEGER, _
BYVAL PAGE AS INTEGER, _
BYVAL VSEG AS INTEGER, _
BYVAL VPTR AS INTEGER)
DIM Array(671)
.
SHELL "DIR"
TRow = 5: LCol = 10: BRow = 15: RCol = 70: Page = 0
QSAVESCR TRow, LCol, BRow, RCol, Page, VARSEG(Array(0)), VARPTR(Array(0))
CLS
WHILE INKEY$ = "": WEND
QRESTSCR TRow, LCol, BRow, RCol, Page, VARSEG(Array(0)), VARPTR(Array(0))
END
Video 102
QSAVESCR -- FUNCTION
Saves a portion of the screen to an array. You do not have to
save the whole screen, only the portions that is needed. The
screen can be restored at a later time using QRESTSCR. The array
that is used must be large enough to hold the saved screen area.
The way to calculate the size array needed is with the following
((BottomRow - TopRow) + 1) * (RightCol - LeftCol) + 1).
The format of the call is as follows:
QSAVESCR TRow, LCol, BRow, RCol, Page, VARSEG(Array(0)), VARPTR(Array(0))
The parameters that are used by QSAVESCR are as follows:
TR The top row location.
LC The left column location.
BR The bottom row location.
RC The right column location.
Page The video page to save from.
VARSEG(A(0)) The array segment address.
VARPTR(A(0)) The array pointer address.
Example:
DEFINT A-Z
DECLARE SUB QSAVESCR (BYVAL TR AS INTEGER, _
BYVAL LC AS INTEGER, _
BYVAL BR AS INTEGER, _
BYVAL RC AS INTEGER, _
BYVAL PAGE AS INTEGER, _
BYVAL VSEG AS INTEGER, _
BYVAL VPTR AS INTEGER)
DIM Array(671)
.
SHELL "DIR"
TRow = 5: LCol = 10: BRow = 15: RCol = 70: Page = 0
QSAVESCR TRow, LCol, BRow, RCol, Page, VARSEG(Array(0)), VARPTR(Array(0))
CLS
WHILE INKEY$ = "": WEND
QRESTSCR TRow, LCol, BRow, RCol, Page, VARSEG(Array(0)), VARPTR(Array(0))
END
Video 103
QSCROLL -- SUB
Scrolls the screen up using the locations that are passed in the
call. One or more lines can be scrolled and if the number is
zero, the whole area will be cleared. Be sure that the rows and
columns are within the screen.
The format of the call is as follows:
QSCROLL Trow, Lcol, Brow, Rcol, Lines
Example:
DEFINT A-Z
DECLARE SUB QSCROLL (BYVAL TRow AS INTEGER, _
BYVAL LCol AS INTEGER, _
BYVAL BRow AS INTEGER, _
BYVAL RCol AS INTEGER, _
BYVAL Lines AS INTEGER)
Trow = 5 : Lcol = 15 : Brow = 15 : Rcol = 65 : Lines = 2
QSCROLL Trow, Lcol, Brow, Rcol, Lines
.
REM The following will clear an area of the screen
Trow = 5 : Lcol = 15 : Brow = 15 : Rcol = 65 : Lines = 0
QSCROLL Trow, Lcol, Brow, Rcol, Lines
QSCROLLB -- SUB
Scrolls the screen down using the locations that are passed in the
call. One or more lines can be scrolled and if the number is
zero, the whole area will be cleared. Be sure that the rows and
columns are within the screen.
The format of the call is as follows:
QSCROLLB Trow, Lcol, Brow, Rcol, Lines
Example:
DEFINT A-Z
DECLARE SUB QSCROLLB (BYVAL TRow AS INTEGER, _
BYVAL LCol AS INTEGER, _
BYVAL BRow AS INTEGER, _
BYVAL RCol AS INTEGER, _
BYVAL Lines AS INTEGER)
Trow = 5 : Lcol = 15 : Brow = 15 : Rcol = 65 : Lines = 2
QSCROLLB Trow, Lcol, Brow, Rcol, Lines
Video 104
QSCRREST -- FUNCTION
Restore the screen from an array that had been saved with
QSCRSAVE. It will restore the screen to any of the 4 video pages.
If an error was encountered, the RC will be -1.
The format of the call is as follows:
RC = QSCRREST(VARSEG(ScrnHold(1)), VARPTR(ScrnHold(1)), Page)
The parameters that are used by QSCRREST are as follows:
VARSEG(Prt$(0)) The VARSEG segment address of the first array
element.
VARPTR(Prt$(0)) The VARPTR address of the first array element.
Page The video page to print on.
Example:
OPTION BASE 1
DEFINT A-Z
DECLARE FUNCTION QSCRREST% (BYVAL ASeg AS INTEGER, _
BYVAL AOffset AS INTEGER, _
BYVAL Page AS INTEGER)
DIM ScrnHold(2000)
Page = 0
IF QSCRREST(VARSEG(ScrnHold(1)), VARPTR(ScrnHold(1)), Page) = 0 THEN
LOCATE RowHold,ColHold
ELSE
PRINT "Error on screen restore"
END IF
Video 105
QSCRSAVE -- FUNCTION
Save the requested video page (0 - 3) into array. Use this in
text mode only. The array must be an integer array dimensioned to
at least 2000 occurrences. The starting address of the array must
be passed, use the VARPTR function to get this address. The
cursor location is not saved so, if it is needed, save the
location. More than one screen can be saved into the array as
long as 2000 occurrences are dimensioned for each screen and the
appropriate VARPTR address is passed the the routine. If an error
is encountered, the RC will be -1.
The format of the call is as follows:
RC = QSCRSAVE(VARSEG(ScrnHold(1)), VARPTR(ScrnHold(1)), Page)
The parameters that are used by QSCRSAVE are as follows:
VARSEG(Prt$(0)) The VARSEG segment address of the first array
element.
VARPTR(Prt$(0)) The VARPTR address of the first array element.
Page The video page to print on.
Example:
OPTION BASE 1
DEFINT A-Z
DECLARE FUNCTION QSCRSAVE% (BYVAL ASeg AS INTEGER, _
BYVAL AOffset AS INTEGER, _
BYVAL Page AS INTEGER)
DIM ScrnHold(2000)
Page = 0
IF QSCRSAVE(VARSEG(ScrnHold(1)), VARPTR(ScrnHold(1)), Page) = 0 THEN
RowHold = CSRLIN
ColHold = POS(0)
ELSE
PRINT "Error on screen save"
END IF
Video 106
QSETMODE -- SUB
This subroutine will set the video mode to the value that is
supplied. This value can be any of the valid BIOS video modes.
The format of the call is as follows:
QSETMODE HoldMode
Example:
DEFINT A-Z
DECLARE SUB QSETMODE (BYVAL VMode AS INTEGER)
HoldMode = QGETMODE
QSETMODE HoldMode - 2
.
.
QSETMODE HoldMode
.
END
Video 107
QWINDOW -- SUB
Displays a pop-up window on the screen. It requires several
parameters which are used to determine where to print the window
as well as the type of frame to be used for the window. The rows
and columns that are used and the ones that will be used for the
frame. The color attribute that must be computed prior to the call
and passed to QWINDOW. If the value passed for frame is not 1-4,
the screen will be cleared based upon the row and column values.
The format of the call is as follows:
QWINDOW TRow, LCol, BRow, RCol, Frame, NAttr, Page
The parameters that are used by QWINDOW are as follows:
TRow The top row of the window.
LCol The left column of the window.
BRow The bottom row of the window.
RCol The right column of the window.
Frame The type of frame to be used for the window.
Attr The video color attribute to use.
Page The video page to print the window on.
The types of frames available with QWINDOW are as follow:
1 Single line frame.
2 Double line frame.
3 Double vertical and single horizontal frame.
4 Single vertical and double horizontal frame.
Example:
DEFINT A-Z
DECLARE SUB QWINDOW (BYVAL TRow AS INTEGER, _
BYVAL LCol AS INTEGER, _
BYVAL BRow AS INTEGER, _
BYVAL RCol AS INTEGER, _
BYVAL Frame AS INTEGER, _
BYVAL Attr AS INTEGER, _
BYVAL Page AS INTEGER)
.
Fgrd=7 : Bkgrd=0
NAttr = QATTR(Fgrd, Bkgrd)
TRow=1 : LCol=1 : BRow=25 : RCol=80 : Frame=2 : Page=0
QWINDOW TRow, LCol, BRow, RCol, Frame, NAttr, Page
Video 108
QWINDOWH -- SUB
Works just like QWINDOW, but in addition, it will draw horizontal
lines across the window based upon the values passed in NLines and
RNum. This routine can be very useful in menu windows. If the
value passed in NLines is zero, it will function the same as
QWINDOW. The VARPTR function must be used to get the address of
the first array element.
To use this routine, you must define a numeric array. Each element
of this array will contain the row in which you wish to have a
line drawn across the window. The address of the first occurrence
of the array is what is passed to the routine.
The format of the call is as follows:
QWINDOWH TRow, LCol, BRow, RCol, NLine, RSeg, RNum, Frame, NAttr, Page
The parameters that are used by QWINDOWH are as follows:
TRow The top row of the window.
LCol The left column of the window.
BRow The bottom row of the window.
RCol The right column of the window.
NLine The number of horizontal lines to draw.
RSeg The VARSEG segment address of the first array element.
RNum The VARPTR address of the first array element.
Frame The type of frame to be used for the window.
Attr The video color attribute to use.
Page The video page to print the window on.
The types of frames available with QWINDOWH are as follows:
1 Single line frame.
2 Double line frame.
3 Double vertical and single horizontal frame.
4 Single vertical and double horizontal frame.
Example:
OPTION BASE 0
DEFINT A-Z
DECLARE SUB QWINDOWH (BYVAL TRow AS INTEGER, BYVAL LCol AS INTEGER, _
BYVAL BRow AS INTEGER, BYVAL RCol AS INTEGER, _
BYVAL NLine AS INTEGER, BYVAL ASeg AS INTEGER, _
BYVAL AOff AS INTEGER, BYVAL Frame AS INTEGER, _
BYVAL Attr AS INTEGER, BYVAL Page AS INTEGER)
DIM ARow(2)
.
Fgrd=7 : Bkgrd=0 : NAttr = QATTR(Fgrd, Bkgrd)
TRow=1 : LCol=1 : BRow=25 : RCol=80 : Frame=2 : Page=0
NLine=2 : ARow(0)=3 : ARow(1)=23
RSeg=VARSEG(ARow(0)) : RNum=VARPTR(ARow(0))
QWINDOWH TRow, LCol, BRow, RCol, NLine, RSeg, RNum, Frame, NAttr, Page
Video 109
QWINDOWV -- SUB
Works just like QWINDOW, but in addition, it will draw vertical
lines down the window based upon the values passed in NLines and
CNum. If the value passed in NLines is zero, it will function the
same as QWINDOW. The VARPTR function must be used to get the
address of the first array element.
To use this routine, you must define a numeric array. Each element
of this array will contain the row in which you wish to have a
line drawn down the window. The address of the first occurrence
of the array is what is passed to the routine.
The format of the call is as follows:
QWINDOWH TRow, LCol, BRow, RCol, NLine, CSeg, CNum, Frame, NAttr, Page
The parameters that are used by QWINDOWV are as follows:
TRow The top row of the window.
LCol The left column of the window.
BRow The bottom row of the window.
RCol The right column of the window.
NLine The number of vertical lines to draw.
CSeg The VARSEG segment address of the first array element.
CNum The VARPTR address of the first array element.
Frame The type of frame to be used for the window.
Attr The video color attribute to use.
Page The video page to print the window on.
The types of frames available with QWINDOWV are as follows:
1 Single line frame.
2 Double line frame.
3 Double vertical and single horizontal frame.
4 Single vertical and double horizontal frame.
Example:
OPTION BASE 0
DEFINT A-Z
DECLARE SUB QWINDOWV (BYVAL TRow AS INTEGER, BYVAL LCol AS INTEGER, _
BYVAL BRow AS INTEGER, BYVAL RCol AS INTEGER, _
BYVAL NLine AS INTEGER, BYVAL ASeg AS INTEGER, _
BYVAL AOff AS INTEGER, BYVAL Frame AS INTEGER, _
BYVAL Attr AS INTEGER, BYVAL Page AS INTEGER)
DIM ACol(2)
.
Fgrd=7 : Bkgrd=0 : NAttr = QATTR(Fgrd, Bkgrd)
TRow=1 : LCol=1 : BRow=25 : RCol=80 : Frame=2 : Page=0
NLine=2 : ACol(0)=5 : ACol(1)=75
CSeg=VARSEG(ACol(0)) : CNum=VARPTR(ACol(0))
QWINDOWH TRow, LCol, BRow, RCol, NLine, CSeg, CNum, Frame, NAttr, Page
Video 110
QWINDOWX -- SUB
Displays a pop-up window on the screen with a user selectable
shadow either below left or below rightp window on the screen. It
requires several parameters which are used to determine where to
print the window as well as the type of frame to be used for the
window. The rows and columns that are used and the ones that will
be used for the frame. The color attribute that must be computed
prior to the call and passed to QWINDOWX. If the value passed for
frame is not 1-4, the screen will be cleared based upon the row
and column values.
The format of the call is as follows:
QWINDOWX TRow, LCol, BRow, RCol, Frame, NAttr, HAttr, Page
The parameters that are used by QWINDOWX are as follows:
TRow The top row of the window.
LCol The left column of the window.
BRow The bottom row of the window.
RCol The right column of the window.
Frame The type of frame to be used for the window.
Attr The video color attribute to use.
Page The video page to print the window on.
The types of frames available with QWINDOWX are as follow:
1 Single line frame, shadow bottom left.
2 Double line frame, shadow bottom left.
3 Double vertical and single horizontal frame, shadow bottom
left.
4 Single vertical and double horizontal frame, shadow bottom
left.
5 Single line frame, shadow bottom right.
6 Double line frame, shadow bottom right.
7 Double vertical and single horizontal frame, shadow bottom
right.
8 Single vertical and double horizontal frame, shadow bottom
right.
Example:
DEFINT A-Z
DECLARE SUB QWINDOWX (BYVAL TRow AS INTEGER, BYVAL LCol AS INTEGER, _
BYVAL BRow AS INTEGER, BYVAL RCol AS INTEGER, _
BYVAL Frame AS INTEGER, BYVAL Attr AS INTEGER, _
BYVAL Attrs AS INTEGER, BYVAL Page AS INTEGER)
.
REM Will print window with a shadow on bottom left.
Fgrd=7 : Bkgrd=0 : NAttr = QATTR(Fgrd, Bkgrd)
Fgrd=3 : Bkgrd=2 : HAttr = QATTR(Fgrd, Bkgrd)
TRow=5 : LCol=10 : BRow=15 : RCol=30 : Frame=2 : Page=0
QWINDOWX TRow, LCol, BRow, RCol, Frame, NAttr, HAttr, Page
Video 111
QVIDREST -- FUNCTION
Restore a screen that was saved with QVIDSAVE. Color and
monochrome screens have 4 pages of video memory and this routine
will move a screen from pages 1-3 to page 0. If an error is
encountered, the RC will be set to -1.
The format of the call is as follows:
RC = QVIDREST(Page)
Example:
DEFINT A-Z
DECLARE FUNCTION QVIDREST% (BYVAL Page AS INTEGER)
Page = 2
RC = QVIDREST(Page)
QVIDSAVE -- FUNCTION
Save a screen to video page 1, 2 or 3 from page 0. If an error is
encountered, the RC will be set to -1.
The format of the call is as follows:
RC = QVIDSAVE(Page)
Example:
DEFINT A-Z
DECLARE FUNCTION QVIDSAVE% (BYVAL Page AS INTEGER)
Page = 2
RC = QVIDSAVE(Page)
Video 112