home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 12
/
CD_ASCQ_12_0294.iso
/
news
/
440
/
mnusysqb
/
menulib.ref
< prev
next >
Wrap
Text File
|
1993-09-07
|
20KB
|
496 lines
Menulib for Menusys-QB
Quick Reference Guide
(C) Copyright 1993 by Tim Gerchmez
All Rights Reserved.
NOTE: Unless otherwise noted, all routines that use
arrays use an LBOUND of ONE (1).
--------------------------------------------------------------------------------
* sub about
Displays a box on the screen giving information about a program -
name, author, etc. The registered version/source code is necessary
to modify/configure this routine to display your name and programname.
This routine calls INFOBOX.
--------------------------------------------------------------------------------
* sub alertbox (message$)
Prints a one-line alert message on the screen and
waits for user to select OK with mouse or ENTER.
See MLIBDEMO.BAS for example.
Example: message$ = "Testing" : CALL alertbox(message$)
--------------------------------------------------------------------------------
* sub background (ch%)
Fills the screen with a special character, creating a
background. Uses colors in clr%, bckg%.
Set chr% = 0 for black background, 1 for dark background, 2 for medium,
3 for light, 4 for pure. See MLIBDEMO.BAS for example.
Example: CALL background(0)
--------------------------------------------------------------------------------
* sub bigprint (ch$, u$)
Prints a giant representation of the ASCII value in ch$.
Uses the character in u$ to represent the "dots" for the big
character. Cursor Position is restored afterward. Characters
are size 8 X 8 regular characters.
Example: ch$ = "T" : u$ = "." : CALL bigprint(ch$, u$)
--------------------------------------------------------------------------------
* sub bigprintline (ln$, u$)
Print an entire line of characters in ln$ in giant size print.
Uses the character in u$ to print the giant "pixels."
Maximum: 10 characters in ln$, 3 lines per screen.
Ready to print another line after routine is called .. begins
on the line the cursor is currently on.
One screen will hold 3 lines of 10 characters.
This routine calls BIGPRINT. See MLIBDEMO.BAS for example.
Example: LOCATE 1, 1 : CALL bigprintline("Test1234", ".")
--------------------------------------------------------------------------------
* sub checkbox (title$, optn$(), optn%())
Displays a list of selections and lets a user "check off" or
select them using the mouse or keyboard. Title$ should contain
the title for the box, optn$() will contain the option names,
and optn%(x) will be returned as 0 for not selected, or 1 for
selected. Locate cursor to upper-left corner position of box
desired before calling. See MLIBDEMO.BAS for example.
Example: title$ = "Select any/all"
DIM optn$(1 TO 3), optn%(1 TO 3)
optn$(1) = "Option 1"
optn$(2) = "Option 2"
optn$(3) = "Option 3"
CALL checkbox(title$, optn$(), optn%())
--------------------------------------------------------------------------------
* sub choosebox (msg$(), choice%)
Prints a multi-line message on the screen in a box,
and waits for user to select OK or CANCEL.
Returns 0 (OK) or 1 (Cancelled).
Shortest string should be >20.
See MLIBDEMO.BAS for example.
Example: DIM msg$(1 TO 2)
msg$(1) = "Choice1"
msg$(2) = "Choice2"
CALL choosebox(msg$(), choice%)
PRINT "You Chose "; choice%
--------------------------------------------------------------------------------
* sub choosedir (dr$, ch$)
Lets the user choose an entry from a subdirectory using the
mouse/cursor keys (see MLIBDEMO.BAS). Upon calling, dr$ should
contain the filespec to be found (*.* for all), and upon
return, ch$ will contain the directory entry the user selected.
If ch$ = "", the user aborted the routine.
See MLIBDEMO.BAS for example.
Example: dr$ = "*.*"
CALL choosedir(dr$, ch$)
PRINT "You Chose "; ch$
--------------------------------------------------------------------------------
* sub clearline (ln%)
Clears a selected screenline, including position 80, without
scrolling the screen.
Example: CALL clearline (25)
--------------------------------------------------------------------------------
* function endofline% (ln%)
Returns the position (column) of the end of a line of text.
Specify the screen line to check in ln% (1-25) before calling.
Upon return, endofline% will contain the position of the last
character on the specified screen line, plus one (the next
available blank on the screen line). Note that this is a
Function, not a Sub.
Example: e% = endofline%(10)
LOCATE 10, e%
PRINT "...more text"
--------------------------------------------------------------------------------
* sub getdirectory (fi$, atype%, dir$(), attrib%())
Gets the directory specified in fi$ (with the attributes to be
searched for specified in atype%) and puts it into a string
array (dir$()), and the attributes for each file in attrib%()).
If no entries of the specified type are found, the routine returns
with fi$="". DIM dir$ and attrib% to any number (such as 1) before
calling, but make sure to use $DYNAMIC, as arrays are re-dimensioned
to correct size to hold all directory entries. The values in attrib%
are returned as follows (use AND to extract the bits):
Zero = "Ordinary" files only (0)
Bit 0 = Read Only (1)
Bit 1 = Hidden File (2)
Bit 2 = System File (4)
Bit 4 = Subdirectory (16)
Bit 5 = Archive (32) - [0 or 32 = "Ordinary" file]
Example: if attrib%(5) AND 4 then print "System File"
Example: If attrib%(2) = 16 then print "Subdirectory"
Example: If attrib%(1) = 0 or attrib%(1) = 32 then print "Normal File"
Set atype% to the desired attributes to be searched for (as defined
above) before calling. For "Normal" files only, set atype% to zero.
GETDIRECTORY is called by CHOOSEDIR.
Example: DIM dir$(1), attrib%(1)
atype% = 0 : fi$ = "*.*"
CALL getdirectory(fi$, atype%, dir$(), attrib%())
--------------------------------------------------------------------------------
* sub getdisk (d%)
Returns drive code of current or default drive.
0 = A, 1 = B, 2 = C, Etc.
Example: CALL getdisk(d%)
PRINT "Current disk is ";chr$(65 + d%)
--------------------------------------------------------------------------------
* sub getfontinfo (code%, points%, rows%, sg, offset)
EGA, MCGA, VGA
Returns a pointer to a font's character definition table, and
the points (bytes per character) and rows for that font.
Call with code% set to one of the following values:
0 = INT 1fh contents, 1 = INT 43h contents, 2 = ROM 8x14
font, 3 = ROM 8x8 font (chars 00h-7fh), 4 = ROM 8x8
font (chars 80h-ffh), 5 = ROM alternate 9x14 font, 6 =
ROM 8x16 font, 7 = ROM alternate 9x16 font. Returns
points%, rows%(char. rows on screen - 1), sg% (segment of
char def table), offset% (offset of char. def table).
GETFONTINFO is called by BIGPRINT.
Example: code% = 3 : CALL getfontinfo(code%, points%, rows%, sg, offset)
--------------------------------------------------------------------------------
* sub getpath (dv%, pth$)
Gets current path from root to current directory for
the drive specified in dv% (0 = Default, 1 = A, Etc).
Returns path in pth$ (including leading backslash).
If error, pth$ will = "".
Example: if current path was C:\QB\SLAM\, pth$
would return \QB\SLAM\. If path was C:\ then
pth$ would return \.
Example: CALL getpath(0, pth$)
Print "Current Path: "; pth$
--------------------------------------------------------------------------------
* sub hscrollbar (starty%, startx%, length%)
Displays a horizontal "scroll bar" on the screen.
Specify the start Y and X position of the bar, and
the length in characters. This routine displays a
scroll bar only. It does not read the mouse or move
an indicator on the scroll bar. See MNSDEMO.BAS for
example usage.
Example: CALL hscrollbar(25, 5, 70)
--------------------------------------------------------------------------------
* sub infobox (msg$())
Prints a multi-line message on the screen in a box,
and waits for user to select OK with mouse or ENTER.
DIM msg$(1 to numofmsg%). See MLIBDEMO.BAS for example.
Example: DIM msg$(1 to 3)
msg$(1) = "This is the first line"
msg$(2) = "of this message which is"
msg$(3) = "being displayed."
CALL infobox(msg$())
--------------------------------------------------------------------------------
* sub inputbox (message$, inp$, max%, ll%, ul%)
Allows user input in a shadowed screen box.
Set message$ to message, max% to max length of user input,
ll% = lowest char allowed, ul% = highest char allowed.
User input is returned in inp$, and is used as "default"
input the next time the routine is called. See MLIBDEMO.BAS
for example usage of this routine.
Example: message$ = "Enter your name: "
max% = 10 : ll% = 0: ul% = 255
CALL inputbox(message$, inp$, max%, ll%, ul%)
--------------------------------------------------------------------------------
* sub menupick (title$, mb$(), help$(), choice%)
Allows user to choose from a menu using either
the mouse or the cursor keys. Dim mb$() and help$()
to the number of menu items desired before calling.
Upon return, choice% will contain the user's choice
(zero for abort). Set help$(x) to help for each menu
item (one line only), or leave blank. See MLIBDEMO.BAS
for example usage of this routine.
Example: DIM mb$(1 to 2), help$(1 to 2)
title$ = "Select one"
mb$(1) = "One" : mb$(2) = "Two"
help$(1) = "Help for Option One"
help$(2) = "Help for Option Two"
CALL menupick(title$, mb$(), help$(), choice%)
PRINT "You picked "; choice%
--------------------------------------------------------------------------------
* sub messagebox (title$, msg$())
This routine prints a multi-line message on the
screen and exits, without any delay. Use it for
messages that you don't need to be erased. See
MLIBDEMO.BAS for example usage of this routine.
Example: DIM msg$(1 to 2)
title$ = "Message"
msg$(1) = "This is a test of the"
msg$(2) = "Emergency Broadcast System"
CALL messagebox(title$, msg$())
--------------------------------------------------------------------------------
* sub mgetpos
Checks current position of mouse cursor and updates the
corresponding global variables msy% and msx%. This will
return the current position of the mouse cursor on the
text screen (if mouse is active and displayed).
Example: CALL mgetpos
PRINT msy% ; msx%
--------------------------------------------------------------------------------
* sub mgetpress (button%, numpresses!, ycc%, xcc%)
Checks button indicated in button% (1 = left, 2 = right)
and returns status of buttons in globals lb% and rb%, number
of presses of specified button since last call (in numpresses!),
and Y and X coordinates of mouse cursor the last time the specified
button was pressed (in ycc% and xcc%).
Example: CALL mgetpress(1, numpresses!, ycc%, xcc%)
IF lb% = 1 THEN PRINT "Left Button Pressed"
IF rb% = 1 THEN PRINT "Right Button Pressed"
PRINT "Left button pressed "; numpresses!; "Times"
PRINT "X = "; xcc%; "Y = "; ycc%
--------------------------------------------------------------------------------
* sub mgetrelease (button%, numreleases!, ycc%, xcc%)
Checks button indicated in button% (1 = left, 2 = right)
and returns status of buttons in globals lb% and rb%, number
of releases of specified button since last call (in numreleases!),
and Y and X coordinates of mouse cursor the last time the specified
button was released (in ycc% and xcc%).
Example: CALL mgetrelease(1, numreleases!, ycc%, xcc%)
IF lb% = 1 THEN PRINT "Left Button Pressed"
IF rb% = 1 THEN PRINT "Right Button Pressed"
PRINT "Left button released "; numreleases!; "Times"
PRINT "X = "; xcc%; "Y = "; ycc%
--------------------------------------------------------------------------------
* sub mousepick (ypos%(), xmin%(), xmax%(), pick%)
Checks to see if mouse cursor is at positions specified
in: ypos%() = line, xmin%() = minimum x pos. on line ypos%,
xmax%() = maximum x pos. on line ypos%. If mouse cursor is
at any of these locations AND left button is pressed, hilights
desired area, waits til left button released, then returns with
position number in pick% (whew). This allows you to simulate
"buttons" at various places on the screen, letting the user
"press" the buttons with the mouse. See MLIBDEMO.BAS for example
of how to use this routine.
--------------------------------------------------------------------------------
* sub msetpos
Uses global variables msy% and msx% to set a new
position for the mouse cursor. Change msy% and/or
msx% before calling this routine.
Example: msy% = 1 : msx% = 1
CALL msetpos
--------------------------------------------------------------------------------
* sub mwaitpress
Waits for a Mouse Button to be Pressed.
Example: CALL mwaitpress
--------------------------------------------------------------------------------
* sub mybounds (min%, max%)
Sets minimum and maximum y-axis boundaries for mouse cursor.
Example: min% = 2 : max% = 24
CALL mybounds(min%, max%)
--------------------------------------------------------------------------------
* function pathstring$
Returns current disk/path in a string of the
form C:\QB\EXE\ ... Trailing backslash included.
Note that this is a Function, not a Sub.
Example: PRINT pathstring$
--------------------------------------------------------------------------------
* sub picklist (list$(), choice%)
Lets the user pick from a long list of options.
The list should be contained in list$() before calling.
Upon return, the user's choice will be in choice%
(zero if aborted). See MLIBDEMO.BAS for example.
Example: DIM list$(1 to 100)
FOR x% = 1 TO 100
READ list$(x%) : NEXT x%
CALL picklist(list$(), choice%)
PRINT "You picked "; choice%
--------------------------------------------------------------------------------
* sub printborder
Prints a "border" around the screen. Used in MNSDEMO to
display the single border around the screen.
Example: CALL printborder
--------------------------------------------------------------------------------
* sub printtitle (title$, starty%, hilight%)
Prints the "title" of a program on the screen, similar to the
way QuickBASIC does on the second screenline, centered. Set
title$ to the desired title, starty% to the desired Y position
of the title on the screen, and hilight% to 1 for yes, 0 no
highlighted (reversed) title. See MNSDEMO.BAS for an example.
Example: CALL printtitle("MENULIB.REF", 2, 1)
--------------------------------------------------------------------------------
* sub radiobox (title$, optn$(), choice%)
Allows user to select a menu option using a "radio button"
type interface. User selects "OK" or "CANCEL" to end the
routine. If cancelled, choice% = 0, otherwise choice% will
contain the user's choice. Locate cursor to upper left corner
of box desired before calling. See MLIBDEMO.BAS for example.
Example: title$ = "Select One"
DIM optn$(3)
optn$(1) = "Option 1"
optn$(2) = "Option 2"
optn$(3) = "Option 3"
LOCATE 1,1
CALL radiobox(title$, optn$(), choice%)
PRINT "You chose ";choice%
--------------------------------------------------------------------------------
* sub screenedit (x1%, x2%, y1%, y2%, key$) static
An advanced routine that allows a user to edit a portion of the screen
using all the normal cursor keys and editing controls. Used by MNSDEMO
to allow editing of the screen. key$ will return keypresses not
recognized by the routine (ESC if user pressed Esc.)
x1%, x2% = Minimum and Maximum X Positions allowed (1-80).
y1%, y2% = Minimum and Maximum Y Positions allowed (1-25).
Example: CALL screenedit (1, 80, 1, 25, key$)
--------------------------------------------------------------------------------
* sub scrolldown (y1%, x1%, y2%, x2%, attrib%, ln%)
Scrolls a specified window of the screen down
y1%,x1% = Upper Left Corner
y2%,x2% = Lower Right Corner
Attrib% = Attrib stored in blanked area
ln% = Number of lines to scroll
Note: x/y pos start from 0 instead of 1
Example: CALL scrolldown(1, 1, 25, 80, 7, 1)
--------------------------------------------------------------------------------
* sub scrollup (y1%, x1%, y2%, x2%, attrib%, ln%)
Scrolls a specified window of the screen up
y1%,x1% = Upper Left Corner
y2%,x2% = Lower Right Corner
Attrib% = Attrib stored in blanked area
ln% = Number of lines to scroll
Note: x/y pos start from 0 instead of 1
Example: CALL scrollup(1, 1, 25, 80, 7, 1)
--------------------------------------------------------------------------------
* sub selectback (cl%)
Allows the user to select a background color from a menu
and returns it in cl% (-1 if user cancelled the routine).
This routine calls MENUPICK. See MLIBDEMO.BAS for example.
Example: CALL selectback(cl%)
--------------------------------------------------------------------------------
* sub selectfore (cl%)
Allows the user to select a foreground color from a menu
and returns it in cl% (-1 if user cancelled the routine).
This routine calls MENUPICK. See MLIBDEMO.BAS for example.
Example: CALL selectfore(cl%)
--------------------------------------------------------------------------------
* sub setdisk (d%)
Sets disk in d% to be default (current drive):
0 = A, 1 = B, 2 = C, etc.
Returns number of logical drives in system in d%.
Example: CALL setdisk(0)
--------------------------------------------------------------------------------
* sub showtextfile (fi$, clr%)
Displays a text file (filename in fi$) using the foreground
color in clr%. See MLIBDEMO.BAS for example.
Example: CALL showtextfile("file.txt", 15)
--------------------------------------------------------------------------------
* sub sounds (num%)
Makes a brief sound through the PC's speaker.
Call with num% set to:
1 = popup
2 = popdown
3 = klaxon
4 = siren
5 = blip
6 = 2-tone
7 = 2-tone triple
8 = 3-tone
9 = buzz
10 = chirp
11-14 = beep1-4
15 = 60hz
Example: CALL sounds(1)
--------------------------------------------------------------------------------
* function startofline% (ln%)
Returns the start of text on a particular screen line.
Call with ln% = the line you wish to check. If there is
no text on a particular screen line, the routine will return
1, otherwise returns the position of the first text (non-space)
character on the line. Note that this is a FUNCTION and not
a SUB.
Example: s% = startofline%(10)
--------------------------------------------------------------------------------
* sub vscrollbar (starty%, startx%, length%)
Displays a vertical scrollbar on the screen at the indicated
start Y and X positions, of length length%. Used by MNSDEMO
to display the vertical scroll bar.
Example: CALL vscrollbar(1, 1, 15)
--------------------------------------------------------------------------------
* sub yesnobox (msg$, choice%)
Prints a one-line message on the screen in a box,
and waits for user to select YES, NO or CANCEL.
Returns 1 (YES), 0 (NO) or -1 (Cancel).
Shortest string should be >20.
See MLIBDEMO.BAS for example.
Example: CALL yesnobox("Are you sure you want to quit?", choice%)
--------------------------------------------------------------------------------