home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-04-07 | 36.3 KB | 1,028 lines |
- *:*********************************************************************
- *:
- *: Program: GPLUS.PRG
- *:
- *: System: GPLUS.prg
- *: Author: ACF
- *: Copyright (c) 1989, Fox Software, Inc.
- *: Last modified: 01/20/89 16:02
- *:
- *: Procs & Fncts: MAIN
- *: : HOUSEKEEP
- *: : FILEMATCH
- *: : HOTKEY
- *: : OPENDBF
- *: : OPENNDX
- *: : ROWVAL
- *: : COLVAL
- *: : GENVAL
- *: : TRACKER
- *: : HELPGRAPH
- *: : PROCEED
- *: : ERRHAND
- *: : ERRMSG
- *:
- *: Calls: MAIN (procedure in GPLUS.PRG)
- *:
- *: Documented: 01/24/89 at 11:14 FoxDoc version 1.0
- *:*********************************************************************
- PARAMETER loadfile
- SET PROCEDURE TO GPLUS
- DO main
- PROCEDURE main
- RELEASE ALL EXCEPT loadfile
- DIMENSION value(12), Head(12), popup(128), sumdata(12)
- DIMENSION fnames(32), oldvals(32)
- **************************************************************
- * Save existing environment and set up FoxGraph environment *
- **************************************************************
- IF SYS(103) = 'ON' && Save TALK status & turn off
- SET TALK OFF
- STORE 'ON' TO save_talk
- ELSE
- STORE 'OFF' TO save_talk
- ENDIF
- ***************************************************************************
- * Initialize smallest set of variables needed to access the error handler *
- ***************************************************************************
- ON ERROR DO errhand
- STORE SPACE(80) TO m->errmsg
- STORE 1 TO m->oldfld
-
- STORE SYS(6) TO save_prdev && Save PRINT DEVICE
- STORE SYS(102) TO save_prnt && Save PRINT status
- STORE SYS(2001, "COLOR") TO save_color && Save COLOR settings
- STORE SYS(2001, "CONFIRM") TO save_conf && Save CONFIRM setting
- STORE SYS(2001, "BELL") TO save_bell && Save BELL setting
- STORE SYS(2001, "STATUS") TO save_stat && Save STATUS setting
- STORE SYS(2001, "SCOREBOARD") TO save_score && Save SCOREBOARD setting
- STORE SYS(2001, "ESCAPE") TO save_escap && Save ESCAPE setting
- ON KEY = 315 DO hotkey && Set F1 to 'HELP' key
- SET CONFIRM OFF
- SET BELL OFF
- SET MESSAGE TO 24
- SET STATUS OFF
- SET SCOREBOARD OFF
- SET ESCAPE OFF
- SET TYPEAHEAD TO 128
- SET COLOR TO N/BG, GR+/N, BG
- CLEAR
- ? SYS(2002) && Hide cursor
- IF SUBSTR(VERSION(1), 16, 10) = '20-June-88'
- errmsg = 'Use G3.PRG with this version of FoxBASE+'
- DO errmsg
- DO proceed WITH 4
- DO housekeep
- RETURN
- ENDIF
- *************************
- * Initialize GET fields *
- *************************
- STORE IIF(LEN(DBF()) > 50, DBF(), LEFT(DBF()+SPACE(50),50)) TO m->dbf
- IF VAL(SYS(21)) = 0 && No active indexes
- STORE SPACE(50) TO m->ndx
- STORE .F. TO m->sumonly
- ELSE
- STORE NDX(VAL(SYS(21))) TO m->ndx
- STORE IIF(LEN(m->ndx) > 50, m->ndx, LEFT(m->ndx+SPACE(50),50)) TO m->ndx
- STORE .T. TO m->sumonly
- ENDIF
- STORE SPACE(40) TO m->thetitle, m->subtitle, m->style
- STORE SPACE(40) TO value, Head
- STORE 'm->dbf' TO fnames(1)
- STORE 'm->ndx' TO fnames(2)
- STORE 'm->sumonly' TO fnames(3)
- STORE 'm->thetitle' TO fnames(4)
- STORE 'm->subtitle' TO fnames(5)
- STORE 'm->style' TO fnames(6)
- STORE 'value(1)' TO fnames(7)
- STORE 'head(1)' TO fnames(8)
- STORE 'head(2)' TO fnames(9)
- m->i = 3
- counter = 10
- DO WHILE m->i < 13
- fnames(m->counter) = 'value('+STR(m->i,2)+')'
- fnames(m->counter+1) = 'head('+STR(m->i,2)+')'
- m->i = m->i + 1
- counter = m->counter + 2
- ENDDO
- STORE 'm->macro' TO fnames(30)
- STORE 'm->macstat' TO fnames(31)
- ******************************
- * Initialize other variables *
- ******************************
- STORE 1 TO m->themenu
- STORE 0 TO m->macstat, m->key
- STORE SPACE(50) TO m->filename, m->macro
- STORE CHR(16) TO m->arrow
- STORE '' TO m->command
- STORE TRIM(m->loadfile) TO m->loadfile
- **************************
- * Main menu control loop *
- **************************
- SET COLOR TO BG/BG,BG/BG
- IF LEN(m->loadfile) = 0
- KEYBOARD 's' && Go immediately to Setup screen
- ELSE
- KEYBOARD 'f'+CHR(13)+loadfile+CHR(13)+CHR(17)+'d' && Load and Draw
- ENDIF
- DO WHILE m->themenu < 7
- @ 22,0
- @ 23,0
- @ 0,0 PROMPT "Setup" MESSAGE ;
- " Setup parameters and values for the graph"
- @ 0,10 PROMPT "Help" MESSAGE ;
- " Display general information about FoxGraph"
- @ 0,20 PROMPT "Draw" MESSAGE ;
- " Build temporary files, and display/modify graph"
- @ 0,30 PROMPT "Files" MESSAGE ;
- " Load or save graph definition from/to file"
- @ 0,40 PROMPT "Macros" MESSAGE ;
- " Use or record keyboard macros from/to file"
- @ 0,50 PROMPT "Exit" MESSAGE ;
- " Exit FoxGraph"
- MENU TO m->themenu
- @ 0,0
- IF LEN(m->loadfile) = 0
- SET COLOR TO N/BG, GR+/N, BG
- ENDIF
- DO CASE
- CASE m->themenu = 1
- *************************************************************
- * Collect information for designing the graph *
- *************************************************************
- IF LEN(TRIM(m->filename)) = 0
- m->i = 1
- DO WHILE m->i < 30
- m->command = fnames(m->i)
- oldvals(m->i) = &command
- m->i = m->i + 1
- ENDDO
- ENDIF
- m->line23 = " Position to fields - " + ;
- CHR(24)+CHR(25)+CHR(26)+CHR(27) + ". Help - F1. Main Menu - PgDn."
- @ 23,0 SAY m->line23
- @ 1,0 TO 21,79 DOUBLE
- @ 2,2 SAY "Database " GET m->dbf FUNCTION "s20" VALID opendbf()
- @ 3,2 SAY "Index " GET m->ndx FUNCTION "s20" VALID openndx()
- @ 4,2 SAY "Summary Only? " GET m->sumonly PICTURE 'y' VALID genval()
- @ 2,40 SAY "Graph Title " GET m->thetitle FUNCTION "s20" VALID genval()
- @ 3,40 SAY "Graph Subtitle" GET m->subtitle FUNCTION "s20" VALID genval()
- @ 4,40 SAY "Graph Style " GET m->style FUNCTION "s20" VALID genval()
- @ 6,2 SAY "Row Definition" GET value(1) FUNCTION "s20" VALID rowval()
- @ 6,40 SAY "Row Title " GET Head(1) FUNCTION "s20" VALID genval()
- @ 7,40 SAY "Columns Title " GET Head(2) FUNCTION "s20" VALID genval()
- @ 10,2 SAY "Column"
- @ 10,17 SAY "Definitions"
- @ 10,56 SAY "Headers"
- m->i = 3
- DO WHILE m->i < 13
- @ 8+m->i,4 SAY STR(m->i-2,2)+' ' GET value(m->i) FUNCTION "s30" VALID colval()
- @ 8+m->i,45 GET Head(m->i) FUNCTION "s30" VALID genval()
- m->i = m->i + 1
- ENDDO
- SET CONFIRM ON
- ? SYS(2002,1)
- STORE 1 TO m->fldnum, m->oldfld
- READ
- SET CONFIRM OFF
- ? SYS(2002)
- CASE m->themenu = 2
- ************************************
- * All about the FoxGraph interface *
- ************************************
- ? SYS(2002)
- CLEAR
- DO helpgraph
- ? SYS(2002,1)
- CASE m->themenu = 3
- *************************************************************
- * Call FoxGraph with name of file containing graph info *
- *************************************************************
- ********************************
- * See if they want to continue *
- ********************************
- IF LEN(m->loadfile) = 0
- errmsg = "Proceed with graph generation"
- IF m->macstat = 1
- m->errmsg = m->errmsg + " - Macro Active"
- ELSE
- IF m->macstat = 2
- m->errmsg = m->errmsg + " - Recording Macro"
- ENDIF
- ENDIF
- DO errmsg
- DO proceed WITH 1
- IF m->key = 27
- LOOP
- ENDIF
- ELSE
- SET COLOR TO N/BG, GR+/N, BG
- ENDIF
- errmsg = "Building data files - Please wait"
- DO errmsg
- **************************************************
- * If SETUP is not complete, just invoke FoxGraph *
- **************************************************
- IF LEN(TRIM(value(1))) = 0
- m->command = 'foxgraph /q'
- IF LEN(TRIM(m->style)) <> 0
- m->command = m->command + ' ' + TRIM(m->style)
- ENDIF
- IF m->macstat <> 0
- m->command = m->command + IIF(m->macstat=1,' /r:',' /w:')+TRIM(m->macro)
- m->macstat = 0
- ENDIF
- &command
- SET COLOR TO N/BG, GR+/N, BG
- LOOP
- ENDIF
- *******************************************************
- * Create a temporary data file to be used by FoxGraph *
- *******************************************************
- SET PRINT TO nul
- EJECT
- STORE "3dDATA\" + SYS(3)+".dat" TO graphfile
- SET PRINT TO &graphfile
- SET PRINT ON
- SET DEVICE TO PRINT
- page = 1
- **********************************************
- * Write general graphing information to file *
- **********************************************
- @ 0,0 SAY '"%%Upper_Top_Left: 11, 2, 1%%"'
- @ 1,0 SAY '"%%Title: 8, 1%%"'
- @ 2,0 SAY '"%%Subtitle: 8, 2%%"'
- @ 3,0 SAY '"%%Row_Title: 9, 1%%"'
- @ 4,0 SAY '"%%Column_Title: 9, 2%%"'
- @ 5,0 SAY '"%%Row_Headers: 11, 1%%"'
- @ 6,0 SAY '"%%Column_Headers: 10, 2%%"'
- @ 7,0 SAY '"'+TRIM(m->thetitle)+'" '+'"'+TRIM(m->subtitle)+'"'
- @ 8,0 SAY '"'+TRIM(Head(1))+'" '+'"'+TRIM(Head(2))+'"'
- Lines = 9
- counter = 12
- DO WHILE m->counter > 2 && Find out how many columns are used
- IF value(m->counter) <> SPACE(30)
- EXIT
- ENDIF
- m->counter = m->counter - 1
- ENDDO
- m->command = "," && Print column headers
- m->i = 3
- DO WHILE m->i <= m->counter
- m->command = m->command + [ "] + TRIM(Head(m->i)) + ["]
- m->i = m->i + 1
- ENDDO
- @Lines,0 SAY m->command
- Lines = m->lines + 1
- ********************
- * Process the data *
- ********************
- IF LEN(ALIAS()) <> 0
- dbfopen = .T.
- GO TOP
- ELSE
- dbfopen = .F.
- ENDIF
- IF m->sumonly .AND. dbfopen
- STORE 0 TO sumdata
- sumdata(1) = &value && Note current key value
- DO WHILE .T.
- IF sumdata(1) <> &value .OR. EOF() && Group change??
- m->i = 3 && Store group summary info in file
- m->command = ["]+sumdata(1)+["]
- DO WHILE m->i <= m->counter
- m->command = m->command + "," + STR(sumdata(m->i),14,2)
- m->i = m->i + 1
- ENDDO
- @ Lines,0 SAY m->command
- Lines = m->lines + 1
- STORE 0 TO sumdata && Prepare for next group
- sumdata(1) = &value && First element of value
- IF EOF()
- EXIT && Finished last group
- ENDIF
- ENDIF
- m->i = 3
- DO WHILE m->i <= m->counter && For each column, add to summary
- thevalue = value(m->i)
- IF LEN(TRIM(m->thevalue)) <> 0
- IF thevalue = '+'
- sumdata(m->i) = sumdata(m->i) + 1
- ELSE
- sumdata(m->i) = sumdata(m->i) + &thevalue
- ENDIF
- ENDIF
- m->i = m->i + 1
- ENDDO
- SKIP
- ENDDO && WHILE .T.
- ELSE
- DO WHILE .NOT. EOF()
- m->command = ["] + &value + ["]
- m->i = 3
- DO WHILE m->i <= m->counter
- thevalue = value(m->i)
- IF LEN(TRIM(thevalue)) <> 0
- m->command = m->command + "," + STR(&thevalue,14,2)
- ENDIF
- m->i = m->i + 1
- ENDDO
- @ Lines,0 SAY m->command
- Lines = m->lines + 1
- IF .NOT. dbfopen
- EXIT
- ENDIF
- SKIP
- ENDDO
- ENDIF && IF m->sumonly
- ******************************************************
- * Mark the end of the data, close file, and graph it *
- ******************************************************
- @ Lines,0 SAY '"%%Lower_Bottom_Right: '+STR(m->lines);
- +','+STR(m->counter-1)+','+STR(m->page)+'%%"'
- SET PRINT OFF
- SET PRINT TO
- SET DEVICE TO SCREEN
- m->command = 'foxgraph '
- IF LEN(TRIM(m->style)) <> 0
- m->command = m->command + ' ' + TRIM(m->style)
- ENDIF
- IF m->macstat <> 0
- m->command = m->command + IIF(m->macstat=1,' /r:',' /w:')+TRIM(m->macro)
- ENDIF
- m->command = m->command + ' /q /d:' + graphfile
- &command
- SET COLOR TO N/BG, GR+/N, BG
- DELETE FILE &graphfile
- IF m->macstat = 2 && Turn off recording mode
- m->macstat = 0
- ENDIF
- IF LEN(m->loadfile) > 0
- KEYBOARD 'e' && Automatic exit
- SET COLOR TO BG/BG,BG/BG
- ENDIF
- CASE m->themenu = 4
- ****************************************
- * Load and Save graph definition files *
- ****************************************
- @ 0,0 TO 23,79 CLEAR
- SET CONFIRM ON
- DO WHILE .T.
- @ 22,0
- m->line23 = " Position to options - " + CHR(24)+CHR(25) + ;
- ". Select - " + CHR(17)+CHR(217) +". Main Menu - Esc. "
- @ 23,0 SAY m->line23
- @ 1,30 TO 4,70 DOUBLE
- @ 2,31 PROMPT 'Load Definition'+SPACE(24)
- @ 3,31 PROMPT 'Save Definition'+SPACE(24)
- MENU TO m->theitem
- m->line23 = " Enter file name - Finish with " + ;
- CHR(17)+CHR(217) + ". Help - F1. Abort Entry - Esc."
- @ 23,0 SAY m->line23
- IF m->theitem = 1 && Load a graph definition
- DO WHILE .T.
- DO getgrf
- IF LEN(TRIM(m->command)) > 0
- RESTORE FROM &command ADDITIVE
- IF LEN(TRIM(m->filename)) <> 0 && no errors
- @ 22,0 && Erase Please wait mssg
- m->i = 1
- DO WHILE m->i < 32
- m->command = fnames(m->i)
- &command = oldvals(m->i)
- m->i = m->i + 1
- ENDDO
- IF LEN(TRIM(m->dbf)) > 0
- USE &dbf INDEX &ndx
- ELSE
- USE
- ENDIF
- EXIT
- ELSE
- IF LEN(m->loadfile) > 0
- CLEAR TYPEAHEAD
- KEYBOARD CHR(17)+'e'
- SET COLOR TO BG/BG,BG/BG
- EXIT
- ENDIF
- ENDIF
- ELSE
- EXIT && Escape pressed
- ENDIF
- ENDDO
- ELSE
- IF m->theitem = 2 && Save a graph definition
- DO getgrf
- IF LEN(TRIM(m->command)) > 0
- @ 24,0 && Be prepared for overwrite mssg
- @ 23,0
- STORE TRIM(m->macro) TO oldvals(30)
- STORE m->macstat TO oldvals(31)
- SAVE TO &command ALL LIKE 'oldvals*'
- @ 22,0 && Erase Please wait mssg
- @ 24,0 && Erase overwrite mssg
- ENDIF
- ELSE
- EXIT
- ENDIF
- ENDIF
- ENDDO
- SET CONFIRM OFF
- IF LEN(m->loadfile) = 0
- CLEAR
- ENDIF
- CASE m->themenu = 5
- ****************************************
- * Use or record keyboard macro files *
- ****************************************
- @ 0,0 TO 23,79 CLEAR
- SET CONFIRM ON
- DO WHILE .T.
- m->line23 = " Position to options - " + CHR(24)+CHR(25) + ;
- ". Select - " + CHR(17)+CHR(217) +". Main Menu - Esc. "
- @ 23,0 SAY m->line23
- @ 1,30 TO 4,70 DOUBLE
- @ 2,31 PROMPT IIF(m->macstat <> 1, 'Activate Macro'+SPACE(25), ;
- LEFT('Deactivate Macro ==> '+m->macro+SPACE(19), 39))
- @ 3,31 PROMPT IIF(m->macstat <> 2, 'Start Recording'+SPACE(24), ;
- LEFT('Stop Recording ==> '+m->macro+SPACE(21), 39))
- IF m->macstat = 1
- m->errmsg = 'Macro active - ' + m->macro
- ELSE
- IF m->macstat = 2
- m->errmsg = 'Macro recording mode on - ' + m->macro
- ELSE
- m->errmsg = 'Macro inactive'
- ENDIF
- ENDIF
- DO errmsg
- MENU TO m->theitem
- m->line23 = " Enter file name - Finish with " + ;
- CHR(17)+CHR(217) + ". Help - F1. Abort Entry - Esc."
- @ 23,0 SAY m->line23
- IF m->theitem = 1 && Activate/Deactivate a macro
- IF m->macstat = 1
- m->macstat = 0
- ELSE
- @ 22,0
- DO WHILE .T.
- DO get3mc
- IF LEN(TRIM(m->command)) > 0
- IF FILE(m->command) && Macro exists
- STORE 1 TO m->macstat
- EXIT
- ELSE
- errmsg = m->command+' does not exist'
- DO errmsg
- ENDIF
- ELSE
- EXIT && Escape pressed
- ENDIF
- ENDDO
- ENDIF
- ELSE
- IF m->theitem = 2 && Start/Stop recording a macro
- IF m->macstat = 2
- m->macstat = 0
- ELSE
- @ 22,0
- DO get3mc
- IF LEN(TRIM(m->command)) > 0
- m->macstat = 2
- IF FILE(m->command) && Macro exists
- @ 24,0
- @ 23,78
- WAIT m->command+' already exists, overwrite it (Y/N)? ' TO m->i
- IF UPPER(m->i) <> 'Y'
- m->macstat = 0
- ENDIF
- @ 24,0
- ENDIF
- ENDIF
- ENDIF
- ELSE
- EXIT
- ENDIF
- ENDIF
- ENDDO
- SET CONFIRM OFF
- CLEAR
- CASE m->themenu = 6
- *************************************************************
- * Bye-bye *
- *************************************************************
- IF LEN(m->loadfile) <> 0
- EXIT
- ELSE
- DO proceed WITH 3
- IF m->key <> 27
- EXIT
- ENDIF
- ENDIF
- ENDCASE
- ENDDO
- DO housekeep
- *************************************************************
- * Housekeeping: Restore previous settings *
- *************************************************************
- PROCEDURE housekeep
- ON KEY
- ON ERROR
- SET ESCAPE &save_escap
- SET SCOREBOARD &save_score
- SET STATUS &save_stat
- SET BELL &save_bell
- SET CONFIRM &save_conf
- SET PRINT TO &save_prdev
- SET PRINT &save_prnt
- SET COLOR TO &save_color
- SET TALK &save_talk
- ? SYS(2002,1)
- CLEAR
- RETURN
- *********************************************************
- * FILEMATCH - get all files in current directory that *
- * match the given wildcard *
- *********************************************************
- PROCEDURE filematch
- PARAMETERS wildcard
- popup(m->counter) = SYS(2000, wildcard) && Get first filename
- DO WHILE LEN(popup(m->counter)) <> 0 .AND. m->counter < 129
- m->counter = m->counter + 1 && Get next filename
- popup(m->counter) = SYS(2000, wildcard, 1)
- ENDDO
- IF popup(m->counter) = ""
- m->counter = m->counter - 1 && counter = number of popup items
- ENDIF
- RETURN
- *********************************************************
- * HOTKEY - provide assistance during the READ command *
- *********************************************************
- PROCEDURE hotkey
- @22,0 && Clear message line
- readitem = SYS(18) && What's the current field name
- STORE 1 TO counter, k
- STORE 0 TO choice
- m->pop23 = " Position to options - " + CHR(24)+CHR(25) + ;
- ". Select - " + CHR(17)+CHR(217) +". Abort Selection - Esc. "
- DO CASE
- CASE m->readitem = 'DBF' && Database field
- DO filematch WITH '*.dbf' && Initialize popup menu
- errmsg = "Select a database for the graph"
- DO errmsg
- IF m->counter > 0 && Accept user selection
- @ 3,12 MENUS popup, m->counter, MIN(m->counter, 10)
- @ 23,0 SAY m->pop23
- READ MENUS TO m->choice
- ENDIF
- CASE m->readitem = 'NDX' && Index field
- DO filematch WITH '*.idx' && Initialize popup menu
- errmsg = "Select an index file for grouping data"
- DO errmsg
- IF m->counter > 0 && Accept user selection
- @ 4,13 MENUS popup, m->counter, MIN(m->counter, 10)
- @ 23,0 SAY m->pop23
- READ MENUS TO m->choice
- ENDIF
- CASE LEFT(m->readitem,5) = 'VALUE' && Row and Column values
- IF m->sumonly
- IF m->fldnum <> 7
- popup(1) = '+ - Count'
- k = m->k + 1
- ELSE
- IF VAL(SYS(21)) > 0
- popup(1) = SYS(14,VAL(SYS(21)))+ ' - Index Key'
- k = m->k + 1
- ENDIF
- ENDIF
- ENDIF
- m->j = 1
- DO WHILE m->j < 11 && Build popup from dbf & related files
- m->limit = fcount(m->j)
- IF m->limit <> 0 .AND. m->j <> SELECT()
- GO TOP
- m->n = RECNO(m->j)
- GO BOTTOM
- IF RECNO(m->j) = m->n && guess if file is related
- m->j = m->j + 1
- LOOP
- ENDIF
- ENDIF
- DO WHILE m->counter <= m->limit && Initialize popup menu
- popup(m->k) = IIF(J=SELECT(),"",ALIAS(J)+"->")+FIELD(m->counter,J)
- m->counter = m->counter + 1
- IF TYPE(popup(m->k)) = 'N' .OR. fldnum = 7
- m->k = m->k + 1 && Skip non-numerics for columns
- ENDIF
- ENDDO
- counter = 1
- m->j = m->j + 1
- ENDDO
- m->k = m->k - 1
- errmsg = IIF(fldnum = 7,;
- "Select an expression for the row definition",;
- "Select a numeric expression for the column definition")
- DO errmsg
- IF m->k > 0 && Accept user selection
- m->i = IIF(fldnum = 7, 5, 0)
- @ 10-m->i,15+m->i MENUS popup, m->k, MIN(m->k, 10)
- @ 23,0 SAY m->pop23
- READ MENUS TO m->choice
- ENDIF
- CASE m->readitem = 'SUMONLY'
- errmsg = 'Summarize data by groups (Y) or graph for all records (N)'
- DO errmsg
- RETURN
- CASE m->readitem = 'THETITLE'
- errmsg = 'Enter title to appear at the top of the graph display'
- DO errmsg
- RETURN
- CASE m->readitem = 'SUBTITLE'
- errmsg = 'Enter subtitle to appear at the bottom of the graph display'
- DO errmsg
- RETURN
- CASE LEFT(m->readitem,4) = 'HEAD'
- IF fldnum = 8
- errmsg = 'Enter row title to appear along the row axis of the graph'
- ELSE
- IF fldnum = 9
- errmsg = 'Enter column title to appear along the column axis of the graph'
- ELSE
- errmsg = 'Enter column header to appear below the corresponding column'
- ENDIF
- ENDIF
- DO errmsg
- RETURN
- CASE m->readitem = 'FILENAME'
- DO filematch WITH '*.grf'
- IF m->counter = 0
- errmsg = 'Cannot find any graph definition files'
- DO errmsg
- RETURN
- ENDIF
- errmsg = 'Select graph definition file name'
- DO errmsg
- @ 1,10 MENUS popup, m->counter, MIN(10, m->counter)
- @ 23,0 SAY m->pop23
- READ MENUS TO m->choice
- CASE m->readitem = 'MACRO'
- DO filematch WITH '*.3mc'
- IF m->counter = 0
- errmsg = 'Cannot find any keyboard macro files'
- DO errmsg
- RETURN
- ENDIF
- errmsg = 'Select keyboard macro file name'
- DO errmsg
- @ 1,10 MENUS popup, m->counter, MIN(10, m->counter)
- @ 23,0 SAY m->pop23
- READ MENUS TO m->choice
- CASE m->readitem = 'STYLE'
- DO filematch WITH '3dlooks\*.3gr'
- IF m->counter = 0
- errmsg = 'Cannot find any graph styles'
- DO errmsg
- RETURN
- ENDIF
- errmsg = 'Select format for initial graph display'
- DO errmsg
- @ 4,45 MENUS popup, m->counter, MIN(10, m->counter)
- @ 23,0 SAY m->pop23
- READ MENUS TO m->choice
- OTHERWISE
- RETURN
- ENDCASE
- IF m->choice > 0 && Replace current value with selection
- m->i = AT(' ',popup(m->choice))
- m->i = IIF(m->i > 0, m->i - 1, LEN(popup(m->choice)))
- KEYBOARD CHR(25)+LEFT(popup(m->choice),m->i)+CHR(13)
- ENDIF
- @ 22,0
- @ 23,0
- @ 23,0 SAY m->line23
- RETURN
- *********************************************************
- * OPENDBF - open the selected dbf *
- *********************************************************
- PROCEDURE opendbf
- @ 22,0
- DO tracker
- IF .NOT. (oldvals(1) == m->dbf) && value changed
- USE &dbf
- IF ALIAS()=="" .AND. LEN(TRIM(m->dbf))<>0 && dbf not successfully opened
- fldnum = 1
- RETURN .F.
- ENDIF
- oldvals(1) = m->dbf
- STORE SPACE(50) TO m->ndx, oldvals(2) && Clear index field
- KEYBOARD IIF(fldnum = 2, CHR(25), 's'+CHR(3)) && Read terminated?
- ENDIF
- IF LEN(ALIAS()) = 0 .AND. m->fldnum = 2 && If no dbf, then no index
- CLEAR TYPEAHEAD
- KEYBOARD CHR(13)+'N'+CHR(13) && ... and no summary
- ENDIF
- RETURN .T.
- *************************************************************
- * OPENNDX - open the selected index *
- *************************************************************
- PROCEDURE openndx
- @ 22,0
- DO tracker
- IF .NOT. (oldvals(2) == m->ndx) && value changed
- oldfld = 2
- SET INDEX TO &ndx
- IF LEN(TRIM(m->ndx)) <> 0 && index name entered
- IF LEN(SYS(14,VAL(SYS(21))))=0 && Index not successfully opened
- fldnum = 2
- RETURN .F.
- ENDIF
- GO BOTT && Test out the index
- SKIP
- IF .NOT. EOF()
- fldnum = 2
- RETURN .F.
- ENDIF
- ndxopen = .T.
- ELSE && index name erased
- ndxopen = .F.
- ENDIF
- oldvals(2) = m->ndx
- IF fldnum = 0 && READ was terminated
- STORE SPACE(30) TO value(1)
- STORE m->sumonly TO oldvals(3)
- KEYBOARD 's'+CHR(3) && Just redisplay the screen
- RETURN .T.
- ENDIF
- IF fldnum = 1 && Used the back arrow
- KEYBOARD CHR(13)+CHR(13)
- ENDIF
- KEYBOARD IIF(ndxopen, 'Y', 'N')
- IF fldnum = 1 && Used the back arrow
- KEYBOARD CHR(5)+CHR(5)
- ENDIF
- ENDIF
- RETURN .T.
- ***************************************************************
- * ROWVAL - make sure that the row value is a valid expression *
- ***************************************************************
- PROCEDURE rowval
- @ 22,0
- IF oldvals(7) <> value(1)
- IF TYPE(value(1)) <> 'C' .AND. LEN(TRIM(value(1))) <> 0
- errmsg = "Row definition must be a character expression"
- DO errmsg
- RETURN .F.
- ENDIF
- oldvals(7) = value(1)
- ENDIF
- DO tracker
- RETURN .T.
- *************************************************************
- * COLVAL - check to see that column values are valid *
- *************************************************************
- PROCEDURE colval
- @ 22,0
- k = (m->fldnum - 4)/2
- IF oldvals(m->fldnum) <> value(m->k)
- IF TYPE(value(m->k)) <> 'N' .AND. value(m->k) <> '+' .AND. ;
- LEN(TRIM(value(m->k))) <> 0
- errmsg = 'Column definitions must be valid numeric expressions'
- DO errmsg
- RETURN .F.
- ENDIF
- ENDIF
- oldvals(m->fldnum) = value(m->k)
- DO tracker
- RETURN .T.
- *************************************************************
- * GENVAL - general validation routine *
- *************************************************************
- PROCEDURE genval
- @ 22,0
- COMMAND = fnames(m->fldnum)
- oldvals(m->fldnum) = &command
- oldfld = m->fldnum
- DO tracker
- IF LEN(ALIAS()) = 0 .AND. fldnum = 3 .AND. oldfld = 4
- KEYBOARD CHR(5)+CHR(5)
- ENDIF
- RETURN .T.
- *************************************************************
- * TRACKER - track which GET field we are on currently *
- *************************************************************
- PROCEDURE tracker
- KEY = MOD(READKEY(),256)
- IF KEY = 0 .OR. KEY = 2 .OR. KEY = 4 && Go back one
- IF m->fldnum > 1
- fldnum = m->fldnum - 1
- ENDIF
- ELSE
- IF KEY = 1 .OR. KEY = 3 .OR. KEY = 5 .OR. KEY = 15 .OR. KEY = 16
- IF m->fldnum < 29
- fldnum = m->fldnum + 1
- ENDIF
- ELSE
- fldnum = 0
- ENDIF
- ENDIF
- RETURN .T.
- ************************************************
- * HELPGRAPH - Provide general HELP information *
- ************************************************
- PROCEDURE helpgraph
- TEXT
- Use the SETUP menu option to specify the data you want to include in your
- graph. Graph data may be derived from database files or they may be values
- that you enter directly. When you are defining your graph, it is easiest to
- think of your graph as a two-dimensional grid with rows and columns.
-
- Example: Using an employee file, salary and bonus amounts can be graphed for
- each employee. The following SETUP definitions are fields in the database:
-
- ROW DEFINITION = LASTNAME
- COLUMN 1 DEFINITION = SALARY
- COLUMN 2 DEFINITION = BONUS
-
- ┌────────────┬────────────┐
- ┌──────> Brown │ 25,000 │ 3,000 <───── COLUMN VALUE
- │ ├────────────┼────────────┤
- ROW Johnson │ 36,000 │ 4,500 │
- VALUE ├────────────┼────────────┤
- Young │ 18,000 │ 2,000 │
- └────────────┴────────────┘
- │Annual Salary 1988 Bonus │
- └─────────────┬─────────────┘
- COLUMN HEADERS
- ENDTEXT
- DO proceed WITH 2
- IF m->key = 27 && Escape
- RETURN
- ENDIF
- TEXT
- The row values are determined by the ROW DEFINITION. If your graph is based on
- database records, the row definition should be a character expression contain-
- ing one or more database fields. If you would like to display summary infor-
- mation, the row definition should be the key upon which the file is either
- sorted or currently indexed. In this case, there will be one row for each dis-
- tinct key value. If you are not summarizing the data, there will be one row
- for each record in the primary database.
-
- The columns are determined by the COLUMN DEFINITIONs. These definitions must
- be numeric expressions. Every row will then contain a value for each column
- that you define. If you would like to display summary information on a data-
- base, the special expression '+' is available in addition to the range of
- valid numeric expressions. The '+' expression indicates that the number of
- records within each key group is to be displayed for each row value.
-
- For example, if you had a customer database, you could sort it by state (row
- definition) and use the '+' expression (column 1 definition) to graph the num-
- ber of customers you have in each state.
-
- Alternately, you could use the TOTAL command to build a summary database
- before performing the SETUP. In this case, you would not request SUMMARY ONLY
- and your graph would have a row for each record in the TOTALed database.
- ENDTEXT
- DO proceed WITH 2
- IF m->key = 27 && Escape
- RETURN
- ENDIF
- TEXT
- As you are entering information in the SETUP screen, you may press F1 at any
- point to get specific HELP information. If you press F1 while you are on the
- DATABASE, INDEX, GRAPH STYLE, ROW DEFINITION or COLUMNs DEFINITION fields, a
- popup menu will be displayed which contains items appropriate to that field.
- You may select these items by positioning with the arrow keys and selecting
- with the Return key.
-
- When you have completed the SETUP, choose the DRAW menu option. At this point
- the data is summarized (if indicated) and written to a temporary data file for
- use by FoxGraph. FoxGraph is then invoked and an initial graph is displayed
- based on your SETUP information. You may then choose other formats for the
- graph and/or select different ranges of data to display in the graph. Once you
- are satisfied with the appearance of the graph you may save it and print it.
-
- You may also wish to save the SETUP definition so that you can generate the
- graph again more conveniently. Use the FILES menu option to save and load
- graph definitions.
-
- Sometimes it is desirable to define a canned procedure for performing a set of
- tasks within the graphing program itself. With the MACROS menu option, you may
- either indicate that you wish to record a macro (sequence of keystrokes) while
- you are running FoxGraph or that you want to activate an existing macro to
- control a FoxGraph session.
- ENDTEXT
- DO proceed WITH 2
- RETURN
- *******************************************************
- * PROCEED - Display message at bottom of help screen *
- *******************************************************
- PROCEDURE proceed
- PARAMETER mproceed
- @ 24,0
- SET COLOR TO GR+/N
- DO CASE
- CASE m->mproceed = 1 && Proceed with graph generation?
- @ 24,0 SAY ' Esc - Main Menu. Any other key - Proceed.';
- + SPACE(19)
- CASE m->mproceed = 2 && Proceed with help screens?
- @ 24,0 SAY ' Esc - Main Menu. Any other key - Continue.';
- + SPACE(18)
- CASE m->mproceed = 3 && Proceed with exiting?
- @ 24,0 SAY ' Esc - Main Menu. Any other key - Exit.';
- + SPACE(20)
- CASE m->mproceed = 4 && Proceed with exiting?
- @ 24,0 SAY ' Press any key to exit.';
- + SPACE(29)
- ENDCASE
- SET COLOR TO N/BG
- IF m->mproceed <> 2 .AND. m->mproceed <> 3
- ?? CHR(7)
- ENDIF
- m->key = INKEY(0)
- CLEAR
- RETURN
- *************************************************************
- * ERRHAND - General error handling routine *
- *************************************************************
- PROCEDURE errhand
- @ 22,0
- m->errmsg = MESSAGE()
- DO CASE
- CASE m->oldfld = 2
- m->errmsg = 'Invalid index file'
- CASE LEFT(MESSAGE(1), 12) = 'RESTORE FROM'
- m->filename = SPACE(50)
- CASE ERROR() = 21 .OR. ERROR() = 1310
- m->errmsg = m->errmsg + ' - Check CONFIG file values'
- DO errmsg
- DO proceed WITH 4
- DO housekeep
- RETURN TO MASTER
- ENDCASE
- DO errmsg
- RETURN
- *************************************************************
- * ERRMSG - Display an error message on line 22 *
- *************************************************************
- PROCEDURE errmsg
- SET COLOR TO GR+*/BG
- @ 22,0 SAY SPACE((80-LEN(m->errmsg)-6)/2)+"<< "
- SET COLOR TO GR+/BG
- @ 22,COL() SAY m->errmsg
- SET COLOR TO GR+*/BG
- @ 22,COL() SAY " >>"
- @ 22,COL()
- SET COLOR TO N/BG
- RETURN
- ****************************************
- * GETGRF - Enter and validate filename *
- ****************************************
- PROCEDURE getgrf
- command = ''
- @ m->theitem+1,47 GET m->arrow
- CLEAR GETS
- filename = IIF(LEN(m->filename) > 50, m->filename, LEFT(m->filename+SPACE(50), 50))
- @ m->theitem+1,48 GET m->filename PICTURE "@s22 "
- ? SYS(2002,1)
- READ
- ? SYS(2002)
- IF READKEY() <> 12 .AND. LEN(TRIM(m->filename)) > 0
- m->filename = TRIM(m->filename)
- m->i = AT('.', m->filename) + 1
- IF m->i > 1
- m->filename = STUFF(m->filename,m->i,LEN(SUBSTR(m->filename,m->i)),'grf')
- ELSE
- m->filename = m->filename + '.grf'
- ENDIF
- m->command = m->filename
- IF LEN(m->loadfile) = 0
- errmsg = IIF(m->theitem = 1, "Loading ", "Saving ")+m->command+" - Please wait"
- DO errmsg
- ENDIF
- ENDIF
- RETURN
- ******************************************
- * GET3MC - Enter and validate macro name *
- ******************************************
- PROCEDURE get3mc
- m->command = ''
- @ m->theitem+1, 47 GET m->arrow
- CLEAR GETS
- m->macro = IIF(LEN(m->macro) > 50, m->macro, LEFT(m->macro+SPACE(50), 50))
- @ m->theitem+1,48 GET m->macro PICTURE "@s22 "
- ? SYS(2002,1)
- READ
- ? SYS(2002)
- IF READKEY() <> 12 .AND. LEN(TRIM(m->macro)) > 0
- m->macro = TRIM(m->macro)
- m->i = AT('.', m->macro) + 1
- IF m->i > 1
- m->macro = STUFF(m->macro,m->i,LEN(SUBSTR(m->macro,m->i)),'3mc')
- ELSE
- m->macro = m->macro + '.3mc'
- ENDIF
- m->command = m->macro
- RETURN
- *: EOF: GPLUS.PRG