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 >
Wrap
Text File
|
1989-12-20
|
15KB
|
397 lines
* Program: FOX2TRH.PRG
* Action : Makes FOXHELP Data File for Tom Rettig's HELP
* from FoxPro's on-line help database: FOXHELP.DBF.
* Syntax : DO fox2trh
* Authors: Tom Rettig and Leonard Zerman
* Notice : Copyright (c) 1989, Tom Rettig Associates, All Rights Reserved
* Version: 1.02 -- December, 1989
* Notes : Runs under all versions of FoxPro
*
* Requires MVARSIZ be set to 45 or more in CONFIG.FP:
* For example: MVARSIZ = 45
* Increase if you get a string-variable overflow error.
*
* Requires these files:
* From FoxPro: FOXHELP.DBF and FOXHELP.FPT
* From TRHELP: FOX2TRH.PRG and FOX2TRH.EXE
*
* Requires available disk space about 2.2 times the size of
* FOXHELP.FPT for temporary and final output files.
* The resulting FOXHELP.TRH file will be about 10%
* bigger than FOXHELP.FPT because we add a great deal
* of information. For example, if FOXHELP.FPT is
* 500,000 bytes, you need about 1,100,000 bytes free,
* half of which is used to store the output
* FOXHELP.TRH Data File, and half of which is used
* for temporary working space and then released.
*
* Set a DOS environmental variable "TMP" to use another
* drive for temporary files. For example, to put all
* temporary files in the root directory on drive D,
* type at the DOS prompt:
* SET TMP=D:\
* This must be done at DOS before entering FoxPro.
* It will not work if RUN from within FoxPro.
*
* You only need run this program once, or anytime you
* modify the FOXHELP database or memo file.
*
* License: You may freely distribute TRHFOX.EXE, FOX2TRH.EXE,
* and FOX2TRH.PRG, to friends, associates, and computer
* bulletin board systems (BBS), provided that you
* distribute unmodified the entire self-unzipping file
* TRH4FOX.EXE rather than the individual files it
* contains. You may charge no more than a nominal fee
* (not to exceed $10) for such distribution.
*
* You may install the individual files from TRH4NG on
* any number of computers and make any number of copies
* for your own use. You may modify and use the source
* code in FOX2TRH.PRG for your own application programs,
* provided that your programs do not compete with, or
* otherwise damage, Tom Rettig's HELP software products.
*
* The contents of FOXHELP.DBF and FOXHELP.FPT are the
* exclusive property of Fox Software, and are subject
* to the terms of the license agreement under which
* they are acquired. Changing the format does not
* change the license and you must treat converted files
* the same as the originals. Consult your FoxPro
* license to determine your rights thereunder.
****************************************************************
* Program environment.
PRIVATE ALL
SET CONSOLE OFF
_talk = SET("TALK") = "ON"
SET CONSOLE ON
IF _talk
SET TALK OFF
ENDIF
_exact = SET("EXACT") = "ON"
IF _exact
SET EXACT OFF
ENDIF
_start = SECONDS()
* Program constants.
_crlf = CHR(13)+CHR(10)
tab = CHR(9)
eof = CHR(26)
space = " "
null = ""
zero = 0
line_width = 69
* Open input database file.
SET HELP OFF && close help file (possibly opened previously)
SELECT (zero)
USE Foxhelp
? "Creating temporary file from FOXHELP.DBF --",;
LTRIM(STR(RECCOUNT(),3)), "entries."
* Open temporary output file.
_tempfile = GETENV("TMP")
IF !EMPTY(_tempfile)
IF !RIGHT(_tempfile,1)$"\:"
_tempfile = _tempfile + "\"
ENDIF
handle = FCREATE(_tempfile)
IF handle == -1 && invalid TMP setting, so
_tempfile = "Foxhelp.trs" && use current directory
handle = FCREATE(_tempfile)
ENDIF
ELSE
_tempfile = "Foxhelp.trs"
handle = FCREATE(_tempfile)
ENDIF
* FoxPro version.
build = VERSION()
start = 1
DO WHILE !ISDIGIT(SUBSTR(build,start))
start = start+1
ENDDO
build = STR(VAL(SUBSTR(build,start)),4,2)
* File header.
string = "\filename FOXHELP.TRH"+;
_crlf+"\notice Copyright 1989 Fox Software, All Rights Reserved"+;
_crlf+"\comment Converted from FOXHELP.DBF " +DTOC(DATE())+;
_crlf+"\version " + build
? string
= FPUTS(handle, string+_crlf)
_error = FERROR() > zero
* Records.
SCAN WHILE !_error
* Keyword.
keyword = STRTRAN(ALLTRIM(Topic), "( )", "()")
is_info = LEFT(keyword,1)==CHR(16) && info prefix
IF is_info
keyword = LTRIM(SUBSTR(keyword,2))
ENDIF
? STR(RECNO(),3), keyword
key4 = space+LEFT(keyword,4)
key3 = space+LEFT(keyword,3)
key1 = LEFT(keyword,1)
set4 = IIF(keyword="SET ", SUBSTR(keyword,4,5), null)
u_keyword = UPPER(keyword)
* Info menu.
IF !is_info
is_info = "EXAMPLE" $ u_keyword .OR.;
"DEFINED FUNCTION" $ u_keyword .OR.;
"SYSTEM MEMORY" $ u_keyword .OR. "READ ME"==u_keyword
ENDIF
string = "\keyword "+IIF(is_info, PROPER(keyword), keyword)+_crlf
* Category.
DO CASE
CASE key1 == "_"
build = "System"
CASE "ARRAY" $ u_keyword .OR. key4 $ " DECLARE DIMENSION"
build = "Array"
CASE key4 $ " $ PADL PADR PADC ALLTRIM TRIM RTRIM LTRIM" +;
" ATLINE CHRTRAN STRTRAN LEFT RIGHT SUBSTR" +;
" ISALPHA ISDIGIT LOWER PROPER SPACE STUFF" +;
" UPPER ISLOWER ISUPPER OCCURS" .OR.;
u_keyword = "REPLICATE" .OR.;
key3 $ " AT( RAT ATC LEN"
build = "Character"
CASE key4 $ " BETWEEN DIFFERENCE EMPTY INLIST LIKE" +;
" MIN( MAX(" .OR. set4 $ " EXACT" .OR.;
keyword = "TYPE("
build = "Comparison"
CASE key4 $ " ASC( CHR( CTOD DTOC DTOS SOUNDEX" +;
" STR( VAL( TRANSFORM" .OR. "&" = keyword
build = "Conversion"
CASE key4 $ " CREATE MODIFY"
build = "Create/Modify"
CASE key4 $ " MEMLINES MLINE" .OR. set4 $ " BLOCKSIZE" .OR.;
("MEMO" $ u_keyword .AND. ! "MEMORY" $ u_keyword)
* Before Database for APPEND MEMO and COPY MEMO.
build = "Memo"
CASE key4 $ " APPEND COPY USED CLOSE BROWSE EDIT FCOUNT" +;
" CHANGE INSERT SORT CALCULATE SCAN ORDER" +;
" COUNT FIELD JOIN KEY( REPLACE LUPDATE" +;
" PACK UPDATE SELECT TARGET TOTAL ZAP FSIZE" +;
" SCATTER GATHER HEADER ALIAS AVERAGE" .OR.;
key3 $ " SUM GO BOF EOF DBF NDX REC" .OR.;
key3 == "USE" .OR.;
"INDEX" $ keyword .OR. "SKIP" $ keyword .OR.;
("DELETE" $ keyword .AND. ! "FILE" $ keyword) .OR.;
"FILTER" $ keyword .OR. "RELATION" $ keyword .OR.;
set4 $ " CARRY CONFIRM HEADING FIELD ORDER UNIQUE BRSTATUS"
build = "Database"
CASE key4 $ " CDOW CMONTH DAY( DMY( GOMONTH MDY(" +;
" MONTH YEAR" .OR. set4 $ " CENTURY MARK" .OR.;
key4 == " DOW(" .OR. "DATE" $ u_keyword
build = "Date"
CASE set4 $ " DEBUG ECHO STEP"
build = "Debug"
CASE key4 $ " GETFILE PUTFILE" .OR. keyword = "GETEXPR"
build = "Dialog"
CASE "SCREEN" $ u_keyword .OR. " DISPLAY" $ u_keyword .OR.;
"BOX" $ u_keyword .OR. "COLOR" $ u_keyword .OR.;
"SCHEME" $ keyword .OR. key4 $ " SCOLS SROWS SCROLL" .OR.;
set4 $ " CLEAR CONSOLE INTENSITY ODOMETER SHADOW NOTIFY" +;
" SHADOW SPACE TALK BORDER BLINK CLOCK SCOREBOARD" +;
" DELIMITERS"
build = "Display"
CASE key4 $ " CAPSLOCK INSMODE CHRSAW ROW( COL( " +;
" DATE TIME NUMLOCK SECONDS CLEAR" +;
" FKLABEL FKMAX"
build = "Environment"
CASE key4 $ " FCLOSE FCREATE FEOF FFLUSH FGETS" +;
" FPUTS FOPEN FREAD FSEEK FWRITE FERROR"
* Before Error for FERROR.
build = "File"
CASE "ERROR" $ keyword .OR. key4 $ " MESSAGE"
build = "Error"
CASE "MODULE" $ keyword .OR. key4 $ " LOAD CALL"
build = "Extend"
CASE key4 $ " FV() PV() PAYMENT" .OR. set4 $ " CURRENCY"
build = "Financial"
CASE "HELP" $ u_keyword .OR. set4 $ " TOPIC"
build = "Help"
CASE "MACRO" $ u_keyword .OR. set4 $ " MACKEY"
build = "Macro"
CASE "MENU" $ u_keyword .OR. "POPUP" $ u_keyword .OR.;
"BAR" $ u_keyword .OR. "PAD" $ u_keyword .OR.;
"PROMPT" $ u_keyword .OR. set4 $ " MESSAGE STICKY SYSMENU"
build = "Menu"
CASE key4 $ " ACCEPT INPUT WAIT INKEY KEYBOARD LASTKEY" +;
" MCOL MROW MDOWN" .OR.;
set4 $ " TYPEAHEAD MOUSE" .OR.;
("READ" $ keyword .AND. !"READ ME"==u_keyword)
* After keyword MENU.
build = "Input"
CASE key4 $ " ABS( CEILING FLOOR EXP( LOG10 LOG(" +;
" INT( MOD( RAND ROUND SIGN SQRT" .OR.;
set4 $ " DECIMALS FIXED POINT SEPARATOR"
build = "Numeric"
CASE key4 $ " DIRECTORY ERASE FULLPATH OS()" +;
" RENAME FLUSH FILE CURDIR DISKSPACE" .OR.;
" FILE" $ keyword .OR. keyword = "GETENV" .OR.;
set4 $ " AUTOSAVE"
build = "OS"
CASE "PRINT" $ u_keyword .OR. keyword = "?" .OR.;
key4 $ " REPORT LABEL LIST DISPLAY PROW PCOL EJECT" +;
" TEXT TYPE" .OR. "ALTERNATE" $ keyword .OR.;
set4 $ " DEVICE MARGIN"
build = "Output"
CASE key4 $ " EXIT QUIT NOTE CANCEL RETRY SUSPEND" +;
" LOOP RETURN FUNCTION COMPILE" +;
" PARAMETERS LINENO PROGRAM RESUME USER" .OR.;
key3 $ " FOR IIF IF DO ON = RUN" .OR.;
"PROCEDURE" $ keyword .OR.;
set4 $ " DEVELOPMENT DOHISTORY STEP ESCAPE"
build = "Program"
CASE key4 $ " FIND SEEK LOOKUP LOCATE CONTINUE FOUND" .OR.;
set4 $ " NEAR"
build = "Search"
CASE key4 $ " ACOS ASIN ATAN ATN2 COS( DTOR PI() RTOD" +;
" SIN( TAN("
build = "Trigonometric"
CASE key4 $ " WCOLS WROWS WEXIST WONTOP WOUTPUT WVISIBLE" +;
" WLCOL WLROW" .OR.;
"WINDOW" $ u_keyword
build = "Window"
CASE key4 $ " PRIVATE PUBLIC RELEASE SAVE STORE RESTORE" .OR.;
"MEMORY" $ u_keyword
* After keyword WINDOW.
build = "Memory"
CASE key3 == " SET"
* Default SETs after other SET keywords.
build = "Environment"
CASE keyword = "@"
* Default @s after keyword PROMPT.
build = IIF("GET"$keyword, "Input", "Output")
OTHERWISE
* Default category is FoxPro if not covered above.
build = "FoxPro"
ENDCASE
string = string + "\category " + build + _crlf
?? " " + build
* Type.
DO CASE
CASE "()" $ keyword
build = "Function"
CASE key1 $ "$&"
* Note that FOXHELP does not document FoxPro operators,
* and calls $ (substring) and & (macro) "functions."
build = "Operator"
CASE key1 == "_"
build = "Variable"
CASE is_info
build = "Info"+_crlf+"\info"
OTHERWISE
* Default type is Command if not covered above.
build = "Command"
ENDCASE
string = string + "\type " + build + _crlf
?? space + IIF(is_info, LEFT(build,4), build)
* See also.
i = 1
start = ATC("See also:", Details, i) + 10
IF start > 10
build = null
DO WHILE .T.
end = AT(_crlf, SUBSTR(Details, start))
IF end==zero
build = build + ALLTRIM(SUBSTR(Details, start))
ELSE
build = build + ALLTRIM(SUBSTR(Details, start, end-1))
ENDIF
i = i+1
start = ATC("See also:", Details, i) + 10
IF start > 10
build = build + ", "
ELSE
string = string + "\also " +;
STRTRAN(build, "( )", "()") + _crlf
EXIT
ENDIF
ENDDO
ENDIF
* Detail.
detail = STRTRAN(STRTRAN(STRTRAN(STRTRAN(STRTRAN(STRTRAN(;
STRTRAN(STRTRAN(STRTRAN(STRTRAN(TRIM(Details),;
"\", "\\"),;
eof, "\a"),;
tab, SPACE(3)),;
_crlf+CHR(186), _crlf+"\n"+CHR(186)),;
_crlf+CHR(211), _crlf+"\n"+CHR(211)),;
CHR(214), "\n"+CHR(214)),;
_crlf+"See also:", _crlf+"\nSee also:\e"),;
_crlf+"See Also:", _crlf+"\nSee Also:\e"),;
_crlf+"WARNING", _crlf+"\hWARNING\e"),;
_crlf+"Warning", _crlf+"\hWarning\e")
start = 1
end = LEN(detail)
DO WHILE SUBSTR(detail,end-1,2) == _crlf .OR.;
SUBSTR(detail,end,1) $ space+tab
end = end-IIF(SUBSTR(detail,end-1,2)==_crlf, 2, 1)
ENDDO
build = null
DO WHILE .T. && handle one line at a time
line = SUBSTR(detail, start, line_width)
IF end-start < line_width && last line
build = build + SUBSTR(line, 1, end-start+1)
EXIT
ENDIF
pos = RAT(_crlf, line)
IF pos > zero && parse line at last hard _crlf, if any
build = build + LEFT(line, pos-1) + _crlf
start = start+pos+1
ELSE && parse line at last hard space
pos = RAT(space, line)
IF pos > zero
build = build + LEFT(line, pos-1) + _crlf
start = start+pos
ELSE && line exceeds line_width with no _crlf or spaces
build = build + line + _crlf
start = start+line_width-1
ENDIF
ENDIF
ENDDO
= FPUTS(handle, string+"\detail"+_crlf+build+_crlf+"\end"+_crlf)
_error = FERROR() > zero
ENDSCAN
* Clean up.
= FCLOSE(handle)
USE
RELEASE ALL EXCEPT _*
* Compile and delete temporary file.
IF ! _error
? "Making Tom Rettig's HELP Data File from temporary file..."+_crlf
RUN /160 Fox2trh
ELSE
? "File Error:", FERROR(), _crlf
ENDIF
ERASE (_tempfile)
* Elapsed time.
et = SECONDS() - _start
?? "FOX2TRH elapsed time: " + LTRIM(STR(INT(et/60))) + " minutes " +;
LTRIM(STR(MOD(et,60),6,3)) + " seconds."
* Restore environment and return to FoxPro.
IF _exact
SET EXACT ON
ENDIF
IF _talk
SET TALK ON
ENDIF
RETURN
* EOF: Fox2trh.prg