* A HELP procedure which displays help screens in a pop- * up window, and allows creation and editing of the help * screen text and moving and resizing of the pop-up * window during execution of your program. * Writen by David Barrett, 72037,105 who retains the copyright * only to prevent these routines, or routines derived * from them, to be sold. You may use these routines * in your programs as long as you do not sell the * source code explicitly as a Help Screen System. * These routines are guaranteed to do NOTHING to protect * you from the terrible scourge of computer viruses * which are sure to strike many of you with DIRE * consequences in the IMMEDIATE future. * This routine assumes a database named help exists * with the following structure: * Field Type Width Decimals * 1. PROCEDURE C 10 0 * 2. HELPVAR C 10 0 * 3. UP N 2 0 * 4. LEFT N 2 0 * 5. DOWN N 2 0 * 6. RIGHT N 2 0 * 7. HELPSCRN M 10 0 * Use the following code to open the HELP database * SELECT 0 * IF FILE("HELP.NTX") * USE Help INDEX Help * ELSE * USE Help * INDEX ON Procedure + HelpVar TO Help * ENDIF * At the top of the program PUBLIC MEditHelp, MHelpScrn * Set MEditHelp to .T. or .F. depending on whether * editing, moving and resizing help screens is to * be allowed. * Assign a new, unique value to MHelpScrn at each place * in the program at which you will want a new help screen * unless the calling procedure parameter passed will be * unique. PUBLIC MHelpColr, MInvHelp * Set MHelpColr to the color string for the help window. * Set MInvHelp to the inverse color string - for * highlighting titles, etc. * When the F1 key is pressed and no help screen is found * for the current procedure and MHelpScrn -- if MEditHelp * is .T. a blank screen is created -- if MEditHelp is .F. * control returns silently to the calling procedure. PROCEDURE Help PARAMETERS call_prg, line_num, input_var PRIVATE MCurrent, MScreen, mup, mle, mdn, mri, MTempStrg PRIVATE MCurColr IF call_prg # "HELP" && Do not interupt self MCurrent = SELECT() ** If the Help Database is already opened SELECT Help ** If Help is not already open * SELECT 0 * IF FILE("HELP.NTX") * USE Help INDEX Help * ELSE * USE Help * INDEX ON Procedure + HelpVar TO Help * ENDIF SAVE SCREEN TO MScreen SEEK PadToLength(call_prg,10) + PadToLength(MHelpScrn,10) IF FOUND() mup = Help->Up mle = Help->Left mdn = Help->Down mri = Help->Right ELSE mup = 1 mle = 4 mdn = 23 mri = 76 ENDIF IF MEditHelp SET CURSOR ON IF FOUND() MTempStrg = Help->HelpScrn ELSE APPEND BLANK REPLACE Procedure WITH call_prg REPLACE HelpVar WITH MHelpScrn MTempStrg = " " ENDIF MDone = .F. MCurColr = SETCOLOR(MHelpColr) DO WHILE ! MDone @ mup,mle CLEAR TO mdn,mri @ mup,mle TO mdn,mri DOUBLE SET COLOR TO (MInvHelp) CENTER(mup,' F2tp dn, F3tp up, F4lf rt, F5lf lf, F6bt dn, F7bt up, F8rt rt, F9rt lf') CENTER(mdn,' call_prg = ' + call_prg + ' MHelpScrn = ' + MHelpScrn) SET COLOR TO (MHelpColr) MTempStrg = MEMOEDIT(MTempStrg, mup + 1, mle + 1, mdn - 1, mri - 1,.T.,"HelpEdit") IF ! MDone RESTORE SCREEN FROM MScreen SAVE SCREEN TO MScreen ENDIF ENDDO REPLACE UP WITH mup REPLACE LEFT WITH mle REPLACE DOWN WITH mdn REPLACE RIGHT WITH mri REPLACE HelpScrn WITH MTempStrg SET CURSOR OFF ELSE IF FOUND() @ mup,mle CLEAR TO mdn,mri @ mup,mle TO mdn,mri DOUBLE SET COLOR TO (MInverse) CENTER(mup,' HELP SCREEN ') CENTER(mdn,' Press ESC to Return ') SET COLOR TO (MHelpColr) MEMOEDIT(Help->HelpScrn,mup + 1,mle + 1,mdn - 1,mri - 1,.F.) ENDIF ENDIF SETCOLOR(MCurColr) RESTORE SCREEN FROM MScreen * If the Help Database is not to be left open * USE SELECT(MCurrent) ENDIF RETURN * Allows moving and resizing Help Pop up screen FUNCTION HelpEdit PARAMETERS status, line, col IF (status = 1) .OR. (status = 2) && re-configurable keystroke mkey = LASTKEY() IF mkey = 23 && ctrl-w MDone = .T. ELSEIF (mkey < 0) .AND. (mkey > -10) IF mkey = -1 && F2 mup = mup + 1 ELSEIF mkey = -2 && F3 mup = mup - 1 ELSEIF mkey = -3 && F4 mle = mle + 1 ELSEIF mkey = -4 && F5 mle = mle - 1 ELSEIF mkey = -5 && F6 mdn = mdn + 1 ELSEIF mkey = -6 && F7 mdn = mdn - 1 ELSEIF mkey = -7 && F8 mri = mri + 1 ELSEIF mkey = -8 && F9 mri = mri - 1 ENDIF RETURN 23 && save and exit ENDIF ENDIF RETURN 0 * Displays STRING centered on row ROW, returns starting column FUNCTION CENTER PARAMETERS ROW, STRING PRIVATE L String = ALLTRIM(String) L = LEN(STRING) IF L > 58 String = LEFT(String,58) L = 58 ENDIF @ ROW, (80 - L) / 2 SAY STRING RETURN L * Pads with spaces or truncates STRING to LENGTH as necessary FUNCTION PadToLength Parameter string, length IF Len(String) < length ReturnString = String + SPACE(length - Len(String)) ELSE ReturnString = LEFT(String, length) ENDIF RETURN ReturnString