home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a009 / 6.ddi / DBU.LIF / DBUHELP.PRG < prev    next >
Encoding:
Text File  |  1991-04-14  |  3.2 KB  |  144 lines

  1. ************
  2. *
  3. *    Program....:  DBU
  4. *    Filename...:  DBUHELP.PRG
  5. *    Author.....:  Dennis L. Dias
  6. *    Date.......:  06/18/86, 06/18/90
  7. *    Purpose....:  Help Module
  8. *
  9. *    Copyright (c) 1986-1990 Nantucket Corp., All Rights Reserved.
  10. *
  11. ************
  12.  
  13.  
  14. ******
  15. *    syshelp
  16. *
  17. *    Display help screens contained in the file DBU.HLP.
  18. *    The help file can be in one of these places:
  19. *
  20. *        <current directory>
  21. *        \CLIPPER\
  22. *
  23. *    The global variable "helpfile" contains the
  24. *    path\filename, or a null string if not found.
  25. ******
  26. PROCEDURE syshelp
  27. local saveColor
  28. PRIVATE hrow, hcol, hwbuf, htext
  29.  
  30. saveColor := SetColor()
  31.  
  32. IF EMPTY(M->helpfile)
  33.     error_msg("Can't find DBU.HLP")
  34.  
  35. ELSE
  36.     * save current row and column
  37.     hrow = ROW()
  38.     hcol = COL()
  39.  
  40.     * save screen in memvar
  41.     hwbuf = SAVESCREEN(8, 10, 22, 69)
  42.  
  43.     * clear window and draw box
  44.     SetColor(M->color8)
  45.     scroll(8, 10, 22, 69, 0)
  46.     @ 8,10,22,69 BOX M->frame
  47.  
  48.     * display help title
  49.     SetColor(M->color10)
  50.     @ 8,(76 - LEN(help_title[M->help_code])) / 2;
  51.     SAY "  " + help_title[M->help_code] + "  "
  52.  
  53.     * get the help text
  54.     htext = helptext(M->helpfile, M->help_code)
  55.  
  56.     * scroll state makes eliminates the need for a cursor
  57.     SET CURSOR OFF
  58.  
  59.     * use editor in browse only mode
  60.     SetColor(M->color8)
  61.     MEMOEDIT(M->htext, 9, 11, 21, 68, .F.)
  62.  
  63.     * restore window
  64.     RESTSCREEN(8, 10, 22, 69, M->hwbuf)
  65.  
  66.     * restore cursor
  67.     @ M->hrow,M->hcol SAY ""
  68.     IF M->curs_on
  69.         SET CURSOR ON
  70.  
  71.     ENDIF
  72. ENDIF
  73.  
  74. * reset
  75. SetColor(saveColor)
  76. local_func = 0
  77. RETURN
  78.  
  79.  
  80. ******
  81. *    helptext()
  82. *
  83. *    extract help text from a helpfile in the following format:
  84. *
  85. *    o    At the beginning of the help file is a table which contains
  86. *        the offset and length of each block of help text in the file.
  87. *
  88. *    o    A table entry is 4 bytes long and consists of two 16 bit unsigned
  89. *        numbers in binary format.  The first number is the offset within
  90. *        the file where the corresponding help text begins; the second
  91. *        number is the length of the text in bytes.
  92. *
  93. *    o    Table entries and related help text are arranged in numeric order
  94. *        according to the global variable "help_code" which is used to
  95. *        access the correct block of text.
  96. *
  97. *    o    Binary numbers at the beginning of the file are assumed to be
  98. *        in standard Intel format where the Least Significant Byte (LSB)
  99. *        is stored first and the Most Significant Byte (MSB) is second.
  100. ******
  101. FUNCTION helptext
  102.  
  103. PARAMETERS hfile, hnum
  104. PRIVATE htbuf, hoff, hlen, hhandle
  105.  
  106. * open the file and get handle
  107. hhandle = FOPEN(M->hfile)
  108.  
  109. IF FERROR() = 0
  110.     * allocate 512 byte buffer
  111.     htbuf = SPACE(512)
  112.  
  113.     * read the file header into memory
  114.     FREAD(M->hhandle, @htbuf, 512)
  115.  
  116.     * isolate the correct 4 byte table entry
  117.     htbuf = SUBSTR(M->htbuf, (4 * (M->hnum - 1)) + 1, 4)
  118.  
  119.     * convert binary numbers (LSB, MSB) to Clipper numerics
  120.     hoff = ASC(M->htbuf) + (256 * ASC(SUBSTR(M->htbuf, 2)))
  121.     hlen = ASC(SUBSTR(M->htbuf, 3)) + (256 * ASC(SUBSTR(M->htbuf, 4)))
  122.  
  123.     * allocate buffer
  124.     htbuf = SPACE(M->hlen)
  125.  
  126.     * position file to the correct offset
  127.     FSEEK(M->hhandle, M->hoff)
  128.  
  129.     * read text into buffer
  130.     FREAD(M->hhandle, @htbuf, M->hlen)
  131.  
  132. ELSE
  133.     * return null string if error
  134.     htbuf = ""
  135.  
  136. ENDIF
  137.  
  138. * close the file and release the handle
  139. FCLOSE(M->hhandle)
  140. RETURN M->htbuf
  141.  
  142.  
  143. * EOF DBUHELP.PRG
  144.