home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / LA / LA016.ZIP / TRH4FOX.EXE / FOX2TRH.PRG < prev    next >
Text File  |  1989-12-20  |  15KB  |  397 lines

  1. * Program: FOX2TRH.PRG
  2. * Action : Makes FOXHELP Data File for Tom Rettig's HELP
  3. *          from FoxPro's on-line help database: FOXHELP.DBF.
  4. * Syntax : DO fox2trh
  5. * Authors: Tom Rettig and Leonard Zerman
  6. * Notice : Copyright (c) 1989, Tom Rettig Associates, All Rights Reserved
  7. * Version: 1.02 -- December, 1989
  8. * Notes  : Runs under all versions of FoxPro
  9. *
  10. *          Requires MVARSIZ be set to 45 or more in CONFIG.FP:
  11. *                   For example: MVARSIZ = 45
  12. *                Increase if you get a string-variable overflow error.
  13. *
  14. *          Requires these files:
  15. *                From FoxPro: FOXHELP.DBF and FOXHELP.FPT
  16. *                From TRHELP: FOX2TRH.PRG and FOX2TRH.EXE
  17. *
  18. *          Requires available disk space about 2.2 times the size of
  19. *                FOXHELP.FPT for temporary and final output files.
  20. *                The resulting FOXHELP.TRH file will be about 10%
  21. *                bigger than FOXHELP.FPT because we add a great deal
  22. *                of information.  For example, if FOXHELP.FPT is
  23. *                500,000 bytes, you need about 1,100,000 bytes free,
  24. *                half of which is used to store the output
  25. *                FOXHELP.TRH Data File, and half of which is used
  26. *                for temporary working space and then released.
  27. *
  28. *          Set a DOS environmental variable "TMP" to use another
  29. *                drive for temporary files.  For example, to put all
  30. *                temporary files in the root directory on drive D,
  31. *                type at the DOS prompt:
  32. *                   SET TMP=D:\
  33. *                This must be done at DOS before entering FoxPro.
  34. *                It will not work if RUN from within FoxPro.
  35. *
  36. *          You only need run this program once, or anytime you
  37. *                modify the FOXHELP database or memo file.
  38. *
  39. * License: You may freely distribute TRHFOX.EXE, FOX2TRH.EXE,
  40. *          and FOX2TRH.PRG, to friends, associates, and computer
  41. *          bulletin board systems (BBS), provided that you
  42. *          distribute unmodified the entire self-unzipping file
  43. *          TRH4FOX.EXE rather than the individual files it
  44. *          contains. You may charge no more than a nominal fee
  45. *          (not to exceed $10) for such distribution.
  46. *
  47. *          You may install the individual files from TRH4NG on
  48. *          any number of computers and make any number of copies
  49. *          for your own use.  You may modify and use the source
  50. *          code in FOX2TRH.PRG for your own application programs,
  51. *          provided that your programs do not compete with, or
  52. *          otherwise damage, Tom Rettig's HELP software products.
  53. *
  54. *          The contents of FOXHELP.DBF and FOXHELP.FPT are the
  55. *          exclusive property of Fox Software, and are subject
  56. *          to the terms of the license agreement under which
  57. *          they are acquired.  Changing the format does not
  58. *          change the license and you must treat converted files
  59. *          the same as the originals.  Consult your FoxPro
  60. *          license to determine your rights thereunder.
  61. ****************************************************************
  62.  
  63. * Program environment.
  64. PRIVATE ALL
  65. SET CONSOLE OFF
  66. _talk = SET("TALK") = "ON"
  67. SET CONSOLE ON
  68. IF _talk
  69.    SET TALK OFF
  70. ENDIF
  71. _exact = SET("EXACT") = "ON"
  72. IF _exact
  73.    SET EXACT OFF
  74. ENDIF
  75. _start = SECONDS()
  76.  
  77. * Program constants.
  78. _crlf = CHR(13)+CHR(10)
  79. tab   = CHR(9)
  80. eof   = CHR(26)
  81. space = " "
  82. null  = ""
  83. zero  = 0
  84. line_width = 69
  85.  
  86. * Open input database file.
  87. SET HELP OFF    && close help file (possibly opened previously)
  88. SELECT (zero)
  89. USE Foxhelp
  90. ? "Creating temporary file from FOXHELP.DBF --",;
  91.   LTRIM(STR(RECCOUNT(),3)), "entries."
  92.  
  93. * Open temporary output file.
  94. _tempfile = GETENV("TMP")
  95. IF !EMPTY(_tempfile)
  96.    IF !RIGHT(_tempfile,1)$"\:"
  97.       _tempfile = _tempfile + "\"
  98.    ENDIF
  99.    handle = FCREATE(_tempfile)
  100.    IF handle == -1               && invalid TMP setting, so
  101.       _tempfile = "Foxhelp.trs"  && use current directory
  102.       handle = FCREATE(_tempfile)
  103.    ENDIF
  104. ELSE
  105.    _tempfile = "Foxhelp.trs"
  106.    handle = FCREATE(_tempfile)
  107. ENDIF
  108.  
  109. * FoxPro version.
  110. build = VERSION()
  111. start = 1
  112. DO WHILE !ISDIGIT(SUBSTR(build,start))
  113.    start = start+1
  114. ENDDO
  115. build = STR(VAL(SUBSTR(build,start)),4,2)
  116.  
  117. * File header.
  118. string = "\filename FOXHELP.TRH"+;
  119.     _crlf+"\notice Copyright 1989 Fox Software, All Rights Reserved"+;
  120.     _crlf+"\comment Converted from FOXHELP.DBF " +DTOC(DATE())+;
  121.     _crlf+"\version " + build
  122. ? string
  123. = FPUTS(handle, string+_crlf)
  124. _error = FERROR() > zero
  125.  
  126. * Records.
  127. SCAN WHILE !_error
  128.    * Keyword.
  129.    keyword = STRTRAN(ALLTRIM(Topic), "( )", "()")
  130.    is_info = LEFT(keyword,1)==CHR(16)     && info prefix
  131.    IF is_info
  132.       keyword = LTRIM(SUBSTR(keyword,2))
  133.    ENDIF
  134.    ? STR(RECNO(),3), keyword
  135.    key4 = space+LEFT(keyword,4)
  136.    key3 = space+LEFT(keyword,3)
  137.    key1 = LEFT(keyword,1)
  138.    set4 = IIF(keyword="SET ", SUBSTR(keyword,4,5), null)
  139.    u_keyword = UPPER(keyword)
  140.  
  141.    * Info menu.
  142.    IF !is_info
  143.       is_info = "EXAMPLE" $ u_keyword .OR.;
  144.                 "DEFINED FUNCTION" $ u_keyword .OR.;
  145.                 "SYSTEM MEMORY" $ u_keyword .OR. "READ ME"==u_keyword
  146.    ENDIF
  147.    string = "\keyword "+IIF(is_info, PROPER(keyword), keyword)+_crlf
  148.  
  149.    * Category.
  150.    DO CASE
  151.       CASE key1 == "_"
  152.          build = "System"
  153.       CASE "ARRAY" $ u_keyword .OR. key4 $ " DECLARE DIMENSION"
  154.          build = "Array"
  155.       CASE key4 $ " $ PADL PADR PADC ALLTRIM TRIM RTRIM LTRIM" +;
  156.                   " ATLINE CHRTRAN STRTRAN LEFT RIGHT SUBSTR" +;
  157.                   " ISALPHA ISDIGIT LOWER PROPER SPACE STUFF" +;
  158.                   " UPPER ISLOWER ISUPPER OCCURS" .OR.;
  159.            u_keyword = "REPLICATE" .OR.;
  160.            key3 $ " AT( RAT ATC LEN"
  161.          build = "Character"
  162.       CASE key4 $ " BETWEEN DIFFERENCE EMPTY INLIST LIKE" +;
  163.                   " MIN( MAX(" .OR. set4 $ " EXACT" .OR.;
  164.            keyword = "TYPE("
  165.          build = "Comparison"
  166.       CASE key4 $ " ASC( CHR( CTOD DTOC DTOS SOUNDEX" +;
  167.                   " STR( VAL( TRANSFORM" .OR. "&" = keyword
  168.          build = "Conversion"
  169.       CASE key4 $ " CREATE MODIFY"
  170.          build = "Create/Modify"
  171.       CASE key4 $ " MEMLINES MLINE" .OR. set4 $ " BLOCKSIZE" .OR.;
  172.            ("MEMO" $ u_keyword .AND. ! "MEMORY" $ u_keyword)
  173.          * Before Database for APPEND MEMO and COPY MEMO.
  174.          build = "Memo"
  175.       CASE key4 $ " APPEND COPY USED CLOSE BROWSE EDIT FCOUNT" +;
  176.                   " CHANGE INSERT SORT CALCULATE SCAN ORDER" +;
  177.                   " COUNT FIELD JOIN KEY( REPLACE LUPDATE" +;
  178.                   " PACK UPDATE SELECT TARGET TOTAL ZAP FSIZE" +;
  179.                   " SCATTER GATHER HEADER ALIAS AVERAGE" .OR.;
  180.            key3 $ " SUM GO BOF EOF DBF NDX REC" .OR.;
  181.            key3 == "USE" .OR.;
  182.            "INDEX" $ keyword .OR. "SKIP" $ keyword .OR.;
  183.            ("DELETE" $ keyword .AND. ! "FILE" $ keyword) .OR.;
  184.            "FILTER" $ keyword .OR. "RELATION" $ keyword .OR.;
  185.            set4 $ " CARRY CONFIRM HEADING FIELD ORDER UNIQUE BRSTATUS"
  186.          build = "Database"
  187.       CASE key4 $ " CDOW CMONTH DAY( DMY( GOMONTH MDY(" +;
  188.                   " MONTH YEAR" .OR. set4 $ " CENTURY MARK" .OR.;
  189.            key4 == " DOW(" .OR. "DATE" $ u_keyword
  190.          build = "Date"
  191.       CASE set4 $ " DEBUG ECHO STEP"
  192.          build = "Debug"
  193.       CASE key4 $ " GETFILE PUTFILE" .OR. keyword = "GETEXPR"
  194.          build = "Dialog"
  195.       CASE "SCREEN" $ u_keyword .OR. " DISPLAY" $ u_keyword .OR.;
  196.            "BOX" $ u_keyword .OR. "COLOR" $ u_keyword .OR.;
  197.            "SCHEME" $ keyword .OR. key4 $ " SCOLS SROWS SCROLL" .OR.;
  198.            set4 $ " CLEAR CONSOLE INTENSITY ODOMETER SHADOW NOTIFY" +;
  199.                   " SHADOW SPACE TALK BORDER BLINK CLOCK SCOREBOARD" +;
  200.                   " DELIMITERS"
  201.          build = "Display"
  202.       CASE key4 $ " CAPSLOCK INSMODE CHRSAW ROW( COL( " +;
  203.                   " DATE TIME NUMLOCK SECONDS CLEAR" +;
  204.                   " FKLABEL FKMAX"
  205.          build = "Environment"
  206.       CASE key4 $ " FCLOSE FCREATE FEOF FFLUSH FGETS" +;
  207.                   " FPUTS FOPEN FREAD FSEEK FWRITE FERROR"
  208.          * Before Error for FERROR.
  209.          build = "File"
  210.       CASE "ERROR" $ keyword .OR. key4 $ " MESSAGE"
  211.          build = "Error"
  212.       CASE "MODULE" $ keyword .OR. key4 $ " LOAD CALL"
  213.          build = "Extend"
  214.       CASE key4 $ " FV() PV() PAYMENT" .OR. set4 $ " CURRENCY"
  215.          build = "Financial"
  216.       CASE "HELP" $ u_keyword .OR. set4 $ " TOPIC"
  217.          build = "Help"
  218.       CASE "MACRO" $ u_keyword .OR. set4 $ " MACKEY"
  219.          build = "Macro"
  220.       CASE "MENU" $ u_keyword .OR. "POPUP" $ u_keyword .OR.;
  221.            "BAR" $ u_keyword .OR. "PAD" $ u_keyword .OR.;
  222.            "PROMPT" $ u_keyword .OR. set4 $ " MESSAGE STICKY SYSMENU"
  223.          build = "Menu"
  224.       CASE key4 $ " ACCEPT INPUT WAIT INKEY KEYBOARD LASTKEY" +;
  225.                   " MCOL MROW MDOWN" .OR.;
  226.            set4 $ " TYPEAHEAD MOUSE" .OR.;
  227.            ("READ" $ keyword .AND. !"READ ME"==u_keyword)
  228.          * After keyword MENU.
  229.          build = "Input"
  230.       CASE key4 $ " ABS( CEILING FLOOR EXP( LOG10 LOG(" +;
  231.                   " INT( MOD( RAND ROUND SIGN SQRT" .OR.;
  232.            set4 $ " DECIMALS FIXED POINT SEPARATOR"
  233.          build = "Numeric"
  234.       CASE key4 $ " DIRECTORY ERASE FULLPATH OS()" +;
  235.                   " RENAME FLUSH FILE CURDIR DISKSPACE" .OR.;
  236.            " FILE" $ keyword .OR. keyword = "GETENV" .OR.;
  237.            set4 $ " AUTOSAVE"
  238.          build = "OS"
  239.       CASE "PRINT" $ u_keyword .OR. keyword = "?" .OR.;
  240.            key4 $ " REPORT LABEL LIST DISPLAY PROW PCOL EJECT" +;
  241.                   " TEXT TYPE" .OR. "ALTERNATE" $ keyword .OR.;
  242.            set4 $ " DEVICE MARGIN"
  243.          build = "Output"
  244.       CASE key4 $ " EXIT QUIT NOTE CANCEL RETRY SUSPEND" +;
  245.                   " LOOP RETURN FUNCTION COMPILE" +;
  246.                   " PARAMETERS LINENO PROGRAM RESUME USER" .OR.;
  247.            key3 $ " FOR IIF IF DO ON = RUN" .OR.;
  248.            "PROCEDURE" $ keyword .OR.;
  249.            set4 $ " DEVELOPMENT DOHISTORY STEP ESCAPE"
  250.          build = "Program"
  251.       CASE key4 $ " FIND SEEK LOOKUP LOCATE CONTINUE FOUND" .OR.;
  252.            set4 $ " NEAR"
  253.          build = "Search"
  254.       CASE key4 $ " ACOS ASIN ATAN ATN2 COS( DTOR PI() RTOD" +;
  255.                   " SIN( TAN("
  256.          build = "Trigonometric"
  257.       CASE key4 $ " WCOLS WROWS WEXIST WONTOP WOUTPUT WVISIBLE" +;
  258.                   " WLCOL WLROW" .OR.;
  259.            "WINDOW" $ u_keyword
  260.          build = "Window"
  261.       CASE key4 $ " PRIVATE PUBLIC RELEASE SAVE STORE RESTORE" .OR.;
  262.            "MEMORY" $ u_keyword
  263.          * After keyword WINDOW.
  264.          build = "Memory"
  265.       CASE key3 == " SET"
  266.          * Default SETs after other SET keywords.
  267.          build = "Environment"
  268.       CASE keyword = "@"
  269.          * Default @s after keyword PROMPT.
  270.          build = IIF("GET"$keyword, "Input", "Output")
  271.       OTHERWISE
  272.          * Default category is FoxPro if not covered above.
  273.          build = "FoxPro"
  274.    ENDCASE
  275.    string = string + "\category " + build + _crlf
  276.    ?? "   " + build
  277.  
  278.    * Type.
  279.    DO CASE
  280.       CASE "()" $ keyword
  281.          build = "Function"
  282.       CASE key1 $ "$&"
  283.          * Note that FOXHELP does not document FoxPro operators,
  284.          * and calls $ (substring) and & (macro) "functions."
  285.          build = "Operator"
  286.       CASE key1 == "_"
  287.          build = "Variable"
  288.       CASE is_info
  289.          build = "Info"+_crlf+"\info"
  290.       OTHERWISE
  291.          * Default type is Command if not covered above.
  292.          build = "Command"
  293.    ENDCASE
  294.    string = string + "\type " + build + _crlf
  295.    ?? space + IIF(is_info, LEFT(build,4), build)
  296.  
  297.    * See also.
  298.    i = 1
  299.    start = ATC("See also:", Details, i) + 10
  300.    IF start > 10
  301.       build = null
  302.       DO WHILE .T.
  303.          end = AT(_crlf, SUBSTR(Details, start))
  304.          IF end==zero
  305.             build = build + ALLTRIM(SUBSTR(Details, start))
  306.          ELSE
  307.             build = build + ALLTRIM(SUBSTR(Details, start, end-1))
  308.          ENDIF
  309.          i = i+1
  310.          start = ATC("See also:", Details, i) + 10
  311.          IF start > 10
  312.             build = build + ", "
  313.          ELSE
  314.             string = string + "\also " +;
  315.                      STRTRAN(build, "( )", "()") + _crlf
  316.             EXIT
  317.          ENDIF
  318.       ENDDO
  319.    ENDIF
  320.  
  321.    * Detail.
  322.    detail = STRTRAN(STRTRAN(STRTRAN(STRTRAN(STRTRAN(STRTRAN(;
  323.             STRTRAN(STRTRAN(STRTRAN(STRTRAN(TRIM(Details),;
  324.                           "\", "\\"),;
  325.                           eof, "\a"),;
  326.                           tab, SPACE(3)),;
  327.                     _crlf+CHR(186), _crlf+"\n"+CHR(186)),;
  328.                     _crlf+CHR(211), _crlf+"\n"+CHR(211)),;
  329.                           CHR(214), "\n"+CHR(214)),;
  330.                     _crlf+"See also:", _crlf+"\nSee also:\e"),;
  331.                     _crlf+"See Also:", _crlf+"\nSee Also:\e"),;
  332.                     _crlf+"WARNING", _crlf+"\hWARNING\e"),;
  333.                     _crlf+"Warning", _crlf+"\hWarning\e")
  334.    start = 1
  335.    end = LEN(detail)
  336.    DO WHILE SUBSTR(detail,end-1,2) == _crlf .OR.;
  337.             SUBSTR(detail,end,1) $ space+tab
  338.       end = end-IIF(SUBSTR(detail,end-1,2)==_crlf, 2, 1)
  339.    ENDDO
  340.    build = null
  341.  
  342.    DO WHILE .T.             && handle one line at a time
  343.       line = SUBSTR(detail, start, line_width)
  344.       IF end-start < line_width    && last line
  345.          build = build + SUBSTR(line, 1, end-start+1)
  346.          EXIT
  347.       ENDIF
  348.       pos = RAT(_crlf, line)
  349.       IF pos > zero   && parse line at last hard _crlf, if any
  350.          build = build + LEFT(line, pos-1) + _crlf
  351.          start = start+pos+1
  352.       ELSE            && parse line at last hard space
  353.          pos = RAT(space, line)
  354.          IF pos > zero
  355.             build = build + LEFT(line, pos-1) + _crlf
  356.             start = start+pos
  357.          ELSE     && line exceeds line_width with no _crlf or spaces
  358.             build = build + line + _crlf
  359.             start = start+line_width-1
  360.          ENDIF
  361.       ENDIF
  362.    ENDDO
  363.    = FPUTS(handle, string+"\detail"+_crlf+build+_crlf+"\end"+_crlf)
  364.    _error = FERROR() > zero
  365. ENDSCAN
  366.  
  367. * Clean up.
  368. = FCLOSE(handle)
  369. USE
  370. RELEASE ALL EXCEPT _*
  371.  
  372. * Compile and delete temporary file.
  373. IF ! _error
  374.    ? "Making Tom Rettig's HELP Data File from temporary file..."+_crlf
  375.    RUN /160 Fox2trh
  376. ELSE
  377.    ? "File Error:", FERROR(), _crlf
  378. ENDIF
  379. ERASE (_tempfile)
  380.  
  381. * Elapsed time.
  382. et = SECONDS() - _start
  383. ?? "FOX2TRH elapsed time: " + LTRIM(STR(INT(et/60))) + " minutes " +;
  384.                           LTRIM(STR(MOD(et,60),6,3)) + " seconds."
  385.  
  386. * Restore environment and return to FoxPro.
  387. IF _exact
  388.    SET EXACT ON
  389. ENDIF
  390. IF _talk
  391.    SET TALK ON
  392. ENDIF
  393. RETURN
  394.  
  395. * EOF: Fox2trh.prg
  396.  
  397.