home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************
- FUNCTION SYSHELP
- *****************************************************************
- *
- * Displays help or other messages contained in a database
- *
- * Copyright(c) 1991 -- James Occhiogrosso
- *
- * Three arguments are passed if SYSHELP is called from a hotkey.
- * If called though a special Developer's Library function,
- * keypress is also passed. All arguments can be used in the
- * help condition statement.
-
- # include "setcurs.ch"
-
- LOCAL old_area := SELECT(), old_color := SETCOLOR(), ;
- old_cursor := SETCURSOR(SC_NONE), ;
- old_help := IF(TYPE('helpcode')!= 'C' .OR. LASTKEY() =-1, ;
- '', TRIM(UPPER(helpcode))), ;
- old_col := COL(), old_row := ROW(), ;
- old_screen := SCRNSAVE( 0, 0, MAXROW(), MAXCOL() ), ;
- open_flag := .F.
-
-
-
- PARAMETERS callproc, linenum, inputvar, keypress
-
- PRIVATE help_col, help_row
-
- * Prevent recursive entry
- IF TYPE('help__on') = 'L'
- * Help is already active
- RETURN .F.
- ELSE
- * Initialize help variable
- help__on = .T.
- ENDIF
-
- * Set defaults for undefined variables
- IF TYPE('helpfile') != 'C'
- PRIVATE helpfile := 'SYSHELP'
- ENDIF
- IF TYPE('helpcode') != 'C'
- PRIVATE helpcode := ''
- ENDIF
-
- IF TYPE('keypress') != 'N'
- * Call may not be from a Developer's Library function.
- * Initialize keypress to prevent runtime error.
- keypress = 0
- ENDIF
-
- * Check for direct call. If fewer than 3 arguments, SYSHELP was
- * called directly. Initialize arguments to prevent error.
- IF PCOUNT() < 3
- callproc = ''
- linenum = 0
- inputvar = ''
- ENDIF
-
- * Select helpfile or open it if necessary. Note that help
- * is addressed only by its alias dl_syshelp. The help database
- * can have any name.
-
- IF SELECT('dl_syshelp') = 0
-
- IF FILE((helpfile) + '.DBF') .AND. FILE((helpfile) + '.DBT');
- .AND. FILE((helpfile) + INDEXEXT())
-
- * Help file exists, open it and set flag
- USE &helpfile ALIAS dl_syshelp INDEX ((helpfile)) NEW
- open_flag := .T.
- ELSE
- * Help file not found
- old_screen = SCRNSAVE(MAXROW(), 0, MAXROW(), MAXCOL())
- CENTERON(MAXROW(),'Helpfile not available. ' + hitanykey)
- ERRORBEEP()
- INKEY(0)
- SCRNREST(old_screen)
- RETURN .F.
- ENDIF
-
- ELSE
- * Help file already open, select it
- SELECT dl_syshelp
- ENDIF
-
- * Set up maximum row and column for SYSHELP messages. Look for
- * special system record with maximum screen coordinates. If not
- * found, default to entire screen.
-
- SEEK '~~HG_SYS~~'
- IF .NOT. FOUND()
- help_row = MAXROW()
- help_col = MAXCOL()
- ELSE
- help_row = dl_syshelp->hlpbott
- help_col = dl_syshelp->hlprgt
- ENDIF
-
- * Locate the message
- GO TOP
- IF .NOT. EMPTY(helpcode)
- SEEK helpcode
-
- IF FOUND() .AND. TRIM(helpcode) == TRIM(dl_syshelp->hlpcode)
-
- * Display message if condition is empty or true
- IF EMPTY(dl_syshelp->hlpcond)
- HELPMSG()
- ELSEIF CHKCOND()
- HELPMSG()
- ELSE
- * Otherwise, no help is available
- NOHELP()
- ENDIF
- ELSE
- * Help code not in file, display message
- NOHELP()
- ENDIF
-
- ELSE
- * No helpcode passed, evaluate condition field only
-
- IF CHKCOND() .AND. EMPTY(dl_syshelp->hlpcode)
- * We found one, display it
- HELPMSG()
- ELSE
- * No help available
- NOHELP()
- ENDIF
-
- ENDIF
-
- * Restore entry conditions and return
-
- IF open_flag
- * We opened help file, close it
- USE
- ENDIF
-
- * Restore everything and return
- SCRNREST(old_screen)
- SELECT(old_area)
- SETCOLOR(old_color)
- helpcode := old_help
- SETCURSOR(old_cursor)
- DEVPOS(old_row, old_col)
- RETURN NIL
-
-
- *****************************************************************
- STATIC FUNCTION NOHELP
- *****************************************************************
-
- * Display no help available message
-
- LOCAL keypress, old_screen
-
- * Clear message row and display error message
- ERRORBEEP()
- @ help_row, 0 CLEAR TO help_row, help_col
- SETCOLOR(colwindow)
- @ help_row, INT((help_col - 52) / 2) SAY ;
- ' No help is available. ' + hitanykey
-
- keypress = INKEY(0)
-
- * The code below is for development. If the "^" key (key 94)
- * is pressed when no help is available, calling conditions
- * appear in a window.
-
- IF keypress = 94 .AND. TYPE('callproc') = 'C'
-
- old_screen = SCRNSAVE(10, 17, 15, 60)
- @ 10, 17, 15, 59 BOX '┌─┐│┘─└│ '
- @ 11, 20 SAY ' Calling Procedure ...... '+ callproc
- @ 12, 20 SAY ' Line Number ............ '+ LTRIM(STR(linenum))
- @ 13, 20 SAY ' Input Variable ......... '+ inputvar
- @ 14, 20 SAY ' Help Code .............. '+ helpcode
-
- @ help_row, 0 SAY PADC('Test key pressed!' + ;
- hitanykey, help_col)
- INKEY(0)
- SCRNREST(old_screen)
-
- ENDIF
-
- RETURN NIL
-
-
- *****************************************************************
- STATIC FUNCTION CHKCOND
- *****************************************************************
-
- * Check condition field of help file. If it is false or
- * empty, return false. Otherwise, return true.
-
- LOCAL checkit
-
- DO WHILE helpcode == TRIM(dl_syshelp->hlpcode) .AND. .NOT. EOF()
-
- IF EMPTY(dl_syshelp->hlpcond)
- * No condition is specified
- SKIP
- ELSE
- checkit = UPPER(dl_syshelp->hlpcond)
- IF &checkit
- * Condition evaluates true
- RETURN(.T.)
- ENDIF
- SKIP
- ENDIF
-
- ENDDO
-
- RETURN .F.
-
-
- *****************************************************************
- STATIC FUNCTION HELPMSG
- *****************************************************************
-
- * Display help message at specified position
-
- @ help_row, 0 CLEAR TO help_row, help_col
-
- SETCOLOR(colwindow)
- @ help_row, INT((help_col - 52) / 2) SAY ;
- ' Use up/down, pgup/pgdn to view. Press ESC to EXIT. '
-
- * Set help color. If no entry, default to colhelp1
- IF .NOT. EMPTY(dl_syshelp->hlpcolr)
- SETCOLOR(&(dl_syshelp->(hlpcolr)))
- ELSE
- SETCOLOR(colhelp1)
- ENDIF
-
- IF dl_syshelp->hlpclr
- @ 0, 0 CLEAR TO help_row - 1, help_col
- ENDIF
-
- IF dl_syshelp->hlpbox
-
- * Load selected box type
- boxdef = IF(dl_syshelp->hlpbx = 'S', '┌─┐│┘─└│ ', '╔═╗║╝═╚║ ')
-
- * Draw box at defined position
- @ dl_syshelp->hlptop, dl_syshelp->hlpleft, ;
- dl_syshelp->hlpbott, dl_syshelp->hlprgt BOX boxdef
-
- * And display message inside box
-
- MEMOEDIT(dl_syshelp->hlpmsg, dl_syshelp->hlptop+1, ;
- dl_syshelp->hlpleft+2, dl_syshelp->hlpbott-1, ;
- dl_syshelp->hlprgt-2, .F.)
-
- ELSE
- * Display message without boxing
-
- MEMOEDIT(dl_syshelp->hlpmsg, dl_syshelp->hlptop, ;
- dl_syshelp->hlpleft, dl_syshelp->hlpbott, ;
- dl_syshelp->hlprgt, .F.)
-
- ENDIF
-
- RETURN NIL
-
-