home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-03-23 | 38.3 KB | 1,173 lines |
- *:*********************************************************************
- *:
- *: Program: G3.PRG
- *:
- *: System: G3.prg
- *: Author: ACF
- *: Copyright (c) 1989, Fox Software, Inc.
- *: Last modified: 01/24/89 11:09
- *:
- *: Procs & Fncts: MAIN
- *: : HOUSEKEEP
- *: : HOTKEY
- *: : VALIDATE
- *: : OPENDBF
- *: : OPENNDX
- *: : ROWVAL
- *: : COLVAL
- *: : GENVAL
- *: : TRACKER
- *: : HELPGRAPH
- *: : PROCEED
- *: : ERRHAND
- *: : ERRMSG
- *: : MAINMENU
- *: : LIGHTBAR
- *: : REDRAW
- *: : GETGRF
- *: : GET3MC
- *: : RESTOREIT
- *:
- *: Calls: MAIN (procedure in G3.PRG)
- *:
- *: Documented: 01/24/89 at 11:13 FoxDoc version 1.0
- *:*********************************************************************
- PARAMETER loadfile
- SET PROCEDURE TO G3
- DO main
- PROCEDURE main
- RELEASE ALL EXCEPT loadfile
- PUBLIC dbxl
- SET TALK OFF
- ***************************************************************************
- * Initialize smallest set of variables needed to access the error handler *
- ***************************************************************************
- ON ERROR DO errhand
- STORE SPACE(80) TO errmsg
- STORE 1 TO oldfld
- dbxl = IIF(UPPER(LEFT(VERSION(),4)) = 'DBXL', .T., .F.)
- if dbxl
- set oops to ''
- endif
-
- SET CONFIRM OFF
- SET BELL OFF
- SET STATUS OFF
- SET SCOREBOARD OFF
- SET ESCAPE OFF
- SET TYPEAHEAD TO 128
- SET COLOR TO N/BG, GR+, BG
- CLEAR
- *************************
- * Initialize GET fields *
- *************************
- STORE IIF(LEN(TRIM(DBF())) > 50, DBF(), LEFT(DBF()+SPACE(50),50)) TO setup1, oldval1
- IF LEN(TRIM(m->setup1)) > 0
- SET ORDER TO 0 && Can't tell which is master, so deactivate all
- ENDIF
- STORE SPACE(50) TO setup2, oldval2
- STORE .F. TO setup3, oldval3
- STORE SPACE(40) TO setup4, setup5, setup6, oldval4, oldval5, oldval6
- I = 7
- DO WHILE m->i < 30
- s = LTRIM(STR(m->i))
- STORE SPACE(40) TO setup&s, oldval&s
- I = m->i + 1
- ENDDO
- ******************************
- * Initialize other variables *
- ******************************
- STORE 1 TO themenu
- STORE 0 TO macstat, KEY
- STORE SPACE(50) TO filename, macro
- STORE TRIM(m->loadfile) TO loadfile
- STORE CHR(16) TO arrow
- **************************
- * Main menu control loop *
- **************************
- DO WHILE m->themenu < 7
- IF LEN(m->loadfile) = 0
- DO mainmenu
- SET FUNCTION 'F10' TO IIF(m->themenu = 1, CHR(3), CHR(27))
- ELSE
- IF m->themenu = 1
- filename = LEFT(m->loadfile+SPACE(21),21)
- command = ''
- DO getgrf
- DO restoreit WITH command
- themenu = IIF(LEN(TRIM(m->filename)) > 0, 3, 6)
- ELSE
- themenu = 6
- ENDIF
- ENDIF
-
- @ 0,0
- DO CASE
- CASE m->themenu = 1
- *************************************************************
- * Collect information for designing the graph *
- *************************************************************
- IF LEN(TRIM(m->filename)) = 0
- I = 1
- DO WHILE m->i < 30
- s = LTRIM(STR(m->i))
- oldval&s = setup&s
- I = m->i + 1
- ENDDO
- ENDIF
- line23 = " Position to fields - " + ;
- CHR(24)+CHR(25)+CHR(26)+CHR(27) + ". Help - F1. Main Menu - F10."
- rc = '02170317041702550355045506170655075511091145120912451309134514091445'+;
- '150915451609164517091745180918451909194520092045'
- DO redraw WITH 30, 24 && fldno, lineno
- STORE 1 TO fldnum, oldfld
- DO WHILE m->fldnum > 0 .AND. m->fldnum < 30
- s = LTRIM(STR(m->fldnum))
- fcode = '@' + IIF(fldnum < 10, IIF(fldnum = 3, ' y', 's20'), 's30')
- @ VAL(SUBSTR(rc,m->fldnum*4-3,2)),VAL(SUBSTR(rc,m->fldnum*4-1,2)) GET setup&s PICTURE fcode
- SET CONFIRM ON
- READ
- SET CONFIRM OFF
- DO validate
- ENDDO
- CASE m->themenu = 2
- ************************************
- * All about the FoxGraph interface *
- ************************************
- CLEAR
- DO helpgraph
- 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
- errmsg = m->errmsg + " - Macro Active"
- ELSE
- IF m->macstat = 2
- errmsg = m->errmsg + " - Recording Macro"
- ENDIF
- ENDIF
- DO errmsg
- DO proceed with 1
- IF m->key = -9 .OR. m->key = 27
- LOOP
- ENDIF
- ENDIF
- errmsg = "Building data files - Please wait"
- DO errmsg
- **************************************************
- * If SETUP is not complete, just invoke FoxGraph *
- **************************************************
- IF LEN(TRIM(setup7)) = 0
- COMMAND = 'foxgraph /q'
- IF LEN(TRIM(m->setup6)) <> 0
- COMMAND = m->command + ' ' + TRIM(m->setup6)
- ENDIF
- IF m->macstat <> 0
- COMMAND = m->command + IIF(m->macstat=1,' /r:',' /w:')+TRIM(m->macro)
- macstat = 0
- ENDIF
- RUN foxswap &command
- SET COLOR TO N/BG, GR+, BG
- CLEAR
- LOOP
- ENDIF
- *******************************************************
- * Create a temporary data file to be used by FoxGraph *
- *******************************************************
- STORE "3dDATA\FOXGRAPH.DAT" TO graphfile
- page = 1
- SET CONSOLE OFF
- SET ALTERNATE TO &graphfile
- **********************************************
- * Write general graphing information to file *
- **********************************************
- SET ALTERNATE ON
- ?? '"%%Upper_Top_Left: 11, 2, 1%%"'
- ? '"%%Title: 8, 1%%"'
- ? '"%%Subtitle: 8, 2%%"'
- ? '"%%Row_Title: 9, 1%%"'
- ? '"%%Column_Title: 9, 2%%"'
- ? '"%%Row_Headers: 11, 1%%"'
- ? '"%%Column_Headers: 10, 2%%"'
- ? '"'+TRIM(m->setup4)+'" '+'"'+TRIM(m->setup5)+'"'
- ? '"'+TRIM(m->setup8)+'" '+'"'+TRIM(m->setup9)+'"'
- Lines = 9
- counter = 28
- DO WHILE m->counter > 9 && Find out how many columns are used
- s = LTRIM(STR(m->counter))
- IF LEN(TRIM(setup&s)) > 0
- EXIT
- ENDIF
- counter = m->counter - 2
- ENDDO
- COMMAND = "," && Print column headers
- I = 11
- DO WHILE m->i <= m->counter + 1
- s = LTRIM(STR(m->i))
- COMMAND = m->command + [ "] + TRIM(setup&s) + ["]
- I = m->i + 2
- ENDDO
- ? m->command
- Lines = m->lines + 1
- ********************
- * Process the data *
- ********************
- errmsg = 'Only the first 246 rows of data will be graphed'
- IF LEN(DBF()) <> 0
- dbfopen = .T.
- GO TOP
- ELSE
- dbfopen = .F.
- ENDIF
- IF m->setup3 .AND. dbfopen
- I = 10
- DO WHILE m->i <= m->counter
- s = LTRIM(STR(m->i))
- sum&s = 0
- I = m->i + 2
- ENDDO
- sum7 = &setup7 && Note current key value
- DO WHILE .T.
- IF sum7 <> &setup7 .OR. EOF() && Group change??
- I = 10 && Store group summary info in file
- COMMAND = ["]+TRIM(sum7)+["]
- DO WHILE m->i <= m->counter
- s = LTRIM(STR(m->i))
- COMMAND = m->command + "," + STR(sum&s,14,2)
- sum&s = 0
- I = m->i + 2
- ENDDO
- ? m->command
- Lines = m->lines + 1
- sum7 = &setup7 && First element of value
- IF EOF()
- EXIT && Finished last group
- ENDIF
- IF m->lines > 255
- SET ALTERNATE OFF
- SET CONSOLE ON
- DO errmsg
- DO proceed WITH 1
- SET CONSOLE OFF
- SET ALTERNATE ON
- EXIT
- ENDIF
- ENDIF
- I = 10
- DO WHILE m->i <= m->counter && For each column, add to summary
- s = LTRIM(STR(m->i))
- thevalue = setup&s
- IF LEN(TRIM(m->thevalue)) <> 0
- IF thevalue = '+'
- sum&s = sum&s + 1
- ELSE
- sum&s = sum&s + &thevalue
- ENDIF
- ENDIF
- I = m->i + 2
- ENDDO
- SKIP
- ENDDO && WHILE .T.
- ELSE
- DO WHILE .NOT. EOF()
- COMMAND = ["] + TRIM(&setup7) + ["]
- I = 10
- DO WHILE m->i <= m->counter
- s = LTRIM(STR(m->i))
- thevalue = setup&s
- IF LEN(TRIM(thevalue)) <> 0
- IF thevalue = '+'
- COMMAND = m->command + "," + STR(1,14,2)
- ELSE
- COMMAND = m->command + "," + STR(&thevalue,14,2)
- ENDIF
- ENDIF
- I = m->i + 2
- ENDDO
- ? m->command
- Lines = m->lines + 1
- IF .NOT. dbfopen
- EXIT
- ENDIF
- IF m->lines > 255
- SET ALTERNATE OFF
- SET CONSOLE ON
- DO errmsg
- DO proceed WITH 1
- SET CONSOLE OFF
- SET ALTERNATE ON
- EXIT
- ENDIF
- SKIP
- ENDDO
- ENDIF && IF m->sumonly
- ******************************************************
- * Mark the end of the data, close file, and graph it *
- ******************************************************
- ? '"%%Lower_Bottom_Right: '+STR(m->lines);
- +','+STR((m->counter-6)/2)+','+STR(m->page)+'%%"'
- CLOSE ALTERNATE
- SET CONSOLE ON
- COMMAND = 'foxgraph '
- IF LEN(TRIM(m->setup6)) <> 0
- COMMAND = m->command + ' ' + TRIM(m->setup6)
- ENDIF
- IF m->macstat <> 0
- COMMAND = m->command + IIF(m->macstat=1,' /r:',' /w:')+TRIM(m->macro)
- ENDIF
- COMMAND = m->command + ' /q /d:' + graphfile
- IF m->key <> -9 .AND. m->key <> 27
- RUN foxswap &command
- ENDIF
- SET COLOR TO N/BG, GR+, BG
- CLEAR
- IF m->macstat = 2 && Turn off recording mode
- macstat = 0
- ENDIF
- CASE m->themenu = 4
- ****************************************
- * Load and Save graph definition files *
- ****************************************
- @ 0,0 CLEAR TO 23,79
- SET CONFIRM ON
- theitem = 1
- lbm1 = 'Load Definition' + SPACE(24)
- lbm2 = 'Save Definition' + SPACE(24)
- lbrc = '02310331'
- lbstring = 'LB'
- lbprompt = .F.
- @ 1,30 TO 4,70 DOUBLE
- DO WHILE .T.
- line23 = " Position to options - " + CHR(24)+CHR(25) + ;
- ". Select - " + CHR(17)+CHR(217) +". Main Menu - F10. "
- @ 23,0 SAY m->line23
- DO lightbar WITH theitem
- IF m->theitem = 1 && Load a graph definition
- DO WHILE .T.
- COMMAND = ''
- DO getgrf
- IF LEN(m->command) > 0 && Filename was entered
- DO restoreit WITH COMMAND
- IF LEN(TRIM(m->filename)) <> 0 && no errors
- EXIT
- ELSE
- IF LEN(m->loadfile) <> 0
- EXIT
- ENDIF
- ENDIF
- ELSE
- EXIT && Escape pressed
- ENDIF
- ENDDO
- ELSE
- IF m->theitem = 2 && Save a graph definition
- COMMAND = ''
- DO getgrf
- IF LEN(m->command) > 0
- @ 24,0 && Be prepared for overwrite mssg
- @ 23,0
- STORE TRIM(m->macro) TO oldval30
- STORE m->macstat TO oldval31
- SAVE TO &command ALL LIKE oldval*
- @ 22,0 && Erase Please wait mssg
- @ 24,0 && Erase overwrite mssg
- ENDIF
- ELSE
- EXIT
- ENDIF
- ENDIF
- ENDDO
- SET CONFIRM OFF
- CLEAR
- CASE m->themenu = 5
- ****************************************
- * Use or record keyboard macro files *
- ****************************************
- @ 0,0 CLEAR TO 23,79
- SET CONFIRM ON
- theitem = 1
- lbrc = '02310331'
- lbprompt = .F.
- @ 1,30 TO 4,70 DOUBLE
- DO WHILE .T.
- lbm1 = IIF(m->macstat <> 1, 'Activate Macro'+SPACE(25), ;
- LEFT('Deactivate Macro ==> '+m->macro+SPACE(19), 39))
- lbm2 = IIF(m->macstat <> 2, 'Start Recording'+SPACE(24), ;
- LEFT('Stop Recording ==> '+m->macro+SPACE(21), 39))
- lbstring = LEFT(lbm1,1)+LEFT(lbm2,1)
- line23 = " Position to options - " + CHR(24)+CHR(25) + ;
- ". Select - " + CHR(17)+CHR(217) +". Main Menu - F10. "
- @ 23,0 SAY m->line23
- errmsg = IIF(m->macstat=1, 'Macro active - ' + m->macro, ;
- IIF(m->macstat=2, 'Macro recording mode on - ' + m->macro, ;
- 'Macro inactive'))
- DO errmsg
- DO lightbar WITH theitem
- 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
- macstat = 0
- ELSE
- @ 22,0
- DO WHILE .T.
- COMMAND = ''
- DO get3mc
- IF LEN(m->command) > 0
- IF FILE(m->command) && Macro exists
- STORE 1 TO 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
- macstat = 0
- ELSE
- @ 22,0
- COMMAND = ''
- DO get3mc
- IF LEN(m->command) > 0
- macstat = 2
- IF FILE(m->command) && Macro exists
- @ 24,0
- @ 23,78
- WAIT m->command+' already exists, overwrite it (Y/N)? ' TO I
- IF UPPER(m->i) <> 'Y'
- 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 <> -9 .AND. m->key <> 27
- EXIT
- ENDIF
- ENDIF
- ENDCASE
- ENDDO
- DO housekeep
- SET CONSOLE OFF
- CANCEL
- RETURN
- *************************************************************
- * Housekeeping: Restore previous settings *
- *************************************************************
- PROCEDURE housekeep
- ON KEY
- ON ERROR
- SET ESCAPE ON
- SET SCOREBOARD ON
- SET STATUS OFF
- SET BELL ON
- SET CONFIRM OFF
- SET COLOR TO
- IF LEN(m->loadfile) = 0
- SET FUNCTION 'F10' TO 'edit;'
- ENDIF
- CLEAR
- SET TALK ON
- RETURN
- *********************************************************
- * HOTKEY - provide assistance during the READ command *
- *********************************************************
- PROCEDURE hotkey
- @22,0 && Clear message line
- DO CASE
- CASE m->fldnum = 1 && Database field
- CLEAR
- @0,0
- DISPLAY Files LIKE *.dbf
- DO proceed with 5
- DO redraw WITH 30, 24
- CASE m->fldnum = 2 && Index field
- CLEAR
- @ 0,0
- DISPLAY Files LIKE *.ndx
- DO proceed WITH 6
- DO redraw WITH 30, 24
- CASE m->fldnum = 7 .OR. (m->fldnum > 9 .AND. MOD(m->fldnum,2) = 0) && Row and Column values
- STORE 1 TO k, J, counter
- lbrc = '0000001600320048006401000116013201480164' + ;
- '0200021602320248026403000316033203480364' + ;
- '0400041604320448046405000516053205480564' + ;
- '0600061606320648066407000716073207480764'
- lbrc = lbrc + '0800081608320848086409000916093209480964' + ;
- '1000101620321048106411001116113211481164' + ;
- '120012161232'
- STORE '' TO lbstring
- lbprompt = .F.
- IF m->setup3 && Summary only
- IF m->fldnum <> 7
- lbm1 = '+ - Count'
- k = m->k + 1
- ENDIF
- ENDIF
- limit = 1
- DO WHILE LEN(LTRIM(FIELD(m->limit))) <> 0
- limit = m->limit + 1
- ENDDO
- limit = m->limit - 1
- DO WHILE m->counter <= m->limit .AND. m->k < 64 && Initialize popup menu
- s = LTRIM(STR(m->k))
- lbm&s = FIELD(m->counter)
- counter = m->counter + 1
- IF TYPE(lbm&s) = 'N' .OR. fldnum = 7
- lbstring = m->lbstring + LEFT(lbm&s,1)
- k = m->k + 1 && Skip non-numerics for columns
- ENDIF
- ENDDO
- counter = 1
- 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
- @ 0,0 CLEAR TO 21,79
- @ 23,0 say " Position to options - " + CHR(27)+CHR(26) + ;
- ". Select - " + CHR(17)+CHR(217) +". Abort Selection - Esc. "
- DO lightbar WITH J
- s = LTRIM(STR(m->fldnum))
- lbstring = LTRIM(STR(m->j))
- setup&s = LEFT(lbm&lbstring+SPACE(40),40)
- DO redraw WITH 30, 24
- ENDIF
- CASE m->fldnum = 3
- errmsg = 'Summarize data by groups (Y) or graph for all records (N)'
- DO errmsg
- CASE m->fldnum = 4
- errmsg = 'Enter title to appear at the top of the graph display'
- DO errmsg
- CASE m->fldnum = 5
- errmsg = 'Enter subtitle to appear at the bottom of the graph display'
- DO errmsg
- CASE m->fldnum = 8 .OR. (m->fldnum > 8 .AND. MOD(m->fldnum,2) = 1)
- 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
- CASE m->fldnum = 6
- CLEAR
- @ 0,0
- DISPLAY Files LIKE 3dlooks\*.3gr
- DO proceed WITH 7
- DO redraw WITH 30,24
- ENDCASE
- RETURN
- ****************************************************
- * VALIDATE - Controlling routine to validate READs *
- ****************************************************
- PROCEDURE validate
- DO CASE
- CASE m->fldnum = 1
- DO opendbf
- CASE m->fldnum = 2
- DO openndx
- CASE m->fldnum = 7
- DO rowval
- CASE m->fldnum > 9 .AND. MOD(m->fldnum,2) = 0
- DO colval
- OTHERWISE
- DO genval
- ENDCASE
- RETURN
- *********************************************************
- * OPENDBF - open the selected dbf *
- *********************************************************
- PROCEDURE opendbf
- @ 22,0
- DO tracker
- IF m->fldnum = 0
- RETURN
- ENDIF
- IF m->oldval1 <> m->setup1 && value changed
- STORE SPACE(50) TO setup2, oldval2 && Clear index field
- USE &setup1
- IF LEN(DBF()) = 0 .AND. LEN(TRIM(m->setup1))<>0 && dbf not successfully opened
- fldnum = 1
- RETURN
- ENDIF
- oldval1 = m->setup1
- ENDIF
- IF LEN(DBF()) = 0 .AND. m->fldnum = 2 && If no dbf, then no index
- fldnum = 4 && ... and no summary
- ENDIF
- IF m->fldnum <> 2
- DO redraw WITH 7, 4
- ENDIF
- RETURN
- *************************************************************
- * OPENNDX - open the selected index *
- *************************************************************
- PROCEDURE openndx
- @ 22,0
- DO tracker
- IF m->fldnum = 0
- RETURN
- ENDIF
- IF m->oldval2 <> m->setup2 && value changed
- oldfld = 2
- SET INDEX TO &setup2 && Try opening index
- IF LEN(TRIM(m->setup2)) <> 0 && Index name entered
- IF m->fldnum = 2
- RETURN
- ENDIF
- GO BOTT && Test out the index
- SKIP
- IF .NOT. EOF()
- fldnum = 2
- RETURN
- ENDIF
- ndxopen = .T.
- ELSE && index name erased
- ndxopen = .F.
- ENDIF
- oldval2 = m->setup2
- * STORE SPACE(40) TO setup7, oldval7
- STORE ndxopen TO setup3, oldval3
- IF m->fldnum <> 3
- DO redraw WITH 7, 4
- ENDIF
- ENDIF
- RETURN
- ***************************************************************
- * ROWVAL - make sure that the row value is a valid expression *
- ***************************************************************
- PROCEDURE rowval
- @ 22,0
- IF m->oldval7 <> m->setup7
- IF TYPE(m->setup7) <> 'C' .AND. LEN(TRIM(m->setup7)) <> 0
- errmsg = "Row definition must be a character expression"
- DO errmsg
- RETURN
- ENDIF
- oldval7 = m->setup7
- ENDIF
- DO tracker
- RETURN
- *************************************************************
- * COLVAL - check to see that column values are valid *
- *************************************************************
- PROCEDURE colval
- @ 22,0
- s = LTRIM(STR(m->fldnum))
- IF oldval&s <> setup&s
- IF TYPE(setup&s) <> 'N' .AND. setup&s <> '+' .AND. ;
- LEN(TRIM(setup&s)) > 0
- errmsg = 'Column definitions must be valid numeric expressions'
- DO errmsg
- RETURN
- ENDIF
- oldval&s = setup&s
- ENDIF
- DO tracker
- RETURN
- *************************************************************
- * GENVAL - general validation routine *
- *************************************************************
- PROCEDURE genval
- @ 22,0
- s = LTRIM(STR(m->fldnum))
- oldval&s = setup&s
- oldfld = m->fldnum
- DO tracker
- IF LEN(DBF()) = 0 .AND. m->fldnum = 3 .AND. m->oldfld = 4
- fldnum = 1
- ENDIF
- RETURN
- *************************************************************
- * TRACKER - track which GET field we are on currently *
- *************************************************************
- PROCEDURE tracker
- KEY = MOD(READKEY(),256)
- DO CASE
- CASE KEY = 15 .OR. KEY = 1 .OR. KEY = 3 .OR. KEY = 5 && Forward
- fldnum = m->fldnum + 1
- CASE KEY = 0 .OR. KEY = 2 .OR. KEY = 4 && Backward
- fldnum = m->fldnum - 1
- CASE KEY = 12 && Escape
- fldnum = 0
- CASE KEY = 14 .OR. KEY = 6 .OR. KEY = 7 && Save
- fldnum = 30
- CASE KEY = 36 && Help
- DO hotkey
- ENDCASE
- RETURN
- ************************************************
- * 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 = -9 .OR. 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. When you display summary information, 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 distinct 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 contain a value for each column that
- you define. Keep in mind, column definitions may include numeric operations
- for scaling or other manipulation of data values.
-
- When you display summary information on a database, the special expression '+'
- is available in addition to normally valid numeric expressions. The '+' ex-
- pression 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 number 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 = -9 .OR. 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
- 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 mnum
- @ 24,0
- SET COLOR TO GR+/N
- DO CASE
- CASE mnum = 1 && Proceed with graph generation?
- @ 24,0 SAY ' F10 - Main Menu. Any other key - Proceed.';
- + SPACE(19)
- CASE mnum = 2 && Proceed with help screens?
- @ 24,0 SAY ' F10 - Main Menu. Any other key - Continue.';
- + SPACE(18)
- CASE mnum = 3 && Proceed with exiting?
- @ 24,0 SAY ' F10 - Main Menu. Any other key - Exit.';
- + SPACE(20)
- CASE mnum = 4 && Proceed with exiting?
- @ 24,0 SAY ' Press any key to exit.';
- + SPACE(29)
- CASE mnum = 5
- @ 24,0 SAY " Directory listing of databases - Press any key to continue.";
- + SPACE(10)
- CASE mnum = 6
- @ 24,0 SAY " Directory listing of indexes - Press any key to continue.";
- + SPACE(11)
- CASE mnum = 7
- @ 24,0 SAY " Directory listing of graph styles - Press any key to continue.";
- + SPACE(9)
- CASE mnum = 8
- @ 24,0 SAY " Directory listing of setup definitions - Press any key to continue.";
- + SPACE(6)
- CASE mnum = 9
- @ 24,0 SAY " Directory listing of keyboard macros - Press any key to continue.";
- + SPACE(7)
- ENDCASE
- SET COLOR TO N/BG
- IF m->mnum = 1 .OR. m->mnum = 4
- ?? CHR(7)
- ENDIF
- KEY = 0
- DO WHILE m->key = 0
- KEY = INKEY()
- ENDDO
- CLEAR
- RETURN
- *************************************************************
- * ERRHAND - General error handling routine *
- *************************************************************
- PROCEDURE errhand
- @ 22,0
- errmsg = MESSAGE()
- DO CASE
- CASE ERROR() = 6 .OR. ERROR() = 21 .OR. ERROR() = 43 .OR. ERROR() = 1310 ;
- .OR. ERROR() = 1410 .OR. (dbxl .AND. ERROR() < 6)
- IF dbxl
- pos = AT(':', m->errmsg)
- errmsg = IIF(m->pos > 0, LEFT(m->errmsg, m->pos - 1), m->errmsg)
- ENDIF
- errmsg = m->errmsg + ' - Check CONFIG file values'
- DO errmsg
- DO proceed WITH 4
- DO housekeep
- RETURN TO MASTER
- CASE m->oldfld = 2
- errmsg = 'Invalid index file'
- fldnum = 2
- CASE ERROR() = 55
- filename = SPACE(50)
- 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+/GB
- @ 22,COL() SAY m->errmsg
- SET COLOR TO GR+*/BG
- @ 22,COL() SAY " >>"
- @ 22,COL()
- SET COLOR TO N/BG
- RETURN
- ************************************
- * MAINMENU - Display the main menu *
- ************************************
- PROCEDURE mainmenu
- lbm1 = 'Setup'
- lbm2 = 'Help'
- lbm3 = 'Draw'
- lbm4 = 'Files'
- lbm5 = 'Macros'
- lbm6 = 'Exit'
- lbp1 = "Setup parameters and values for the graph"
- lbp2 = "Display general information about FoxGraph"
- lbp3 = "Build temporary files, and display/modify graph"
- lbp4 = "Load or save graph definition from/to file"
- lbp5 = "Use or record keyboard macros from/to file"
- lbp6 = "Exit FoxGraph"
- lbstring = 'SHDFME'
- lbprompt = .T.
- lbrc = '000000100020003000400050'
- @ 22,0
- @ 23,0
- DO lightbar WITH themenu
- IF m->themenu = 0
- themenu = 6
- ENDIF
- RETURN
- ********************************************************************
- * LIGHTBAR - Generic routine to replace @ ... PROMPT/MENU commands *
- ********************************************************************
- PROCEDURE lightbar
- * Calling seqence:
- * Assign menu items to lbm1 ...lbmn
- * Assign corresponding prompts to lbp1 ... lbpn
- * Assign corresponding row and column numbers to lbrc
- * Assign corresponding letters to lbstring
- * Assign .t. or .f. to lbprompt
- PARAMETER which
- choices = LEN(lbstring)
- oldchoice = -1
- DO WHILE .T.
- IF m->oldchoice = -1
- N = 1
- DO WHILE m->n <= m->choices
- mstr = LTRIM(STR(m->n))
- @ VAL(SUBSTR(m->lbrc,m->n*4-3,2)), VAL(SUBSTR(m->lbrc,m->n*4-1,2)) SAY lbm&mstr
- N = m->n + 1
- ENDDO
- ELSE
- mstr = LTRIM(STR(m->oldchoice))
- @ VAL(SUBSTR(m->lbrc,m->oldchoice*4-3,2)), VAL(SUBSTR(m->lbrc,m->oldchoice*4-1,2)) SAY lbm&mstr
- ENDIF
- oldchoice = which
- mstr = LTRIM(STR(which))
- @ VAL(SUBSTR(lbrc,which*4-3,2)), VAL(SUBSTR(lbrc,which*4-1,2)) GET lbm&mstr && Highlight current choice
- IF lbprompt && Display prompt, if any
- @ 24,0
- N = (80 - LEN(lbp&mstr))/2
- @ 24,N SAY lbp&mstr
- ENDIF
- N = 0
- DO WHILE N <= 0 && Capture input key
- N = INKEY()
- IF n = -9
- n = IIF(lbprompt, 0, 27)
- ENDIF
- ENDDO
- DO CASE
- CASE N = 4 .OR. N = 24 && Right or down arrow
- which = m->which + 1
- IF m->which > choices
- which = 1
- ENDIF
- CASE N = 19 .OR. N = 5 && Left or up arrow
- which = m->which - 1
- IF m->which < 1
- which = choices
- ENDIF
- CASE N = 1 .OR. N = 18 && Home or PgUp
- which = 1
- CASE N = 6 .OR. N = 3 && End or PgDn
- which = choices
- CASE N = 13 && Carriage return
- EXIT
- CASE N = 27
- which = 0
- EXIT
- OTHERWISE && Was a letter entered?
- N = AT(UPPER(CHR(N)), lbstring)
- IF N <> 0
- which = N
- IF lbprompt && Display prompt, if any
- mstr = LTRIM(STR(m->which))
- @ 24,0
- N = (80 - LEN(lbp&mstr))/2
- @ 24,N SAY lbp&mstr
- ENDIF
- EXIT
- ENDIF
- ENDCASE
- CLEAR GETS
- ENDDO
- CLEAR GETS
- RETURN
- ***********************************************
- * REDRAW - Routine to redraw the setup screen *
- ***********************************************
- PROCEDURE redraw
- PARAMETER fldno, lineno
- IF m->fldno = 30 .AND. m->lineno = 24 && Full redraw
- @ 0,0 CLEAR TO lineno,79
- @ 0,0
- TEXT
-
- Database Graph Title
- Index Graph Subtitle
- Summary Only? Graph Style
-
- Row Definition Row Title
- Columns Title
-
-
- Column Definitions Headers
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- ENDTEXT
- @ 1,0 TO 21,79 DOUBLE
- ENDIF
- k = 1
- DO WHILE m->k < m->fldno
- s = LTRIM(STR(k))
- fcode = '@' + IIF(k < 10, IIF(k = 3, ' y', 's20'), 's30')
- @ VAL(SUBSTR(rc,k*4-3,2)),VAL(SUBSTR(rc,k*4-1,2)) GET setup&s PICTURE fcode
- k = k + 1
- ENDDO
- @ 23,0 SAY m->line23
- CLEAR GETS
- RETURN
- ******************************************************************
- * GETGRF - Get user to input the name of a setup definition file *
- ******************************************************************
- PROCEDURE getgrf
- line23 = " Enter file name - Finish with " + ;
- CHR(17)+CHR(217) + ". Help - F1. Abort Entry - Esc."
- DO WHILE .T.
- IF LEN(m->loadfile) = 0
- @ 23,0 SAY m->line23
- filename = IIF(LEN(m->filename) > 50, m->filename, LEFT(m->filename+SPACE(50), 50))
- @ m->theitem+1,47 GET m->arrow
- CLEAR GETS
- @ m->theitem+1,48 GET m->filename FUNCTION "@s22"
- READ
- KEY = MOD(READKEY(),256)
- IF m->key = 36
- CLEAR
- @ 0,0
- DISP Files LIKE *.gr3
- DO proceed WITH 8
- CLEAR
- IF m->theitem = 1
- @ 02,31 GET lbm1
- @ 03,31 SAY lbm2
- ELSE
- @ 02,31 SAY lbm1
- @ 03,31 GET lbm2
- ENDIF
- CLEAR GETS
- @ 23,0 SAY m->line23
- @ 1,30 TO 4,70 DOUBLE
- LOOP
- ENDIF
- ENDIF
- IF m->key <> 12 .AND. LEN(TRIM(m->filename)) > 0
- I = AT('.', m->filename) + 1
- IF m->i > 1
- filename = STUFF(m->filename,m->i,LEN(SUBSTR(m->filename,m->i)),'gr3')
- ELSE
- filename = TRIM(m->filename) + '.gr3'
- ENDIF
- COMMAND = TRIM(m->filename)
- IF LEN(m->loadfile) = 0
- errmsg = IIF(m->theitem = 1,"Loading ","Saving ")+m->command+" - Please wait"
- DO errmsg
- ENDIF
- ENDIF
- EXIT
- ENDDO
- RETURN
- *******************************************************
- * GET3MC - Get user to input the name of a macro file *
- *******************************************************
- PROCEDURE get3mc
- @ 22,0
- DO WHILE .T.
- macro = IIF(LEN(m->macro) > 50, m->macro, LEFT(m->macro+SPACE(50), 50))
- @ m->theitem+1,47 GET m->arrow
- CLEAR GETS
- @ m->theitem+1,48 GET m->macro FUNCTION "@s22"
- READ
- KEY = MOD(READKEY(),256)
- IF m->key = 36
- CLEAR
- @ 0,0
- DISP Files LIKE *.3mc
- DO proceed WITH 9
- CLEAR
- IF m->theitem = 1
- @ 02,31 GET lbm1
- @ 03,31 SAY lbm2
- ELSE
- @ 02,31 SAY lbm1
- @ 03,31 GET lbm2
- ENDIF
- CLEAR GETS
- @ 23,0 SAY m->line23
- @ 1,30 TO 4,70 DOUBLE
- LOOP
- ENDIF
- IF m->key <> 12 .AND. LEN(TRIM(m->macro)) > 0
- I = AT('.', m->macro) + 1
- IF m->i > 1
- macro = STUFF(m->macro,m->i,LEN(SUBSTR(m->macro,m->i)),'3mc')
- ELSE
- macro = TRIM(m->macro) + '.3mc'
- ENDIF
- COMMAND = TRIM(m->macro)
- ENDIF
- EXIT
- ENDDO
- RETURN
- **********************************************************
- * RESTOREIT - Restore setup information from a save file *
- **********************************************************
- PROCEDURE restoreit
- PARAMETER savefile
- IF .NOT. FILE(savefile)
- errmsg = 'File does not exist'
- DO errmsg
- filename = SPACE(50)
- ELSE
- RESTORE FROM &savefile ADDITIVE
- IF LEN(TRIM(m->filename)) <> 0 && no errors
- @ 22,0 && Erase Please wait mssg
- I = 1
- DO WHILE m->i < 32
- s = LTRIM(STR(m->i))
- setup&s = oldval&s
- I = m->i + 1
- ENDDO
- IF LEN(TRIM(m->setup1)) > 0
- IF LEN(TRIM(m->setup2)) > 0
- USE &setup1 INDEX &setup2
- ELSE
- USE &setup1
- ENDIF
- ELSE
- USE
- ENDIF
- ENDIF
- ENDIF
- RETURN
- *: EOF: G3.PRG