Dec 222017
 
A few QBasic routines that access the screen and keyboard.
File BASSUBS.ZIP from The Programmer’s Corner in
Category BASIC Language
A few QBasic routines that access the screen and keyboard.
File Name File Size Zip Size Zip Type
BASSUB.DOC 9782 3256 deflated
CHKCURS.BAS 755 372 deflated
FLDEDIT.BAS 5040 1483 deflated
KEYTOGL.BAS 705 302 deflated
MENUKEY.BAS 637 321 deflated
SCRNCLK.BAS 1134 597 deflated
TOLOWER.FN 569 322 deflated
TOUPPER.FN 571 320 deflated
TPCREAD.ME 199 165 deflated

Download File BASSUBS.ZIP Here

Contents of the BASSUB.DOC file

























BASSUB

by

Wayne E. Robinson

CIS 70277,131

10-18-87

Public Domain Software

for the enhancement of the

QuickBasic environment

Version 1.0







This collection of five subprograms and two functions are my
contribution to the community of QuickBasic programmers from
which I have garnered much knowledge, not to mention source
code and programs, in the past.


It is difficult not to build on others' work and in this spirit,
one of these programs, SCRNCLK(), requires FASTPRT() from
Dave Evers' BASWIND2. If you don't have this marvelous work, I
suggest you acquire it soon. The rest of these routines will
stand alone, though they can be compiled and linked into a
library with other programs such as Mr. Evers'.


I will from time to time release new versions of this library
and am always open to suggestions from anyone as to how to
improve my work, or ideas for new projects.


I hope you find these routines useful in whole or in part. In
this respect please feel free to disect, change, alter,
mutilate, or otherwise personalize any of my code as you see
fit. Incorporate it into you own work at will as it is now
public property. If you find a better way to accomplish a task
than I have presented in these programs, please don't keep it
to yourself. Give it to the rest of us.


-------------------


Version 1.0 files:

FldEdit()
MenuKey()
ScrnClk()
Keytogl()
ChkCurs()
ToUpper.Fn
ToLower.Fn







FldEdit()


Passed Parameters:

FRow% - Line on which the string will be edited
FCol% - Column of the first byte of the string
FLength% - Maximum length of the string
FFore% - Foreground color the editor will use
FBack% - Background color the editor will use
FRKey% - Returns second byte of extended key code or the single
byte value of a non extended key. If the process terminates
normally with a carriage return then FRKey% returns 0.

key values returned are:
________________________________

key code

HOME 71
END 79
PgUP 73
PgDn 81
Up 72
Dn 80
TAB 9
ESC 27

FTemp$ - String passed to and from parent process.

Format:

CALL FldEdit(FRow%, FCol%, FLength%, FFore%, FBack%, FRKey%, FTemp$)


This program will allow you to use either the overwrite (normal
cursor) or the insert (block cursor) modes, with full cursoring
inside the specified string space. While the cursor keys are
non-destructive the backspace key is destructive. The cursor
will be confined to the specified space which cannot exceed 79
columns nor can it encompass more than one row. Because this
program alters the cursor and screen colors, steps may need to
be taken to allow recovery of the previous states. If the parent
process will pass FTemp$ containing other than a null string
then this string will be placed on the screen by FldEdit() and
the field will be padded with spaces to the length supplied in
FLength%. If the background color specified is other than the
current screen color then this highlights the entire string space.
None of the padded spaces are counted in the string however and are
not passed back to the parent process. The use of FRKey% allows
this process to be incorporated into a multiple field editor by
parsing the value returned and moving the cursor and changing the
edited field accordingly.







MenuKey()


Passed Parameters:

MRow% - Row location of cursor waiting for keypress
MCol% - Column location of cursor
MKey$ - Parent passes a string containing all of the possible
keys accepted by the process. ie: MKey$ = "YyNnCc".
Child passes back a single byte, the pressed key.

Format:

CALL MenuKey(MRow%, MCol%, MKey$)

Program puts a normal blinking cursor at the designated screen
location in the current color and waits for a keypress. Program
loops back on itself until the key pressed is found in MKey$.
When a match is found MKey$ is changed to the pressed key and
the process exits.

This program does not alter the COLOR statement but it does leave
the cursor turned off so take care to save the state of the cursor
before you issue the call.







ScrnClk()


Passed Parameters:

CFore% - Foreground color
CBack% - BAckground color
Cloc$ - String containing the location of the clock

Format:

ON TIMER (1) GOSUB CallClock
TIMER ON

---- PROGRAM BODY ----

CallClock:
CALL ScrnClk(CFore%, CBack% , CLoc$)
RETURN

This program requires linking with FASTPRT() from the BASWIND2
library by Dave Evers. The usage of this assembly routine allows
ScrnClk() to write to the screen every second without changing
the current cursor parameters or the COLOR statement. This
process acts almost totally transparent in so far as you are
relieved of the responibility to recover this data after every
write.

The CLoc$ parameter must be in one of two forms. Either it must
be a numeral (1 to 6) sent in string form or it must be in the
coordinate form of "##:##". If a single numeral, then the clock,
a 10 byte string (24 hour), is placed on the left, center, or
right sides of row 1 (1 to 3) or row 25 (4 to 6). If the clock
is to be placed at any other coordinate then the string must
contain 5 bytes, the 3rd being a colon and either of the numbers
on the left or right sides padded with a "0" if necessary.

It is unfortunate that QB does not support a "ON EVENT CALL"
statement. The use of a GOSUB routine, however does not seem to
slow the process down to any harmful degree. If you intend to
place the clock inside a window such as with MakeWind() then you
should make the window inside the program body and outside of
the GOSUB routine to avoid flickering with each rewrite not to
mention serious slowdown.

Hint: All subprograms must contain the ON TIMER GOSUB statement
in order for the clock to work while inside these subprograms.
If you use libraries one of the subprograms must contain the
GOSUB routine itself attached to its code when compiled. Note the
routine must be outside the attached subprograms code.







KeyTogl()


Passed Parameters:

Cap% - value of 1 if Caps Lock is on, 0 if off
Num% - value of 1 if Num Lock is on, 0 if off
Scr% - value of 1 if Scroll Lock is on, 0 if off
Ins% - value of 1 if Insert key active, 0 if inactive

Format:

CALL KeyTogl(Cap%, Num%, Scr%, Ins%)

This checks in QB's storage area for the current values of these
keyboard unknowns. Unless you have a keyboard that clues you in
you might need to know this information from time to time. This
short process makes it easy to incorporate it into your programs.







ChkCurs()


Passed Parameters:

CRow% - 1st parameter of the LOCATE Statement
CCol% - 2nd parameter of the LOCATE Statement
COn% - 3rd parameter of the LOCATE Statement
CTop% - 4th parameter of the LOCATE Statement
CBot% - 5th parameter of the LOCATE Statement

Format:

CALL ChkCurs(CRow%, CCol%, COn%, CTop%, CBot%)

Program checks in QB's storage area for the cursor's current
parameters and stores them in variables which can later be
substituted into the LOCATE Statement resulting in the cursor
returning to the state it was in at the time of the call.







ToUpper.Fn


This is a multiline function which will convert all of the
alphabetic lower case characters in a string to upper case.
It does not effect non-alphabetic characters.

Format:

Word$ = Fn ToUpper$("Hello")
PRINT Word$ -> HELLO







ToLower.Fn


This is a multiline function which will convert all of the
alphabetic upper case characters in a string to lower case.
It does not effect non-alphabetic characters.

Format:

Word$ = Fn ToLower$("Hello")
PRINT Word$ -> hello



 December 22, 2017  Add comments

Leave a Reply