home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-03-23 | 33.9 KB | 1,069 lines |
- *:*********************************************************************
- *:
- *: Program: GPRO.PRG
- *:
- *: System: gpro.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 GPRO.PRG)
- *:
- *: Documented: 01/24/89 at 11:14 FoxDoc version 1.0
- *:*********************************************************************
- PARAMETER loadfile
- DO main
- PROCEDURE main
- RELEASE ALL EXCEPT loadfile
- PUBLIC FOX
- DECLARE sum[12]
- DECLARE setup[32], oldval[32]
- **************************************************************
- * Save existing environment and set up FoxGraph environment *
- **************************************************************
- IF SET('TALK') = '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 .f. TO m->errflag
- STORE SET("CONFIRM") TO save_conf && Save CONFIRM setting
- STORE SET("BELL") TO save_bell && Save BELL setting
- STORE SET("STATUS") TO save_stat && Save STATUS setting
- STORE SET("SCOREBOARD") TO save_score && Save SCOREBOARD setting
- STORE SET("ESCAPE") TO save_escap && Save ESCAPE setting
- STORE SET("FULLPATH") TO save_path && Save FULLPATH setting
- STORE SET("SAFETY") TO save_safe && Save SAFETY setting
- ON KEY LABEL F1 DO hotkey && Set F1 to 'HELP' key
- SET CONFIRM OFF
- SET BELL OFF
- SET STATUS OFF
- SET SCOREBOARD OFF
- SET ESCAPE OFF
- SET TYPEAHEAD TO 128
- SET FULLPATH ON
- SET SAFETY OFF
- normal = IIF(SET("COLOR") = 'ON', 'n/bg, gr+/n, bg', '')
- inverse = IIF(SET("COLOR") = 'ON', 'GR+/N', 'N/W')
- SET COLOR TO &normal
- CLEAR
- RESTORE MACROS FROM foxgraph
- *************************
- * Initialize GET fields *
- *************************
- STORE IIF(LEN(DBF()) > 50, DBF(), LEFT(DBF()+SPACE(50),50)) TO setup[1]
- IF LEN(ORDER()) = 0 && No active indexes
- STORE SPACE(50) TO setup[2]
- STORE .F. TO setup[3]
- ELSE
- STORE LEFT(ORDER()+SPACE(50),50) TO setup[2]
- STORE .T. TO setup[3]
- ENDIF
- i = 4
- DO WHILE m->i < 30
- STORE SPACE(40) TO setup[m->i]
- m->i = m->i + 1
- ENDDO
- ******************************
- * Initialize other variables *
- ******************************
- STORE 0 TO m->macstat, m->key, m->fldnum
- STORE SPACE(50) TO m->filename, m->macro
- STORE .f. TO gotpopup
- STORE TRIM(m->loadfile) TO loadfile
- *******************************
- * Define menu bars and popups *
- *******************************
- DEFINE MENU main
- DEFINE PAD setup OF main PROMPT "Setup" AT 0,0 MESSAGE ;
- "Setup parameters and values for the graph"
- DEFINE PAD help OF main PROMPT "Help" AT 0,10 MESSAGE ;
- "Display general information about FoxGraph"
- DEFINE PAD draw OF main PROMPT "Draw" AT 0,20 MESSAGE ;
- "Build temporary files, and display/modify graph"
- DEFINE PAD files OF main PROMPT "Files" AT 0,30 MESSAGE ;
- "Load or save graph definition from/to file"
- DEFINE PAD macros OF main PROMPT "Macros" AT 0,40 MESSAGE ;
- "Use or record keyboard macros from/to file"
- DEFINE PAD exit OF main PROMPT "Exit" AT 0,50 MESSAGE ;
- "Exit FoxGraph"
-
- ON SELECTION PAD setup OF main DO setup
- ON SELECTION PAD help OF main DO Help
- ON SELECTION PAD draw OF main DO Draw
- ON SELECTION PAD files OF main DO Files
- ON SELECTION PAD macros OF main DO Macros
- ON SELECTION PAD exit OF main DO Exit
- **************************
- * Main menu control loop *
- **************************
- IF LEN(m->loadfile) = 0
- m->i = 1
- DO WHILE m->i < 31
- oldval[m->i] = setup[m->i]
- m->i = m->i + 1
- ENDDO
- SET FUNCTION 'F10' TO CHR(27)
- DO WHILE .T.
- ACTIVATE MENU main
- IF LEN(PROMPT()) = 0 && Escape was hit
- DO exit
- ENDIF
- IF m->key <> -9 .AND. m->key <> 27
- EXIT
- ENDIF
- ENDDO
- ELSE
- filename = m->loadfile
- DO getgrf
- DO restoreit WITH filename
- IF .NOT. m->errflag
- DO draw
- ENDIF
- DO exit
- ENDIF
-
-
- *********************************************************************
- * SETUP - Collect information for designing the graph *
- *********************************************************************
- PROCEDURE setup
- @ 0,0
- DEFINE POPUP dbf FROM 3,12 TO 20,25 PROMPT FILES LIKE *.dbf
- ON SELECTION POPUP dbf DO getpopup
- DEFINE POPUP ndx FROM 3,12 TO 20,25 PROMPT FILES LIKE *.ndx
- ON SELECTION POPUP ndx DO getpopup
- DEFINE POPUP style FROM 3,12 TO 20,25 PROMPT FILES LIKE 3dlooks\*.3gr
- ON SELECTION POPUP style DO getpopup
- DEFINE POPUP fields FROM 3,12 TO 20,23 PROMPT STRUCTURE
- ON SELECTION POPUP fields DO getpopup
- m->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
- SET FUNCTION 'F10' TO CHR(3)
- DO WHILE m->fldnum > 0 .AND. m->fldnum < 30
- 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[m->fldnum] PICTURE fcode valid validate()
- SET CONFIRM ON
- READ
- SET CONFIRM OFF
- ENDDO
- fldnum = 0
- @ 22,0
- @ 23,0
- SET FUNCTION 'F10' TO CHR(27)
- *******************************************
- * HELP - All about the FoxGraph interface *
- *******************************************
- PROCEDURE help
- CLEAR
- 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
- 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 more convenient-
- ly generate the graph again. 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
- @ 22,0
- @ 23,0
- RETURN
- *************************************************************
- * Call FoxGraph with name of file containing graph info *
- *************************************************************
- PROCEDURE draw
- ********************************
- * See if they want to continue *
- ********************************
- IF LEN(m->loadfile) = 0
- errmsg = "Proceed with graph generation" + IIF(m->macstat = 1, ;
- " - Macro Active", IIF(m->macstat = 2, " - Recording Macro", ""))
- DO errmsg
- DO proceed with 1
- IF m->key = -9 .OR. m->key = 27
- RETURN
- ENDIF
- ENDIF
- m->key = 0
- errmsg = "Building data files - Please wait"
- DO errmsg
- **************************************************
- * If SETUP is not complete, just invoke FoxGraph *
- **************************************************
- IF LEN(TRIM(setup[7])) = 0
- command = 'foxgraph /q'
- IF LEN(TRIM(setup[6])) <> 0
- command = m->command + ' ' + TRIM(setup[6])
- ENDIF
- IF m->macstat <> 0
- command = m->command + IIF(m->macstat=1,' /r:',' /w:')+TRIM(macro)
- macstat = 0
- ENDIF
- IF FOX
- &command
- ELSE
- RUN foxswap &command
- CLEAR
- ENDIF
- RETURN
- 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(setup[4])+'" '+'"'+TRIM(setup[5])+'"'
- ? '"'+TRIM(setup[8])+'" '+'"'+TRIM(setup[9])+'"'
- lines = 9
- counter = 28
- DO WHILE m->counter > 9 && Find out how many columns are used
- IF LEN(TRIM(setup[m->counter])) > 0
- EXIT
- ENDIF
- counter = m->counter - 2
- ENDDO
- COMMAND = "," && Print column headers
- I = 11
- DO WHILE m->i <= m->counter + 1
- COMMAND = m->command + [ "] + TRIM(setup[m->i]) + ["]
- 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 setup[3] .AND. dbfopen
- I = 10
- DO WHILE m->i <= m->counter
- STORE 0 TO sum[m->i]
- I = m->i + 2
- ENDDO
- STORE &setup[7] TO sum[7] && Note current key value
- DO WHILE .T.
- IF sum[7] <> &setup[7] .OR. EOF() && Group change??
- I = 10 && Store group summary info in file
- command = ["]+TRIM(sum[7])+["]
- DO WHILE m->i <= m->counter
- command = m->command + "," + STR(sum[m->i],14,2)
- STORE 0 TO sum[m->i]
- I = m->i + 2
- ENDDO
- ? m->command
- Lines = m->lines + 1
- STORE &setup[7] TO sum[7] && First element of value
- IF EOF()
- EXIT && Finished last group
- ELSE
- 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
- ENDIF
- I = 10
- DO WHILE m->i <= m->counter && For each column, add to summary
- thevalue = setup[m->i]
- IF m->thevalue = '+'
- STORE sum[m->i] + 1 TO sum[m->i]
- ELSE
- STORE sum[m->i] + &thevalue TO sum[m->i]
- ENDIF
- I = m->i + 2
- ENDDO
- SKIP
- ENDDO && WHILE .T.
- ELSE
- DO WHILE .NOT. EOF()
- command = ["] + TRIM(&setup[7]) + ["]
- I = 10
- DO WHILE m->i <= m->counter
- thevalue = setup[m->i]
- IF LEN(TRIM(m->thevalue)) <> 0
- IF m->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
- ELSE
- 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
- 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(setup[6])) <> 0
- command = m->command + ' ' + TRIM(setup[6])
- 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
- IF FOX
- &command
- ELSE
- RUN foxswap &command
- ENDIF
- ENDIF
- CLEAR
- IF m->macstat = 2 && Turn off recording mode
- macstat = 0
- ENDIF
- RETURN
- ************************************************
- * FILES - Load and Save graph definition files *
- ************************************************
- PROCEDURE files
- @ 0,0 CLEAR TO 23,79
- line23 = " Position to options - " + CHR(24)+CHR(25) + ;
- ". Select - " + CHR(17)+CHR(217) +". Main Menu - Esc. "
- SET CONFIRM ON
- DEFINE POPUP grf FROM 3,12 TO 20,25 PROMPT FILES LIKE *.gr4
- ON SELECTION POPUP grf DO getpopup
- DEFINE POPUP files FROM 1,30
- DEFINE BAR 1 OF files PROMPT ' ' SKIP
- DEFINE BAR 2 OF files PROMPT 'Load Definition' + SPACE(24) ;
- MESSAGE 'Load graph definition from file'
- DEFINE BAR 3 OF files PROMPT 'Save Definition' + SPACE(24) ;
- MESSAGE 'Save graph definition to file'
- DEFINE BAR 4 OF files PROMPT ' ' SKIP
- ON SELECTION POPUP files DO dofiles
- @ 23,0 SAY m->line23
- ACTIVATE POPUP files
- SET CONFIRM OFF
- CLEAR
- fldnum = 0
- RETURN
- ****************************************
- * Use or record keyboard macro files *
- ****************************************
- PROCEDURE macros
- @ 0,0 CLEAR TO 23,79
- line23 = " Position to options - " + CHR(24)+CHR(25) + ;
- ". Select - " + CHR(17)+CHR(217) +". Main Menu - Esc. "
- msg1 = 'Activate/Deactivate macro file for controlling a FoxGraph session'
- msg2 = 'Turn keyboard recording mode on/off during FoxGraph session'
- SET CONFIRM ON
- DEFINE POPUP threemc FROM 3,12 TO 20,25 PROMPT FILES LIKE *.3mc
- ON SELECTION POPUP threemc DO getpopup
- DEFINE POPUP macros FROM 1,30
- DEFINE BAR 1 OF macros PROMPT ' ' SKIP
- DEFINE BAR 2 OF macros PROMPT IIF(m->macstat <> 1, 'Activate Macro' + SPACE(25), ;
- LEFT('Deactivate Macro ==> '+m->macro+SPACE(19), 39)) MESSAGE msg1
- DEFINE BAR 3 OF macros PROMPT IIF(m->macstat <> 2, 'Start Recording' + SPACE(24), ;
- LEFT('Stop Recording ==> '+m->macro+SPACE(21), 39)) MESSAGE msg2
- DEFINE BAR 4 OF macros PROMPT ' ' SKIP
- ON SELECTION POPUP macros DO domacros
- @ 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
- ACTIVATE POPUP macros
- SET CONFIRM OFF
- CLEAR
- fldnum = 0
- RETURN
- ********************
- * EXIT - All done? *
- ********************
- PROCEDURE exit
- IF LEN(m->loadfile) = 0
- @ 0,0
- DO proceed WITH 3
- IF m->key = -9 .OR. m->key = 27
- RETURN
- ENDIF
- ENDIF
- DO housekeep
- DEACTIVATE MENU
- RETURN
- ******************************************
- * HOUSEKEEP - Try to restore environment *
- ******************************************
- PROCEDURE housekeep
- DEACTIVATE MENU
- RELEASE POPUPS
- RELEASE MENUS
- 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 COLOR TO
- SET FULLPATH &save_path
- SET SAFETY &save_safe
- SET TALK &save_talk
- IF LEN(m->loadfile) = 0
- SET FUNCTION 'F10' TO 'edit;'
- ENDIF
- CLEAR
- RETURN
- *********************************************************
- * HOTKEY - provide assistance during the READ command *
- *********************************************************
- PROCEDURE hotkey
- m->pop23 = " Position to options - " + CHR(24)+CHR(25) + ;
- ". Select - " + CHR(17)+CHR(217) +". Abort Selection - Esc. "
-
- DO CASE
- CASE m->fldnum = 1 && Database field
- ON KEY
- errmsg = "Select a database for the graph"
- DO errmsg
- @ 23,0 SAY m->pop23
- ACTIVATE POPUP dbf
- CASE m->fldnum = 2 && Index field
- ON KEY
- errmsg = "Select an index file for grouping data"
- DO errmsg
- @ 23,0 SAY m->pop23
- ACTIVATE POPUP ndx
- CASE m->fldnum = 6
- ON KEY
- errmsg = 'Select format for initial graph display'
- DO errmsg
- @ 23,0 SAY m->pop23
- ACTIVATE POPUP style
- CASE m->fldnum = 30 && Setup definition file
- ON KEY
- errmsg = "Select graph definition file name"
- DO errmsg
- @ 23,0 SAY m->pop23
- ACTIVATE POPUP grf
- filename = prompt()
- CASE m->fldnum = 31 && Macro file
- ON KEY
- errmsg = "Select keyboard macro file name"
- DO errmsg
- @ 23,0 SAY m->pop23
- ACTIVATE POPUP threemc
- macro = prompt()
- CASE m->fldnum = 7 .OR. (m->fldnum > 9 .AND. MOD(m->fldnum,2)=0) && Row and Column values
- errmsg = IIF(m->fldnum = 7, "Select an expression for the row definition",;
- "Select a numeric expression for the column definition")
- DO errmsg
- @ 23,0 SAY m->pop23
- ACTIVATE POPUP fields
- CASE m->fldnum = 3
- errmsg = 'Summarize data by groups (Y) or graph for all records (N)'
- DO errmsg
- RETURN
- CASE m->fldnum = 4
- errmsg = 'Enter title to appear at the top of the graph display'
- DO errmsg
- RETURN
- CASE m->fldnum = 5
- errmsg = 'Enter subtitle to appear at the bottom of the graph display'
- DO errmsg
- RETURN
- CASE m->fldnum = 8
- errmsg = 'Enter row title to appear along the row axis of the graph'
- DO errmsg
- RETURN
- CASE m->fldnum = 9
- errmsg = 'Enter column title to appear along the column axis of the graph'
- DO errmsg
- RETURN
- CASE m->fldnum > 10 .AND. MOD(m->fldnum,2) = 1
- errmsg = 'Enter column header to appear below the corresponding column'
- DO errmsg
- RETURN
- OTHERWISE
- RETURN
- ENDCASE
- IF gotpopup
- PLAY MACRO F9
- ENDIF
- @ 23,0
- @ 23,0 SAY m->line23
- ON KEY LABEL F1 DO hotkey
- RETURN
- *********************************************************
- * OPENDBF - open the selected dbf *
- *********************************************************
- FUNCTION opendbf
- @ 22,0
- IF m->gotpopup
- gotpopup = .f.
- m->fldnum = 1
- setup[1] = IIF(LEN(PROMPT()) > 50, PROMPT(), LEFT(PROMPT()+SPACE(50),50))
- RETURN .T.
- ELSE
- DO tracker
- ENDIF
- IF oldval[1] <> setup[1] && value changed
- USE TRIM(setup[1])
- IF LEN(ALIAS())=0 .AND. LEN(TRIM(setup[1]))<>0 && dbf not successfully opened
- fldnum = 1
- RETURN .F.
- ENDIF
- oldval[1] = setup[1]
- STORE SPACE(50) TO setup[2], oldval[2] && Clear index field
- ENDIF
- RETURN .T.
- *************************************************************
- * OPENNDX - open the selected index *
- *************************************************************
- FUNCTION openndx
- @ 22,0
- IF m->gotpopup
- gotpopup = .f.
- m->fldnum = 2
- setup[2] = IIF(LEN(PROMPT()) > 50, PROMPT(), LEFT(PROMPT()+space(50),50))
- RETURN .T.
- ELSE
- DO tracker
- ENDIF
- IF .NOT. (oldval[2] = setup[2]) && value changed
- oldfld = 2
- SET INDEX TO TRIM(setup[2])
- IF LEN(TRIM(setup[2])) <> 0 && index name entered
- IF LEN(ORDER())=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
- oldval[2] = setup[2]
- * STORE SPACE(40) TO setup[7], oldval[7]
- STORE IIF(ndxopen, .T., .F.) TO setup[3], oldval[3]
- ENDIF
- RETURN .T.
- ***************************************************************
- * ROWVAL - make sure that the row value is a valid expression *
- ***************************************************************
- FUNCTION rowval
- @ 22,0
- IF m->gotpopup
- gotpopup = .f.
- setup[7] = IIF(LEN(PROMPT()) > 40, PROMPT(), LEFT(PROMPT()+SPACE(40),40))
- RETURN .T.
- ENDIF
- IF oldval[7] <> setup[7]
- IF TYPE(setup[7]) <> 'C' .AND. LEN(TRIM(setup[7])) <> 0
- errmsg = "Row definition must be a character expression"
- DO errmsg
- RETURN .F.
- ENDIF
- oldval[7] = setup[7]
- ENDIF
- DO tracker
- RETURN .T.
- *************************************************************
- * COLVAL - check to see that column values are valid *
- *************************************************************
- FUNCTION colval
- @ 22,0
- IF gotpopup
- gotpopup = .f.
- setup[m->fldnum] = IIF(LEN(PROMPT()) > 40, PROMPT(), LEFT(PROMPT()+SPACE(40),40))
- RETURN .T.
- ENDIF
- IF oldval[m->fldnum] <> setup[m->fldnum]
- IF TYPE(setup[m->fldnum]) <> 'N' .AND. setup[m->fldnum] <> '+' .AND. ;
- LEN(TRIM(setup[m->fldnum])) > 0
- errmsg = 'Column definitions must be valid numeric expressions'
- DO errmsg
- RETURN .F.
- ENDIF
- oldval[m->fldnum] = setup[m->fldnum]
- ENDIF
- DO tracker
- RETURN .T.
- *************************************************************
- * GENVAL - general validation routine *
- *************************************************************
- FUNCTION genval
- @ 22,0
- IF m->gotpopup
- gotpopup = .f.
- m->fldnum = 6
- setup[6] = IIF(LEN(PROMPT()) > 40, PROMPT(), LEFT(PROMPT()+SPACE(40),40))
- RETURN .T.
- ENDIF
- oldval[m->fldnum] = setup[m->fldnum]
- DO tracker
- IF LEN(ALIAS()) = 0 .AND. fldnum = 3 .AND. oldfld = 4
- fldnum = 1
- ENDIF
- RETURN .T.
- *************************************************************
- * TRACKER - track which GET field we are on currently *
- *************************************************************
- PROCEDURE tracker
- key = MOD(READKEY(),256)
- DO CASE
- CASE key = 0 .OR. key = 2 .OR. key = 4 && Go back one
- fldnum = m->fldnum - 1
- CASE key = 1 .OR. key = 3 .OR. key = 5 .OR. key = 15 .OR. key = 16
- fldnum = m->fldnum + 1
- CASE key = 12
- fldnum = 0
- CASE key = 14 .OR. key = 6 .OR. key = 7
- fldnum = 30
- ENDCASE
- RETURN
- *******************************************************
- * PROCEED - Display message at bottom of help screen *
- *******************************************************
- PROCEDURE proceed
- PARAMETER mproceed
- @ 24,0
- SET COLOR TO &inverse
- DO CASE
- CASE m->mproceed = 1 && Proceed with graph generation?
- @ 24,0 SAY ' F10 - Main Menu. Any other key - Proceed.';
- + SPACE(18)
- CASE m->mproceed = 2 && Proceed with help screens?
- @ 24,0 SAY ' F10 - Main Menu. Any other key - Continue.';
- + SPACE(17)
- CASE m->mproceed = 3 && Proceed with exiting?
- @ 24,0 SAY ' F10 - Main Menu. Any other key - Exit.';
- + SPACE(19)
- CASE m->mproceed = 4 && Proceed with exiting?
- @ 24,0 SAY ' Press any key to exit.';
- + SPACE(29)
- ENDCASE
- SET COLOR TO &normal
- IF m->mproceed <> 2 .AND. m->mproceed <> 3
- ?? CHR(7)
- ENDIF
- m->key = INKEY(0)
- CLEAR
- RETURN
- *************************************************************
- * ERRHAND - General error handling routine *
- *************************************************************
- PROCEDURE errhand
- m->errmsg = MESSAGE()
- errflag = .T.
- DO CASE
- CASE m->oldfld = 2
- m->errmsg = 'Invalid index file'
- 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
- *@ 22,0
- IF SET("COLOR") = 'ON'
- @ 22,0 SAY SPACE((80-LEN(m->errmsg)-6)/2)+"<< " COLOR GR+*/BG
- @ 22,COL() SAY m->errmsg COLOR GR+/BG
- @ 22,COL() SAY " >>" COLOR GR+*/BG
- @ 22,COL()
- SET COLOR TO N/BG
- ELSE
- @ 22,0 SAY SPACE((80-LEN(m->errmsg)-6)/2)+"<< " COLOR W+*/N
- @ 22,COL() SAY m->errmsg COLOR W+/N
- @ 22,COL() SAY " >>" COLOR W+*/N
- @ 22,COL()
- SET COLOR TO
- ENDIF
- RETURN
- ******************************************************************
- * GETPOPUP - The ON SELECTION routine for the hotkey popup menus *
- ******************************************************************
- PROCEDURE getpopup
- gotpopup = .t.
- DEACTIVATE POPUP
- 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
- 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[m->k] PICTURE fcode
- k = k + 1
- ENDDO
- @ 23,0 SAY m->line23
- CLEAR GETS
- RETURN
- ****************************************************
- * VALIDATE - Controlling routine to validate READs *
- ****************************************************
- FUNCTION validate
- DO CASE
- CASE m->fldnum = 1
- ok = opendbf()
- CASE m->fldnum = 2
- ok = openndx()
- CASE m->fldnum = 7
- ok = rowval()
- CASE m->fldnum > 9 .AND. MOD(m->fldnum,2) = 0
- ok = colval()
- OTHERWISE
- ok = genval()
- ENDCASE
- RETURN ok
- ******************************************************************
- * GETGRF - Get user to input the name of a setup definition file *
- ******************************************************************
- PROCEDURE getgrf
- IF LEN(m->loadfile) = 0
- line23 = " Enter file name - Finish with " + ;
- CHR(17)+CHR(217) + ". Help - F1. Abort Entry - Esc."
- arrow = CHR(16)
- @ 23,0 SAY m->line23
- @ m->theitem+1,47 GET arrow
- CLEAR GETS
- filename = IIF(LEN(m->filename) > 50, m->filename, LEFT(m->filename+SPACE(50),50))
- @ m->theitem+1,48 GET m->filename FUNCTION "s22"
- fldnum = 30
- READ
- fldnum = 0
- IF m->gotpopup
- gotpopup = .f.
- filename = IIF(LEN(PROMPT()) > 50, PROMPT(), LEFT(PROMPT()+SPACE(50),50))
- ENDIF
- key = MOD(READKEY(),256)
- ENDIF
- IF m->key <> 12 .AND. LEN(TRIM(m->filename)) > 0
- I = AT('.', m->filename) + 1
- filename = IIF(m->i > 1, ;
- STUFF(m->filename, m->i, LEN(SUBSTR(m->filename,m->i)), 'gr4'), ;
- TRIM(m->filename) + '.gr4')
- command = TRIM(m->filename)
- IF LEN(m->loadfile) = 0
- errmsg = IIF(m->theitem = 2,"Loading ","Saving ")+m->command+" - Please wait"
- DO errmsg
- ENDIF
- ELSE
- theitem = 0
- ENDIF
- RETURN
- *******************************************************
- * GET3MC - Get user to input the name of a macro file *
- *******************************************************
- PROCEDURE get3mc
- line23 = " Enter file name - Finish with " + ;
- CHR(17)+CHR(217) + ". Help - F1. Abort Entry - Esc."
- arrow = CHR(16)
- @ 23,0 SAY m->line23
- @ m->theitem+1,47 GET arrow
- CLEAR GETS
- macro = IIF(LEN(m->macro) > 50, m->macro, LEFT(m->macro+SPACE(50),50))
- @ m->theitem+1,48 GET m->macro FUNCTION "s22"
- fldnum = 31
- READ
- fldnum = 0
- IF gotpopup
- gotpopup = .f.
- macro = IIF(LEN(PROMPT()) > 50, PROMPT(), LEFT(PROMPT()+SPACE(50),50))
- ENDIF
- key = MOD(READKEY(),256)
- IF m->key <> 12 .AND. LEN(TRIM(m->macro)) > 0
- I = AT('.', m->macro) + 1
- macro = IIF(m->i > 1, ;
- STUFF(m->macro, m->i, LEN(SUBSTR(m->macro,m->i)), '3mc'), ;
- TRIM(m->macro) + '.3mc')
- command = TRIM(m->macro)
- ELSE
- theitem = 0
- ENDIF
- RETURN
- **********************************************************
- * RESTOREIT - Restore setup information from a save file *
- **********************************************************
- PROCEDURE restoreit
- PARAMETER savefile
- RESTORE FROM &savefile ADDITIVE
- IF m->errflag
- RETURN
- ENDIF
- IF LEN(TRIM(m->filename)) <> 0 && no errors
- I = 1
- DO WHILE m->i < 32
- setup[m->i] = oldval[m->i]
- I = m->i + 1
- ENDDO
- USE TRIM(setup[1]) INDEX TRIM(setup[2])
- @ 22,0 && Erase Please wait mssg
- ENDIF
- RETURN
- ***************************************************************
- * DOFILES - The ON SELECTION routine for the files popup menu *
- ***************************************************************
- PROCEDURE dofiles
- theitem = BAR()
- DO WHILE .T.
- errflag = .F.
- command = ''
- DO getgrf
- IF m->errflag
- LOOP
- ENDIF
- DO CASE
- CASE theitem = 2
- IF LEN(m->command) > 0 && Filename was entered
- DO restoreit WITH command
- ENDIF
- CASE theitem = 3
- IF LEN(m->command) > 0
- STORE TRIM(m->macro) TO oldval[30]
- STORE m->macstat TO oldval[31]
- SAVE TO &command ALL LIKE oldval*
- ENDIF
- ENDCASE
- IF .NOT. m->errflag
- @ 22,0
- EXIT
- ENDIF
- ENDDO
- RETURN
- *****************************************************************
- * DOMACROS - The ON SELECTION routine for the macros popup menu *
- *****************************************************************
- PROCEDURE domacros
- theitem = BAR()
- DO WHILE .T.
- IF m->theitem = 2 .AND. m->macstat = 1 .OR. m->theitem = 3 .AND. m->macstat = 2
- macstat = 0
- EXIT
- ENDIF
- errflag = .F.
- command = ''
- DO get3mc
- IF m->errflag
- LOOP
- ENDIF
- DO CASE
- CASE theitem = 2
- IF LEN(m->command) > 0 && Filename was entered
- IF FILE(m->command)
- STORE 1 TO m->macstat
- ELSE
- errmsg = m->command + ' does not exist'
- DO errmsg
- errflag = .T.
- ENDIF
- ENDIF
- CASE theitem = 3
- IF LEN(m->command) > 0
- macstat = 2
- IF FILE(m->command)
- @24,0
- @23,78
- WAIT m->command + ' already exists, overwrite it (Y/N)? ' TO m->i
- IF UPPER(m->i) <> 'Y'
- macstat = 0
- errflag = .T.
- ENDIF
- @24,0
- ENDIF
- ENDIF
- ENDCASE
- IF .NOT. m->errflag
- @ 22,0
- EXIT
- ENDIF
- ENDDO
- DEFINE BAR 2 OF macros PROMPT IIF(m->macstat <> 1, 'Activate Macro' + SPACE(25), ;
- LEFT('Deactivate Macro ==> '+m->macro+SPACE(19), 39)) MESSAGE msg1
- DEFINE BAR 3 OF macros PROMPT IIF(m->macstat <> 2, 'Start Recording' + SPACE(24), ;
- LEFT('Stop Recording ==> '+m->macro+SPACE(21), 39)) MESSAGE msg2
- errmsg = IIF(m->macstat = 1, 'Macro active - ' + m->macro, ;
- IIF(m->macstat = 2, 'Macro recording mode on - ' + m->macro, ;
- 'Macro inactive'))
- DO errmsg
- RETURN
- *: EOF: GPRO.PRG