home *** CD-ROM | disk | FTP | other *** search
- /*
- Grumpfish Library 5.0 demo
- Author: Greg Lief
- Copyright (c) 1988-90, Greg Lief
- Compile instructions: clipper demo /n/w/a
- */
-
- #include "grump.ch"
- #include "grumpr.ch"
- #include "grumpm.ch"
- #include "inkey.ch"
-
- #define PRIMARY_COLOR "W/RB"
-
- memvar getlist
-
- //───── next two statics are used for highlighting info during GETSYS demo
- static ptr
- static verbiage_ := { ;
- [@ 15,0 gget y calculator picture '#####.##' message "Right-to-left entry"], ;
- [@ 16,0 gget team list teams message "Use spacebar or backspace to toggle"], ;
- [@ 17,0 gget w step color 'n/bg,+w/r' message "Use + and - keys"], ;
- [@ 18,0 gget pass1 message "Enter a password" password "?"], ;
- [@ 19,0 gget pass2 message "Enter a password" password], ;
- [@ 20,0 gget z proper message "This will be proper-case"], ;
- [@ 21,0 gget x array days picture '@!' message "Please pick a day!"] }
-
- #command CLEARSCREEN [COLOR <color>] => ;
- dispbox(0, 0, maxrow(), maxcol(), replicate(chr(250),9), <color>)
-
- function main(skip_it)
- external soundex, helpdev
- local x, selected, maincolor, mfile := '!!!!!!!!.!!!', mrow, ;
- mtone, any_key, msg := "The Grumpfish Library"
- setblink(.f.)
- colorinit('colors.gf')
- setcursor(0)
- set scoreboard off
- set wrap on
- SAVE_DRAPE(mfile)
- selected := 'i'
- if skip_it == NIL
- setcolor('+W/N')
- cls
- Fallguy(03, 29, msg, 100)
- SCRNCENTER(maxrow(), 'Press space bar for demo or Esc for DOS', '+BR/N')
- rainbow(msg)
- if lastkey () != K_ESC
- lets_go()
- ENDif
- else
- lets_go()
- endif
- CLEARSCREEN COLOR "I"
- setcolor('W/BR')
- expbox(1, 6, 23, 73, 1, 30)
- setcolor('+W/BR')
- rollup("Grumpfish Library is written 99.9% in Clipper. You get two")
- rollup("versions of the source code: one for Summer '87, and another")
- rollup("FULLY OPTIMIZED for Clipper 5.01. You also get a no-nonsense")
- rollup("royalty-free integration license, easy-to-read documentation,")
- rollup("one year free BBS technical support on the Grumpfish BBS (a")
- rollup("worldwide haven for Clipper expertise), and thirty days free")
- rollup("voice support. Our ' ' guarantee: if you are")
- rollup("not absolutely tickled pink by Grumpfish, return it within 30")
- rollup("days from your date of purchase for a full and courteous refund!")
- rollup('')
- rollup('Grumpfish Library is available for just $199 (shipping: $7.50')
- rollup("US/Canada, $20 overseas). Order NOW by calling (503) 588-1815")
- rollup("or fax your order to (503) 588-1980. MC/VISA/AMEX accepted.")
- rollup('')
- rollup(SPACE(20) + 'Grumpfish, Incorporated')
- rollup(SPACE(20) + 'Post Office Box 17761')
- rollup(SPACE(20) + 'Salem, Oregon 97305 USA')
- rollup('')
- rollup('')
- rollup("Tel 0268 590955 Tel 93 16 09 12 Tel 089 570 6031")
- rollup("Fax 0268 590005 Fax 93 88 08 90 Fax 089 570 7631")
- setcolor('+GR/BR')
- @ 4,8 SAY 'FULLY OPTIMIZED'
- @ 8,29 SAY 'No Grumpy Customers'
- @ 13,56 say "(503) 588-1815"
- @ 14,29 say "(503) 588-1980"
- @ 20,8 say "United Kingdom" color 'i'
- @ 20,37 say "France" color 'i'
- @ 20,60 say "Germany" color 'i'
- inkey(20)
- impbox(60)
- ferase('help.dbf')
- ferase('help.cfg')
- ferase('help.dbt')
- ferase('help.ntx')
- ferase('demo2.scr')
- ferase('demo3.scr')
- set color to
- any_key='fadeback.scr'
- if file(any_key)
- fadein(any_key)
- else
- blindopen(mfile)
- endif
- ferase(mfile)
- ferase('gftemp.dbf')
- setblink(.t.)
- devpos(maxrow(), 0)
- return nil
-
-
- function lets_go
- local xx, any_key, mfile, screens := {}, sel := 1, dumbo, mstate, thefiles, ;
- mainmenu, buff, maincolor := if(Iscolor(), 'w/b', 'w/n'), mvar, ;
- menulist, getcolor, mdate, mnum, mpassword, mstring, mliststring, ;
- mnum2
- local w, x, y, z, pass1, pass2, oldf1, team, teams
- static days := { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }
- static lookup_ := { { "ABCD", "A Better Code Dollop" } , ;
- { "WXYZ", "Where's Xenia's Young Zoo?" } , ;
- { "GYRH", "Get Yer Red Hots" } , ;
- { "WITW", "What In The World!?" } , ;
- { "NOYH", "Newsprint On Your Hands" } , ;
- { "TMNB", "This Means Nothing, Bucko" } , ;
- { "YACA", "Yet Another Cryptic Acronym" } , ;
- { "DNGC", "Definitely No Grumpy Customers!" } , ;
- { "PTYF", "Please Tell Your Friends" } , ;
- { "TSFR", "This Space For Rent" } }
- CLEARSCREEN COLOR maincolor
- set message to 24
- set key K_F1 to helpdev
- Shadowbox(0,0,4,16,6,,,'w/r')
- @ 1,1 say 'Press F1 to' color '+w/r'
- @ 2,1 say 'make your own' color '+w/r'
- @ 3,1 say 'help screen!' color '+w/r'
- if ! file('demo.scr')
- save_drape('demo.scr')
- endif
- /*
- create phone database if it doesn't already exist - we will
- need this for GrumpBrow(), POPNOTE, and SETFILT
- */
- if ! file('phone.dbf')
- dbcreate("phone.dbf", { {"FNAME", "C", 15, 0} , ;
- {"LNAME", "C", 15, 0} , ;
- {"PHONE_NO","C", 12, 0} , ;
- {"EXT", "C", 4, 0} , ;
- {"COMPANY", "C", 20, 0} , ;
- {"ADDRESS", "C", 25, 0} , ;
- {"CITY", "C", 15, 0} , ;
- {"STATE", "C", 2, 0} , ;
- {"ZIP", "C", 10, 0} , ;
- {"LONGDIST","L", 1, 0} } )
- use phone
- //----- add a dummy record, and I do mean DUMMY!
- append blank
- replace fname with "GREG", lname with "LIEF", phone_no with "503-588-1815", ;
- company with "Grumpfish, Inc", address with "P. O. Box 17761", ;
- city with "Salem", state with "OR", zip with "97305"
- use
- endif
- if ! file('phone.ntx')
- use phone
- index on upper(phone->lname + phone->fname) to phone
- use
- endif
- colorset(PRIMARY_COLOR)
- shadowbox(3, 31, 20, 48, 2)
- do while sel != 0 .and. sel != 16
- /*
- these @..PROMPTS and MENU TO are preprocessed into calls to the
- Grumpfish LITE_MENU2() function, which permits highlighted and/or
- alternate trigger letters, and different colors for each message!
- */
- @4,32 prompt "Calculator" message "Pop-up calculator" messagecolor "+W/B"
- @5,32 prompt "Spreadsheet" message "Pop-up spreadsheet" ;
- triggercolor "N/BG" messagecolor "+W/B"
- @6,32 prompt "Notepad" message "Pop-up notepad" messagecolor "+W/B"
- @7,32 prompt "Phone Directory" message "Magnetic rolodex" messagecolor "+W/B"
- @8,32 prompt "Calendar/~Appts" message "Pop-up calendar" messagecolor "+W/B"
- @9,32 prompt "Stop~Watch" message "Pop-up stopwatch" messagecolor "+W/B"
- @10,32 prompt "Filter Builder" message "User-definable filters"
- @11,32 prompt "Grump~Browse()" message "DBF browser with a difference!" ;
- triggercolor "N/BG" messagecolor "+W/RB"
- @12,32 prompt "View PHONE.PRG" message "View code generated by GrumpBrow!" ;
- messagecolor "+W/G"
- @13,32 prompt "Grump's GETSYS" message "Explore the new Grumpfish GETs" ;
- messagecolor "N/BG"
- @14,32 prompt "Bo~x Tricks" message "Exploding/imploding/etc." ;
- messagecolor "W/R"
- @15,32 prompt "String Tricks" message "Falling/spreading/teletype" ;
- messagecolor "W/R"
- @16,32 prompt "Screen Tric~ks" message "Peeling/folding/splitting" ;
- messagecolor "W/R"
- @17,32 prompt "User Feedback" message "Many other useful functions"
- @18,32 prompt "Color ~Management"
- @19,32 prompt "Exit"
- menu to sel initial sel event gfclock(,,'w/b') timeout 30
- mainmenu := savescreen(0, 0, maxrow(), maxcol())
- do case
-
- case sel == 1
- popcalc()
-
- case sel == 2
- CLEARSCREEN COLOR maincolor
- colorset(C_MESSAGE)
- expbox(0, 1, 8, maxcol() - 2, 1, 10, , "GrumpCalc()")
- @ 1, 3 say 'GrumpCalc() is a full-featured miniature spreadsheet that you can pop up'
- @ 2, 3 say 'within a numeric GET. Press F1 from within the GET below to pop up the'
- @ 3, 3 say 'spreadsheet. Within the spreadsheet, do some calculations to derive a'
- @ 4, 3 say 'value. Then press ESC to return to the GET. Your final value will be'
- @ 5, 3 say 'pasted into the GET!'
- @ 7, 3 say 'If you need help on active keys in the spreadsheet, press F1.'
- w := 0
- oldf1 := setkey(K_F1, { |p,l,v| grumpcalc(p, l, v) } )
- colorset(maincolor)
- @ 11, 10 say "This is a numeric GET - press F1" get w
- setcursor(1)
- read
- setcursor(0)
- setkey(K_F1, oldf1)
- impbox(50)
-
- case sel == 3
- use phone new
- popnote()
- use
-
- case sel == 4
- CLEARSCREEN COLOR maincolor
- popphone()
-
- case sel == 5
- CLEARSCREEN COLOR "I"
- popdate()
-
- case sel == 6
- popstop()
-
- case sel == 7 .or. sel == 8
- use phone index phone new
- setcolor(maincolor)
- if sel == 7
- Setfilt()
- else
- CLEARSCREEN COLOR maincolor
- colorset(C_MESSAGE)
- exbox(0, 1, 8, maxcol() - 2, 6, 5, '', .t.)
- @ 0, 2 say 'GrumpBrow is the last word in generic database browsers. For starters, it'
- @ 1, 2 say 'includes automatic add/edit/view/delete/QBE/search routines. You determine'
- @ 2, 2 say 'what you want the user to be able to do by passing the first letter of each'
- @ 3, 2 say [option. In this example, the function call is "GRUMPBROW('AEDVQS')".]
- @ 4, 2 say 'But the coup de grace is the integrated screen painter. Press "P" from the'
- @ 5, 2 say 'Browse window, and then mock up your data entry screen. You can move'
- @ 6, 2 say 'and delete fields, add static text, draw boxes, change colors. (For a'
- @ 7, 2 say 'complete list of commands, press F1 while in the screen painter.) When you'
- @ 8, 2 say 'are satisfied, press Shift-F10 to generate fully-optimized 5.0 code!'
- inkey(1)
- grumpbrow('aedvqsp', 10, 0, maxrow(), maxcol())
- endif
- close data
-
- case sel= 9
- if file( mfile := "phone.prg" )
- Shadowbox(0, 0, maxrow(), maxcol(), 2, ;
- 'Viewing GrumpBrow() code', , 'w/rb')
- setcolor('+w/rb')
- memoedit(memoread(mfile), 1, 1, maxrow() - 1, maxcol() - 1, .f.)
- else
- err_msg(mfile + ' not found -- visit the GrumpBrow() screen painter')
- endif
-
- case sel == 10
- CLEARSCREEN COLOR "N/BG"
- colorset(C_MESSAGE)
- expbox(0, 2, 9, 76, 1, 30, setcolor(), "Grumpfish GETSYS")
- @ 1, 7 say "Here is the source code for the GETs at the bottom of the screen"
- aeval(verbiage_, { | text | setpos(row()+1, 3), dispout(text) } )
- ptr := 1 // pointer for highlighted verbiage lines
- w := y := 0
- x := space(10)
- z := space(20)
- team := space(9)
- teams := "Orioles;Red Sox;Blue Jays;Indians;Tigers;Yankees"
- pass1 := pass2 := space(12)
- hilite_info(.t.)
- @ 15, 0 gget y calculator when hilite_info() picture '#####.##' ;
- message "Right-to-left entry"
- @ 16, 0 gget team list teams when hilite_info() ;
- message "Use spacebar or backspace to toggle team"
- @ 17, 0 gget w step color 'n/bg,+w/r' when hilite_info() ;
- message "Use + and - keys"
- @ 18, 0 gget pass1 message "Enter a password" password "?" ;
- when hilite_info()
- @ 19, 0 gget pass2 message "Enter a password" password ;
- when hilite_info()
- @ 20, 0 gget z proper message "This will be proper-case" ;
- when hilite_info() valid hilite_info( , .t.)
- @ 21, 0 gget x array days picture '@!' noedit message "Please pick a day!"
- setcursor(1)
- read timeout 20 warning 10 exitevent blankscr3(-1)
- setcursor(0)
- waiton("Your passwords were '" + trim(pass1) + "' and '" + ;
- trim(pass2) + "'")
- inkey(2)
- waitoff()
- impbox(50)
-
- case sel == 11
- any_key := 'Exploding Box'
- setcolor(maincolor)
- cls
- Expbox(00, 00, 9, 36, 5, 20, '+w/rb', any_key)
- inkey(1)
- Expbox(15, 10, 23, 50, 1, 24, '+w/r', any_key+' 2')
- inkey(1)
- Expbox(07, 01, 16, 60, 2, 50, '+gr/n', any_key+' 3')
- inkey(.4)
- Expbox(12, 48, 22, 78, 3, 30, 'n/gr', any_key + ' 4')
- inkey(.4)
- Expbox(01, 30, 04, 78, 1, 75, '+w/g', 'Yet Another '+any_key)
- inkey(2.5)
- impbox(60)
- inkey(.3)
- impbox(60)
- inkey(.3)
- impbox(60)
- inkey(.3)
- impbox(60)
- inkey(.3)
- impbox(60)
- inkey(1)
- *** note the use of the return value and BYEBYEBOX()
- setcolor('n/bg')
- aadd(screens, Popbox(00, 00, 22, 40, 2, 18, .F., 'Pop-up Box 1'))
- inkey(.35)
- setcolor('+gr/n')
- aadd(screens, Dropbox(00, 55, 18, 79, 1, 25, .F., 'Pull-down Box 1', .T.))
- inkey(.35)
- setcolor('n/gr')
- aadd(screens, Popbox(03, 44, 20, 70, 5, 20, .F., 'Pop-up Box 2'))
- inkey(.35)
- setcolor('n/w')
- aadd(screens, Dropbox(04, 38, 13, 60, 4, 25, .F., 'Pull-down Box 2'))
- inkey(.35)
- setcolor('+w/r')
- aadd(screens, Popbox(12, 30, 23, 55, 2, 20, .F., 'Pop-up Box 3', .T.))
- inkey(.35)
- setcolor('+w/b')
- aadd(screens, Popbox(03, 05, 20, 29, 2, 18, .F., 'Another Pop-up'))
- inkey(.35)
- setcolor('n/g')
- aadd(screens, Dropbox(06, 28, 20, 66, 1, 12, .T., 'Another Pull-down Box'))
- inkey(.35)
- setcolor('n/r')
- aadd(screens, Popbox(02, 15, 17, 45, 1, 10, .T., 'Pop-up Box w/ Crossbar', .T.))
- inkey(.35)
- aadd(screens, Shadowbox(09, 20, 14, 50, 2, 'Shadow Box', .T., '+w/rb'))
- inkey(1)
- FOR xx := 9 TO 1 STEP -1
- ByeByeBox(screens[xx])
- inkey(.12)
- NEXT
- asize(screens, 0)
-
- case sel == 12
- setcolor(maincolor)
- cls
- setcolor('+w/bg')
- Exbox(9, 07, 15, 71, 1, 5, '', .T., 'Silly Strings')
- Spread('It is a snap to display character strings from the middle out',10,35)
- Spread('as we are demonstrating here. You may also wish to use either',11,35)
- Spread('of the two teletype functions, which continuously scroll your',12,35)
- Spread('message across a specified row. Perhaps you already saw the',13,35)
- Spread('falling string trick, but in case you missed it, ',14,35)
- inkey(4)
- FallGuy(14,58,'here it is!!')
- setcolor(maincolor)
- inkey(1)
- tty(20, 'Copyright (C) 1988-90 Greg Lief', 35, 24)
- tty2(maxrow(), 'Press any key to return to the main menu', 0, maincolor)
-
- case sel == 13
- setcolor('W/N')
- FOR xx := 1 TO 9
- clrscr(xx)
- inkey(.2)
- if xx < 9
- RESTSCREEN(0, 0, maxrow(), maxcol(), mainmenu)
- ENDif
- inkey(.2)
- NEXT
- inkey(1.5)
- mfile := 'DEMO3.SCR'
- PULL_DRAPE('demo.scr')
- inkey(2)
- cls
- inkey(1)
- BLINDOPEN('demo.scr')
- HBLINDSAVE(mfile)
- inkey(1)
- BLINDCLOSE()
- inkey(2)
- HBLINDOPEN(mfile)
- inkey(2)
- HBLINDCLOS()
- inkey(2)
- if file("fadein.scr")
- fadein("fadein.scr")
- inkey(2)
- endif
- if file("fadeout.scr")
- fadeout("fadeout.scr")
- inkey(2)
- endif
- FOR xx := 0 TO maxrow()
- @ xx, 0 say REPLICATE(CHR(xx), maxcol() + 1)
- NEXT
- dumbo := SAVESCREEN(0, 0, maxrow(), maxcol())
- hscrnscrl('demo.scr')
- inkey(.75)
- RESTSCREEN(0, 0, maxrow(), maxcol(), dumbo)
- inkey(.5)
- hscrnscrl('demo.scr', 1)
- inkey(.75)
- RESTSCREEN(0, 0, maxrow(), maxcol(), dumbo)
- inkey(.5)
- vscrnscrl(mfile)
- inkey(.75)
- RESTSCREEN(0, 0, maxrow(), maxcol(), dumbo)
- inkey(.5)
- vscrnscrl(mfile, 1)
- inkey(.75)
-
- case sel == 14
- CLEARSCREEN COLOR maincolor
- setcolor('+w/bg')
- Expbox(9, 10, 15, 68, 1, 60, , 'User Feedback')
- Spread('The Grumpfish Library includes many user feedback items.',10,20)
- Spread('There are functions for yes/no prompts, printer status, ',11,20)
- Spread('error messages, wait messages, index status graph, state',12,20)
- Spread("validation, and a sleek ACHOICE() replacement. We will ",13,20)
- Spread("start out with the index graph function, IndexBar().... ",14,20)
- inkey(5)
- ImpBox(60)
- if ! file('gftemp.dbf') .or. ! file('lookup.dbf')
- waiton("Preparing temporary files... please wait")
- dbcreate("lookup", { { 'code', 'C', 4, 0 } , ;
- { 'descrip', 'C', 30, 0} } )
- use lookup new
- for xx := 1 to 10
- append blank
- replace code with lookup_[xx, 1], descrip with lookup_[xx, 2]
- next
- dbcreate("gftemp", { { 'lastname', 'C', 30, 0 } } )
- use gftemp new
- for xx := 1 to 1000
- append blank
- replace lastname with chr(gfrand(100) + 65)
- next
- waitoff()
- else
- use lookup new
- use gftemp new
- endif
- indexbar('lastname')
- inkey(2)
- indexbar('lastname','lastname', 9, .t.)
- inkey(1)
- if ! YES_NO('This is one of the two Grumpfish yes/no prompts',;
- 'Want to see the other one')
- Err_Msg("Too bad, you're going to see it anyway")
- ENDif
- yes_no2('Shall we zap the database now?', 12, ' OK ', ' Cancel ', .F.)
- if ! yes_no2('Send the report to:', 12, ' Printer ', ' File ')
- waiton("Let's assume that we are printing now")
- inkey(2)
- waitoff()
- ENDif
-
- inkey(1)
- if isprinter()
- waiton('Please turn off your printer for this demo')
- do while isprinter()
- enddo
- waitoff()
- endif
- printok()
- SET DEVICE TO SCREEN
- Err_msg('This is the error message function!')
- CLEARSCREEN
- setcolor('+w/rb')
- dumbo := Exbox(11, 19, 13, 59, 1, 5, '', .T., 'GETDATE()')
- Spread('Get dates the easy way with GetDate()', 12, 20)
- inkey(2)
- Spread('You selected ' + DTOC(GetDate(DATE(), 0, 56)), 13, 20)
- inkey(3)
- byebyebox(dumbo)
- dumbo := Exbox(10, 15, 14, 64, 1, 5, '', .T., 'Validation')
- Spread('Grumpfish Library offers validation routines for',11,21)
- Spread('state abbreviations and Canadian postal codes...',12,21)
- mstate := space(2)
- @ 13, 21 say "Enter a state abbreviation now:" get mstate valid isstate(@mstate)
- set cursor on
- read
- set cursor off
- inkey(2)
- byebyebox(dumbo)
- dumbo := Exbox(10, 20, 13, 58, 1, 5, '', .T., 'APICK()')
- Spread('This is an example of APICK() - the',11,20)
- Spread('Grumpfish enhancement for ACHOICE()',12,20)
- inkey(4)
- byebyebox(dumbo)
- thefiles := directory("*.*")
- aeval(thefiles, { | a, x | thefiles[x] := a[1] } )
- setcolor('+W/BG')
- if ( sel := APICK(9, 33, 15, 46, thefiles) ) > 0
- Spread('You selected ' + thefiles[sel], 15, 20)
- inkey(3)
- ENDif
- setcolor('+W/R')
- dumbo := Exbox(10, 13, 14, 66, 1, 5, '', .T., 'HELPBROW()')
- Spread("Last but not least, Grumpfish has a great picklist", 11, 20)
- Spread("function for data validation. Let's give it a try", 12, 20)
- inkey(1)
- mvar := "JUNK"
- @ 13, 15 say "Your code:" get mvar valid helpbrow("lookup", "code", ;
- "Code", "descrip", "Description", .t., "+w/b", 13, 35)
- setcursor(1)
- readmodal(getlist)
- getlist := {}
- setcursor(0)
- inkey(1)
- byebyebox(dumbo)
- close data
- ferase('lastname.ntx')
-
- case sel == 15
- CLEARSCREEN COLOR 'w/b'
- colormod()
-
- endcase
- restscreen(0, 0, maxrow(), maxcol(), mainmenu)
- colorset(PRIMARY_COLOR)
- enddo
- return NIL
-
-
- static function rollup(mtext)
- local xx
- scroll(2, 8, 22, 71, 1)
- @ 22,08 say padr(mtext, 64)
- for xx := 1 to 35
- next
- return NIL
-
-
-
- static function hilite_info(restart, lastline)
- static buffer
- //───── if 1st parameter was passed, clear out old BUFFER and do nothing else
- if restart != NIL
- buffer := NIL
- else
-
- dispbegin()
-
- setpos(ptr + 1, 3)
- //───── restore previous line if there was one saved
- if buffer != NIL
- restscreen(row(), col(), row(), maxcol(), buffer)
- endif
-
- //───── 2nd parameter passed only to force highlighting of last line
- //───── necessary cause you can't use ARRAY clause in conjunction with a WHEN
- if lastline != NIL
- ptr := len(verbiage_)
- else
- ptr := ggetno()
- endif
-
- //───── move to new position, save screen, and display text
- setpos(ptr + 1, 3)
- buffer := savescreen(row(), col(), row(), maxcol())
- dispout(padr(verbiage_[ptr], 73), colorset(C_MESSAGEBLINK, .T.))
-
- dispend()
-
- endif
- return .t.
-
- * eof demo5.prg
-