home *** CD-ROM | disk | FTP | other *** search
- * Program Name: help.prg *
- * Author: James J. Orlowski, M.D. *
- * Created: 03/22/1987 *
- * Revision: 3 Last Revised: 04/23/1988 at 0:00 *
- ************************************************************
- PARAMETERS call_prg, line_num, input_var
- IF call_prg = "HELP" .OR. call_prg = "MEMOEDIT" .OR. call_prg = "GENHELP"
- RETURN
- ENDIF
-
- * set up help_code
- DO CASE
- CASE help_code = 0
- RETURN
- CASE call_prg = "SUBMENUS"
- help_code = menunum
- ENDCASE
-
- * open all keys so can use MEMOEDIT() within PROCEDURE genhelp
- * below in this help.prg. These were previously set within
- * PROCEDURES MAIN & SUBMENU within DEMOHELP.PRG
- SET KEY 18 TO
- SET KEY 3 TO
- SET KEY 5 TO
- SET KEY 24 TO
- SET KEY 1 TO
- SET KEY 6 TO
- SET KEY 19 TO
- SET KEY 4 TO
- DO genhelp
- * reset menu commands if main.prg or submenus
- DO CASE
- CASE call_prg = "DEMOHELP"
- SET KEY 18 TO menu_up && pg-up arrow
- SET KEY 3 TO menu_dn && pg-down arrow
- SET KEY 5 TO menu_up && up arrow
- SET KEY 24 TO menu_dn && down arrow
- CASE call_prg = "SUBMENUS"
- SET KEY 1 TO menu_home && home arrow
- SET KEY 6 TO menu_end && end arrow
- SET KEY 18 TO menu_up && pg-up arrow
- SET KEY 3 TO menu_dn && pg-down arrow
- SET KEY 19 TO menu_lft && left arrow
- SET KEY 4 TO menu_rgt && right arrow
- ENDCASE
- RETURN
- * EOF regular listing for help.prg
-
- ************
- * Procedure..: GENHELP
- * As modified from:
- * Filename...: DBUHELP.PRG
- * Author.....: Dennis L. Dias
- * Date.......: 06/18/86
- * Copyright (c) 1986,1987 Nantucket Corp., All Rights Reserved.
- *
- * PROCEDURE genhelp modified by James J. Orlowski, M.D.
- * to be used independently as a generalized help utility 04/09/88 by:
- * 1.) using any help text stored in global variable "helpfile"
- * 2.) adds color and other commands spread throughout dbu*.prg files
- * to incorporate all info to allow this file to run independently
- * 3.) Also uses global variable help_code as used in original DBUHELP.PRG
- * NOTE: IF YOU HAVE DBU*.OBJ LINKED WITHIN YOUR PROGRAM,
- * YOU SHOULD DELETE FUNCTION helptext SECTION FROM THIS PROGRAM
- * SINCE THIS IS AN EXACT DUPLICATE FROM DBUHELP.PRG
- * YOU WOULD ALSO HAVE TO DETERMINE IF DUPLICATE MEMVARS CAUSE
- * PROBLEMS WITH DBU.PRG (i.e. help_code, helpfile)
- ************
-
- ******
- * genhelp
- *
- * Display help screens contained in the
- * file stored in the global variable "helpfile"
- * The global variable "helpfile" must contain the
- * full path\filename or it will not be found by
- * IF FILE(helpfile) command
- ******
- PROCEDURE genhelp
-
- PRIVATE hrow, hcol, hwbuf, htext
- PRIVATE colorstart, cl_firstcr, cl_helphd
- colorstart = SETCOLOR()
- IF ISCOLOR()
- color1 = "W+/B,W+/R,B" && normal
- color2 = "W+/R" && item hilite
- color3 = "N/GR" && error or high intensity
- ELSE
- color1 = ""
- color2 = "I"
- color3 = "W+"
- ENDIF
-
- * search for help file
- IF .NOT. FILE(helpfile)
- SET COLOR TO &color3
- @ 0,0 SAY "Can't find " + UPPER(helpfile)
- SET COLOR TO &color1
- ELSE
- * save current row and column
- hrow = ROW()
- hcol = COL()
-
- * save screen in memvar
- hwbuf = SAVESCREEN(7, 2, 24, 77)
-
- * clear window and draw box
- SET COLOR TO &color1
- scroll(7, 2, 24, 77, 0)
- @ 8,05,22,74 BOX "╒═╕│╛═╘│"
-
- * get the help text
- htext = HELPTEXT(M->helpfile, M->help_code)
-
- * scroll state eliminates the need for a cursor
- SET CURSOR OFF
-
- * display help title
- SET COLOR TO &color2
- cl_firstcr = AT(CHR(13), htext)
- cl_helphd = SUBSTR(htext, 1, cl_firstcr - 1)
- @ 8,(76 - LEN(cl_helphd)) / 2 SAY " " + cl_helphd + " "
- @ 23,09 SAY "Use Cursor Keys To View Help Text; Press ESC Key To Quit Help"
- SET COLOR TO &color1
-
- * use editor in browse only mode
- htext = SUBSTR(htext, cl_firstcr + 2)
- MEMOEDIT(M->htext, 9, 06, 21, 73, .F.)
-
- * restore window
- RESTSCREEN(7, 2, 24, 77, M->hwbuf)
-
- * restore cursor
- @ M->hrow,M->hcol SAY ""
- SET CURSOR ON
- ENDIF
- SETCOLOR(colorstart)
- RETURN
- * EOP genhelp
-
- ******
- * helptext()
- *
- * extract help text from a helpfile in the following format:
- *
- * o At the beginning of the help file is a table which contains
- * the offset and length of each block of help text in the file.
- *
- * o A table entry is 4 bytes long and consists of two 16 bit unsigned
- * numbers in binary format. The first number is the offset within
- * the file where the corresponding help text begins; the second
- * number is the length of the text in bytes.
- *
- * o Table entries and related help text are arranged in numeric order
- * according to the global variable "help_code" which is used to
- * access the correct block of text.
- *
- * o Binary numbers at the beginning of the file are assumed to be
- * in standard Intel format where the Least Significant Byte (LSB)
- * is stored first and the Most Significant Byte (MSB) is second.
- ******
- FUNCTION helptext
-
- PARAMETERS hfile, hnum
- PRIVATE htbuf, hoff, hlen, hhandle
-
- * open the file and get handle
- hhandle = FOPEN(M->hfile)
-
- IF FERROR() = 0
- * allocate 512 byte buffer
- htbuf = SPACE(512)
-
- * read the file header into memory
- FREAD(M->hhandle, @htbuf, 512)
-
- * isolate the correct 4 byte table entry
- htbuf = SUBSTR(M->htbuf, (4 * (M->hnum - 1)) + 1, 4)
-
- * convert binary numbers (LSB, MSB) to Clipper numerics
- hoff = ASC(M->htbuf) + (256 * ASC(SUBSTR(M->htbuf, 2)))
- hlen = ASC(SUBSTR(M->htbuf, 3)) + (256 * ASC(SUBSTR(M->htbuf, 4)))
-
- * allocate buffer
- htbuf = SPACE(M->hlen)
-
- * position file to the correct offset
- FSEEK(M->hhandle, M->hoff)
-
- * read text into buffer
- FREAD(M->hhandle, @htbuf, M->hlen)
- ELSE
- * return null string if error
- htbuf = ""
- ENDIF
-
- * close the file and release the handle
- FCLOSE(M->hhandle)
- RETURN M->htbuf
- * EOFcn helptext()
- * EOF help.prg
-
-
-