home *** CD-ROM | disk | FTP | other *** search
- DECLARE SUB DIR (mask$, fil$())
- '+-------------------------[ READ ME ]------------------------------+
- ' To start the demo, read the instructions below to make sure it
- ' is set up for your QB implementation, and start it with:
- '
- ' QB4: QB glibdemo /L GLIB14 /cmd /NC (or /C) /qwerty foobar /1 /B
- ' /NC /C is Color - No Color parameter, the rest of the command
- ' line is for demonstration purposes.
- ' -----------------------------------------------------------------+
- COMMON /fedvars/ fg%, bg%, fgd%, bgd%, bleep%, edt%, nums%, num$, upcase%
-
-
- ' The folowing includs all the GLIB DECLARE statements
- REM $INCLUDE: 'GLIB14.INC'
-
-
-
- '+----------------------------------------
- '| GLIBDEMO
- '|
- '| Demo of key routines in GIZLIB
- '| Copr. InfoSoft 1986-1987, 1988
- '+----------------------------------------
- '| This demo will demonstrate some of the
- '| routines of the QuickBASIC Library that
- '| should accompany it.
- '| Additionally it will augment the DOCs with its actual use.
- '+----------------------------------------
- CLEAR
- DEFINT A-Z
- OPTION BASE 1
-
- REM $DYNAMIC
- REDIM sarry%(14001) ' array to save screns to: holds 7
- REM $STATIC
-
- GOSUB set.pointers ' __MUST__ be dynamic
-
- quote$ = CHR$(34): clr$ = SPACE$(78)
-
- 'make sure it is set up right
-
- chkset:
- CLS : SOUND 750, 2: LOCATE 5, 5
- PRINT "Depending on your display, you may want to restart this demo"
- LOCATE 7, 5
- PRINT "with the command line parameter [/CMD /NC] to supress color."
- LOCATE 10, 5
- PRINT "Tap `S' to stop the demo, any other key to continue."
-
- ky$ = INKEY$
- WHILE ky$ = ""
- ky$ = INKEY$
- WEND
- PRINT ky$
-
- IF ky$ = "S" OR ky$ = "s" THEN
- ky$ = ""
- GOTO extt
- END IF
-
- '*********** get command line parms and set colors
- DIM arg$(6): q% = 0
-
- FOR x = 1 TO 6
- arg$(x) = SPACE$(LEN(COMMAND$) / 2)
- NEXT x
- CALL cmdline(arg$(), q%)
-
- IF arg$(1) = "/NC" THEN
- cmode = 0
- fg = 7: bg = 0
- fge = 15: bge = 0
- fgw = 0: bgw = 7
- fgs = 7: bgs = 0
- fgt = 15: fgd = 15
- ELSE
- cmode = 1
- fg = 3: bg = 0
- fge = 12: bge = 3
- fgw = 14: bgw = 4
- fgs = 11: bgs = 0
- fgt = 10: fgd = 14
- END IF
-
- eattr = (bge * 16) + fge
- wattr = (bgw * 16) + fgw
- attr = (bg * 16) + fg
- done = 0
-
- IF q = 0 THEN ' used in the demo of cmdline
- arg$(2) = "No command line entered."
- END IF
-
-
- DO
- CLS : LOCATE 1, 27
- COLOR fgw, bgw: PRINT "[ GizLib Version 1.4 Demo ]"
- PRINT : COLOR fgs, 0: PRINT TAB(30); " For QuickBASIC 4.0 "
-
- LOCATE 8, 5: COLOR fgd, 0
- PRINT TAB(5); " A - BOXES I - ERRMSG Q - PRTSCRN, PTRCTRL "
- PRINT TAB(5); " B - CHRP J - EXIST * R - QUIKPRT"
- PRINT TAB(5); " C - CMDLINE K - FUNIQ * S - SINFO, CPUINFO, MISC"
- PRINT TAB(5); " D - DATE / DFRMAT L - GETCH, VFNAME ** T - SCROLL, SCROLLER "
- PRINT TAB(5); " E - DIR, FILCNT M - LCOUNT * U - TFRMAT / SYSTIME * "
- PRINT TAB(5); " F - DLY, MDLY N - NFRMAT V - SVSCRN, RSTSCRN "
- PRINT TAB(5); " G - DRVSPACE O - MENUCTRL W - WDW"
- PRINT TAB(5); " H - DAYOFYR * P - PCASE X - VIDON / VIDOFF *"
- PRINT TAB(5); " <Esc> Ends the demo ": COLOR fg, bg
- PRINT TAB(15); " * indicates new function or major enhancement"
-
-
- LOCATE 19, 10: COLOR fgs, bgs
- PRINT "There are MORE routines in the library, than there are in the DEMO, "
- PRINT TAB(10); "like all the MOUSE functions, most of the DOS File Functions etc."
- PRINT
- PRINT TAB(10); "There is even DEMO code in here with no menu selection!"
-
- getkey:
- ky$ = INKEY$: WHILE ky$ = "": ky$ = INKEY$: WEND
-
- IF ky$ = CHR$(27) THEN done = 1
- ky$ = UCASE$(ky$) ' convert to upper for one SELECT object
-
- SELECT CASE ky$
- CASE "A": GOSUB bxs
- CASE "B": GOSUB chrp
- CASE "C": GOSUB cmdl
- CASE "D": GOSUB dformat
- CASE "E": GOSUB ddir
- CASE "F": GOSUB dlys
- CASE "G": GOSUB dspace
- CASE "H": GOSUB daycnt
- CASE "I": GOSUB err.msg
- CASE "J": GOSUB filex
- CASE "K": GOSUB funique
- CASE "L": GOSUB getch.and.vfname
- CASE "M": GOSUB lcountr
- CASE "N": GOSUB num.frmat
- CASE "O": GOSUB menuctrl
- CASE "P": GOSUB pcase
- CASE "Q": GOSUB pscrn
- CASE "R": GOSUB qprt
- CASE "S": GOSUB sysinfo
- CASE "T": GOSUB scrl
- CASE "U": GOSUB tformat
- CASE "V": GOSUB xscrn
- CASE "W": GOSUB wdws
- CASE "X": GOSUB video.junk
- CASE ELSE: IF done = 0 THEN GOTO getkey
- END SELECT
-
- LOOP UNTIL done
-
-
-
- here:
- SYSTEM
- COLOR fg, bg
- CLS
- GOSUB title
- COLOR fgs, bgs
-
- video.junk:
- CLS
- GOSUB title
- COLOR fgs, bgs
-
- LOCATE 5, 15: PRINT "Function: VIDON / VIDOFF - Disable / enable the video"
- LOCATE 6, 15: PRINT "Syntax: CALL vidon / CALL vidoff"
-
- LOCATE 10, 5: COLOR fg, bg
-
- PRINT TAB(10); "To demo this, we will turn off the display, but beep short, soft"
- PRINT TAB(10); "tones in the background to show that the system is on."
- PRINT
- PRINT TAB(10); "To re - enable the video, tap any key."
-
- GOSUB wait.key
-
- video2:
- CALL vidoff
- vky$ = "": vdone = 0 ' set loop indicator
- cy = 0
-
- DO UNTIL vdone
- CALL dly(2) ' delay 2 secs
- vky$ = INKEY$ ' key waiting?
- IF vky$ > "" THEN vdone = 1 ' yes we are done
- SOUND 1200, .5 ' no make some noise
-
- cy = cy + 1 ' I'm bored
- IF cy MOD 2 = 0 THEN PLAY "L64O3AGE"
- LOOP
- CALL vidon
-
- CALL pgetch(" Do it Again? ", 20, 78, "YN", vky$)
- IF vky$ = "Y" THEN GOTO video2
-
- RETURN
-
- filex:
- CLS : GOSUB title
- LOCATE 5, 15: PRINT "Function: EXIST - Test if a file exists."
- LOCATE 6, 15: PRINT "Syntax: fil$=" + quote$ + "filename.ext" + quote$
- LOCATE 7, 15: PRINT " IF exist(fil$) THEN ... "
- LOCATE 8, 15: PRINT " This FUNCTION MUST be DECLAREd !!"
-
- COLOR fg, bg: LOCATE 10, 10
- PRINT " This is a simple assembler call to test if the file exists. This"
- PRINT TAB(10); "is extremely useful in avoiding run time errors in professional"
- PRINT TAB(10); "quality programs."
-
- fil$ = "glibdemo.bas": fil1$ = "foobar.fil"
-
- LOCATE 14, 15: COLOR fgt, 0
- PRINT fil$; " "; : COLOR fg, bg
- IF exist(fil$) THEN PRINT "EXISTS! " ELSE PRINT "is missing!"
-
- LOCATE 16, 15: COLOR fgt, 0 ' hopefully no FOO BAR
- PRINT fil1$; " "; : COLOR fg, bg
- IF exist(fil1$) THEN PRINT "EXISTS! " ELSE PRINT "is missing!"
-
- GOSUB wait.key
- RETURN
-
-
-
- ddir:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: FILCNT - Number of files matching a mask."
- LOCATE 6, 15: PRINT "Syntax: mask$=" + quote$ + "*.BAS" + quote$ + " : CALL filcnt(mask$, num)"
-
- LOCATE 8, 15: PRINT "Function: DIR - Return matching files in an array."
- LOCATE 9, 15: PRINT "Syntax: DIM file$(num) : file$(1 to num)=SPACE$(12)"
- LOCATE 10, 15: PRINT " CALL dir(mask$, file$() )"
-
- COLOR fg, bg
- LOCATE 12, 10: PRINT "These 2 tools provide access to filenames much the same as you"
- PRINT TAB(10); "would have from DOS. FILCNT returns the number of matching files"
- PRINT TAB(10); "primarily for you to DIM the file array to the right size. Then"
- PRINT TAB(10); "CALLing DIR with the array and mask will return the file names."
- PRINT
- PRINT TAB(10); "Since Assembler routines cannot change string lengths, be SURE to"
- PRINT TAB(10); "initialize your file name array to SPACE$(12)."
-
- GOSUB wait.key
- CLS
- mask$ = "*.*": numf = 0
- CALL filcnt(mask$, numf)
- IF numf <= 5 THEN
- mask$ = "*.*": numf = 0
- CALL filcnt(mask$, numf)
- END IF
- REDIM file$(numf) ' redim in case we run this again
-
- FOR x = 1 TO numf
- file$(x) = SPACE$(12)
- NEXT x
-
- ' +----------------------------------------------------------------+
- ' | In QB 4, we need not pass the number of |
- ' | DIMensions in an array, so select the syntax for the QB |
- ' | version you are operating under. |
- ' +----------------------------------------------------------------+
- CALL DIR(mask$, file$()) ' QB 4 Syntax
-
-
- COLOR fgs, 0: LOCATE 2, 25: PRINT numf;
- COLOR fg, bg: PRINT " Files Found in mask "; : COLOR fgs, 0: PRINT mask$
- IF numf > 51 THEN COLOR 7, 0: PRINT TAB(20); "(Only the first 51 will be displayed.)"
-
- LOCATE 5, 1: x = 1
- IF numf > 51 THEN numf = 51 ' prevent screen from scrolling
- lnum = (numf \ 3) * 3 ' set to even loop of #
-
- DO
- COLOR fgs, 0
- PRINT USING " ## "; x; : COLOR fg, bg: PRINT file$(x); TAB(30);
- x = x + 1: COLOR fgs, 0
-
- PRINT USING "## "; x; : COLOR fg, bg: PRINT file$(x); TAB(55);
- x = x + 1: COLOR fgs, 0
-
- PRINT USING "## "; x; : COLOR fg, bg: PRINT file$(x)
- x = x + 1: COLOR fgs, 0
- LOOP UNTIL x >= lnum
-
- FOR x = lnum + 1 TO numf
- PRINT USING " ## "; x; : COLOR fg, bg: PRINT file$(x); SPACE$(5);
- COLOR fgs, 0
- NEXT x
-
-
- GOSUB wait.key
- RETURN
-
-
- menuctrl:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: MENUCTRL - Accept limited KB input."
- LOCATE 6, 15: PRINT "Syntax: ky=0 : CALL menuctrl(ky) "
- COLOR fg, bg
- LOCATE 8, 10: PRINT "This routine is ideal for menu driven applications. Using it"
- PRINT TAB(10); "to control, limit or weed out invalid input saves considerable"
- PRINT TAB(10); "code space and time."
- PRINT
- PRINT TAB(10); "MENUCTRL traps for a number or Function Key or Esc ignoring all"
- PRINT TAB(10); "other keystrokes before returning an integer or code indicating"
- PRINT TAB(10); "what was pressed. The code is simply 1-10 or 15 for Esc. You"
- PRINT TAB(10); "code can then branch to the correct routines. MENUCTRL even"
- PRINT TAB(10); "clears the KB buffer prior to the start of the trap."
-
- LOCATE 18, 15: COLOR fgd, 0: mdone = 0: j = 0
- PRINT "Press F1 - F10 or enter a number for demo....<Esc> ends loop."
- DO UNTIL mdone
- CALL menuctrl(j)
- IF j = 15 THEN
- mdone = 1
- EXIT DO
- END IF
- LOCATE 20, 15
- PRINT "You pressed "; j; " or [ F"; j; "] "
- LOOP
-
- GOSUB wait.key
- RETURN
-
-
- dspace: '************************
- CLS : GOSUB title
-
- a% = 0: b% = 0: C% = 0: d% = 0'initialize vars for the call
- ' a is drive to poll:
- ' 1=A, 2=B etc 0=Default
-
- CALL drvspace(a%, b%, C%, d%) ' get drive and free space
- total# = CDBL(a%) * CDBL(C%) * CDBL(d%)
- free# = CDBL(a%) * CDBL(C%) * CDBL(b%)
-
- LOCATE 5, 15: PRINT "Function: DRVSPACE - Get drive info."
- LOCATE 6, 15: PRINT "Syntax: a%=0:b%=0:c%=0:d%=0 : CALL drvspace(a%,b%,c%,d%) "
- COLOR fg, bg
- LOCATE 8, 15: PRINT " total#=CDBL(a%)*CDBL(c%)*CDBL(d%)"
- LOCATE 9, 15: PRINT " free#=CDBL(a%)*CDBL(c%)*CDBL(b%) "
-
- LOCATE 12, 5: PRINT " Also like other LIBs, we can get the size of a drive and/or free space."
- LOCATE 13, 5: PRINT " We have already done it to find:"
- LOCATE 15, 10: PRINT " Total drive space is: "; : COLOR fgs, 0: PRINT total#
- COLOR fg, bg
- LOCATE 17, 10: PRINT " Free space is: "; : COLOR fgs, 0: PRINT free#
-
- GOSUB wait.key
- RETURN
-
-
-
- sysinfo: '*************************
- CLS : GOSUB title
-
- ram = 0: ser = 0: par = 0: vga = 0
- CALL sinfo(ram, ser, par, ega, vga)
-
- LOCATE 4, 15: PRINT "Function: SINFO - Get general system info."
- LOCATE 5, 15: PRINT "Syntax: ram=0 : ser=0 : par=0 : ega=0 : vga=0"
- LOCATE 6, 15: PRINT "CALL sinfo(ram, ser, par, ega, vga)"
-
- LOCATE 8, 15: PRINT "Function: CPUINFO - Get specific CPU info."
- LOCATE 9, 15: PRINT "Syntax: idcod%=0 : mhz%=0 : cpu%=0 : ndp%=0"
- LOCATE 10, 15: PRINT "CALL cpuinfo(idcod, cpu, ndp)"
-
- COLOR fg, bg
- idcod = 0: mz = 0: cpu% = 0: ndp% = 0
- CALL cpuinfo(idcod, cpu, ndp)
-
- drv$ = " ": CALL getdrv(drv$)
- switch = 0: CALL getverfy(switch)
-
- LOCATE 12, 10: PRINT "Testing CPU speed..."
- 'CALL mhz(mz)
-
- LOCATE 12, 50: COLOR fgs, 0: PRINT "Misc:"
- LOCATE 13, 50: COLOR fg, 0: PRINT "Current Drive: ";
- COLOR fgs, 0: PRINT drv$
- LOCATE 14, 50: COLOR fg, 0: PRINT "Verify Setting: ";
- COLOR fgs, 0
- IF switch THEN PRINT "ON" ELSE PRINT "OFF"
-
- LOCATE 12, 10: COLOR fgs, 0: PRINT "SINFO: ": COLOR fg, 0
- LOCATE 13, 10: PRINT "RAM installed :"; : COLOR fgs, 0: PRINT ram%: COLOR fg, 0
- LOCATE 14, 10: PRINT "# Serial ports:"; : COLOR fgs, 0: PRINT ser%: COLOR fg, 0
- LOCATE 15, 10: PRINT "Parallel ports:"; : COLOR fgs, 0: PRINT par%: COLOR fg, 0
- LOCATE 16, 10: PRINT "EGA memory :"; : COLOR fgs, 0: PRINT ega%: COLOR fg, 0
- LOCATE 17, 10: PRINT "VGA installed?: "; : COLOR fgs, 0:
- IF vga THEN PRINT "Yes" ELSE PRINT "No"
- COLOR fgs, 0
-
- LOCATE 19, 10: PRINT "CPUINFO: "
- COLOR fg, 0
- LOCATE 20, 10: PRINT "Type CPU installed: "; : COLOR fgs, 0: PRINT "80 -"; cpu%: COLOR fg, 0
- LOCATE 21, 10: PRINT "Type NDP installed: "; : COLOR fgs, 0
- IF ndp > 0 THEN PRINT ndp% ELSE PRINT "None"
- COLOR fg, 0
- LOCATE 22, 10: PRINT "Approx. Effec. Mhz: "; : COLOR fgs, 0: PRINT mz / 100: COLOR fg, 0
- LOCATE 23, 10: PRINT "BIOS machine code : "; : COLOR fgs, 0: PRINT idcod;
- SELECT CASE idcod%
- CASE 255: PRINT " (PC class)"
- CASE 254: PRINT " (XT class)"
- CASE 253: PRINT " (PCjr )"
- CASE 252: PRINT " (286 class machine)"
- CASE 249: PRINT " (Convertible)"
- CASE 250: PRINT " (PS/2 Model 30)"
- CASE 251: PRINT " (PS/2 Model 40)"
- CASE 252: PRINT " (PS/2 Model 50-60)"
- CASE 248: PRINT " (PS/2 Model 80 or 386 Class)"
- CASE ELSE: PRINT " (Unknown to me!)"
- END SELECT
- COLOR fg, 0
-
- GOSUB wait.key
- RETURN
-
-
- dformat:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: DATE - Returns system date info."
- LOCATE 6, 15: PRINT "Syntax: mon=0 : day=0 : yr=0 : dow=0 "
- LOCATE 7, 15: PRINT "CALL date(mon%, day%, yr%, dow%)"
-
- LOCATE 9, 15: PRINT "Function: DFRMAT - Formats a date."
- LOCATE 10, 15: PRINT "Syntax: m=[1-12] : d=[1-31] : y=[1800+] "
- LOCATE 11, 15: PRINT "CALL dfrmat(m%, d%, yr%, nudate$)"
-
- COLOR fg, bg: m = 0: d = 0: y = 0: dow = 0
- CALL date(m%, d%, yr%, dow%)
- CALL dfrmat(m%, d%, yr%, nudate$)
-
- LOCATE 13, 10: PRINT "These allow you to easily put a more friendly face on"
- LOCATE 14, 10: PRINT "BASIC's DATE$, and DATE allows access to the system"
- LOCATE 15, 10: PRINT "date as held in BIOS including the day of the week."
-
- LOCATE 16, 10: PRINT "Today's DATE$ is "; : COLOR fgs, 0: PRINT DATE$: COLOR fg, bg
- LOCATE 17, 10: PRINT "DFRMAT freshens it to :"; : COLOR fgs, 0: PRINT nudate$
- COLOR fg, bg
- LOCATE 19, 10: PRINT "Since DFRMAT works off integers, you can easily format a"
- LOCATE 20, 10: PRINT "string for days gone by, and to easily and quickly get todays"
- LOCATE 21, 10: PRINT "date in integer format, use the routine DATE."
-
- GOSUB wait.key
- RETURN
-
-
-
- daycnt:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: DAYOFYR - Get day count for this year"
- LOCATE 6, 15: PRINT "Syntax: DECLARE FUNCTION dayofyr% "
- LOCATE 7, 15: PRINT " today = dayofyr"
-
-
- COLOR fg, bg
- today = dayofyr
-
- LOCATE 10, 10: PRINT "So far this year there have been";
- COLOR fgs, 0: PRINT today; : COLOR fg, bg: PRINT "days."
-
- COLOR fg, bg: LOCATE 12, 10
- PRINT "DAYOFYR is accurate until Feb 28, 2100 which will be a"
- PRINT TAB(10); "centennial skip-leap year if all goes well."
-
-
- GOSUB wait.key
- RETURN
-
-
- tformat:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: TFRMAT - Format BASIC's TIME$"
- LOCATE 6, 15: PRINT "Syntax: label%=[0/1] : nutime$=TIME$"
- LOCATE 7, 15: PRINT "CALL tfrmat(nutime$, label% )"
- LOCATE 9, 15: PRINT "Function: SYSTIME - Get system time"
- LOCATE 10, 15: PRINT "Syntax: CALL systime(hrs%, mins%, sec%, hh%)"
-
-
- COLOR fg, bg
- nutime0$ = TIME$: CALL tfrmat(nutime0$, 0)
- nutime1$ = TIME$: CALL tfrmat(nutime1$, 1)
-
- LOCATE 12, 10: PRINT "We can cleanup BASIC's time output to a cleaner,";
- PRINT TAB(10); "more professional display with simple call."
- PRINT
-
- PRINT TAB(10); "The current time is: "; TIME$
- PRINT TAB(10); "TFRMAT freshens it to :"; : COLOR fgs, 0: PRINT nutime0$;
- COLOR fg, bg: PRINT " Or to "; : COLOR fgs, 0: PRINT nutime1$
- COLOR fg, bg: LOCATE 17, 10: PRINT "Notice the option of an am/pm label."
-
- CALL systime(hrs, mins, sec, hh)
- LOCATE 20, 5
- PRINT "SYSTIME reports time integers (hrs, mins, sec, hh) as: ";
- COLOR fgs, bgs: PRINT hrs; mins; sec; hh
- COLOR fg, bg
- PRINT TAB(15); "Note that the hundredths may not be accurate on all systems."
-
- GOSUB wait.key
- RETURN
-
- pcase:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: PCASE - Format string to Proper Case."
- LOCATE 6, 15: PRINT "Syntax: CALL pcase(text$)"
- COLOR fg, bg: ky$ = "": text$ = ""
-
- LOCATE 9, 10: PRINT "This routine converts incoming or other text to Proper"
- LOCATE 10, 10: PRINT "Case (first letter each word). The text to convert "
- LOCATE 11, 10: PRINT "must passed in lower case, easy in QB 4."
-
- LOCATE 13, 1: PRINT "Please type in a few words of text and tap ENTER. "
-
- lin = 14: max = 25: GOSUB get.string
- ' text$=lcase$(text$)
- CALL pcase(text$) ' convert to Proper Case
- LOCATE 20, 5: PRINT "Output from PCASE: "; : COLOR fgs, 0: PRINT text$: COLOR fg, bg
-
- LOCATE 22, 5: PRINT "These leave non alpha characters alone, and do NOT choke on Null strings."
-
- GOSUB wait.key
- RETURN
-
-
- err.msg:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: ERRMSG - Allows you to 'flash' a message to the screen."
- LOCATE 6, 15: PRINT "Syntax: emsg$=" + quote$ + "Text to display. " + quote$ + " emsgline=[any line]"
- LOCATE 7, 15: PRINT " emsgattr=[(fore*16) + back ] : emsgsnd=[0/1]"
- LOCATE 8, 15: PRINT "CALL errmsg(emsg$, emsgline, emsgattr, emsgsnd)"
- COLOR fg, bg: eml = 22: ems% = 2: max = 35
-
- LOCATE 10, 10: PRINT "What ERRMSG does, is save the display on the screen, display"
- LOCATE 11, 10: PRINT "your message, centered, on the line you tell it, sounds a low "
- LOCATE 12, 10: PRINT "tone if you desire, waits 2 secs, then pops the original display"
- LOCATE 13, 10: PRINT "back onto the screen without you having to redraw it."
-
- LOCATE 15, 5: PRINT "Type in a line to use as an error message or <ENTER> for the demo's own."
- lin = 16'*******************************************
- GOSUB get.string
- IF LEN(text$) < 2 THEN text$ = " Ooops, an error! - You entered no text!"
- CALL errmsg(text$, eml%, eattr%, ems%)
-
- GOSUB wait.key
- RETURN
-
-
- dollarf:
-
- RETURN
-
-
- lcountr:
-
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: LCOUNT - VERY quickly count lines in a text file."
- LOCATE 6, 15: PRINT "Syntax: DECLARE FUNCTION lcount%(fhandle%)"
- LOCATE 7, 15: PRINT " NumLines = lcount(fhandle)"
-
- COLOR fg, bg
-
- LOCATE 9, 10: PRINT "We will attempt to count the lines in GLIB14.DOC, and"
- LOCATE 10, 10: PRINT "if it does not exist, it will try GLIBDEMO.BAS. If"
- PRINT TAB(10); "this demo is in the binary 'quick save' format, it will return"
- PRINT TAB(10); "an oddball count. Do a SAVE AS text for accuracy if GLIB14.DOC"
- PRINT TAB(10); "is not in the current directory."
-
- GOSUB wait.key
- LOCATE 15, 1
- IF exist("glib14.doc") THEN
- fil$ = "glib14.doc"
- ELSE
- fil$ = "glibdemo.bas"
- END IF
-
- t1! = TIMER
- ercode = fopen(fil$, 0, fhandle)
- totallines = lcount(fhandle)
- t2! = TIMER
- elaps! = t2! - t1!
-
- PRINT : PRINT
- PRINT TAB(15); fil$; " was tested and found to have";
- COLOR fgs, bgs
- PRINT totallines
- COLOR fg, bg
- PRINT TAB(15); "and processing took a paltry ";
- COLOR fgs, bgs: PRINT USING "#.###"; elaps!;
- COLOR fg, bg: PRINT " seconds."
-
- GOSUB wait.key
-
- RETURN
-
- num.frmat:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: NFRMAT - Allows you to formatting of numeric strings."
- PRINT TAB(15); " Formats to phone and social security number formats."
- LOCATE 7, 15: PRINT "Syntax: num$="; quote$; 12345; quote$; " : mode%=[0|1|2|3|4|5|6]"
- LOCATE 8, 15: PRINT " p=<place to put '-' in mode 6>"
-
- COLOR fg, bg
- LOCATE 10, 10: PRINT "Mode 0 - Disallows '-' as an element.'"
- PRINT TAB(10); "Mode 1 - allows '-' as an element."
- PRINT TAB(10); "Mode 2 - formats to 7 digit phone: xxx-xxxx"
- PRINT TAB(10); "Mode 3 - formats to 10 digit phone: xxx-xxx-xxxx"
- PRINT TAB(10); "Mode 4 - formats to social security format: xxx-xx-xxxx"
- PRINT TAB(10); "Mode 5 - extarcts numbers from string - no exclusions."
- PRINT TAB(10); "Mode 6 - formats to account number style."
- PRINT TAB(10); " p points to location of '-' in returned string.": COLOR 7, 0
- PRINT TAB(10); "(Tapping Enter feeds the NFRMAT error message directly to ERRMSG)."
- COLOR fg, bg
-
- LOCATE 20, 10: PRINT "Enter seven digits for a phone number: "
- max = 15: lin = 21
- GOSUB get.string
- m = 2: mm = 2
- GOSUB nflabel
-
- LOCATE 20, 10: PRINT "Enter 10 digits for a phone number: "
- GOSUB get.string
- m = 3: mm = 3
- GOSUB nflabel
-
- LOCATE 20, 10: PRINT "Enter 11 digits for a social security number:"
- GOSUB get.string
- m = 4: mm = 4
- GOSUB nflabel
-
- LOCATE 20, 10: PRINT "Enter some digits as if an account number: "
- GOSUB get.string
- m = 6: mm = 6: p = 3
- GOSUB nflabel
-
- GOTO nf.end
-
- nflabel:
- CALL nfrmat(text$, m, p)
- IF m = mm THEN
- LOCATE 21, 20: PRINT "Mode "; m; " output "; text$
- ELSE
- CALL errmsg(text$, 24, eattr, 1)
- LOCATE lin, 1: PRINT clr$;
- text$ = ""
- END IF
- GOSUB wait.key
- FOR x = 19 TO 25
- LOCATE x, 1
- PRINT clr$;
- NEXT x
- RETURN
-
- nf.end:
- BEEP
- GOSUB wait.key
-
- RETURN
-
- chrp:
- CLS : GOSUB title
- LOCATE 5, 15: PRINT "Function: CHRP - Produce a simple Chirp."
- LOCATE 6, 15: PRINT " 0-descending 1-ascending."
- LOCATE 7, 15: PRINT "Syntax: CALL chrp(1) <or> CALL chrp(0) "
- LOCATE 8, 15: PRINT " Alternative: n=[0 | 1] : CALL chrp(n%) "
-
- COLOR fg, bg
- LOCATE 11, 10: PRINT "The descending tone is suitable for emulating a"
- PRINT TAB(10); "psuedo closing sound for window removal."
- COLOR fgs, 0
-
- y = 1: LOCATE 13, 10
- FOR x = 1 TO 3
- LOCATE 13 + x, 10: PRINT "Ascending ...";
- CALL chrp(1)
- CALL dly(1)
- PRINT " Descending ...";
- CALL chrp(0)
- CALL dly(1)
- NEXT x
-
- GOSUB wait.key
- RETURN
-
-
- dlys:
- CLS : GOSUB title
- LOCATE 5, 15: PRINT "Function: DLY - Produce a delay for x seconds."
- LOCATE 6, 15: PRINT "Syntax: CALL dly(1) <or> CALL dly(0) "
- LOCATE 7, 15: PRINT " Alternative: n=[0 | 1] : CALL dly(n%) "
-
- LOCATE 10, 15: PRINT "Function: MDLY - Produce a delay for x milli-seconds."
- LOCATE 11, 15: PRINT "Syntax: CALL mdly(500)"
- LOCATE 12, 15: PRINT " Alternative: n=500 : CALL mdly(n%) "
-
- COLOR fg, bg: LOCATE 15, 10
- PRINT "Delay for 3 seconds:"; TIMER; " ";
- CALL dly(3)
- PRINT TIMER
-
- LOCATE 17, 10
- PRINT "Delay for 500 milli secs (approx .5 secs): "; TIMER;
- CALL mdly(500): PRINT TIMER
-
- LOCATE 18, 10
- PRINT "Delay for 1000 milli secs (approx 1 secs): "; TIMER;
- CALL mdly(1000): PRINT TIMER
-
- GOSUB wait.key
- RETURN
-
-
- getch.and.vfname:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: GETCH - Allow Input only from predefined string."
- LOCATE 6, 15: PRINT "Syntax: ky$=" + quote$ + " " + quote$ + ": okay$=" + quote$ + "ABCDEF" + quote$
- LOCATE 8, 15: PRINT " CALL getch(okay$, ky$)"
-
- COLOR fg, bg
- LOCATE 10, 5: PRINT "Select any odd number (all other input ignored): "
- num$ = "13579": ky$ = " "
- CALL getch(num$, ky$)
- COLOR fgs, bgs
- PRINT TAB(15); "You selected "; ky$
-
- COLOR fg, bg
- PRINT : PRINT TAB(10); "Do you understand how this works? (Y/N)? ";
- yorn$ = "YN"
- CALL getch(yorn$, ky$)
- COLOR fgs, bgs
- PRINT ky$: PRINT TAB(10);
-
- SELECT CASE ky$
- CASE "Y": PRINT "Good, I am glad you do."
- CASE "N": PRINT "Well, too bad for you!"
- CASE ELSE: PRINT "Demo Code has been violated"
- END SELECT
-
- xdone = 0
- DO UNTIL xdone
- LOCATE 16, 15: COLOR fgs, bgs
- PRINT "Type a name that MIGHT or MIGHT not be capable of"
- PRINT TAB(15); "being a legal DOS name: ";
- fsiz = 12: fil$ = ""
- CALL fed(fil$, fsiz, fcode) ' whoa! he uses it!
- fil$ = LTRIM$(RTRIM$(fil$)) ' we know a space is illegal
- invalchar = 0: doscode = 0 ' this is in a loop
- invalchar = vfname(fil$, doscode)
- LOCATE 18, 15
- IF invalchar THEN PRINT "Nope, "; quote$; CHR$(invalchar); quote$; " is illegal."
-
- SELECT CASE doscode ' was there a DOS error
- CASE 0 ' do nothing - no error
- CASE 1: PRINT "odd error"
- CASE 3: PRINT "path or drive illegal"
- CASE 5: PRINT "access denied!"
- CASE ELSE: PRINT "nope - no can do!"
- END SELECT
-
- CALL pgetch(" Test another filename? ", 20, 78, yorn$, ky$)
- IF ky$ = "Y" THEN ' clear part of screen
- FOR x = 15 TO 24
- LOCATE x, 1
- PRINT SPACE$(79);
- NEXT x
- ELSE
- xdone = 1
- END IF
-
- LOOP
-
- GOSUB wait.key
-
- RETURN
-
-
- sdump:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: SCRNDUMP - Send current display to disk."
- LOCATE 6, 15: PRINT "Syntax: fil.num=x : CALL scrndump(fil.num%) "
-
- LOCATE 9, 10: COLOR fg, bg
- PRINT " With SCRNDUMP, you can dump the screen display to disk."
- PRINT TAB(10); "SCRNDUMP is very versatile in that by passing the file number,"
- PRINT TAB(10); "you have control over whether the display is APPENDed to a file"
- PRINT TAB(10); "already open or whether a new file is started with the SCRNDUMP."
-
- LOCATE 14, 20: PRINT "Examples of APPEND and non APPEND mode: "
- LOCATE 15, 10: PRINT "210: OPEN "; quote$; "SCREEN.FIL"; quote$; "FOR APPEND AS #3 <or> "
- LOCATE 16, 10: PRINT "210: OPEN "; quote$; "SCREEN.FIL"; quote$; "FOR OUTPUT AS #3"
- PRINT TAB(10); "220: CALL scrndump(3) "
-
- PRINT : ky$ = ""
- PRINT TAB(10); "Press any key, we will dump this screen to a"
- PRINT TAB(10); "file called SCRNDUMP.FIL, you can examine later."
- WHILE ky$ = ""
- ky$ = INKEY$
- WEND
-
- OPEN "scrndump.fil" FOR OUTPUT AS #1
- BEEP: CALL scrndump(1)
- CLOSE #1
- COLOR fgs, bgs
- LOCATE 10, 15: PRINT "SCRNDUMP.FIL contains the screendump just executed."
-
- GOSUB wait.key
- RETURN
-
-
-
- qprt:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: QUIKPRT - Replacement for BASICA's terribly slow"
- LOCATE 6, 15: PRINT " PRINT statement."
- LOCATE 7, 15: PRINT "Syntax: msg$="; quote$; "Thing to print"; quote$; " : row=x : col=y : attr=(fg*16)+bg)"
- LOCATE 8, 15: PRINT " CALL quikprt(msg$, row%, col%, attr%) "
-
- COLOR fg, bg
-
- LOCATE 10, 10: PRINT "This is a VERY, VERY fast replacement for BASIC's native PRINT"
- PRINT TAB(10); "statement that is pitifully slow. There is a fair amount of set up"
- PRINT TAB(10); "to use this, so it is not ideal for character based output, but for"
- PRINT TAB(10); "string and array output, it speeds things up on an order of MAGNITUDE."
- PRINT TAB(10); "The attribute parameter is caluculated via the formula:"
- PRINT TAB(10); "(FOREGROUND * 16) + BACKGROUND": COLOR fgs, 0
- PRINT TAB(10); "QUIKPRT is also quite smart, recognizing mono and EGA adapters to"
- PRINT TAB(10); "print even FASTER on systems so equipped."
- PRINT : COLOR fg, bg
- PRINT TAB(10); "To demo this, we will fill the screen with characters 10 times using"
- PRINT TAB(10); "PRINT then again using QUIKPRT and then compare the times."
-
- GOSUB wait.key
- CLS
- pstart! = TIMER
- FOR z = 1 TO 10
- FOR x = 1 TO 24
- PRINT STRING$(80, CHR$(47 + z))
- NEXT x
- NEXT z
- pend! = TIMER
-
- CLS : BEEP
-
- qstart! = TIMER
- FOR z = 1 TO 10
- FOR x = 1 TO 24
- CALL quikprt(STRING$(80, CHR$(47 + z)), x, 1, attr%)
- NEXT x
- NEXT z
- qend! = TIMER
-
- pelaps! = pend! - pstart!
- qelaps! = qend! - qstart!
- CLS : LOCATE 10, 1
- PRINT "Elapsed time for PRINT "; pelaps!
- PRINT "Elapsed time for QUIKPRT "; qelaps!
-
- GOSUB wait.key
- RETURN
-
-
- pscrn:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: PRTSCRN - Send current display to printer."
- LOCATE 6, 15: PRINT "Syntax: CALL prtscrn "
-
- LOCATE 8, 15: PRINT "Function: PINIT(num) - Initialize printer 1,2 or 3"
- LOCATE 9, 15: PRINT "Syntax: p=1 : CALL pinit(p)"
-
- LOCATE 8, 15: PRINT "Function: PSTAT(num) - Test if printer is online/ready."
- LOCATE 9, 15: PRINT "Syntax: p=1 : CALL pstat(p)"
-
- GOSUB wait.key
- LOCATE 24, 1: PRINT clr$;
-
- COLOR fg, bg: ky$ = "": p = 1
-
- LOCATE 11, 10: PRINT "Initialize printer:": CALL pinit(1)
- CALL dly(2) 'wait for it to finish initializing before testing
-
- LOCATE 13, 10: PRINT "Testing printer status:";
- CALL pstat(p)
-
- LOCATE 14, 15: PRINT "Your Printer is ";
- IF p = 0 THEN PRINT "NOT ";
- PRINT "Ready !"
-
- LOCATE 17, 10: INPUT "Perform PRTSCRN demo? (Y/n) ", ky$
- IF ky$ = "N" OR ky$ = "n" THEN GOTO pscrn.end
- IF p = 0 THEN
- PRINT "Can't - it is not online!"
- GOTO pscrn.end
- END IF
-
- CALL prtscrn
-
- pscrn.end:
- GOSUB wait.key
-
- RETURN
-
-
- cmdl:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: CMDLINE - Retrieve and parse any command line"
- LOCATE 6, 15: PRINT " parameters."
- LOCATE 7, 15: PRINT "Syntax: DIM arg$(x) : q=y "
- LOCATE 8, 15: PRINT " CALL cmdline(arg$(),q%) "
-
- COLOR fg, bg
- LOCATE 10, 10: PRINT "DIMension the array that will hold the arguments preferably to"
- PRINT TAB(10); "a size one or 2 larger than the total number of arguments your program"
- PRINT TAB(10); "expects or allows. Q is set to 0 or 1 depending on your OPTION BASE"
- PRINT TAB(10); "to tell CMDLINE where to put the first argument, element 0 or 1. OPTION"
- PRINT TAB(10); "BASE 1 can be emulated here by setting Q to 1; Q returns the actual"
- PRINT TAB(10); "number passed, to aid in FOR...NEXT loop analysis in your program."
- PRINT
- PRINT TAB(10); "If you started this demo from the batch file provided, the demo of this"
- PRINT TAB(10); "routine will display the first 6 command line parameters passed from"
- PRINT TAB(10); "that batch file (that is all I expect)."
-
- ' DIM arg$(6) : q=6 (this was already done and read
- ' CALL cmdline(arg$(),q) earlier - see the code at the start)
-
- GOSUB wait.key
- CLS : LOCATE 5, 10
- PRINT "In OPTION BASE 1, q returns the quatity of args AND high array"
- PRINT TAB(10); "Dimension filled. In OPTION BASE 0 q returns only the"
- PRINT TAB(10); "number of arguments, the last element = Q+1 as with"
- PRINT TAB(10); "most OPTION BASE 0 operations."
-
- IF q > 0 THEN ' in case they were removed
- LOCATE 10, 10: PRINT "Actual number of arguments present: "; q
- PRINT
- PRINT TAB(10); "Arguments passed:"
- ' start with LBOUND so you can test OPTION BASE 0
- FOR x = LBOUND(arg$) TO q
- PRINT TAB(15); "Argument "; x; ": "; arg$(x)
- NEXT
- ELSE
- LOCATE 10, 10: PRINT "Demo was started with no command line."
- END IF
-
- GOSUB wait.key
- RETURN
-
-
-
- xscrn:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: SVSCRN, RSTSCRN - Save the current video display to"
- LOCATE 6, 15: PRINT " an integer array and Restore it later when desired."
- LOCATE 7, 10: PRINT "Syntax: CALL svscrn(VARSEG(sarry(1)), VARPTR(sarry(1)) )"
-
-
- COLOR fg, bg
- LOCATE 11, 5: PRINT "These routines allow you to save and restore a screen image."
- PRINT TAB(5); "If you are not familiar with VARPTR, refer to it in the QB book."
- PRINT TAB(5); "Study the docs carefully before using these. Improper set up will"
- PRINT TAB(5); "send the machine on a search for Spock."
- PRINT
- PRINT TAB(5); " Each screen to save requires 2000 bytes in an array, so to save 3, DIM"
- PRINT TAB(5); "it to 6000 bytes. The method used here, utilizes DYNAMIC memory, which"
- PRINT TAB(5); "means it resides outside the local segment. In so doing, the routine will"
- PRINT TAB(5); "require that we pass a pointer to the array's SEGMENT as well as the first"
- PRINT TAB(5); "element to use. This is done with the VARSEG function, and VARPTR for the "
- PRINT TAB(5); " pointer to the first element. The demo for this is integrated"
- PRINT TAB(5); "into the next demo but feel free to examine this code for additional info.";
-
- GOSUB wait.key
-
- wdws:
- CLS : GOSUB title
- LOCATE 5, 15: PRINT "Function: WDW - Pop a window to the screen with sound "
- LOCATE 6, 15: PRINT " and color control."
- LOCATE 7, 15: PRINT "Syntax: top=n : rt=n : btm=n : lft=n : sfx=0/1 : gro=0/1 "
- LOCATE 8, 15: PRINT " grame=x; attr=(fg*16)+bg : label$="; quote$; "Window Label"; quote$
- LOCATE 9, 15: PRINT " CALL wdw(top, lft, btm, rt, sfx, gro, fr, attr, l$)"
-
- COLOR fg, bg
- LOCATE 11, 10: PRINT "The first 4 parameters define the perimeter of the window, while"
- PRINT TAB(10); "SND and GRO are (0/1) switches that determine if there is to be sound"
- PRINT TAB(10); "or if the window is to grow. The attribute is determined in the same"
- PRINT TAB(10); "manner as it is in QUIKPRT, frame is your choice of frame style, (see"
- PRINT TAB(10); "the manual for full information). Finally, LABEL$ is a label to center"
- PRINT TAB(10); "across the top of the window (which can be omitted)."
- PRINT
- PRINT TAB(10); "The GROW is quite swift, making it acceptable for use on 8088 based"
- PRINT TAB(10); "machines, maybe too fast on 286's, but it's an effect not a function."
- ' PRINT TAB(10) ; "Via a environment switch, you can set sound on and let the end user"
- ' PRINT TAB(10) ; "override it for maximum flexibility."
- ' the assembler version no longer supports the environ switch, but it may later
-
- GOSUB wait.key
- wattr2% = (1 * 16) + 15: wattr3% = (2 * 16) + 15: wattr4% = (0 * 16) + 11: wattr5 = (3 * 16) + 0
- wattr6% = (5 * 16) + 14
-
- ' DIM sarry%(14000) ' This was done earlier to be available
-
- GOSUB set.pointers
-
- CALL sinfo(j, j, j, ega, vga) ' a REAL use for this one:
- ' if ega or vga, wdws are REAL fast!
-
- CALL svscrn(segmt1, sptr1) ' now we have the screen with text
- ' captured in array
- CALL wdw(2, 2, 15, 55, 1, 1, 1, wattr%, "Gro & SFX")
- IF ega + vga > 0 THEN
- CALL mdly(250) ' pause a bit if EGA or VGA
- LOCATE 8, 5: COLOR fgw, bgw ' so wdws appear individually
- PRINT "There is a one tenth second delay"
- LOCATE 9, 5: PRINT "between each window call for effect."
- LOCATE 10, 5: PRINT "Untethered, they are even faster!"
- END IF
-
- CALL svscrn(segmt2, sptr2) ' capturd one with window one on it
-
- CALL wdw(12, 5, 23, 30, 0, 0, 2, wattr2%, "No Gro, No SFX")
- CALL svscrn(segmt3, sptr3)
- IF ega + vga > 0 THEN CALL mdly(150)
-
- CALL wdw(2, 42, 13, 75, 0, 1, 3, wattr3%, "SFX Only")
- CALL svscrn(segmt4, sptr4)
- IF ega + vga > 0 THEN CALL mdly(150)
-
- CALL wdw(5, 52, 23, 75, 1, 0, 4, wattr4%, "Gro Only")
- CALL svscrn(segmt5, sptr5)
- IF ega + vga > 0 THEN CALL mdly(150)
-
- CALL wdw(15, 32, 24, 52, 1, 1, 0, wattr5%, "Gro & SFX")
- CALL svscrn(segmt6, sptr6)
- IF ega + vga > 0 THEN CALL mdly(150)
-
- CALL wdw(2, 2, 6, 22, 0, 1, 3, wattr6%, "SFX Only")
- CALL svscrn(segmt7, sptr7)
- CALL mdly(150)
-
- COLOR 15, 1
- LOCATE 13, 6: PRINT "With SVSCRN and RSTSCRN"
- LOCATE 14, 6: PRINT "we can back up one "
- LOCATE 15, 6: PRINT "layer at a time..."
- LOCATE 17, 6: PRINT "I have added a .5 sec"
- LOCATE 18, 6: PRINT "delay so you see what"
- LOCATE 19, 6: PRINT "is going on."
- CALL clrkbd
- GOSUB wait.key
-
- GOSUB set.pointers
- CALL rstscrn(segmt6, sptr6) ' pops them back one at a time
- CALL mdly(500)
- CALL rstscrn(segmt5, sptr5)
- CALL mdly(500)
- CALL rstscrn(segmt4, sptr4)
- CALL mdly(500)
- CALL rstscrn(segmt3, sptr3)
- CALL mdly(500)
- CALL rstscrn(segmt2, sptr2)
- CALL mdly(500)
- CALL rstscrn(segmt1, sptr1)
-
- COLOR 15, 1
- CALL wdw(12, 5, 23, 30, 0, 0, 2, wattr2%, "Window 2")
- LOCATE 13, 6: PRINT "We still have each level"
- LOCATE 14, 6: PRINT "of screen in memory, and"
- LOCATE 15, 6: PRINT "can recall any level we"
- LOCATE 16, 6: PRINT "chose! "
- LOCATE 17, 6: PRINT "Let's peel them back "
- LOCATE 18, 6: PRINT "with sound."
-
- GOSUB wait.key
- GOSUB set.pointers
-
- CALL rstscrn(segmt6, sptr6) ' no window level
- CALL chrp(0)
- CALL mdly(500)
-
- CALL rstscrn(segmt5, sptr5)
- CALL chrp(0)
- CALL mdly(500)
-
- CALL rstscrn(segmt4, sptr4)
- CALL chrp(0)
- CALL mdly(500)
-
- CALL rstscrn(segmt3, sptr3)
- CALL chrp(0)
- CALL mdly(500)
-
- CALL rstscrn(segmt2, sptr2)
- CALL chrp(0)
- CALL mdly(500)
-
- CALL rstscrn(segmt1, sptr1)
- CALL chrp(0)
-
- GOSUB wait.key
- RETURN
-
- bxs:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: BOXES - Pops a frame onto the screen as you might"
- LOCATE 6, 15: PRINT " for a menu."
- LOCATE 7, 15: PRINT "Syntax: box=x : frame=x : foreground=x "
- LOCATE 8, 15: PRINT " CALL boxes(box%, frame%, foreground%)"
-
- COLOR fg, bg
-
- LOCATE 10, 10: PRINT "This is really an attempt on my part to make WDW depend more"
- PRINT TAB(10); "dependant on asm routines, but even though I am not done with it, I"
- PRINT TAB(10); "have found a few uses for it. At point it worked out great for a "
- PRINT TAB(10); "split screen application I wrote."
- PRINT TAB(10); "Regardless, less coding and code space is consumed with an ASM CALL"
- PRINT TAB(10); "even with what is left for you to finish."
- PRINT
- PRINT TAB(10); "There are 5 boxes, tap <Enter> at the BEEP to move thru them..."
-
- GOSUB wait.key: CLS
- CALL boxes(1, 1, 15)
- BEEP: GOSUB waitk2: CLS
- CALL boxes(2, 2, 14)
- BEEP: GOSUB waitk2: CLS
- CALL boxes(3, 3, 3)
- BEEP: GOSUB waitk2: CLS
- CALL boxes(4, 4, 4)
- BEEP: GOSUB waitk2: CLS
- CALL boxes(5, 1, 11)
- BEEP: GOSUB waitk2: CLS
- CALL boxes(6, 1, 11)
- BEEP: GOSUB waitk2
-
- CALL boxes(3, 4, 2)
- CALL boxes(4, 4, 2)
-
- COLOR fg, bg
- LOCATE 2, 3: PRINT "You can probably imagine how this came in handy on a "
- LOCATE 3, 3: PRINT "split screen application..."
- LOCATE 14, 3: PRINT "Yes I can!!"
- GOSUB wait.key
- RETURN
-
- scrl:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: USCROLL, DSCROLL - Scroll the display up or down."
- LOCATE 6, 15: PRINT "Syntax: Num lines [1-24] to scroll and use legal coordinates:"
- LOCATE 7, 15: PRINT " CALL USCROLL(num%, top%, lft%, bttm%, rght%)"
- LOCATE 8, 15: PRINT " CALL DSCROLL(num%, top%, lft%, bttm%, rght%)"
-
- LOCATE 10, 15: PRINT "Function: SCROLLER - Scroll the display left or right."
- LOCATE 11, 15: PRINT "Syntax: Num lines [1-24] to scroll +(left) or -(right)"
- LOCATE 12, 15: PRINT " CALL SCROLLER(-40)"
- LOCATE 13, 15: PRINT " CALL SCROLLER(+10)"
-
- COLOR fg, bg
- LOCATE 15, 10: PRINT "This allows us to scroll any legal window any number of lines."
- PRINT TAB(10); "We will fill the screen with a test pattern and then scroll a window"
- PRINT TAB(10); "of text within it to demonstrate one of the more impressive aspects of"
- PRINT TAB(10); "the first routine. A second demo does a screen left-right scroll demo."
- PRINT TAB(10); "The area of the screen to be scrolled and the number of lines to"
- PRINT TAB(10); "scroll is fully user definable."
-
- GOSUB wait.key
- CLS
-
- COLOR fgt, 0 ' QUIKPRT a test pattern
- FOR x = 1 TO 24
- CALL quikprt(STRING$(80, CHR$(x + 96)), x, 1, 2)
- NEXT x
-
- GOSUB set.pointers
-
- BEEP: CALL svscrn(segmt1, sptr1) ' save the test pattern
- COLOR fgd, 0
-
- FOR x = 1 TO 15 ' print the text at the
- CALL uscroll(1, 5, 20, 19, 59) ' same line, let SCROLL
- LOCATE 19, 22 ' move the text up the screen
- PRINT "Scroll Up Line # "; x;
- NEXT x
-
- COLOR fgt, 0: LOCATE 15, 44: PRINT "Slow now, w/"
- LOCATE 16, 44: PRINT "frame (from WDW)!"
-
- GOSUB wait.key ' wait for you to catch up
-
- GOSUB set.pointers
- CALL rstscrn(segmt1, sptr1) ' restore test pattern
-
- CALL wdw(6, 30, 16, 50, 0, 0, 2, 4, "15 Lines") 'could be done with box #6
-
- COLOR fgd, 0
- FOR x = 1 TO 15 ' loop for 15 lines
- CALL dscroll(1, 6, 30, 16, 50) ' scroll down a line
- LOCATE 6, 31 ' at top of window,....
- IF cmode THEN COLOR x, 0 ELSE COLOR 15, 0
- PRINT "Scroll Dn Line #"; x; ' print the message
- CALL mdly(500) ' waitasec
- NEXT x
-
- BEEP
-
- CLS : LOCATE 10, 22
- PRINT "Now, shifting the screen using SCROLLER."
-
- GOSUB wait.key
-
- GOSUB set.pointers
- BEEP: CALL rstscrn(segmt1, sptr1) ' restore test pattern
-
- FOR x = 1 TO 6
- CALL scroller(40)
- CALL mdly(500)
- CALL scroller(-40)
- CALL mdly(500)
- NEXT x
- CALL dly(1)
- CALL rstscrn(segmt1, sptr1) ' restore test pattern
-
- BEEP
- FOR x = 1 TO 80
- CALL scroller(-1)
- NEXT x
- SOUND 1200, .75
- LOCATE 15, 25: PRINT "Scrolled lines are lost."
- CALL dly(1): LOCATE 16, 30: PRINT "Forever"
-
- GOSUB wait.key
- RETURN
-
-
- funique:
- CLS : GOSUB title
-
- LOCATE 5, 15: PRINT "Function: FUNIQ - Create a unique file (name and HANdle)."
- LOCATE 6, 15: PRINT "Syntax: DECLARE FUNCTION funiq(fil$, fhandle%)"
-
- COLOR fg, bg
- LOCATE 10, 10: PRINT " To demo this, we'll creat a file, tell you the name and"
- PRINT TAB(10); "handle but leave it on disk for you to look at later. There will"
- PRINT TAB(10); "be NOTHING in the file as we have no use for it, but it will be"
- PRINT TAB(10); "there with 0 bytes. "; ""
-
- GOSUB wait.key
- drv$ = " " ' always initialize sting storage
- CALL getdrv(drv$) ' get current drive
- temp$ = drv$ + ":\" + SPACE$(13) ' save room for the name
- ' this will put it in the root because we did not
- ' fetch the current directory
- ercode = funiq(temp$, 0, fhandle) ' normal attributes
- LOCATE 16, 5
-
- IF ercode THEN
- COLOR fgs, bgs
- PRINT "Ooops, ercode of"; ercode; " means something went wrong."
- ELSE
- COLOR fg, bg
- PRINT " The UNIQUE, temporary or scratch file's name is: ";
- COLOR fgs, bgs
- PRINT temp$
- COLOR fg, bg
- PRINT TAB(10); "and the other file functions address it as handle: ";
- COLOR fgs, bgs
- PRINT fhandle
- END IF
-
- GOSUB wait.key
- ercode = fclose(fhandle)
- RETURN
-
- the.end:
- CALL wdw(10, 10, 20, 70, 1, 1, 1, wattr%, "The End")
- x = 11: y = 15: COLOR fgw, bgw
- LOCATE x, y
- PRINT " Thanks for your time and interest in GIZLIB."
- x = x + 2
- LOCATE x, y: PRINT "This demo is meant to demonstrate the use and"
- x = x + 1: LOCATE x, y: PRINT "implementation of some of the routines, and not"
- x = x + 1: LOCATE x, y: PRINT "a complete tutorial on using GIZLIB. All the"
- x = x + 1: LOCATE x, y: PRINT "routines available are not even demonstrated! "
- x = x + 2: LOCATE x, y: PRINT "Refer to the documentation for complete details on"
- x = x + 1: LOCATE x, y: PRINT "usage and implementation."
-
-
- extt:
- SYSTEM
-
-
- '---------------------[subroutines]-----------------
- ' This next step is very important. As a matter of course,
- ' BASIC will shift an array's location in memory. To make
- ' sure that your screen array pointers are indeed pointing
- ' to the right spot, do a GOSUB to set them before CALLing
- ' any routine that depends on the segment and offset of a
- ' screen array.
-
- set.pointers:
- segmt1 = VARSEG(sarry(1)): sptr1 = VARPTR(sarry(1))
- segmt2 = VARSEG(sarry(2001)): sptr2 = VARPTR(sarry(2001))
- segmt3 = VARSEG(sarry(4001)): sptr3 = VARPTR(sarry(4001))
- segmt4 = VARSEG(sarry(6001)): sptr4 = VARPTR(sarry(6001))
- segmt5 = VARSEG(sarry(8001)): sptr5 = VARPTR(sarry(8001))
- segmt6 = VARSEG(sarry(10001)): sptr6 = VARPTR(sarry(10001))
- segmt7 = VARSEG(sarry(12001)): sptr7 = VARPTR(sarry(12001))
-
- RETURN
-
-
-
- title: '********************
- COLOR fgt, 0
- LOCATE 2, 25: PRINT "GIZLIB 1.4 Demo of QB Routines. "
- COLOR fgs, bgs
- RETURN
-
-
- wait.key: '***********************
- LOCATE 24, 25
- COLOR 14, 0: PRINT "Press any key to continue.";
-
- waitk2:
- cont$ = INKEY$
- WHILE cont$ = ""
- cont$ = INKEY$
- WEND
- LOCATE 23, 25: PRINT SPACE$(50);
- COLOR fg, bg
- RETURN
-
-
- get.string:
- COLOR fgt, 0: LOCATE lin, 1: PRINT "=> "; : COLOR fgs, 0
- ky$ = "": text$ = ""
- ky$ = INKEY$
- DO UNTIL ky$ = CHR$(13) OR LEN(text$) >= max 'this is new to QB 3.0
- ky$ = INKEY$
- IF ky$ >= CHR$(32) THEN
- PRINT ky$;
- text$ = text$ + ky$
- ELSEIF ky$ = CHR$(8) AND LEN(text$) >= 1 THEN
- PRINT CHR$(29) + CHR$(32) + CHR$(29);
- text$ = LEFT$(text$, LEN(text$) - 1)
- END IF
- LOOP
- IF text$ = CHR$(13) THEN GOTO get.string
- RETURN
-
- ' unREM the following lines with a text editor for QB4
- '
- SUB DIR (mask$, fil$()) STATIC
-
- REM $INCLUDE: 'DIR.SUB' ' This provides an interface similar
-
- END SUB
-
-