home *** CD-ROM | disk | FTP | other *** search
- '*************************
- '* GLIBDEMO
- '*
- '* Demo of key routines in GIZLIB
- '* (C) InfoSoft 1986, 1987
- '*************************
- ' This demo will demonstrate some of the
- ' routines of the QuickBASIC GIZLIB that
- ' should accompany it.
- ' Additionally it will augment the DOCs with its actual use.
- '**************************
- CLEAR
- DEFINT a-z
- OPTION BASE 1
-
- 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] or [/CMD /C]. /NC for"
- LOCATE 9,5
- PRINT "No Color, /C for color version. This should be noted in DEMO.BAT"
- LOCATE 13,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
-
- IF q=0 THEN
- arg$(2)="No command line entered."
- END IF
-
- COLOR fg,bg
- CLS
- GOSUB title
- COLOR fgs,bgs
-
-
-
- ' start with the easy ones
- dosver: '*************************************
- dos%=0
- CALL dosv(dos%)
- 'the dos version * 100 will return in DOS variable
-
- LOCATE 5,15:PRINT "Function: DOSV - Get DOS version."
- LOCATE 6,15:PRINT "Syntax: dos%=0: CALL dosv(dos%)"
-
-
- LOCATE 10,5:COLOR fg,bg
-
- PRINT "Like most other QB libs, GIZLIB contains a routine to fetch the"
- LOCATE 11,5:PRINT "DOS version number. Unlike most others, it returns"
- LOCATE 12,5:PRINT "a single whole number rather than a MAJOR and MINOR version."
- LOCATE 14,5:PRINT "On your machine, DOSV returned ";:COLOR fgs,0 : PRINT dos
- COLOR fg,bg
- LOCATE 16,5:PRINT "This makes it a little more workable and fewer variables."
- LOCATE 17,5:PRINT "Simply divide by 100 to get a legitimate number: ";:
- COLOR fgs,0 : PRINT dos/100 : COLOR fg,bg
-
- GOSUB wait.key
- CLS:GOSUB title
-
-
- dspace: '************************
- 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 10,5:PRINT" Also like other LIBs, we can get the size of a drive"
- LOCATE 11,5:PRINT" 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 16,10:PRINT" Free space is: ";: COLOR fgs,0 : PRINT free#
-
- GOSUB wait.key
- CLS:GOSUB title
-
-
- sysinfo: '*************************
- ram%=0:ser%=0:par%=0
- CALL sinfo(ram%,ser%,par%,ega%)
-
- LOCATE 5,15 : PRINT "Function: SINFO - Get peripheral info "
- LOCATE 6,15 : PRINT "Syntax: ram%=0 : ser%=0 : par%=0"
- LOCATE 7,15 : PRINT "CALL sinfo(ram%,ser%,par%,ega%)"
- COLOR fg,bg
-
- LOCATE 9,10:PRINT "Also we can poll the machine to get some hardware"
- LOCATE 10,10:PRINT "and peripheral info:"
- LOCATE 12,10:PRINT "RAM installed: ";: COLOR fgs,0 : PRINT ram% : COLOR fg,0
- LOCATE 13,10:PRINT "# Serial ports:";: COLOR fgs,0 : PRINT ser% : COLOR fg,0
- LOCATE 14,10:PRINT "Parallel ports:";: COLOR fgs,0 : PRINT par% : COLOR fg,0
- LOCATE 15,10:PRINT "EGA memory : ";: COLOR fgs,0
- SELECT CASE ega%
- CASE 1 : PRINT "64k"
- CASE 2 : PRINT "128k"
- CASE 3 : PRINT "256k"
- CASE ELSE : PRINT "None"
- END SELECT
- COLOR fg,0
-
- LOCATE 16,5:PRINT "If your system is an AT, a separate routine returns any ";
- PRINT "installed"
- LOCATE 17,5:PRINT "Extended memory.
-
- GOSUB wait.key
- CLS:GOSUB title
-
-
- dformat:
- LOCATE 5,15 : PRINT "Function: DFRMAT - Formats a date."
- LOCATE 6,15 : PRINT "Syntax: m=[1-12] : d=[1-31] : y=[1800+] "
- LOCATE 7,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 9,10 : PRINT "This simply allows you to easily put a more friendly face"
- LOCATE 10,10 : PRINT "on BASIC's rather unfreindly DATE$, by formatting the"
- LOCATE 11,10 : PRINT "system date, or any other date with the month name etc."
-
- LOCATE 13,10 : PRINT "Today's DATE$ is ";DATE$
- LOCATE 14,10 : PRINT "DFRMAT freshens it to :";:COLOR fgs,0:PRINT nudate$
- COLOR fg,bg
- LOCATE 16,10 : PRINT "Since DFRMAT works off integers, you can easily format a"
- LOCATE 17,10 : PRINT "string for days gone by, and to easily and quickly get todays"
- LOCATE 18,10 : PRINT "date in integer format, the routine DATE returns the day,"
- LOCATE 19,10 : PRINT "month and year as well as the day of the week as integers."
-
- GOSUB wait.key
- CLS:GOSUB title
-
-
- tformat:
- 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(label%,nutime$)"
- COLOR fg,bg
- nutime0$=TIME$ : CALL tfrmat(0,nutime0$)
- nutime1$=TIME$ : CALL tfrmat(1,nutime1$)
-
-
- LOCATE 9,10 : PRINT " Likewise we can cleanup BASIC's time output to a cleaner,";
- LOCATE 10,10 : PRINT " more professional display with simple call."
-
- LOCATE 12,10:PRINT "The current time is: ";TIME$
- LOCATE 13,10:PRINT "TFRMAT freshens it to :"; : COLOR fgs,0 : PRINT nutime0$
- COLOR fg, bg : LOCATE 14,10 : PRINT "Or to ";:COLOR fgs, 0 : PRINT nutime1$
- COLOR fg, bg : LOCATE 16,10 : PRINT "Notice the option of an am/pm label."
-
- GOSUB wait.key
- CLS:GOSUB title
-
-
- ucase:
- LOCATE 5,15:PRINT "Function: UCASE, LCASE, PCASE - Input characters formatting."
- LOCATE 6,15:PRINT "Syntax: "
- LOCATE 7,15:PRINT "CALL ucase(text$) : CALL lcase(test$) : CALL pcase(text$)"
- COLOR fg,bg : ky$="" : text$=""
-
- LOCATE 9,10 : PRINT "These routines convert incoming or other text to Upper Case,"
- LOCATE 10,10 : PRINT "lower case or Proper Case (first letter each word)."
-
- LOCATE 13,1 : PRINT "Please type in a few words of text and tap ENTER. "
-
- lin=14 : max=25 : GOSUB get.string
-
- COLOR fg, bg
- CALL ucase(text$) ' convert to upper
- LOCATE 18,5 : PRINT "Output from UCASE: ";: COLOR fgs,0 : PRINT text$ : COLOR fg,bg
-
- CALL lcase(text$) ' convert to lower
- LOCATE 19,5 : PRINT "Output from LCASE: ";: COLOR fgs,0 : PRINT text$ : COLOR fg,bg
- t$=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
- CLS:GOSUB title
-
-
- err.msg:
- 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
- CLS : GOSUB title
-
-
-
- dollarf:
- LOCATE 4,15 : PRINT "Function: DLRFRMAT - Format numeric strings from blind input."
- LOCATE 5,15 : PRINT "Syntax: dollarsgn%=[0/1/2/3] : decimals%=[0/2/3] "
- LOCATE 6,15 : PRINT "CALL dlrfrmat(number$, dollarsign%, decimals%)"
-
- COLOR fg,bg : ky$="" : num$=""
-
- LOCATE 9,10 : PRINT "This routine is helpful in formatting numeric input to a KNOWN format."
- PRINT TAB(10) ; "The DECIMALS switch will return the string formatted to 2 or 3"
- PRINT TAB(10) ; "decimals, 0 mode forces automatic dollar format if no '.' is entered."
- PRINT TAB(10) ; "With the dollarsign switch, we tell DLRFRMAT whether or not we want a"
- PRINT TAB(10) ; "'$' on the returned string and whether or not to demand a decimal."
- PRINT TAB(10) ; "This is useful in dollar value i/o from the keyboard or random files.";
-
- inpt1:
- LOCATE 16,5 : PRINT "Please type in a number under $10.00 (include the decimal !). "
- lin=17 : max=6 : GOSUB get.string
-
- PRINT
- num$=text$ : m=0 : p=2 ' save a copy for multiple calls
- CALL dlrfrmat(text$, m, p)
- IF m=0 THEN ' if they trick me, M indicates an error
- COLOR fg,bg : PRINT "Formatted to 2 decimals, no $: ";: COLOR fgs,bgs :
- PRINT text$
- ELSE
- CALL errmsg(text$,eml,eattr, ems)
- LOCATE 17,1 : PRINT clr$;
- GOTO inpt1
- END IF
-
-
- m=1 : p=2 ' reset pointers
- text$=num$
- CALL dlrfrmat(text$, m, p)
-
- COLOR fg,bg : PRINT "Formatted to 2 decimals, with $: ";: COLOR fgs,bgs :
- PRINT text$
-
- GOSUB wait.key
-
- FOR x=15 TO 23 ' clear lower (demo) portion of screen
- LOCATE x,1
- PRINT clr$;
- NEXT
-
-
- LOCATE 16,5 : PRINT "Please type in a number under $10.00 (DO NOT include the decimal !). "
- lin=17 : max=6 : GOSUB get.string
-
- PRINT
- m=1 : p=0
- CALL dlrfrmat(text$, m, p)
- COLOR fg,bg : PRINT "Formatted in auto mode, with $: ";: COLOR fgs,bgs :
- PRINT text$
-
- GOSUB wait.key
-
- FOR x=9 TO 23 ' clear lower (demo) portion of screen
- LOCATE x,1
- PRINT clr$;
- NEXT
-
- LOCATE 10,5 : PRINT "You really need to toy with this one as it is VERY powerful, more"
- PRINT TAB(5) ; "so than this demo shows. The auto mode would take input of '2' and"
- PRINT TAB(5) ; "ouput is either $.02 or .02 depending on what you set the dollar sign"
- PRINT TAB(5) ; "switch to. You can also force a decimal to be entered, if the user"
- PRINT TAB(5) ; "does not, dollarsgn returns an error condition, and number$ returns
- PRINT TAB(5) ; "a message directly usable in ERRMSG (which you may have seen). In
- PRINT TAB(5) ; "the case of invalid characters like A-z, [{*&^, the decimals%
- PRINT TAB(5) ; "parameter points to the invalid character."
-
-
- GOSUB wait.key
- CLS:GOSUB title
-
- keylox:
- LOCATE 5,15 : PRINT "Function: KEYLOCKS - Allows you to toggle the NumLock,"
- LOCATE 6,15 : PRINT " CapsLock and Scroll Lock Keys"
- LOCATE 7,15 : PRINT "Syntax: CALL NLON, NLOFF, CLON, CLOFF, SCRLON or SCRLOFF "
-
- COLOR fg,bg
-
- LOCATE 9,10 : PRINT "Go ahead and type a few keys to see the effect: "
- LOCATE 10,10 : PRINT "Demo will abort after 10 keypresses or with <ESC>."
- PRINT : PRINT : COLOR fgs,0 : y=1 : ky$="" : l=5 : h=13
-
- FOR x=1 TO 10
- WHILE ky$=""
- ky$=INKEY$
- WEND
- LOCATE h,l
- IF ky$=CHR$(27) THEN GOTO keylox.end
- PRINT ky$;" ";
- h=CSRLIN : l=POS(0)
- IF y=1 THEN
- CALL nlon
- CALL clon
- y=0
- LOCATE 24, 45 : PRINT "Nums ON Caps ON ";
- ELSE
- CALL nloff
- CALL cloff
- y=1
- LOCATE 24, 45 : PRINT "Nums OFF Caps OFF";
- END IF
- ky$=""
- NEXT x
-
- keylox.end:
- COLOR fg,bg : CALL nloff : CALL clon
- BEEP
- LOCATE 24,1 : PRINT SPACE$(79);
- GOSUB wait.key
- CLS:GOSUB title
-
-
- kb.loop:
- LOCATE 5,15 : PRINT "Function: KBLOOP - Allows you to loop thru other functions while"
- LOCATE 6,15 : PRINT " waiting for keyboard input."
- LOCATE 7,15 : PRINT "Syntax: kbin$=SPACE$(x) : time.to.loop%=30 : no$=CHR$(224)"
- LOCATE 8,15 : PRINT "CALL kbloop(kbin$, time.to.loop%, no$)"
-
- COLOR fg,bg
- LOCATE 10,10 : PRINT "The string variable kbin$ will convert to upper case and return"
- PRINT TAB(10) ; "the actual string of keys pressed. Predefine it to the length you"
- PRINT TAB(10) ; "want to collect: if you start it as SPACE$(1) it will return 1 key,"
- PRINT TAB(10) ; "SPACE$(3) will return a string of 3 keys etc. The time integer tells"
- PRINT TAB(10) ; "KBLOOP how long to loop internally - make sure the time is long enough"
- PRINT TAB(10) ; "to collect the entire string."
- PRINT TAB(10) ; "If the routine times out, kbin$ returns as no$ to indicate a timeout"
- PRINT TAB(10) ; "has occurred whereby you could execute any routines such as time"
- PRINT TAB(10) ; "display refreshes. Also useful in security routines"
-
- LOCATE 20,20 : PRINT "Press any key for demo "
- GOSUB waitK2
- LOCATE 20,20 : PRINT "Third keypress or run thru loop terminates."
- x=1 : t=1 : no$="" : n$=CHR$(224) : keycount=0
- COLOR fgs,0
-
-
- kb.demo:
- FOR x=1 TO 3
- kbin$=" "
- CALL kbloop(kbin$, t%, no$)
- IF kbin$=no$ THEN
- PRINT TAB(15) ; "No K.B. entry loop number ";x;". Time refresh: "TIME$;
- ELSE
- PRINT TAB(20); "Key pressed: ";kbin$;
- END IF
- t=3
- NEXT x
-
- BEEP
- GOSUB wait.key
- CLS:GOSUB title
-
-
- num.frmat:
- 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."
-
- LOCATE 19,10 : PRINT "Enter seven digits for a phone number: "
- max=15 : lin=20
- GOSUB get.string
- m=2 : mm=2
- GOSUB nflabel
-
- LOCATE 19,10 : PRINT "Enter 10 digits for a phone number: "
- GOSUB get.string
- m=3 : mm=3
- GOSUB nflabel
-
- LOCATE 19,10 : PRINT "Enter 11 digits for a social security number:"
- GOSUB get.string
- m=4 : mm=4
- GOSUB nflabel
-
- LOCATE 19,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 20,20 : PRINT "Mode ";m;" output ";text$
- ELSE
- CALL errmsg(text$, 24, eattr, 2)
- LOCATE lin,1 : PRINT clr$;
- text$=""
- END IF
- GOSUB wait.key
- FOR x=19 TO 21
- LOCATE x,1
- PRINT clr$;
- NEXT x
- RETURN
-
- nf.end:
- BEEP
- GOSUB wait.key
- CLS : GOSUB title
-
-
- chrp.dly:
- LOCATE 5,15 : PRINT "Function: CHRP - Produces 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%) "
-
- LOCATE 11,15 : PRINT "Function: DLY - Produce a delay for x seconds."
- LOCATE 12,15 : PRINT "Syntax: CALL dly(1)"
- LOCATE 13,15 : PRINT " Alternative: n=13 : CALL dly(n%) "
-
- COLOR fg, bg
- LOCATE 15,10 : PRINT "These are used by other routines, but can be used alone."
- COLOR fgs, 0
-
- y=1 : LOCATE 16, 10
- FOR x= 1 TO 5
- LOCATE 16+x, 10 : PRINT "Delaying ";x;" seconds."
- CALL dly(x)
- IF y=1 THEN y=0 ELSE y=1
- CALL chrp(y)
- NEXT x
-
- GOSUB wait.key
- CLS:GOSUB title
-
-
- graf:
- LOCATE 5,15 : PRINT "Function: GRAPH - Produce a Horizontal or Vertical bar graph"
- LOCATE 6,15 : PRINT " on up to 10 elements"
- LOCATE 7,15 : PRINT "Syntax: CALL hgraph(elements%(), bas%, label$(), title$)"
- LOCATE 8,15 : PRINT " CALL vgraph(elements%(), bas%, label$(), title$)"
-
- COLOR fg,bg
- LOCATE 10,10 : PRINT "Elements%() holds the values to graph, label$() is another array"
- PRINT TAB(10) ; "holding a set of labels relating to the elements. Base is the divisor"
- PRINT TAB(10) ; "to use for percentage labels (which may or may not be the sum of the"
- PRINT TAB(10) ; "elements).
-
- DIM elmts(10), label$(10)
- elmts(1)=7 : elmts(2)=2 : elmts(3)=9 : elmts(4)=10 : elmts(5)=5
- elmts(6)=4 : elmts(7)=12 : elmts(8)=8 : elmts(9)=75 : elmts(10)=10
- bas=0
- FOR x=1 TO 10
- x$=STR$(x)
- CALL stripl(x$)
- label$(x)="L"+x$
- bas=bas+elmts(X)
- NEXT x
-
- title$="Vertical Graph Demo"
-
- LOCATE 22, 25 : PRINT " Press any key for VERTICAL demo"
- ky$=""
- WHILE ky$=""
- ky$=INKEY$
- WEND
- CLS
- CALL chrp(1)
- CALL vgraph(elmts%(), bas%, label$(), title$)
- DEF SEG = &HB800
- BSAVE "glib.bin",0,4000
- CALL dly(3)
- GOSUB wait.key
- title$="Horizontal Graph Demo"
-
- CLS
- CALL chrp(1)
- CALL hgraph(elmts%(), bas%, label$(), title$)
- CALL dly(3)
- GOSUB wait.key
-
- CLS
- LOCATE 10,5 : PRINT " HGRAPH and VGRAPH only allow 10 elements to be graphed,"
- PRINT TAB(5) ; "due to the screen size, but they do adequately adjust the spacing"
- PRINT TAB(5) ; "accordingly. Unfortunately, at the current time the labeling you"
- PRINT TAB(5) ; "saw at the bottom of the screen, is limited to 3 characters."
- PRINT TAB(5) ; "The upside is that the entire algorithm to plot it out, print the"
- PRINT TAB(5) ; "actual count for each element has been worked out for you."
-
- GOSUB wait.key
- CLS:GOSUB title
-
- qprt:
- 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 used quite a bit in other routines, but is just as handy
- PRINT TAB(10) ; "used on its own. Since there is a fair amount of set up for this"
- PRINT TAB(10) ; "routine, it is not given to character based routines, but for string"
- PRINT TAB(10) ; "routines, it can speed things immensely."
- PRINT TAB(10) ; "The attribute parameter is caluculated via the formula:"
- PRINT TAB(10) ; "(FOREGROUND * 16) + BACKGROUND" : COLOR fgs,0
- PRINT TAB(10) ; "The major source for this was in BYTE magazine a few years ago."
- 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
- CLS:GOSUB title
-
-
- pscrn:
- LOCATE 5,15 : PRINT "Function: PRTSCRN - Send current display to printer."
- LOCATE 6,15 : PRINT "Syntax: CALL prtscrn "
-
- COLOR fg,bg : ky$=""
-
- LOCATE 9,10 : PRINT "We can re-display one of the graphs we had earlier and"
- PRINT TAB(10) ; "demo the PRTSCRN function provided you have a printer."
- LOCATE 12, 10 : INPUT "Perform PRTSCRN demo? (Y/n) ",ky$
- CALL ucase(ky$)
- IF ky$="N" THEN GOTO pscrn.end
-
- DEF SEG = &HB800
- BLOAD "glib.bin",0
- CALL prtscrn
-
- pscrn.end:
- GOSUB wait.key
- CLS:GOSUB title
-
-
- sdump:
- LOCATE 5,15 : PRINT "Function: SCRNDUMP - Send current display to disk."
- LOCATE 6,15 : PRINT "Syntax: fil.num=x : CALL prtscrn(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 prtscrn(3) "
-
- PRINT : ky$=""
- PRINT TAB(10) ; "Press any key, we will again reload the Vertical Graph and do a
- PRINT TAB(10) ; "PRTSCRN to a file called SCRNDUMP.FIL, you can examine later."
- WHILE ky$=""
- ky$=INKEY$
- WEND
-
- DEF SEG = &HB800
- BLOAD "glib.bin",0
- 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
- CLS:GOSUB title
-
-
- cmdl:
- 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
-
- IF q > 0 THEN ' in case they were removed
- LOCATE 10,10 : PRINT "Actual number of arguments present: ";q
- LOCATE 11,10 : PRINT "(This count is only accurate with OPTION BASE 1 !)
- PRINT
- PRINT TAB(10) ; "Arguments passed:"
- FOR x=1 TO q
- PRINT TAB(15) ; "Argument ";x;": ";arg$(x)
- NEXT
- END IF
-
- GOSUB wait.key
- CLS:GOSUB title
-
-
- xscrn:
- 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,15 : PRINT "Syntax: DIM scrn.arry%(2000) : pointer%=VARPTR(scrn.arry%(1)"
- LOCATE 8,15 : PRINT " CALL svscrn(pointer%) <or> CALL rstscrn(pointer%)"
-
- COLOR fg,bg
- LOCATE 10,5 : PRINT "These two routines also have ancient roots in BYTE magazine."
- PRINT TAB(5) ; "If you are not familiar with VARPTR, or the screen save-restore technique,"
- PRINT TAB(5) ; "you may want to study the docs carefully before using this, but briefly:"
- PRINT TAB(5) ; "Each screen to save will require 2000 bytes in the array, so to save 3, DIM"
- PRINT TAB(5) ; "it to 6000 bytes. VARPTR is used to point to the first array element for"
- PRINT TAB(5) ; "the first screen ala' ptr%=VARPTR(scrnarry(0)) (or 1 if using OPTION BASE"
- PRINT TAB(5) ; "1), and ptr3%=VARPTR(scrnarry%(3000)) points to the 1st element of the third"
- PRINT TAB(5) ; "screen. Once the pointer is set for the first element of the desired "
- PRINT TAB(5) ; "screen, issue the call to save or restore the screen passing the pointer:"
- PRINT TAB(5) ; "CALL svscrn(ptr%) ' saves current screen to wherever ptr points to"
- PRINT TAB(5) ; "CALL rstscrn(ptr3%) ' restores a screen from wherever ptr3 points to"
- PRINT
- PRINT TAB(5) ; "The actual demo for this is integrated into the next demo but examine feel"
- PRINT TAB(5) ; "free to examine this code for additional info."
-
- GOSUB wait.key
- CLS:GOSUB title
-
-
- wdws:
- 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=x : rt=x : btm=x : lft=x : snd=x : gro=x : frame=x"
- LOCATE 8,15 : PRINT " attr=(fg*16)+bg : label$=";quote$;"Window Label";quote$
- LOCATE 9,15 : PRINT " CALL wdw(top%, lft%, btm%, rt%, snd%, gro%, fr%, attr%, l$)"
-
- COLOR fg,bg
- LOCATE 11,10 : PRINT "The first 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 (I find this preferable to passing the 2"
- PRINT TAB(10) ; "parameters of fore and back), frame is your choice of frame style,"
- PRINT TAB(10) ; "(see the docs for full information). Finally, LABEL$ is a label to"
- PRINT TAB(10) ; "center across the top of the window (which can be omitted)."
-
- 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) ' array to save screns to: hold
- ' be sure to DIM array as static !!!
-
- sptr1%=VARPTR(sarry%(1)) ' we are on OPTION BASE 1
- sptr2%=VARPTR(sarry%(2001)) ' points to start of 2nd screen
- sptr3%=VARPTR(sarry(4001)) ' points to 3rd screen
-
- sptr4%=VARPTR(sarry%(6001)) ' points to 4th
- sptr5%=VARPTR(sarry%(8001)) ' points to 5th
- sptr6%=VARPTR(sarry%(10001)) ' points to 6th
- sptr7%=VARPTR(sarry%(12001)) ' points to 7th
-
- CALL svscrn(sptr1%) ' now we have the screen with text
- ' captured in array
- CALL wdw(2,2,15,55,1,1,1,wattr%,"Window 1")
- CALL svscrn(sptr2%) ' capturd one with window one on it
-
- CALL wdw(12,5,23,30,0,0,2,wattr2%,"Window 2")
- CALL svscrn(sptr3%)
-
- CALL wdw(2,42,13,75,1,1,3,wattr3%,"Window 3")
- CALL svscrn(sptr4%)
-
- CALL wdw(5,52,23,75,0,0,4,wattr4%,"Window 4")
- CALL svscrn(sptr5%)
-
- CALL wdw(15,32,24,52,0,0,4,wattr5%,"Window 5")
- CALL svscrn(sptr6%)
-
- CALL wdw(2,2,6,22,1,1,3,wattr6%,"Window 6")
- CALL svscrn(sptr7%)
-
- 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 1 sec"
- LOCATE 18,6 : PRINT "delay so you see what"
- LOCATE 19,6 : PRINT "is going on."
- GOSUB wait.key
-
- CALL rstscrn(sptr6%) ' pops them back one at a time
- CALL dly(1)
- CALL rstscrn(sptr5%)
- CALL dly(1)
- CALL rstscrn(sptr4%)
- CALL dly(1)
- CALL rstscrn(sptr3%)
- CALL dly(1)
- CALL rstscrn(sptr2%)
- CALL dly(1)
- CALL rstscrn(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 "could recall any level "
- LOCATE 16,6 : PRINT "we chose! "
- LOCATE 17,6 : PRINT "Now let's peel them back"
- LOCATE 18,6 : PRINT "with sound."
-
- GOSUB wait.key
-
- CALL rstscrn(sptr6%) ' no window level
- CALL chrp(0)
- CALL dly(1)
-
- CALL rstscrn(sptr5%)
- CALL chrp(0)
- CALL dly(1)
-
- CALL rstscrn(sptr4%)
- CALL chrp(0)
- CALL dly(1)
-
- CALL rstscrn(sptr3%)
- CALL chrp(0)
- CALL dly(1)
-
- CALL rstscrn(sptr2%)
- CALL chrp(0)
- CALL dly(1)
-
- CALL rstscrn(sptr1%)
- CALL chrp(0)
-
-
- GOSUB wait.key
- CLS:GOSUB title
-
-
- bxs:
- 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
- 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
- CLS:GOSUB title
-
-
- scrl:
- LOCATE 5,15 : PRINT "Function: USCROLL, DSCROLL - Scroll the display up or down"
- LOCATE 6,15 : PRINT " a given number of lines."
- LOCATE 7,15 : PRINT "Syntax: Num lines [1-24] to scroll and use legal coordinates"
- LOCATE 8,15 : PRINT " CALL USCROLL(num%, top%, lft%, bttm%, rght%)
- LOCATE 9,15 : PRINT " CALL DSCROLL(num%, top%, lft%, bttm%, rght%)
-
- COLOR fg,bg
- LOCATE 11,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) ; "this routine. A second demo does a screen shift routine."
- PRINT TAB(10) ; "The area of the screen to be scrooled and the number of lines to"
- PRINT TAB(10) ; "scroll is fully user definable."
-
- GOSUB wait.key
- CLS
-
- COLOR fgt,0
- FOR x=1 TO 24
- PRINT STRING$(80,CHR$(x+96));
- NEXT x
-
- BEEP : CALL svscrn(sptr1%) ' save the test pattern
- COLOR fgd,0
-
- FOR X= 1 TO 15
- CALL uscroll(1,5,20,19,59)
- LOCATE 19, 22
- 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
-
- CALL rstscrn(sptr1%)
-
- CALL wdw(6,30,16,50,0,0,2,(0*16)+14,"15 Lines") ' could be done with box #6 too
-
- COLOR fgd,0
- FOR X= 1 TO 15
- CALL dscroll(1,6,30,16,50)
- LOCATE 6, 31
- IF cmode THEN COLOR x,0 : ELSE COLOR 15,0
- PRINT "Scroll Dn Line #";x;
- CALL dly(1)
- NEXT x
-
- BEEP
- FOR X= 1 TO 15
- CALL uscroll(1,6,30,16,50)
- CALL dly(.5) ' not really a half sec delay
- NEXT x ' goes out to DLY and returns
-
- CLS : LOCATE 10,12
- PRINT "Now a simpler implementation, shifting a portion out of the way."
-
- GOSUB wait.key
-
- BEEP : CALL rstscrn(sptr1%) ' restore test pattern
- CALL uscroll(12,0,0,12,80) ' scroll bottom part to top
- CALL dly(1) ' let em see it
-
- FOR X=1 TO 5 ' 'bounce' bottom part
- CALL dscroll (11,1,1,25,80)
- CALL dly(1)
- CALL uscroll (11,1,1,25,80)
- NEXT X
-
- BEEP
-
- FOR X=1 TO 15 ' now FAST
- CALL dscroll (11,1,1,25,80)
- CALL uscroll (11,1,1,25,80)
- NEXT X
-
- GOSUB wait.key
- CLS:GOSUB title
-
- fad:
- LOCATE 5,15 : PRINT "Function: FADE - Clears the screen as if disintegating."
- LOCATE 6,15 : PRINT "Syntax: CALL fade"
-
-
- LOCATE 10,10 : PRINT " To demo this we will put some test on the screen, then"
- PRINT TAB(10);"call fade to disolve it."
- GOSUB wait.key
- CLS
- SHELL "dir /w"
- CALL dly(1) ' wait a sec
- CALL fade ' waste it
-
-
-
-
- GOSUB wait.key
- CLS
-
- 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]-----------------
- title: '********************
- COLOR fgt,0
- LOCATE 2,25:PRINT "GIZLIB 1.0 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
-
-
-
-