home *** CD-ROM | disk | FTP | other *** search
- *┌──────────────────────────────────────┐ │
- *│ DEMO.prg │
- *│ Grumpfish Library demo │
- *│ June 1989 - Greg Lief │
- *└──────────────────────────────────────┘
-
- *
- * Modified by Roger Donnay to run under dCLIP
-
- LIBLOAD('\GRUMP\GRUMP')
- LIBLOAD('\GRUMPFUN\GRUMPFUN')
-
- EXTERNAL soundex
- PUBLIC start_time, thepalette
- SET CURSOR OFF
- SET WRAP ON
- SAVE SCREEN TO predemo
- selected = 'i'
- maincolor = IF(Iscolor(), 'w/b', 'w/n')
-
- thepalette = ''
- FOR xx = 0 TO 127
- thepalette = thepalette + ' ' + chr(xx) + chr(4) + chr(xx) + ' ' + chr(xx)
- NEXT
-
- DO WHILE .T.
- SETCOLOR('+W/N')
- CLEAR
- mstring = 'The Grumpfish Library'
- colorstr = 'W BRR GRBGB G '
- Fallguy(03,30,mstring)
- X = 1
- MROW = 3
-
- SETCOLOR('+BR/N')
- CENTER(24, 'Press space bar for the demo or Esc for DOS')
-
- DO WHILE LASTKEY() <> 32 .AND. LASTKEY() <> 27
- SHOWSTRING(IF(INT(X%7)=0, 7, INT(X%7)), MROW, MROW+2, .05)
- X = X + 1
- MROW = MROW + 3
- IF MROW > 20
- MROW = 3
- ENDIF
- ENDDO
- IF LASTKEY() = 27
- EXIT
- ENDIF
- DO lets_go
- ENDDO
- RESTORE SCREEN FROM predemo
- SET COLOR TO
- SET CURSOR ON
- RETURN
-
- PROCEDURE lets_go
- IF FILE('demo.scr')
- pull_drape('demo.scr')
- ELSE
- SETCOLOR(maincolor)
- coolscrn()
- SETCOLOR('W/RB')
- Shadowbox(5,29,19,49,1)
- SETCOLOR('+W/RB')
- ENDIF
- DO WHILE .T.
- SETCOLOR('+W/RB')
- @ 06,30 PROMPT ' Calculator '
- @ 07,30 PROMPT ' Notepad '
- @ 08,30 PROMPT ' Phone Directory '
- @ 09,30 PROMPT ' Appointments '
- @ 10,30 PROMPT ' Stopwatch '
- @ 11,30 PROMPT ' Query Builder '
- @ 12,30 PROMPT ' Box Functions '
- @ 13,30 PROMPT ' String Tricks '
- @ 14,30 PROMPT ' Screen Tricks '
- @ 15,30 PROMPT ' User Feedback '
- @ 16,30 PROMPT ' Color Palette '
- @ 17,30 PROMPT ' Frivolous Things '
- @ 18,30 PROMPT ' Exit '
- IF ! FILE('demo.scr')
- SAVE_DRAPE('demo.scr')
- ENDIF
- save screen to mainmenu
- menu to sel
- DO CASE
- CASE sel = 1
- do popcalc
- CASE sel = 2
- do popnote
- CASE sel = 3
- setcolor(maincolor)
- do popphone
- CASE sel = 4
- setcolor(maincolor)
- do popdate
- CASE sel = 5
- do popstop
- CASE sel = 6
- IF ! FILE('phone.dbf') .OR. ! FILE('phone.ntx')
- Err_msg("Select the 'phone directory' option before using this")
- else
- USE phone INDEX phone
- setcolor(maincolor)
- DO Setfilt
- CLOSE data
- endif
- CASE sel=7
- SETCOLOR(maincolor)
- CLEAR
- SETCOLOR('+w/rb')
- Exbox(07, 01, 14, 60, 2, 5, '', .F., 'Exploding Box')
- INKEY(.4)
- SETCOLOR('+w/r')
- Exbox(18, 10, 23, 50, 4, 6, '', .F., 'Exploding Box 2', .T.)
- INKEY(.4)
- SETCOLOR('+gr/n')
- Exbox(00, 00, 4, 36, 2, 5, '', .F., 'Exploding Box 3')
- INKEY(.4)
- SETCOLOR('n/gr')
- Exbox(12, 65, 22, 78, 3, 3, '', .F., 'Box #4', .T.)
- INKEY(.4)
- SETCOLOR('+w/g')
- Exbox(01, 45, 04, 78, 1, 11, '', .F., 'Yet Another Exploding Box')
- INKEY(2.5)
- Shrbox(01, 45, 04, 78, 5, maincolor)
- INKEY(.3)
- Shrbox(12, 65, 22, 78, 5, maincolor)
- INKEY(.3)
- Shrbox(00, 00, 4, 36, 5, maincolor)
- INKEY(.3)
- Shrbox(18, 10, 23, 50, 5, maincolor)
- INKEY(.3)
- Shrbox(07, 01, 14, 60, 5, maincolor)
- INKEY(1)
- SETCOLOR('n/bg')
- Popbox(00, 00, 22, 40, 2, 18, .F., 'Pop-up Box 1')
- INKEY(.35)
- SETCOLOR('+gr/n')
- Dropbox(00, 55, 18, 79, 1, 25, .F., 'Pull-down Box 1', .T.)
- INKEY(.35)
- SETCOLOR('n/gr')
- Popbox(03, 44, 20, 70, 5, 20, .F., 'Pop-up Box 2')
- INKEY(.35)
- SETCOLOR('n/w')
- Dropbox(04, 38, 13, 60, 4, 25, .F., 'Pull-down Box 2')
- INKEY(.35)
- SETCOLOR('+w/r')
- Popbox(12, 30, 23, 55, 2, 20, .F., 'Pop-up Box 3', .T.)
- INKEY(.35)
- SETCOLOR('+w/b')
- Popbox(03, 05, 20, 29, 2, 18, .F., 'Another Pop-up')
- INKEY(.35)
- SETCOLOR('n/g')
- Dropbox(06, 28, 20, 66, 1, 12, .T., 'Another Pull-down Box')
- INKEY(.35)
- SETCOLOR('n/r')
- Popbox(02, 15, 17, 45, 1, 10, .T., 'Pop-up Box w/ Crossbar', .T.)
- INKEY(.35)
- SETCOLOR('+w/rb')
- Shadowbox(09, 20, 14, 50, 2, 'Shadow Box', .T.)
- INKEY(.35)
- TTY2(24, 'Press any key to return to the main menu', 0, maincolor)
-
- CASE sel=8
- SETCOLOR(maincolor)
- CLEAR
- 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,25)
- SPREAD('as we are demonstrating here. You may also wish to use either',11,25)
- SPREAD('of the two teletype functions, which continuously scroll your',12,25)
- SPREAD('message across a specified row. Perhaps you already saw the',13,25)
- SPREAD('falling string trick, but in case you missed it, ',14,25)
- INKEY(4)
- FallGuy(14,58,'here it is!!')
- SETCOLOR(maincolor)
- INKEY(1)
- TTY(20, 'Copyright (C) 1988-89 Greg Lief', 35, 24)
- TTY2(24, 'Press any key to return to the main menu', 0, maincolor)
-
- CASE sel=9
- SETCOLOR('W/RB')
- coolscrn()
- SAVE SCREEN TO tempscrn
- SETCOLOR('+W/RB')
- SPREAD('Clear the screen in seven novel ways with Grumpfish', 0)
- INKEY(2)
- SETCOLOR('W/N')
- FOR xx = 1 TO 7
- CLRSCR(xx)
- INKEY(.2)
- RESTORE SCREEN FROM tempscrn
- INKEY(.2)
- NEXT
- SETCOLOR('+W/RB')
- SPREAD('or use the spreading curtains to display your title screen like this...', 0)
- INKEY(2)
- PULL_DRAPE('demo.scr')
-
- CASE sel=10
- SETCOLOR(maincolor)
- coolscrn()
- SETCOLOR('+W/BG')
- Exbox(9, 08, 14, 70, 1, 5, '', .T., 'User Feedback')
- SPREAD('The Grumpfish Library includes several user feedback items.',10,20)
- SPREAD('There are two functions for yes/no prompts, printer status ',11,20)
- SPREAD('test function, error message display, messages for tedious ',12,20)
- SPREAD("routines (printing, reindexing, etc). Let's look at them...",13,20)
-
- INKEY(5)
- firstans = YES_NO('This is one of the two Grumpfish yes/no prompts',;
- 'Would you like to see the other one')
- IF ! firstans
- Err_Msg('Too bad, you are going to see it anyway')
- ENDIF
- yes_no2('Shall we zap the database now?', 12, ' OK ', ' Cancel ', .F.)
- waiton('Now zapping database... please wait')
- INKEY(2)
- waitoff()
- firstans = yes_no2('Print the report now?', 12, ' OK ', ' Cancel ')
- IF ! firstans
- waiton("For the sake of argument, let's assume that we are printing now")
- INKEY(2)
- waitoff()
- ENDIF
-
- inkey(1)
- if isprinter()
- waiton('Please turn off your printer so you can see how Grumpfish handles it')
- do while isprinter()
- enddo
- waitoff()
- endif
- printok()
-
- Err_msg('Hey! You forgot to wear deodorant today!!')
-
- CASE sel=11
- coolscrn()
- save screen to temp
- SETCOLOR('RB/N')
- shadowbox(10, 06, 14, 72, 2, 'Interactive Color Palette')
- SETCOLOR('+GR/N')
- Spread('If Michelango were alive today, he would get a kick out of this',11,20)
- Spread('interactive color palette! Plug it instantly into your program',12,20)
- Spread('for maximum color flexibility. Try changing the screen with it!',13,20)
- INKEY(4)
- restore screen from temp
- COLORPAL()
-
- CASE sel=12
- DO WHILE .T.
- @ 06,30 PROMPT ' Mastermind '
- @ 07,30 PROMPT ' Number Puzzle '
- @ 08,30 PROMPT ' Ballgame '
- @ 09,30 PROMPT ' Star Trek '
- @ 10,30 PROMPT ' Jeopardy '
- @ 11,30 PROMPT " That's All Folks! "
- @ 12,30 PROMPT ' Girl From Ipanema '
- @ 13,30 PROMPT ' Birthday '
- @ 14,30 PROMPT 'Pop Goes The Weasel'
- @ 15,30 PROMPT 'Nanny-Nanny-Boo-Boo'
- @ 16,30 PROMPT ' Green Acres '
- @ 17,30 PROMPT ' Blue Danube '
- @ 18,30 PROMPT ' Quit '
- MENU TO silly_sel
- DO CASE
- CASE silly_sel = 1
- DO POPMM
- CASE silly_sel = 2
- DO POPPUZ
- CASE silly_sel = 3
- DO BALLGAME
- CASE silly_sel = 4
- DO STARTREK
- CASE silly_sel = 5
- DO JEOPARDY
- CASE silly_sel = 6
- DO THATSALL
- CASE silly_sel = 7
- DO IPANEMA
- CASE silly_sel = 8
- DO BIRTHDAY WITH 'GRUMPY'
- CASE silly_sel = 9
- DO WEASEL
- CASE silly_sel = 10
- DO NANNYBOO
- CASE silly_sel = 11
- DO GREENACR
- CASE silly_sel = 12
- DO BLUEDANU
- CASE silly_sel = 13 .OR. silly_sel = 0
- EXIT
- ENDCASE
- ENDDO
-
- CASE sel=13
- exit
- ENDCASE
- RESTORE SCREEN FROM mainmenu
- ENDDO
- RETURN
-
-
- FUNCTION showstring
- PARAM mcolor,mstart,mstop,delay
- PRIVATE mrow
- SETCOLOR('+'+TRIM(SUBSTR(colorstr,(mcolor-1)*2+1,2))+'/N')
- FOR mrow = mstart TO mstop
- @ mrow,30 SAY mstring
- IF PCOUNT() = 4
- INKEY(delay)
- ENDIF
- NEXT
- RETURN('')
-
-
- FUNCTION coolscrn
- FOR X = 0 TO 24
- @ X,0 SAY REPLICATE(CHR(250),80)
- NEXT
-
-
- ********************************************************************
- * colorpal(): virtually identical to Grumpfish Library version
- * except that it repaints the screen when color changes
- ********************************************************************
- FUNCTION colorpal
- PRIVATE oldrow, oldcol, oldcolor, mrow, mcol, palettetop, oldscrn, ;
- colorstrng, mfore, mback, keypress, buffer
- palettetop = 16 && top row for palette - change this to suit your needs
- ** save environment
- oldrow = ROW()
- oldcol = COL()
- oldcolor = SETCOLOR()
- oldscrn = SAVESCREEN(palettetop, 16, palettetop + 8, 63)
-
- ** this string will be used in converting color numbers in the
- ** range of 0-127 to dBASE color strings (e.g. "W/N" etc)
- colorstrng = 'N B G BG R BR GR W N+ B+ G+ BG+R+ BR+GR+W+ '
-
- curr_color = 7
-
- RESTSCREEN(palettetop, 16, palettetop + 7, 63, thepalette)
- SETCOLOR('GR+/N')
- SCROLL(palettetop + 8, 16, palettetop + 8, 63, 00)
- @ 24,16 SAY CHR(24)+CHR(25)+CHR(27)+CHR(26)+' to move'
- @ 24,33 SAY 'Enter to select'
- @ 24,53 SAY 'Esc to exit'
-
- ** determine starting row and column within palette
- mrow = palettetop + INT(curr_color/16)
- mcol = 17 + curr_color % 16 * 3
-
- ** commence main keypress loop
- DO WHILE .T.
-
- ** draw blinking diamond to mark current color and get keypress
- SETCOLOR('*' + color_n2s(curr_color))
- @ mrow,mcol SAY CHR(4)
- INKEY(0)
- keypress = LASTKEY()
-
- ** clear blinking diamond
- SETCOLOR(color_n2s(curr_color))
- @ mrow,mcol SAY CHR(4)
-
- ** process keystroke
- DO CASE
- ** user pressed an arrow key (24=down, 5=up, 4=left, 19=right)
- CASE (keypress = 24 .AND. mrow < palettetop+7) .OR. ;
- (keypress = 5 .AND. mrow > palettetop) .OR. ;
- (keypress = 4 .AND. mcol < 62) .OR. ;
- (keypress = 19 .AND. mcol > 17)
- ** adjust row position for up or down arrows
- mrow = mrow + IF(keypress = 24, 1, IF(keypress = 5, -1, 0))
- ** adjust column position for left or right arrows
- mcol = mcol + IF(keypress = 4, 3, IF(keypress = 19, -3, 0))
- ** change color number accordingly
- curr_color = curr_color + IF(keypress=24, 16, ;
- IF(keypress = 5, -16, IF(keypress = 4, 1, -1)))
- ** user pressed Enter or Esc - time to move along
- CASE keypress = 13 .OR. keypress = 27
- EXIT
- ** user pressed something else
- OTHERWISE
- TONE(220,1)
- TONE(220,1)
- ENDCASE
- *** here is where this version of ColorPal() differs from
- *** what is in the Grumpfish Library - I have added the
- *** following code to redraw the screen in each new color
- *** please refer to the documentation on how to do this
- *** it is actually very simple and incredibly useful!
- SETCOLOR(color_n2s(curr_color))
- buffer = SAVESCREEN(palettetop, 16, palettetop + 8, 63)
- coolscrn()
- RESTSCREEN(palettetop, 16, palettetop + 8, 63, buffer)
- ENDDO
-
- ** restore environment
- @ oldrow, oldcol SAY ''
- SETCOLOR(oldcolor)
- RESTSCREEN(palettetop, 16, palettetop + 8, 63, oldscrn)
- ** if user pressed Esc to abort, return the old color
- RETURN (IF(keypress = 27, oldcolor, color_n2s(curr_color)))
-
- ***********************************************************
- * color_n2s(): convert color number (0-127) to color string
- ***********************************************************
- FUNCTION color_n2s
- PARAM colorno
- RETURN (TRIM(SUBSTR(colorstrng, (colorno % 16) * 3 + 1, 3)) + '/' + ;
- TRIM(SUBSTR(colorstrng, INT(colorno / 16) * 3 + 1, 3)))
-
- * End of File: DEMO.prg