home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boston 2
/
boston-2.iso
/
DOS
/
PROGRAM
/
BASIC
/
POWBASIC
/
LIBRARY3
/
APLIB.ZIP
/
HBDEMO.BAS
< prev
next >
Wrap
BASIC Source File
|
1990-11-24
|
64KB
|
1,776 lines
'
' ╔═════════════════════════════════════════════╗
' ║ ║
' ║ ║
' ║ THE NEW HB ALL-PURPOSE LIBRARY DEMO ║
' ║ ║
' ║ ║
' ║ FOR POWER-BASIC PROGRAMMERS ║
' ║ ║
' ║ ║
' ║ SPRING / SUMMER 1990 ║
' ║ ║
' ╚═════════════════════════════════════════════╝
' ┌─────────────────────────┐
' │ TO CREATE THIS DEMO OF │
' L O O K =============== >>>> │ THE APLIB ROUTINES JUST │
' :) │ TYPE "makedemo" FROM │
' │ THE COMMAND LINE ! │
' └─────────────────────────┘
'
' Version 2.00002 // NOVEMBER '90
' 9-16-90 fixed a bit (mostly so it'll work
' with the upcoming Power Basic version 2.10)
'
' 11-90: Incorporating some suggested improvements
' and a 3 fixes into FENTRY-U. The window preprocessors
' now both compile under PB -- one of them hadn't
' been updated from the TB 1.1 version when I first
' uploaded this suite. Oops!
' Someone also noted that APLQREF.BAS won't compile.
' I never thought it would. It's a Quick Reference
' guide I made up! It has a .BAS extension only so it
' will come up when I press F3 + CR from PB and get the
' file select menu; that way I can jump to it for help!
' MORE FIXES: Bulletproofing of QBox () and BOXMESSAGE ()
' Menu selection to test box routines
' Improved RotaDate -- the user can either use the
' arrow keys as before or just type the 4- or
' 6-digit date (1124 or 112490) directly. Thanks
' to Al Musella for the idea.
' Insert status in entry fields now a Global var.
' (so it stays set from field to field)
' Improved PWW & SWW
' NEW ROUTINE: FASTPHONE () -- much better than ENTERPHONE.
' (I keep forgetting most people can TYPE !!)
'
' And -- I know I've made more improvements, undocumented,
' as I continue to hack away at my office DBMS (which
' is getting quite GOOD, pardon me saying so!)
'
' -- Howard, 11-24-90
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'
' This is my custom routines library, a set of procedures etc. that I have
' written over a few years time, mostly for use in database programs. Also
' I include a do-nothing program intended for demonstration and
' development of the functions in the library.
'
' FEATURES:
' ------
'
' MAIN MENUS ACROSS TOP OF SCREEN AND PULLDOWN SUBMENUS -- WITH
' STANDARD KEYBOARD AND MOUSE CONTROL
'
' POP UP AND VANISH MENUS AND DIALOG BOXES, ANYWHERE ON THE SCREEN
'
' INPUT ROUTINES FOR TEXT FIELDS, NUMBERS, DATES ETC. W/ FULL EDITING --
'
' POP-UP DATA ENTRY WINDOWS -- CURSOR OR TAB BACK AND FORTH FROM
' FIELD TO FIELD
'
' GET DISK, DIRECTORY AND SYSTEM INFO DIRECTLY FROM DOS
'
' ALL IN BASIC FOR RELIABILITY AND EASY MAINTENENACE
'
' NOW USES UNITS, SAVES SCREENS DIRECTLY TO MEMORY
' (USED TO NEED A RAM-DISK, BUT NO MORE)
'
'
' Your feedback is welcomed -- write to 2097 7th St. in
' Oakland, Ca. 94607 -- or via the CompuServe PCVENB
' Forum (# 71121,776), or MOE in the Bay Area.
'
' -- Howard Ballinger
'
$COMPILE EXE
$LIB LPT ON,_
COM OFF, GRAPH OFF, FULLFLOAT OFF, IPRINT OFF
$STACK 3072
$ERROR ALL ON
%ScrnStackSize = 12
' Correct order seems to be: DIM Statements, $LINK statements,
' then PUBLIC statements. WORKS !!
$INCLUDE "APLIB-H.BAS"
$LINK "INIT-U.PBU"
$LINK "FENTRY-U.PBU"
$LINK "FIGDAT-U.PBU"
$LINK "BOXES-U.PBU"
$LINK "MENUS-U.PBU"
$LINK "MISC-U.PBU"
$INCLUDE "HBDEMO.PV"
' The *.PV files are lists of all the
' public variables in a program's units.
' Any time you change the EXTERNAL
' variables in your units, run
' PUBVARS.EXE and you will get a fresh,
' sorted list to include in the main
' file, like this.
ButtonsActive = %False ' (button feature used only in MC-MENU.BAS)
LocalAreaCode$ = "415"
Item% = 101 ' (starting # for demo checkbook entries)
CALL Initialize (%LQ2500) ' see INIT-U.BAS for other sets of
' printer codes you can select. (New!)
ON ERROR GOTO Oops
' =============================================== TITLE SCREEN
GOSUB SetColors
COLOR ScrColor MOD 16, ScrColor \ 16 ' This breaks down an integer color
' attribute into foreground & backgrd
CLS
GOSUB Logo3 ' print a title in a box on screen
COLOR ScrColor MOD 16, ScrColor \ 16
' and next, open a Static Window
' (by that I mean one that displays
' some data at run-time but doesn't
' let the user enter any) and
' displays some disk and system
' info in it.
' ===========================================================================
' USE OF THE SWW.EXE is a screen generator
' STATIC WINDOW and by processing DEMO.SW
' PAINT UTILITY gives the BASIC statements in
' SWW.EXE these lines to draw window
' and set up its static fields.
' The template files are similar
' to those use to make POPWINDOW
' designs, as described below.
' See OPENDEMO.SW for an example.
' ===========================================================================
$INCLUDE "opendemo.inc"
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 24, 41: PRINT "note: use a mouse if you wish. L = yes.";
COLOR BarColor MOD 16, BarColor \ 16
LOCATE 25,1: CALL ClearLine ' SUB ClearLine erases screen from cursor
' position all the way to rt edge of scrn
PRINT " SOUND ON ?? ";
SoundOn = GetYesOrNo ' FUNCTION GetYesOrNo simply writes a
' "(y/n)" prompt to the screen and then
' awaits the user's pleasure. It is case
' insensitive & also Mousable. (L = Yes.)
GOSUB SetBeeps
If SoundOn THEN PLAY ArribaBeep$
Choice = 256 ' We don't want Choice, the
' menu return value, to be 0 at
' the start. A Choice value of
' 0 is used for a specific
' purpose: it means [Esc] was
' pressed in reponse to a
' pull-down menu.
' ==================================== PRINT MAIN MENU -- A BAR ACROSS TOP
MainMenu:
GOSUB SetColors ' set colors based on defaults
COLOR ScrColor MOD 16, ScrColor \ 16 ' or command line switches.
CLS
NextScrn2Pop = 1 ' Reset the screen stack pointer
' to 1. At this point the
' next screen we "push" (save) will
' be numbered 2 (I'm not using an 0)
IF Choice > 0 THEN ' unless user has just backed out of a menu w/o selecting,
TChoice = 1 ' the return variable Choice will be > 0 and
GOSUB Logo2 ' the main menu will be reset to choice #1
END IF
TLine$ = " HB's POW-Bas Routines Library: the Demo " ' menu title
RESTORE MainMenu
If SoundOn THEN PLAY LookitBeep$
' =============================================================================
'
' How to use "TOPMENU ()" -- The Horizontal Main Menu Procedure --
' -----------------------------------------------------------
'
' This procedure writes a list of choices across the top of the screen and
' allows the user to select from them by one of three methods: (1) Press the
' first letter of the desired choice (note that you can't have two choices
' starting with the same letter!) or (2) use the cursor arrows to highlight
' your choice and then press Enter (CR), or (3) if you have a Furry Friend,
' just click on your choice with the left button. (This is pretty much the
' way people expect a menu to behave!)
'
' Set it up with a DATA list of selection titles like the one following --
' follow w/ DATA END; don't forget to RESTORE to the label above the list.
' you can use less than a three line menu (to save screen space) but
' frankly I haven't used 2-line or 1-line TOPMENU's enough to even know
' whether they have bugs, so just use 3 for now. T$ should be the menu
' title if you want one, and after the CALL returns, will be set to the
' string chosen by the user or "HELP!" if F1 pressed. Mostly I just branch
' the program on the basis of TChoice, an integer showing which selection
' was made.
' =============================================================================
DATA "POPWINDOW DEMO","FILES","MENUS & BOXES","OTHER DEMOS","QUIT/CONFIG"
DATA END
NumberOfLines = 3
DO
CALL TOPMENU (NumberOfLines,TChoice,T$)
' if T$ = "HELP!"a suitable help screen may be added here ...
LOOP UNTIL T$ <> "HELP!"
CALL SCREENPUSH ' save this screen to memory ...
MainMenuScreen = NextScrn2Pop ' make a note of what number it is ...
ON TChoice GOTO OpenEntryWindow, FileSubmenu, MenuDemo, MiscDemos, QuitSubMenu
' ------------------ MAIN MENU CHOICE # 2: FILE SUBMENU ------------------
FileSubmenu:
' ============================================================================
' Notes: *** HOW TO USE: SUPERMENU () ***
' ===================
'
'Syntax:
'CALL SUPERMENU (MenuData$(), MenuRight, MenuDown, Choice, Title$, KeyPressed)
'
'
' MENU SETUP: THE MenuData$ ARRAY:
' Each choice on your menu is represented by one string element in
' this array. The decription of each choice -- for example, "LOAD",
' will start with the third character of this string. If you are
' specifying the hot-key for each choice put it into the first
' character -- set MenuData$ (1) as something like "L LOAD". To let
' the software number or letter the items in order for you, set
' MenuData$ as just " LOAD". (If there are <10 items, numbers
' are used rather than letters.) After the last menu item, you
' must set the next array element as "END".
' PASSING HELP LINES TO MENU: Set MenuHelpLine$() to contain lines (up
' to 80 chr long) to appear at screen bottom whenever the
' corresponding menu choice is highlighted.
' POSITION OF MENU ONSCREEN ETC.: MenuRight moves it right or left --
' MenuDown moves it -- you guessed it! 0,0 is top center. Errors are
' trapped. Vertical centering is gotten by setting MenuDown = 25.
' Usually set Choice = 1. Title$ is title of menu.
' *** AFTER MENU ROUTINE: Choice will hold the choice #. Title$ reset to "".
' MKeyPressed$ = the actual key used (if L. Mousebutton was used it
' simulates the CR key, i.e. CHR$(13)) -- or if [ESC] or a legal
' function key was pressed it contains "ESC", "PgDn", "PgUp", "F1",
' or "F2". (Right Mousebutton = "ESC".)
' ============================================================================
MenuData$(1) = "F Directory"
MenuData$(2) = "V View .BAS"
MenuData$(3) = "D View .DOC"
MenuData$(4) = "C Copy files"
MenuData$(5) = "O Shell to DOS"
MenuData$(6) = "END"
MenuHelpLine$ (1) =_
"Using CALL DirFirst & DirNext (SUB's that get info direct from DOS)"
MenuHelpLine$ (2) = "this lets you read the source file HBDEMO.BAS"
MenuHelpLine$ (3) =_
"this lets you display the documentation accompanying HBLib"
MenuHelpLine$ (4) = "here a dummy function"
MenuHelpLine$ (5) = "this works -- if it can find COMMAND.COM & load it ..."
Title$ = ""
Choice = 1
PullDown = %Yes ' Make this a pulldown supermenu ...
UseRArrow = %Yes ' We want to be able to drag it either
UseLArrow = %Yes ' rt or left with arrow keys or rodent ...
MenuRight = -15
MenuDown = 2
CALL SUPERMENU (MenuData$(), MenuRight, MenuDown,_
Choice, Title$, KeyPressed)
DECR NextScrn2Pop ' we won't need to pop the previous screen
IF Choice = 0 THEN MainMenu
IF KeyPressed = %LArrow THEN GOSUB MZap: GOTO OpenEntryWindow
IF KeyPressed = %RArrow THEN GOSUB MZap: GOTO MenuDemo
SELECT CASE LEFT$ (MenuData$ (Choice), 1)
CASE "F"
GOSUB Directory
GOTO MainMenu
CASE "V", "D"
If SoundOn THEN PLAY LookitBeep$
IF ColorDisplay THEN COLOR %Wht, %Vlt ELSE COLOR %Gry, %Blk
CLS
IF Choice = 3 THEN File2View$ ="AP-LIB.DOC" ELSE File2View$ = "HBDEMO.BAS"
IF EXIST (File2View$) THEN ' uses function EXIST () ...
TxtFile = FREEFILE ' gets an available handle # ...
OPEN File2View$ FOR INPUT AS #TxtFile
Ln = 0
DO UNTIL EOF (TxtFile) OR FileError ' and views the file.
LINE INPUT #1, L$
INCR Ln
PRINT LEFT$ (L$, 79)
IF CSRLIN = 23 THEN
Color %Blu, %Cyn
PRINT STRING$ (80, 205);
CALL ClearLine
PRINT " WORLD'S MOST PRIMITIVE FILE VIEWER: File ";
PRINT File2View$; ", LINE "; Ln-21;
LOCATE 25,1
CALL ClearLine
PRINT " PRESS [ESC] TO EXIT, [PG-UP] TO GO BACK TO LINE 1, ";
PRINT "ANY OTHER KEY TO GO ON";
Color %Wht, %Vlt
DO: LOOP UNTIL INSTAT
K$ = INKEY$
IF K$ = CHR$ (27) THEN EXIT LOOP
IF K$ = CHR$ (0) + CHR$ (&H49) THEN
If SoundOn THEN PLAY TinyBeep$
CLOSE #TxtFile
OPEN File2View$ FOR INPUT AS #TxtFile
Ln = 0
END IF
FOR N = 1 TO 23: LOCATE N, 1: CALL ClearLine: NEXT: LOCATE 1,1
END IF
LOOP
If SoundOn THEN PLAY ArribaBeep$
CLOSE #1
ELSE
CALL QBox (10,30,1,"DID NOT FIND FILE " + File2View$, 0)
' QBox was written to put little dialog boxes
' onscreen -- but it turns out to very handy
' as a message box as well. This will print
' a box at position 19,13 with this string
' in it and an answer field length of zero
CALL PressAKey ' Little box says Press Any Key ... if mouse
END IF ' present it also suggests a click.
EXIT SELECT
CASE "O"
If SoundOn THEN PLAY LookitBeep$
IF ColorDisplay THEN COLOR %Ylo, %Red ELSE COLOR %Blk, %Gry
CLS
LOCATE 2,12: PRINT "TYPE `EXIT' TO RETURN TO PROGRAM"
SHELL
GOTO MainMenu
CASE ELSE
GOTO FakeFunction
END SELECT
GOTO MainMenu
' -------------------- MAIN MENU CHOICE #3: MENU DEMOS ----------------
MenuDemo:
MenuData$ (1) = " Demo of MESSAGEBOX"
MenuData$ (2) = " Demo of QBOX"
MenuData$ (3) = " Demo of SUPERMENU"
MenuData$ (4) = " Hundred Items Menu"
MenuData$ (5) = "END"
Choice = 1
PullDown = %Yes
UseRArrow = %Yes
UseLArrow = %Yes
CALL SUPERMENU (MenuData$ (), 0, 2, Choice, "", KeyPressed)
IF KeyPressed = %LArrow THEN GOSUB MZap: GOTO FileSubMenu
IF KeyPressed = %RArrow THEN GOSUB MZap: GOTO MiscDemos
ON Choice GOSUB MessageBoxTest, QBoxTest, MoveAMenuII, HundredItemsMenu
' NOTE: if [Esc] was pressed, Choice = 0 and there's no GOSUB at all.
GOTO MainMenu
' ==================== MAIN MENU CHOICE # 4 -- MISC. SUBMENU
MiscDemos:
' set up menu lines & help lines ...
MenuData$ (1) = " ENTRY MODES" ' note that for this menu I've
MenuData$ (2) = " DATE ARITHMETIC" ' left two spaces in front of
MenuData$ (3) = " BEEPS" ' each choice. SUPERMENU will
MenuData$ (4) = " END" ' number them (or letter if > 9)
MenuHelpLine$ (1) = "many different types of line entries demonstrated"
MenuHelpLine$ (2) = "the all-knowing machine will tell you your age ..."
MenuHelpLine$ (3) =_
"this is a test-bed to invent, hear and save your own favorite Beeps ..."
MenuRight = 18 ' locate menu ...
MenuDown = 2
Choice = 1 ' start with first item highlighted ...
Title$ = "" ' no title ...
Choice = 1
UseRArrow = %Yes
UseLArrow = %Yes
PullDown = %Yes
CALL SUPERMENU (MenuData$(), MenuRight, MenuDown, Choice, Title$, KeyPressed)
IF KeyPressed = %LArrow THEN GOSUB MZap: GOTO MenuDemo
IF KeyPressed = %RArrow THEN GOSUB MZap: GOTO QuitSubMenu
DECR NextScrn2Pop ' we won't need to pop the previous screen
ON Choice GOSUB EnterDemo, DateTest, BeepTest
GOTO MainMenu
QuitSubMenu: ' ====================== MAIN MENU CHOICE #5: QUIT
MenuData$ (1) = "Y Exit to DOS"
IF SoundOn THEN
MenuData$ (2) = "S Sound Off"
ELSE
MenuData$ (2) = "S Sound On"
END IF
MenuData$ (3) = "E Fake ERROR"
MenuData$ (4) = "N Cancel"
MenuData$ (5) = "END"
MenuHelpLine$ (3) = "force an error just to see the error handling routine"
MenuHelpLine$ (4) = "don't quit after all ... "
Title$ = ""
Choice = 1
PullDown = %Yes
UseLArrow = %Yes
CALL SUPERMENU (MenuData$(), 40, 2, Choice, Title$, KeyPressed)
IF KeyPressed = %LArrow THEN GOSUB MZap: GOTO MiscDemos
If SoundOn THEN PLAY LookitBeep$
IF CHOICE = 0 THEN
CALL SCREENPOP
GOTO MainMenu
ELSE
IF LEFT$ (MenuData$ (Choice), 1) <> "E" THEN COLOR 0,0:CLS:DECR NextScrn2Pop
END IF
IF Choice <> 0 THEN OldChoice = 1
SELECT CASE LEFT$ (MenuData$ (Choice), 1)
CASE "Y"
LastScrn:
CLS
CALL CloseFiles ' Take care of writing database files back if any...
DELAY 0.5
ON ERROR GOTO HarmlessError
CALL RestoreDOSScreen ' restore screen that was there to begin with;
LOCATE ,,0
' write a boxed Farewell Message on top
' of the restored screen -- really
' impress 'em!
DATA "Thank you for using", "the HB Library DEMO",""
DATA Program ends., Press something.
DATA END
' ===================================
' USING BOXMESSAGE ():
' You need a DATA list like this;
' use a RESTORE statement so the
' runtime system can find it;
RESTORE LastScrn ' set the margin ...
Margin = 1 ' set CornerLin & CornerCol or use
If SoundOn THEN PLAY TaskBeep$ ' %Center as we do here to center the
CALL SCREENPUSH ' window ... and it's ready.
' ===================================
CALL BOXMESSAGE (%Center, %Center, Margin)
GOSUB ClickOrStrike
CALL SCREENPOP ' erase the box and return control to DOS.
LOCATE OrigL, OrigC
END ' ================>> EXIT POINT
CASE "S"
SoundOn = NOT SoundOn
CASE "E"
ErrorMessage$ = "fake error generated from HBDEMO menus"
DO
CALL SCREENPUSH
EType$ = " "
CALL QBox_
(5,10,1,"D for DOS ERROR, P for PRINTER ERROR, O for OTHER ERROR ", 2)
COLOR FldColor MOD 16, FldColor \ 16
Opt$ = "AutoCap"
FieldSize = 1
CALL ENTERSTRING (EType$, FieldSize, Opt$)
' =============================================================================
' How to use SUB ENTERSTRING (Wkg$,FLength,Opt$)
' ----------------------------------------
' This routine provides a field at current corsor loc
' for the operator
' to enter data into. Wkg$ is the current value of the field.
' FLength = length of field. Opt$ may be "" or may hold
' the strings "Cap" for all uppercase, "Auto" for automatic
' entry when full, "UpOut" or "BackOut" if UpArrow or Left/
' backspace keys are to be able to end entry. Tab and ShfTab
' also work.
'
' On exiting sub, Opt$ may be reset as Left, Auto, Up, Down, ESC or CR.
' At any time during string entry the operator can press [CR] or DOWN-
' ARROW to enter; [F2] is pressed for Database Function commands
' (Clear, Find, Next/Prev, View Notes, Save) implemented (see SUB
' FileFunctions)
' 2-4-89: Now supports: Ins default (in Opt$), ^Y, ^T, and ^Arrow
' Negative numbers not allowed unless Opt$ includes a "-"
'
' N.B.: OF COURSE THIS IS JUST A ONE-CHR STRING TO ENTER. I PUT THE DOC
' BLOCK HERE 'CAUSE IT'S THE F I R S T INSTANCE OF THIS CALL.
' THERE ARE MANY MORE-TYPICAL EXAMPLES TO FOLLOW ...
' ===========================================================================
CALL SCREENPOP
LOOP UNTIL EType$ = "O" OR EType$ = "P" OR EType$ = "D" OR Opt$ = "ESC"
ON ERROR GOTO Oops
IF Opt$ = "ESC" THEN MainMenu
SELECT CASE EType$
CASE "O"
ERROR 5
CASE "D"
JustDemonstratingOops = %True
ERROR 53
EXIT SELECT
CASE ELSE
ERROR 27
END SELECT
END SELECT
GOTO MainMenu ' here end the various pulldown menus. Next
' come major routines ... Starting with
' OpenEntryWindow (lifted, as you might guess,
' from my personal custom Checkbook Program).
OpenEntryWindow:
'===============================================================================
' ABOUT POPWINDOWS:
' Here's how to create a window for data entry like the one demonstrated
' here: (1) Create a plain-ASCII template file for your window and name
' it like WHATEVER.PW (See PWDEMO.PW for a sample).
' (2) Draw out the top and left side of the window box using the
' carat (^^^) symbol. Type in the field titles and then use a
' left bracket ("{") to show where you want each data entry field
' to start.
' (3) Under that type a backslash ("\") at the left margin, followed
' by a list of the following: First your name for the field, then
' a comma, and then IN QUOTES the mask string you want to use for
' the data in your field (according to the rules for the
' PRINT USING statement).
' (4) Now you need to use a utility PWW.EXE. Compile PWW.BAS to create
' it if you need to. Type PWW, followed optionally by the name
' of your POPWINDOW file (with or without its .PW extension). If
' you haven't screwed up, an INClude file will be created just
' like PWDEMO.INC, to include (or read into) your program !!
'===============================================================================
RESTORE OpenEntryWindow
$INCLUDE "PWDEMO.INC" ' contains DATA statements
' to define the window.
CALL POPWINDOW
If SoundOn THEN PLAY LookItBeep$
'===============================================================================
' OK, now what's happened ?? First off, your data entry window has been
' opened (drawn) on the screen, using the attribute BoxColor; and the blank
' data fields have been added using FieldColor. Also a table has been created
' in memory consisting of several arrays to instantly reset the cursor to
' any of the fields in the window and find which mask string to use on that
' particular field. This job is done by PWSetUp (). Read on ...
'===============================================================================
' ____________________________
NewRec = %True
BeginEntry:
GetTypeOfTransaction:
LOCATE 25,1: CALL ClearLine
LOCATE 24,1: CALL ClearLine: PRINT Esc2Q$;
' create a SUPERMENU of these choices ...
MenuData$ (1) = "C CHECK"
MenuData$ (2) = "D DEPOSIT"
MenuData$ (3) = "A AUTO DEBIT"
MenuData$ (4) = "T TRANSFER"
MenuData$ (5) = "J ADJUSTMENT"
MenuData$ (6) = "END"
CALL SCREENPUSH
Choice = 1 ' start with first item highlighted ...
Title$ = "" ' no title ...
Choice = 1
UseRArrow = %Yes
PullDown = %Yes
MenuDown = 2
MenuRight = -40
CALL SUPERMENU (MenuData$(), MenuRight, MenuDown, Choice, Title$, KeyPressed)
IF KeyPressed = %RArrow THEN GOSUB MZap: GOTO FileSubMenu
IF Choice = 0 THEN
COLOR %Vlt, %Vlt: CLS
GOTO MainMenu
END IF
TypeOfTransferMenu:
IF Choice = 4 THEN
DATA FROM CHECKING TO SAVINGS,
DATA FROM SAVINGS TO CHECKING,
DATA END
' this is a POPMENU, the predecessor
' of SUPERMENU. Now SUB POPMENU ()
' is just a wrapper for SUPERMENU
RESTORE TypeOfTransferMenu ' so I don't have to convert all my
MLine$ = "type of transfer" ' old code. It uses READ intead of
Choice = 1 ' passing an array.
CALL POPMENU ("1", -12, 9, Choice, MLine$, Dum$)
CALL SCREENPOP
IF Choice = 0 THEN GOTO BeginEntry
IF ColorDisplay THEN COLOR %Ylo,%Red
IF Choice = 1 THEN TransactionType$ = "TRANSFER C-S" ELSE_
TransactionType$ = "TRANSFER S-C"
ELSE
CALL SCREENPOP
TransactionType$ = MID$ (MenuData$ (Choice), 3)
END IF
'===============================================================================
' OK, gentle hackfriend -- don't panic! What happens in the first data entry
' field in this dummy checkbook program, is that two successive menus are used
' as "pick lists" to get the data rather than having the user type it in. (If
' this isn't clear, try it out -- run HBDEMO.EXE -- and it should make
' a modicum of sense.)
'
' So here is that PWSetUp () call. It searches out a field name in the table
' I mentioned above to match the field description string (FldN$)
'===============================================================================
FldN$ = "TYPE OF TRANSACTION"
COLOR FldColor MOD 16, FldColor \ 16
KeyField = %False
CALL PWSetUp (FldN$,Tbl%)
' now the cursor should be in
' the right place and Tbl%
' should be the right item # in
' the array. Let's try it & see ...
PRINT USING FieldMask$(Tbl%); TransactionType$
' _______________________________________ WOW !!! NeatO !!
CheckNumberEntry:
COLOR %Blk, %Blk: LOCATE 23,1: CALL ClearLine
COLOR FldColor MOD 16, FldColor \ 16
LOCATE 25,1: CALL ClearLine: PRINT " "; F2Fun$; Up2B$; Esc2Q$;
LOCATE 24,1: CALL ClearLine: PRINT EnHelp$;
FldN$ = "NUMBER": A# = Item%
CALL PWSetUp (FldN$,Tbl%)
IF RTRIM$ (TransactionType$) = "CHECK" THEN
KeyField = %True ' this clues in the FileFunctions menu
Opt$ = "F1 F2 UpOut"
' ENTERNUMBER () works a lot
CALL ENTERNUMBER (A#,"####",Opt$) ' like ENTERSTRING () except
' you specify a Mask String
' so it can do PRINT USING.
IF Opt$ = "HELP!" THEN GOSUB EDHelp: GOTO CheckNumberEntry
IF Opt$ = "Up" OR Opt$ = "ShfTab" GOTO GetTypeOfTransaction
Item% = A#
GOSUB F2orEscHandler
ELSE
PRINT " -- "
END IF
DateEntry:
LOCATE 25,1: CALL ClearLine: PRINT " "; Up2B$; Esc2Q$;
BXScreenSaved = %False
KeyField = %True
FldN$ = "DATE"
CALL PWSetUp (FldN$,Tbl%)
L = CSRLIN: C = POS
IF DateLastUsed$ = "" OR_
FigDate& (DateLastUsed$) = 0 THEN DateLastUsed$ = GetDate$
IF Opt$ <> "Up" AND Opt$ <> "ShfTab" OR_
FigDate& (TransactionDate$) = 0 THEN TransactionDate$ = DateLastUsed$
Opt$ = "N/AOK"
CALL RotaDate (TransactionDate$,Opt$)
' =========================================================================
' ROTADATE: This is the date entry routine where you can use the cursor
' keys to go ahead or back to the date you want. If you want you can
' also key in the date in the usual way ...
' =========================================================================
IF Opt$ = "HELP!" THEN GOSUB EDHelp: GOTO DateEntry
' FigDate returns a 0 if
' LOCATE L,C
' PRINT TransactionDate$
IF Opt$ = "Up" OR Opt$ = "ShfTab" GOTO CheckNumberEntry
GOSUB F2orEscHandler
DateLastUsed$ = TransactionDate$
ToFromWhomEntry:
LOCATE 24,1: CALL ClearLine: PRINT EnHelp$;
LOCATE 25,1: CALL ClearLine: PRINT " "; F2Fun$; Up2B$; Esc2Q$;
KeyField = %True
FldN$ = "TO/FROM"
CALL PWSetUp (FldN$,Tbl%)
X = CSRLIN: Y = POS
Opt$ = "F1F2UpOutCaps"
IF RTRIM$ (TransactionType$) = "AUTO DEBIT" THEN
ToFrom$ = "CASH FROM A.T.M."
ELSE
ToFrom$ = ""
END IF
CALL ENTERSTRING (ToFrom$,LEN(FieldMask$(Tbl%)),Opt$)
IF Opt$ = "HELP!" THEN GOSUB EDHelp: GOTO ToFromWhomEntry
IF Opt$ = "Up" OR Opt$ = "ShfTab" THEN GOTO DateEntry
GOSUB F2orEscHandler
KeyField = %False
IF Opt$ = "Up" THEN
GOTO DateEntry
ELSE
ToFrom$ = A$
END IF
EntAmt:
COLOR Ink2, Paper2
COLOR FldColor MOD 16, FldColor \ 16
LOCATE 25,1: CALL ClearLine: PRINT Up2B$; Esc2Q$;
FldN$ = "AMOUNT": Amt# = 0
CALL PWSetUp (FldN$,Tbl%)
Opt$ = "F2UpOut - "
CALL ENTERNUMBER (Amt#, FieldMask$(Tbl%), Opt$)
IAmtCents& = 100 * Amt#
IF Opt$ = "Up" OR Opt$ = "ShfTab" GOTO ToFromWhomEntry
GOSUB F2orEscHandler
SaveRecord:
COLOR %Wht,%Blk: LOCATE 24,1: CALL ClearLine: LOCATE 25,1: CALL ClearLine
LOCATE 24,9: PRINT "Note: THERE IS NO REAL SAVE RECORD FUNCTION -- DUMMY ONLY";
CALL SCREENPUSH
CALL QBox (19,30,1,"SAVE RECORD ?? ",3)
If SoundOn THEN PLAY LookitBeep$
CALL ENTERYESNO (Confirm) ' query if save to be done ...
CALL SCREENPOP
IF Confirm THEN
If SoundOn THEN PLAY TaskBeep$
DELAY 1.6
IF RTRIM$ (TransactionType$) = "CHECK" THEN INCR Item%
GOTO MainMenu
ELSE
GOTO BeginEntry
END IF
GOSUB SaveRecord
GOTO OpenEntryWindow
'___________________________________________________________________________
F2orEscHandler:
' Smart menu of choices appropriate to a database,
' such as SAVE, CLEAR, FIND, NEXT etc.
IF Opt$ = "F2" THEN
If SoundOn THEN PLAY LookitBeep$
SELECT CASE GetFileFunction$
CASE "C"
RETURN OpenEntryWindow
CASE "F"
RETURN FakeFunction
CASE "S"
RETURN SaveRecord
CASE ELSE
RETURN
END SELECT
ELSEIF Opt$ = "ESC" THEN
IF NOT IsBlank (TransactionType$) THEN
CALL SCREENPUSH
CALL QBox (%Center, %Center, 1,_
"DO YOU WANT TO CLEAR THIS ENTRY AND RETURN TO MAIN MENU ?? ", 7)
IF NOT GetYesOrNo THEN CALL SCREENPOP: RETURN
END IF
NextScrn2Pop = MainMenuScreen
CALL SCREENPOP
RETURN MainMenu
END IF
RETURN
' ___________________________________________________________________
EnterDemo:
If SoundOn THEN PLAY LookitBeep$
IF ColorDisplay THEN
FldColor = %Ylo + %Background * %Red
ScrColor = %Ylo + %Background * %Blk
END IF
COLOR %Gry, %Blk
CLS
' Code to write Static Window {ENTERDEM} to Screen
' note: created by StatWindow Writer (SWW) from ENTERDEM.SW
COLOR BoxColor MOD 16, BoxColor \ 16
LOCATE 2, 9
PRINT "┌───────────────────────────────────────────────────────────┐"
LOCATE 3, 9
PRINT "│ A-P Library Demo : the Data Entry Routines │";
LOCATE 4, 9
PRINT "│ │";
LOCATE 5, 9
PRINT "│ (ENTERSTRING, ENTERNUM, ENTERDATE ETC.) │";
LOCATE 6, 9
PRINT "└───────────────────────────────────────────────────────────┘";
COLOR ScrColor MOD 16, ScrColor \ 16
' 07-06-1990, 23:46: end of StatWindow generated code for window {ENTERDEM}
LOCATE 24,1: CALL ClearLine: PRINT EnHelp$;
LOCATE 25,1: CALL ClearLine: PRINT F1Help$;
' ----------------------- First line: a plain entry, except no lower case:
StartEntries:
O$ = "DEFAULT ENTRY" ' the string starts off as this
LOCATE 7,4: PRINT "REGULAR ENTRY, ALL CAPS w/ DEFAULT: "; ' leave cursor here
COLOR FldColor MOD 16, FldColor \ 16
Opt$ = "Caps F1" ' use all capitals, accept F1
FLength = 14
CALL ENTERSTRING (O$, FLength, Opt$)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 7,60: PRINT "Opt$ = ";Opt$;" " ' The value of Opt$
IF Opt$ = "HELP!" THEN GOSUB EDHelp: GOTO StartEntries ' on termination of
IF Opt$ = "ESC" GOTO DoneED ' SUB ENTER* shows
' what key was used
' to exit the sub.
' -------------------------- Next line: a string with Auto-CR when field full:
P$ = "Just keep typing ..."
AutoE:
LOCATE 9,4: PRINT "ENTRY w/ AUTOMATIC TERMINATION: ";
COLOR FldColor MOD 16, FldColor \ 16
Opt$ = "F1 Auto"
CALL ENTERSTRING (P$, 20, Opt$)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 9,60: PRINT "Opt$ = ";Opt$;" "
IF Opt$ = "HELP!" THEN GOSUB EDHelp: GOTO AutoE
IF Opt$ = "ESC" GOTO DoneED
' ------------------------ This time up-arrow, ShfTab or left arrow will exit
LOCATE 25,1: PRINT Up2B$; F1Help$;
UpArrE:
LOCATE 11,4: PRINT "ENTRY w/ UP-ARROW & BACK-OUT ENABLED: ";
COLOR FldColor MOD 16, FldColor \ 16
Opt$ = "F1UpOut BackOut"
CALL ENTERSTRING (Q$, 4, Opt$)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 11,60: PRINT "Opt$ = ";Opt$;" "
IF Opt$ = "HELP!" THEN GOSUB EDHelp: GOTO UpArrE
IF Opt$ = "Up" OR Opt$ = "Left" OR Opt$ = "ShfTab" GOTO AutoE
IF Opt$ = "ESC" GOTO DoneED
' ----------------------------- Let us not forget the main purpose of
' computers, counting beans! Here is money entry:
DollE:
LOCATE 13, 4: PRINT "DOLLAR AMOUNT ENTRY: ";
COLOR FldColor MOD 16, FldColor \ 16
IF Opt$ <> "Up" THEN O# = 0: Opt$ = "F1UpOut"
' Here is ENTERNUMBER ().
CALL ENTERNUMBER (O#,"$####.##", Opt$) ' Note that the second argument is
' a mask string for PRINT USING.
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 13,60: PRINT "Opt$ = ";Opt$;" "
IF Opt$ = "HELP!" THEN GOSUB EDHelp: GOTO DollE
IF Opt$ = "Up" OR Opt$ = "ShfTab" GOTO UpArrE
IF Opt$ = "ESC" GOTO DoneED
' ---------------------------- Now let's enter a decimal number.
NumE:
LOCATE 15, 4: PRINT "NUMERIC ENTRY, 1 DECIMAL: ";
COLOR FldColor MOD 16, FldColor \ 16
Opt$ = "F1UpOut"
IF Opt$ <> "Up" THEN P# = 98.6
CALL ENTERNUMBER (P#,"##.#", Opt$)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 15,60: PRINT "Opt$ = ";Opt$;" "
IF Opt$ = "HELP!" THEN GOSUB EDHelp: GOTO NumE
IF Opt$ = "Up" OR Opt$ = "ShfTab" GOTO DollE
IF Opt$ = "ESC" GOTO DoneED
' --------------------------------- ... an SSA # ...
SSNE:
LOCATE 17,4: PRINT "ENTER A SOCIAL SECURITY #: ";
COLOR FldColor MOD 16, FldColor \ 16
' IF Opt$ <> "Up" THEN SSN$ = ""
Opt$ = "F1UpOut"
CALL ENTERSSN (SSN$, Opt$)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 17,60: PRINT "Opt$ = ";Opt$;" "
IF Opt$ = "HELP!" THEN GOSUB EDHelp: GOTO SSNE
IF Opt$ = "Up" OR Opt$ = "ShfTab" GOTO NumE
IF Opt$ = "ESC" GOTO DoneED
' ------------------------------------
PhoneE:
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 19,4: PRINT "ENTER A PHONE #: ";
COLOR FldColor MOD 16, FldColor \ 16
IF Opt$ <> "Up" THEN Phone$ = ""
Opt$ = "F1UpOut"
CALL ENTERPHONE (Phone$, Opt$)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 19,60: PRINT "Opt$ = ";Opt$;" "
IF Opt$ = "HELP!" THEN GOSUB EDHelp: GOTO PhoneE
IF Opt$ = "Up" OR Opt$ = "ShfTab" GOTO SSNE
IF Opt$ = "ESC" GOTO DoneED
' =========== NEW !!! ====================
CALL SCREENPUSH
CALL QBox (%Center, %Center, 3,_
"Here's the NEW phone # routine, FASTPHONE", 14)
CALL FASTPHONE (Phone2$, Opt$)
DELAY 3
CALL SCREENPOP
' ------------------------------------------------------- a date & a time ...
IF DateLastUsed$ = "" OR_
FigDate& (DateLastUsed$) = 0 THEN DateLastUsed$ = GetDate$
IF Opt$ <> "Up" AND Opt$ <> "ShfTab" OR_
FigDate& (D0$) = 0 THEN D0$ = DateLastUsed$
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 21,4: PRINT "DATE (use arrows or numbers) ";
COLOR FldColor MOD 16, FldColor \ 16
Opt$ = "F1 N/Aok"
CALL ROTADATE (D0$, Opt$)
IF Opt$ = "Up" OR Opt$ = "ShfTab" GOTO PhoneE
IF Opt$ = "ESC" GOTO DoneED
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 21,50: PRINT "TIME: ";
COLOR FldColor MOD 16, FldColor \ 16
T$ = ""
Opt$ = "F1UpOut"
CALL ENTERTIME (T$, Opt$)
IF Opt$ = "Up" OR Opt$ = "ShfTab" GOTO PhoneE
DoneED:
LOCATE 25,1: CALL ClearLine
IF NeedDCon THEN
PRINT " hit a key or click your beast to go on ...";
ELSE
PRINT " hit a key to go on ...";
END IF
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 24,1: CALL ClearLine
GOSUB ClickOrStrike
GOTO MainMenu
EDHelp:
CALL SCREENPUSH
RESTORE EDHelp
CALL BOXMESSAGE (0, 0, 1)
GOSUB ClickOrStrike
CALL SCREENPOP
COLOR FldColor MOD 16, FldColor \ 16
RETURN
DATA "HELP FOR DATA ENTRY ROUTINES FROM HB'S ALL-PURPOSE POWER-BASIC TOOLBOX"
DATA ""
DATA "There is a space on the screen to type something into. The keyboard"
DATA "works the way you'd expect it to -- just like typing on a word"
DATA "processing program. If numbers are expected, no other keys will work."
DATA ""
DATA "You can switch between INSERT MODE (big cursor) OVERSTRIKE MODE w/"
DATA "[INSERT] key. The [DELETE] key removes the letter the cursor is on;"
DATA "the [BACKSPACE] key also works. Press [ESC] to quit the entry process."
DATA ""
DATA "If there is something in the field to begin with and you start"
DATA "typing something else, the field clears. If the cursor is moved"
DATA "around first, that doesn't happen. Use Ctrl-U to undo."
DATA ""
DATA " Use: [HOME] key, [END] key, Arrow Keys (Rt & Left) to move cursor "
DATA " Ctrl-Y to clear the line "
DATA " Ctrl-T to delete one word (to right) "
DATA " Ctrl-U to undo (restore original string) "
DATA " Ctrl-Rt or Left Arrow, (jumps to beginning of a word) "
DATA ""
DATA "See bottom line of screen for more help. PRESS ANY KEY "
DATA END
' ===========================================================================
DateTest:
If SoundOn THEN PLAY LookitBeep$
IF ColorDisplay THEN Ink1 = %Blu: Paper1 = %Cyn: Ink2 = %Wht: Paper2 = %Red
COLOR Ink1, Paper1: CLS
ON KEY (15) GOSUB Done
DO
DoB$ = ""
COLOR Ink1, Paper1
LOCATE 5,6: PRINT "Date of Birth :";
COLOR Ink2, Paper2
Opt$ = ""
CALL ENTERDATE (DoB$, Opt$)
LOOP UNTIL DoB$ <> "" ' if date entered not valid,
' the result string will be ""
COLOR Ink1, Paper1
LOCATE 7,6
W& = FigDate&(DoB$)
IF W& = 0 THEN RETURN MainMenu
PRINT "Days from 1-1-1900 (Julioid) = ";
COLOR Ink2, Paper2: PRINT W&
LOCATE 9,6: COLOR Ink1, Paper1
PRINT "Converting Back to Date = ";
COLOR Ink2, Paper2: PRINT WriteDate$(W&)
LOCATE 10,6
COLOR Ink1, Paper1: PRINT " (This Date was a ";
COLOR Ink2, Paper2: PRINT WkDay$(W&);
COLOR Ink1, Paper1: PRINT " )."
Today$ = GetDate$ ' a function ...
LOCATE 12,6: COLOR Ink1, Paper1: PRINT "Today is ";
COLOR Ink2, Paper2
PRINT Today$
LOCATE 14,6: COLOR Ink1, Paper1: PRINT "YOUR AGE IS: ";
COLOR Ink2, Paper2
PRINT YearsSince (DoB$)
BDay$ = DoB$: MID$ (Bday$,7) = RIGHT$ (Today$,2)
N = FigDate& (BDay$) - FigDate& (Today$)
LOCATE 16,6: COLOR Ink1, Paper1
SELECT CASE N
CASE 0
L = CSRLIN: C = POS
COLOR Ink1+16, Paper1
PRINT "HAPPY BIRTHDAY !!"
LOCATE ,,0
PLAY "O2 G8 G16 A4 G4 O3 C4 O2 B2": DELAY 2
COLOR Ink1, Paper1: LOCATE L,C,1
PRINT "HAPPY BIRTHDAY !!"
CASE > 0
PRINT "Your BIRTHDAY is only ";N;" days from today !"
If SoundOn THEN PLAY TaskBeep$
CASE < 0
PRINT "Your BIRTHDAY was ";ABS(N);" days ago."
If SoundOn THEN PLAY TaskBeep$
END SELECT
LOCATE 25,1: CALL ClearLine
CALL PressAKey
GOSUB Done
Done:
RETURN MainMenu
'__________________________________________________________________________
Logo2:
DATA HB's ALL-PURPOSE LIBRARY DEMO, For POWER BASIC, JULY 1990, END
RESTORE Logo2
CALL BOXMESSAGE (0,0,1)
RETURN
Logo3:
RESTORE Logo2
CALL BOXMESSAGE (1,1,1)
RETURN
'__________________________________________________________________________
SUB CloseFiles PUBLIC
' What normally has to be done here, in a database program, is the
' index file closures (writing back data). If the program just crashes
' out to DOS, thus automatically closing all files at the DOS level,
' the index files will have been corrupted.
Dummy = IsRodent ' also reset your furry friend if any ...
END SUB
' ______________________________________________________________________
Oops:
' if error is the printer, beeps til you press a key; if any other
' error, calls file closure procedures and ends the program ...
SELECT CASE ERR
CASE 52, 53, 54, 55, 58, 61, 64, 67, 70, 71, 72, 73, 74, 75, 76
PLAY "ML O0 C16 D64"
FileError = %True
L00 = CSRLIN: C00 = POS
CALL SCREENPUSH
IF ErrorMessage$ <> "" THEN
LOCATE 23,1: COLOR %Red, %Wht: CALL ClearLine
PRINT " => ";ErrorMessage$
END IF
BoxColor = %Wht + %Background * %Red
CALL QBox (6, 20, 1,"OOPS: DOS UNABLE TO USE FILE. ERROR" + STR$(ERR), 0)
DELAY 1
CALL PressAKey
CALL SCREENPOP
LOCATE L00, C00
RESUME NEXT
CASE 24, 25, 27
DATA "P R I N T E R E R R O R"
DATA "====="
DATA "Please check the printer. Apparently it is either"
DATA "off, not on-line, unplugged or out of paper."
DATA "Kindly FIX IT ... then PRESS ANY KEY to"
DATA "go ahead with printing"
DATA END
L00 = CSRLIN: C00 = POS
CALL SCREENPUSH
IF ErrorMessage$ <> "" THEN
LOCATE 23,1: COLOR %Red, %Wht: CALL ClearLine
PRINT " => ";ErrorMessage$
END IF
RESTORE Oops
CALL BOXMESSAGE (6, 16, 1)
DO
PLAY "O3 C64 P16 O4 C64 O3 P16 G-64"
FOR N = 1 TO 30
DELAY .1
IF INSTAT THEN EXIT FOR
NEXT
LOOP UNTIL INSTAT
CALL SCREENPOP
LOCATE L00, C00
IF INKEY$ = CHR$(27) THEN
CALL CloseFiles
END 1
ELSEIF ErrorMessage$ = "fake error generated from HBDEMO menus" THEN
JustDemonstratingOops = %False
RESUME NEXT
ELSE
RESUME
END IF
CASE ELSE
PLAY "ML O0 C16 D64"
IF ErrorMessage$ <> "" THEN
LOCATE 21,1: COLOR %Red, %Wht: CALL ClearLine
PRINT " => ";ErrorMessage$
END IF
LOCATE 22,1: COLOR %Red, %Wht: CALL ClearLine
PRINT " OOPS! UNABLE TO CONTINUE. ERROR";ERR;" AT ADDRESS ";ERADR;" "
COLOR %Red, %Gry
BXScreenSaved = %False
CALL CloseFiles
COLOR %Grn, %Blk
LOCATE 25,1: CALL ClearLine
LOCATE 24,1: CALL ClearLine: END 1 ' this places the DOS
END SELECT ' prompt at 25,1 for you
RESUME ' without messing up
' the display otherwise.
' Note: ERRORLEVEL is set to 1.
HarmlessError:
DATA "FILE ERROR APPARENTLY"
DATA "====="
DATA "PRESS ANY KEY"
DATA END
ON ERROR GOTO 0
L00 = CSRLIN: C00 = POS
Ink3 = %Wht + %Flash
Paper3 = %Red
BXScreenSaved = %False
RESTORE HarmlessError
CALL SCREENPUSH
CALL BOXMESSAGE (6, 16, 1)
PLAY "O3 B32 P64 G32"
DO: LOOP UNTIL INKEY$ <> ""
CALL SCREENPOP
LOCATE L00, C00
RESUME NEXT
SetBeeps:
LookitBeep$ = "T100 O5 C64 P64 O4 E64"
ArribaBeep$ = "T70 O2 A32 P32 A32 A32 > E4"
TaskBeep$ = "MN T100 O3 C16 E32 F32 G16 E16 C16"
PressAKeyBeep$ = "T120 MS O4 P4 G64 P16 G64 MN"
OopsBeep$ = "T120 O1 A64"
TinyBeep$ = "MS T240 O3 C64"
RETURN
FakeFunction:
COLOR %LCyn, %Blu
If SoundOn THEN PLAY LookitBeep$
CLS
LOCATE 10,10,0:PRINT "This function will of course be brilliantly implemented"
DELAY .5
LOCATE 12, 11: PRINT "by you, the creator of your own magnificent applications
DELAY .5
LOCATE 14, 13: PRINT "using Power Basic and this humble Library."
If SoundOn THEN PLAY ArribaBeep$
CALL PressAKey
GOTO MainMenu
'____________________________________________________________________________
MZap:
NextScrn2Pop = MainMenuScreen
CALL SCREENPOP
DEF SEG = VideoSeg&
TopAtt = PEEK (1)
FOR I = 161 TO 320 STEP 2: POKE I, TopAtt: NEXT
DEF SEG
RETURN
ClickOrStrike:
DO: LOOP UNTIL INKEY$ <> "" OR MouseClicked
RETURN
' ===========================================================================
Directory:
DIM DYNAMIC ListOfDirectories$ (32)
CALL QBox (5,36,1,"FileSpec ?? ", 20)
COLOR FldColor MOD 16, FldColor \ 16
M$ = "*.*"
CALL ENTERSTRING (M$, 20, "Cap")
U$ = "File \ \ saved \ \ at \ \ -- "
M$ = FQFileSpec$ (M$)
Heading$ = "HB Custom Directory of " + M$
Heading$ = LEFT$ (Heading$, 80)
COLOR %Cyn, %Blk: CLS: LOCATE 1, 41-LEN(Heading$)\2: PRINT Heading$
Fls% = 0
FlName$ = M$
CALL DirFirst (FlName$, FileSize&, DateCode&, TimeCode&)
IF FlName$= "" THEN
CALL QBox (11, 30, 1, "No file "+ M$ +" found", 0)
CALL PressAKey
RETURN
ELSE
INCR Fls%
GOSUB PrDir
DO
CALL DirNext (FlName$, FileSize&, DateCode&, TimeCode&)
IF FlName$ = "" THEN EXIT LOOP
GOSUB PrDir
INCR Fls%
IF CSRLIN > 23 THEN
COLOR %Cyn, %Blk
IF NeedDCon THEN
PRINT " ... PRESS ANY KEY (OR MOUSEBUTTON) TO GO ON";
ELSE
PRINT " ... PRESS ANY KEY TO GO ON";
END IF
T& = TIMER
DO: K$ = INKEY$: LOOP UNTIL K$ <> "" OR MouseClicked OR TIMER - T& > 4
IF K$ = CHR$ (27) THEN GOTO DoneDirectory
COLOR %Cyn, %Blk: CLS
LOCATE 1, 41-LEN(Heading$)\2: PRINT Heading$
END IF
LOOP
PRINT
COLOR %Cyn, %Blk: PRINT Fls% ;"Files found"
END IF
IF RIGHT$ (M$, 3) = "*.*" THEN ' only show subdirectories if a full
PRINT ' directory was listed
COLOR %Wht, %Blk
PRINT STRING$ (80, 205);
PRINT
PRINT "Subdirectories of "; M$;
N = 1: D% = 1
DO WHILE (ListOfDirectories$ (N)) <> ""
PRINT
IF MID$ (ListOfDirectories$ (N), 2, 1) <> "." THEN
PRINT USING " \ \ (directory)"; ListOfDirectories$ (N);
INCR D%
END IF
INCR N
LOOP UNTIL INKEY$ <> ""
IF D% = 1 THEN PRINT " None"
END IF
CALL PressAKey
DoneDirectory:
ERASE ListOfDirectories$
D% = 0
RETURN
PrDir:
IF ColorDisplay THEN
COLOR 2 + (7 * (CSRLIN - 2*(CSRLIN\2))), 0
ELSE
COLOR (7 * (CSRLIN - 2*(CSRLIN\2))), 7 - (7 * (CSRLIN - 2*(CSRLIN\2)))
END IF
IF LEFT$ (FlName$, 1) = "<" THEN
INCR D%
ListOfDirectories$ (D%) =FlName$
ELSE
PRINT USING U$; FlName$, DecodeDate$ (DateCode&), DecodeTime$ (TimeCode&);
IF FileSize& < 1024 THEN
PRINT USING " #### bytes"; FileSize&
ELSE
PRINT USING "###.# KB"; FileSize& / 1024
END IF
END IF
RETURN
' ======================================================================
$SEGMENT
' ======================================================================
MoveAMenuII:
S = NextScrn2Pop
NextScrn2Pop = 1
CALL SCREENPOP
NextScrn2Pop = S
DELAY 1
RANDOMIZE TIMER
FOR Word = 1 TO 50
LOCATE INT (1+RND*25), INT (1+RND*61)
COLOR INT (1+RND*15), 0: PRINT "Important Data";
DELAY .05
NEXT Word
MenuColor = %Blk + %Background * %Gry
BarColor = %Ylo + %Background * %Grn
FakePage = 1
FakePages = 2
D = 3: R = -4
' menu lines are set up (D,R,L & Q will be the HotKeys) ...
MenuData$(1) = "U UP"
MenuData$(2) = "D DOWN"
MenuData$(3) = "R RIGHT"
MenuData$(4) = "L LEFT"
MenuData$(5) = "Q QUIT"
MenuData$(6) = "END"
Choice = 1
DO
Title$ = "MOVE ME" ' title
MenuRight = R
MenuDown = D
CALL SCREENPUSH
IF FakePage < FakePages THEN UsePgDn = %Yes ELSE UsePgUp = %Yes
CALL SUPERMENU (MenuData$ (), MenuRight, MenuDown, Choice, Title$, Ky%)
CALL SCREENPOP
If SoundOn THEN PLAY TinyBeep$
SELECT CASE Choice
CASE 1
IF D > 0 THEN DECR D,2
CASE 2
IF D < 30 THEN IF D = 3 THEN INCR D,1 ELSE INCR D,2
CASE 3
IF R < 40 THEN INCR R,4
CASE 4
IF R > -40 THEN DECR R,4
END SELECT
IF Ky% = %PgDn THEN INCR FakePage: D = 20
IF Ky% = %PgUp THEN DECR FakePage: D = 1
IF ColorDisplay THEN
COLOR 15,5
ELSE
COLOR 0,7
END IF
LOCATE 25,3,0
PRINT "ARGUMENTS: Choice = ";Choice;"MenuDown = ";D;
PRINT " -- ";"MenuRight = ";R;
IF Ky% = %F1 THEN GOSUB MenuHelpScrn
IF Ky% = %F2 THEN LOCATE 23,1: COLOR 14,7: PRINT " F2 Pressed! "
LOOP UNTIL Choice = 5 OR Ky% = %Esc
GOSUB SetColors
RETURN
HundredItemsMenu:
CALL SCREENPUSH ' a multipage menu ...
RANDOMIZE TIMER
StartScreen = NextScrn2Pop
REDIM T$ (1:100)
MenuPages = 7
DO
COLOR 0, RND * 8: CLS
COLOR %Ylo, %Grn
MenuPage = 1
Choice = 1
DATA "Hundred Items", "Menu", "====", Use PG-DN or just
DATA drag bar down past, last line to see, "more choices"
DATA END
RESTORE HundredItemsMenu
CALL BOXMESSAGE (2, 1, 1)
FOR I = 1 TO 100
T$ (I) = USING$ (" This is menu item ###", I)
NEXT
DO
FOR I = 1 TO 16
IF (MenuPage - 1) * 16 + I > 100 THEN
MenuData$ (I) = "END"
ELSE
MenuData$ (I) = T$ ((MenuPage - 1) * 16 + I)
END IF
NEXT
MenuData$ (17) = "END"
MenuRight = 6 * MenuPage -20
MenuDown = MenuPage - 1
Title$ = "PgUp/Pg-Dn for more"
IF MenuPage > 1 THEN UsePgUp = %Yes
IF MenuPage < 7 THEN UsePgDn = %Yes
CALL SUPERMENU (MenuData$ (), MenuRight, MenuDown, Choice, Title$, Ky%)
SELECT CASE Ky%
CASE %PgUp
DECR MenuPage
CALL SCREENPOP
Choice = 16
CASE %PgDn
INCR MenuPage
CALL SCREENPUSH
Choice = 1
CASE %F1
GOSUB MenuHelpScrn
END SELECT
LOOP UNTIL Ky% = %Esc OR Ky% = %CR
NextScrn2Pop = StartScreen
CALL SCREENPOP
LOOP UNTIL Ky% = %Esc
ERASE T$
RETURN MainMenu
' -------------------------------------------------------------------
SetColors:
IF COMMAND$ <> "" THEN
ScrColor = ReadParamFor ("ScrC") ' ReadParamFor looks
MenuColor = ReadParamFor ("MnuC") ' for a command line switch
BarColor = ReadParamFor ("BarC") ' like "BoxC=3F", for example,
WinColor = ReadParamFor ("WinC") ' which sets the color of a
FldColor = ReadParamFor ("FldC") ' box to &H3F (like COLOR 15,3)
BoxColor = ReadParamFor ("BoxC") ' that is, white letters on cyan
ELSE ' background ...
MenuColor = 0: BarColor = 0: WinColor = 0
FldColor = 0: BoxColor = 0: ScrColor = 0
END IF
' then if colors are not yet set (= 0) we give
' them a default value here:
IF ColorDisplay THEN
IF MenuColor = 0 THEN MenuColor = %Wht + %Background * %Blu
IF BarColor = 0 THEN BarColor = %Ylo + %Background * %Red
IF WinColor = 0 THEN WinColor = %Blu + %Background * %Gry
IF FldColor = 0 THEN FldColor = %Ylo + %Background * %Red
IF BoxColor = 0 THEN BoxColor = %Wht + %Background * %Grn
IF ScrColor = 0 THEN ScrColor = %Wht + %Background * %Vlt
ELSE
IF MenuColor = 0 THEN MenuColor = %Blk + %Background * %Gry
IF BarColor = 0 THEN BarColor = %Gry + %Background * %Blk
IF WinColor = 0 THEN WinColor = %Gry + %Background * %Blk
IF FldColor = 0 THEN FldColor = %Blk + %Background * %Gry
IF BoxColor = 0 THEN BoxColor = %Wht + %Background * %Blk
IF ScrColor = 0 THEN ScrColor = %Gry + %Background * %Blk
END IF
RETURN
MenuHelpScrn:
CALL SCREENPUSH
RESTORE MenuHelpScrn
DATA "WHAT DOES THIS MENU DO ?? -- Not much really. After all, this whole"
DATA "program is nothing but a demo."
DATA ""
DATA "IN THAT CASE, HOW DO I USE A MENU LIKE THIS ??"
DATA " I thought you'd never ask! Well, you can use ..."
DATA "(1) THE ONE KEY METHOD: Just find which item on the menu you want."
DATA "There will be a letter or number at the start of the"
DATA "item. Just press it and that's all."
DATA "(2) THE CURSOR KEY METHOD: Use the up or down cursor / arrow keys"
DATA "to move the highlighted bar to your selection, then"
DATA "press the ENTER key."
DATA "(3) THE PLASTIC PEST METHOD: Your mouse can make the choice you want!"
DATA "You don't see a mouse cursor but don't panic. Just press the left"
DATA "button and drag the highlighted bar to your choice; then let go."
DATA ""
DATA "TO CANCEL THE MENU (Not make a choice):"
DATA "Press the Escape key, or the right mouse button. (You can even press"
DATA "the right button while you hold the left one -- or right after you"
DATA "let it go.)"
DATA END
CALL BOXMESSAGE (%Center, %Center, 0)
GOSUB ClickOrStrike
CALL SCREENPOP
RETURN
' -------------------------------------------------------------------------
BeepTest:
LOCATE 22,1
IF ColorDisplay THEN
Ink1 = %Blu: Paper1 = %Cyn: Ink2 = %LCyn: Paper2 = %Blu
ELSE
Ink1 = %Gry: Paper1 = %Blk: Ink2 = %Blk: Paper2 = %Gry
END IF
DELAY .7: If SoundOn THEN PLAY LookitBeep$
DO
IF CSRLIN > 20 THEN
COLOR Ink1, Paper1: CLS
COLOR Ink2, Paper2
LOCATE 1,22: PRINT " HB BEEP-TESTING ENVIRONMENT, V. 1.0 "
LOCATE 22,1: CALL ClearLine
LOCATE 23,1: CALL ClearLine
PRINT " Use syntax for PLAY as in BASICA and ";
PRINT "PowerBasic, e.g. O0 G2 A4 B-4 P4 G4"
LOCATE 24,1: CALL ClearLine
COLOR Ink1, Paper1
LOCATE 3,1
END IF
PLAY "O3"
PRINT " PLAY ";CHR$(34);SPACE$(45);CHR$(34);
LOCATE CSRLIN, 8
Opt$ = "Auto Caps"
CALL ENTERSTRING (A$, 45, Opt$)
IF Opt$ = "ESC" OR A$ = "" THEN
PRINT " QUIT ?? ";
Quit = GetYesOrNo
IF Quit THEN
EXIT LOOP
ELSE
GOTO There
END IF
ELSE
ON ERROR GOTO Clunker
IF A$ <> "" THEN PLAY A$
ON ERROR GOTO Oops
LOCATE (CSRLIN), 56
PRINT "Print It ?";
Yes = GetYesOrNo
IF Yes THEN
INPUT " Comment ? ",B$
L = CSRLIN
COLOR 16+Ink2, Paper2
LOCATE 25,3,0: CALL ClearLine: PRINT "PRINTING ...";
LPRINT "From HB PowerBasic Beep Tester, ";GetDate$;":"
LPRINT " Name: ";B$;" -- PLAY ";CHR$(34);A$;CHR$(34)
LOCATE 25,1,1: CALL ClearLine
COLOR Ink1, Paper1
LOCATE L+1, 1
ELSE
PRINT
END IF
END IF
There:
LOOP
RETURN
Clunker:
PLAY "O1 C2"
A$ = ""
RESUME NEXT
MessageBoxTest:
COLOR ScrColor MOD 16, ScrColor \ 16
CLS
CALL QBox (3, %Center, 1, "DEMO OF MESSAGE WINDOWS (TRY TO MAKE IT FAIL!)", 0)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 10, 50: PRINT "... 0 = Horiz. Centered Box"
LOCATE 10,5: PRINT "LEFT UPPER CORNER AT COLUMN ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (CCol#, "###", Opt$)
IF Opt$ <> "CR" THEN RETURN MainMenu
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 12, 50: PRINT "... 0 = Vert. Centered Box"
LOCATE 12,5: PRINT "LEFT UPPER CORNER AT ROW ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (CLin#, "###", Opt$)
IF Opt$ <> "CR" THEN RETURN MainMenu
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 14,5: PRINT " MARGIN ? ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (Marg#, "#", Opt$)
IF Opt$ <> "CR" THEN RETURN MainMenu
Margin = MIN (CINT(Marg#), 3)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 16,5: PRINT "HOW LONG SHALL WE MAKE THE TEXT LINES ? ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (LinL#, "###", Opt$)
IF Opt$ <> "CR" THEN RETURN MainMenu
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 18,5: PRINT " ... AND HOW MANY LINES ? ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (LinsNum#, "###", Opt$)
IF Opt$ <> "CR" THEN RETURN MainMenu
TenChr$ = "<Ten Chrs>"
Digital$ = "123456789"
N = INT (LinsNum#)
L = INT (LinL#)
Text4Box$ = REPEAT$ (L \ 10, TenChr$) + LEFT$ (Digital$, L MOD 10)
DIM DYNAMIC T$ (1:N)
FOR I = 1 TO N
T$(I) = Text4Box$
NEXT
CALL BOXMESSAGE2 (CINT (CLin#), CINT (CCol#), Margin, T$(), N, L)
CALL PressAKey
CLS
ERASE T$
RETURN
QBoxTest:
COLOR ScrColor MOD 16, ScrColor \ 16
CLS
CALL QBox (3, %Center, 1, "DEMO OF DIALOG BOX (TRY TO MAKE IT FAIL!)", 0)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 10, 50: PRINT "... 0 = Horiz. Centered Box"
LOCATE 10,5: PRINT "LEFT UPPER CORNER AT COLUMN ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (CCol#, "###", Opt$)
IF Opt$ <> "CR" THEN RETURN MainMenu
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 12, 50: PRINT "... 0 = Vert. Centered Box"
LOCATE 12,5: PRINT "LEFT UPPER CORNER AT ROW ";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (CLin#, "###", Opt$)
IF Opt$ <> "CR" THEN RETURN MainMenu
Lins# = INT (Lins#)
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 14,5: PRINT " ONE LINE BOX OR THREE LINE BOX ?? ";
COLOR FldColor MOD 16, FldColor \ 16
L = CSRLIN: C = POS
DO
LOCATE L, C
Lins$ = " "
CALL ENTERSTRING (Lins$, 1, Opt$)
Lins = VAL (Lins$)
LOOP UNTIL Lins = 1 OR Lins = 3
IF Opt$ <> "CR" THEN RETURN MainMenu
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 16,5: PRINT "ENTER TEXT LINE: ";
COLOR FldColor MOD 16, FldColor \ 16
IF Prompt$ = "" then Prompt$ = "Sample Prompt"
CALL ENTERSTRING (Prompt$, 40, Opt$)
IF Opt$ <> "CR" THEN RETURN MainMenu
COLOR ScrColor MOD 16, ScrColor \ 16
LOCATE 18,5: PRINT "LENGTH OF ANSWER FIELD ?";
COLOR FldColor MOD 16, FldColor \ 16
CALL ENTERNUMBER (AFL#, "##", Opt$)
IF Opt$ <> "CR" THEN RETURN MainMenu
AnsLength = CINT (AFL#)
CALL QBox (CINT (CLin#), CINT (CCol#), Lins, Prompt$, AnsLength)
DELAY 2
COLOR FldColor MOD 16, FldColor \ 16
FOR I = 1 TO AnsLength
PRINT " ";
DELAY .03
NEXT
DELAY 1
CALL PressAKey
COLOR ScrColor MOD 16, ScrColor \ 16
CLS
RETURN