home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: Java
/
Java.zip
/
sse99067.zip
/
JSSEARCH.CMD
next >
Wrap
OS/2 REXX Batch file
|
1999-03-08
|
38KB
|
1,133 lines
/*
* Generator : PPWIZARD version 99.067
* : FREE tool for OS/2, Windows, DOS and UNIX by Dennis Bareis (db0@anz.com)
* : http://www.labyrinth.net.au/~dbareis/ppwizard.htm
* Time : Monday, 8 Mar 1999 12:24:57pm
* Input File : E:\DB\PROJECTS\OS2\jssearch\JSSEARCH.x
* Output File : .\OUT\JSSEARCH.CMD
*/
PgmVersion = "99.067"
call RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
call RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
call time('Reset')
numeric digits 14
trace off
HttpSourcePage = 'http://www.labyrinth.net.au/~dbareis/freeos2.htm'
Delimiter = d2c(29)
CopyrightDisplayed = 'N'
LowerCase = "abcdefghijklmnopqrstuvwxyz"
UpperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
DecimalDigits = '0123456789'
AllwaysInWord = LowerCase || UpperCase || DecimalDigits
call WordChars AllwaysInWord
MaxLeadingLengthCode = 50
CodeFromAscii = 130
LongestLeadingCodeUsed = 0
/*
* QSORT.XH Version 98.158 by Dennis Bareis
* The base code was not written by me (not sure where it came from
* http://www.labyrinth.net.au/~dbareis/index.htm (db0@anz.com)
*/
signal EndQsortXh_1
_SortWordAndFiles: PROCEDURE EXPOSE WordFile.
parse arg top, down
if ( ( down-top ) < 2 ) then
do
if ( ( down - top ) > 0 ) then
/* if ( WordFile.top > WordFile.down ) then */
if ( NormalSort( WordFile.top, WordFile.down ) > 0 ) then
do
tmpval = WordFile.top
WordFile.top = WordFile.down
WordFile.down = tmpval
end
end
else
do
l = top
r = down
m = top + trunc( ( down-top )/2 )
do while ( l<r )
m_val = WordFile.m
/* do while ( WordFile.l < m_val ) */
do while ( NormalSort( WordFile.l, m_val ) < 0 )
if ( l < m ) then
l=l+1
else
leave
end
/* do while ( WordFile.r > m_val ) */
do while ( NormalSort( WordFile.r, m_val ) > 0 )
if ( m < r ) then
r=r-1
else
leave
end
if ( l < r ) then
do
tmpval = WordFile.l
WordFile.l = WordFile.r
WordFile.r = tmpval
select
when ( m=r ) then
do
r = r-1
m = l
end
when ( m=l ) then
do
l = l+1
m = r
end
otherwise
do
l = l+1
r = r-1
end
end
end
end
if ( ( r-top ) < ( down-l ) ) then
do
call _SortWordAndFiles top, m-1
call _SortWordAndFiles m+1, down
end
else
do
call _SortWordAndFiles m+1, down
call _SortWordAndFiles top, m-1
end
end
return
SortWordAndFiles: PROCEDURE EXPOSE WordFile.
call _SortWordAndFiles 1, WordFile.0
return
EndQSORTXh_1:
signal EndQsortXh_2
_SortFiles: PROCEDURE EXPOSE File.
parse arg top, down
if ( ( down-top ) < 2 ) then
do
if ( ( down - top ) > 0 ) then
/* if ( File.top > File.down ) then */
if ( CaseInsensitiveSort( File.top, File.down ) > 0 ) then
do
tmpval = File.top
File.top = File.down
File.down = tmpval
end
end
else
do
l = top
r = down
m = top + trunc( ( down-top )/2 )
do while ( l<r )
m_val = File.m
/* do while ( File.l < m_val ) */
do while ( CaseInsensitiveSort( File.l, m_val ) < 0 )
if ( l < m ) then
l=l+1
else
leave
end
/* do while ( File.r > m_val ) */
do while ( CaseInsensitiveSort( File.r, m_val ) > 0 )
if ( m < r ) then
r=r-1
else
leave
end
if ( l < r ) then
do
tmpval = File.l
File.l = File.r
File.r = tmpval
select
when ( m=r ) then
do
r = r-1
m = l
end
when ( m=l ) then
do
l = l+1
m = r
end
otherwise
do
l = l+1
r = r-1
end
end
end
end
if ( ( r-top ) < ( down-l ) ) then
do
call _SortFiles top, m-1
call _SortFiles m+1, down
end
else
do
call _SortFiles m+1, down
call _SortFiles top, m-1
end
end
return
SortFiles: PROCEDURE EXPOSE File.
call _SortFiles 1, File.0
return
EndQSORTXh_2:
/*
* KEYEDVAR.XH Version 98.169 by Dennis Bareis
* http://www.labyrinth.net.au/~dbareis/index.htm (db0@anz.com)
*/
signal EndKeyedVarXH
KeySaveInfo:
interpret arg(1) || '_?.?_' || arg(2) || ' = arg(3)'
return(0)
KeyExists:
if symbol(arg(1) || '_?.?_' || arg(2)) = 'VAR' then
return('Y')
else
return('N')
KeyGetInfo:
siSaveAs = arg(1) || '_?.?_' || arg(2)
if symbol(siSaveAs) <> 'VAR' then
return("<KeyedVarUnknown>")
interpret "siContents = " || siSaveAs
return(siContents)
EndKeyedVarXH:
signal EndExcludeXH
LoadExcludeFile:
ExcludeFile = strip(arg(1))
if stream(ExcludeFile, 'c', 'query exists') = '' then
do
say 'ERROR: "' || ExcludeFile || '" does not exist'
ThatsAllFolks(255)
end
CloseRc = stream(ExcludeFile, 'c', 'close')
do while lines(ExcludeFile) <> 0
CurrentWord = strip(linein(ExcludeFile))
if CurrentWord = '' then
iterate
if left(CurrentWord, 1) = ';' then
iterate
call KeySaveInfo "X", CurrentWord
end
CloseRc = stream(ExcludeFile, 'c', 'close')
return
ExcludeWord:
return( KeyExists("X", arg(1)) )
EndExcludeXH:
MaxElementlength = 245
CookieName = 'Cookie' || time('Seconds')
signal EndGenerateXh
_GenerateCmt:
if OptionCompact = 'N' then
call _GenerateLine arg(1) || '<!--- ' || arg(2) || ' ------------------------------->'
return
_GenerateLine:
TheLine = translate(arg(1), "'", "`")
if OptionCompact <> 'N' then
TheLine = ReplaceString(TheLine, '', "")
else
TheLine = translate(TheLine, ' ', '')
if OptionCompact <> 'N' then
do
if TheLine = '' then
return
end
call charout OptionOutputFileName, TheLine || Eol
return
GenerateJavaScript:
if OptionCompleteHtmlPage = 'Y' then
call _GenerateLine "<HTML>"
IndexTime = date('Weekday') || ', ' || date() || ' ' || GetAmPmTime()
call _GenerateLine "<!-------------------------------------------------------------->"
call _GenerateLine "<!--- This code was automatically generated by JSSEARCH.CMD --->"
call _GenerateLine "<!--- version " || PgmVersion || ", this tool was written by Dennis Bareis --->"
call _GenerateLine "<!--- He has a homepage of free OS/2, DOS & Windows tools at --->"
call _GenerateLine "<!--- http://www.labyrinth.net.au/~dbareis (db0@anz.com) --->"
call _GenerateLine "<!-------------------------------------------------------------->"
call _GenerateLine "<NOSCRIPT>"
call _GenerateLine "<H1>Can't Perform Search</H1>"
call _GenerateLine "<P>Your browser does not support JavaScript or you don't have it available!<BR>"
call _GenerateLine "</NOSCRIPT>"
call _GenerateLine "<SCRIPT>"
call _GenerateLine "<!---"
call _GenerateCmt Tab1, 'Simply add the passed value to the array'
call _GenerateLine Tab1 || 'function AddOneValue(Value)'
call _GenerateLine Tab1 || '{'
if OptionUseCodes = 'Y' then
do
call _GenerateCmt Tab2, 'Look for compression codes & expand'
call _GenerateLine Tab2 || 'FirstChar=Value.charAt(0)'
call _GenerateLine Tab2 || 'MatchPosn=CompCodes.indexOf(FirstChar)'
call _GenerateLine Tab2 || 'if(MatchPosn!' || '=-1)'
call _GenerateLine Tab3 || 'Value=A[A.length].substring(0,MatchPosn+2)+Value.substring(1)'
call _GenerateLine ''
end
call _GenerateLine ''
call _GenerateCmt Tab2, 'Add the value to the end of the array'
call _GenerateLine Tab2 || 'A[++A.length]=Value'
call _GenerateLine Tab1 || '}'
call _GenerateLine ''
call _GenerateCmt Tab1, 'Add Listed Values to growing array - Items May Have Leading Codes'
call _GenerateLine Tab1 || 'function L(List)'
call _GenerateLine Tab1 || '{'
call _GenerateCmt Tab2, 'Seperate the value into individual parts'
call _GenerateLine Tab2 || 'while((Posn=List.indexOf("|"))!' || '=-1)'
call _GenerateLine Tab2 || '{'
call _GenerateCmt Tab3, 'Extract the 1st value'
call _GenerateLine Tab3 || 'AddOneValue(List.substring(0,Posn))'
call _GenerateLine ''
call _GenerateCmt Tab3, 'Prepare for next loop'
call _GenerateLine Tab3 || 'List=List.substring(Posn+1)'
call _GenerateLine Tab2 || '}'
call _GenerateLine ''
call _GenerateCmt Tab2, 'Handle the last word'
call _GenerateLine Tab2 || 'AddOneValue(List)'
call _GenerateLine Tab1 || '}'
call _GenerateLine ''
if OptionUseFileOffsetCodes = 'Y' then
do
call _GenerateCmt Tab1, "Add Listed Values to occurs array - Items Don't Have Leading Codes but are compressed"
call _GenerateLine Tab1 || 'function C(List)'
call _GenerateLine Tab1 || '{'
call _GenerateCmt Tab2, 'Seperate the value into individual parts'
call _GenerateLine Tab2 || 'while((Posn=List.indexOf("|"))!' || '=-1)'
call _GenerateLine Tab2 || '{'
call _GenerateCmt Tab3, 'Extract the 1st value (add to array)'
call _GenerateLine Tab3 || 'A[++A.length]=List.substring(0,Posn)'
call _GenerateLine ''
call _GenerateCmt Tab3, 'Prepare for next loop'
call _GenerateLine Tab3 || 'List=List.substring(Posn+1)'
call _GenerateLine Tab2 || '}'
call _GenerateLine ''
call _GenerateCmt Tab2, 'Add last value to array'
call _GenerateLine Tab2 || 'A[++A.length]=List'
call _GenerateLine Tab1 || '}'
call _GenerateLine ''
call _GenerateCmt Tab1, 'Passed compressed form, return occurs list (comma seperated)'
call _GenerateLine Tab1 || 'function Code2List(Code)'
call _GenerateLine Tab1 || '{'
call _GenerateLine Tab2 || 'var FIndex=0'
call _GenerateLine Tab2 || 'var List=""'
call _GenerateLine ''
call _GenerateLine Tab2 || 'while(Code!' || '="")'
call _GenerateLine Tab2 || '{'
call _GenerateCmt Tab3, 'Seperate bits'
call _GenerateLine Tab3 || 'FirstChar=Code.charAt(0)'
call _GenerateLine Tab3 || 'Code=Code.substring(1)'
call _GenerateLine ''
call _GenerateCmt Tab3, 'Work out Index'
call _GenerateLine Tab3 || 'FIndex=FIndex+OffsetCodes.indexOf(FirstChar)+1'
call _GenerateLine ''
call _GenerateCmt Tab3, 'Save Value'
call _GenerateLine Tab3 || 'if(List=="")'
call _GenerateLine Tab4 || 'List=FIndex.toString()'
call _GenerateLine Tab3 || 'else'
call _GenerateLine Tab4 || 'List+=","+FIndex.toString()'
call _GenerateLine Tab2 || '}'
call _GenerateLine Tab2 || 'return(List)'
call _GenerateLine Tab1 || '}'
call _GenerateLine ''
end
call _GenerateCmt Tab1, 'Create FILE array (' || FileCount || ' files)'
call _GenerateLine Tab1 || 'function CreateFileArray()'
call _GenerateLine Tab1 || '{'
call _GenerateLine Tab2 || 'A=this'
call _GenerateLine Tab2 || 'A.length=0'
call _InitializeArray 'L'
do Index = 1 to FileCount
call _AddToArray translate(File.Index, '/', '\')
end
call _FlushArray
call _GenerateLine Tab1 || '}'
call _GenerateLine ''
call _GenerateCmt Tab1, 'Create WORD array (' || WordCount || ' words)'
call _GenerateLine Tab1 || 'function CreateWordArray()'
call _GenerateLine Tab1 || '{'
call _GenerateLine Tab2 || 'A=this'
call _GenerateLine Tab2 || 'A.length=0'
call _InitializeArray 'L'
do Index = 1 to WordCount
call _AddToArray Word.Index
end
call _FlushArray
call _GenerateLine Tab1 || '}'
call _GenerateLine ''
call _GenerateCmt Tab1, 'Create WORD OCCURS IN array (' || WordCount || ' words)'
call _GenerateLine Tab1 || 'function CreateOccursArray()'
call _GenerateLine Tab1 || '{'
call _GenerateLine Tab2 || 'A=this'
call _GenerateLine Tab2 || 'A.length=0'
if OptionUseFileOffsetCodes = 'Y' then
call _InitializeArray 'C'
else
call _InitializeArray 'L'
do Index = 1 to WordCount
if OptionUseFileOffsetCodes = 'Y' then
PreviousElement = ''
call _AddToArray Occurs.Index
end
call _FlushArray
call _GenerateLine Tab1 || '}'
call _GenerateLine ''
if OptionUseFileOffsetCodes = 'Y' then
do
call _GenerateLine Tab1 || 'var OffsetCodes="' || left(FileOffsetArray, HighestOffsetUsed) || '"'
end
if OptionUseCodes = 'Y' then
do
CodeFrom = d2c(CodeFromAscii)
CodeTo = d2c(CodeFromAscii + LongestLeadingCodeUsed)
call _GenerateLine Tab1 || 'var CompCodes="' || xrange(CodeFrom, CodeTo) || '"'
end
call _GenerateLine ''
call _GenerateCmt Tab1, 'Are we displaying the results of a test?'
call _GenerateLine Tab1 || 'CookieValue=FindCookie("' || CookieName || '")'
call _GenerateLine ''
call _GenerateCmt Tab1, 'Generate the search form'
call _GenerateLine Tab1 || 'document.write("<CENTER>")'
call _GenerateLine Tab1 || 'document.write("<FORM NAME=`SearchForm` onSubmit=`return PerformSearch(SearchText.value.toUpperCase())`>")'
if OptionSearchButton = 'Y' then
call _GenerateLine Tab1 || 'document.write("<TABLE BORDER=0 CELLSPACING=10><TR><TD ALIGH=RIGHT>")'
call _GenerateLine Tab1 || 'document.write("Search Site For: <INPUT TYPE=`text` Name=`SearchText` SIZE=25 MAXLENGTH=50 VALUE=`"+CookieValue+"`>")'
if OptionSearchButton = 'Y' then
do
call _GenerateLine Tab1 || 'document.write("<TD ALIGH=LEFT>")'
call _GenerateLine Tab1 || 'document.write("<INPUT TYPE=`submit` NAME=`PBUTTON` VALUE=`SEARCH`>")'
call _GenerateLine Tab1 || 'document.write("</TR></TABLE>")'
end
call _GenerateLine Tab1 || 'document.write("</FORM><BR>")'
call _GenerateLine ''
call _GenerateLine Tab1 || 'if(CookieValue!' || '="")'
call _GenerateLine Tab1 || '{'
call _GenerateLine Tab2 || 'F=new CreateFileArray()'
call _GenerateLine Tab2 || 'W=new CreateWordArray()'
call _GenerateLine Tab2 || 'O=new CreateOccursArray()'
call _GenerateLine Tab1 || '}'
call _GenerateLine ''
call _GenerateCmt Tab1, 'Cause search to be performed'
call _GenerateLine Tab1 || 'function PerformSearch(Find)'
call _GenerateLine Tab1 || '{'
call _GenerateCmt Tab2, 'Make sure no space was specified'
call _GenerateLine Tab2 || 'if(Find.indexOf(" ")!' || '=-1)'
call _GenerateLine Tab3 || 'alert("\n\nSPACES ARE NOT ALLOWED!\n\nYou can only search for one word (or part of).")'
call _GenerateLine Tab2 || 'else'
call _GenerateLine Tab2 || '{'
call _GenerateCmt Tab3, 'Valid search specification'
call _GenerateLine Tab3 || 'document.cookie="' || CookieName || '="+Find'
call _GenerateLine Tab3 || 'if(Find!' || '=""&&CookieValue!' || '=Find)'
call _GenerateLine Tab4 || 'location.reload(false)'
call _GenerateLine Tab2 || '}'
call _GenerateLine Tab2 || 'return(false)'
call _GenerateLine Tab1 || '}'
call _GenerateLine ''
call _GenerateCmt Tab1, 'Generate file link'
call _GenerateLine Tab1 || 'function GenerateFileInfo(FileIndex)'
call _GenerateLine Tab1 || '{'
call _GenerateLine Tab2 || 'document.write("<A ' || OptionLinkTarget || 'HREF=`" + F[FileIndex] + "`>" + F[FileIndex] + "</A><BR>")'
call _GenerateLine Tab1 || '}'
call _GenerateLine ''
call _GenerateCmt Tab1, 'Find a Cookie'
call _GenerateLine Tab1 || 'function FindCookie(CookieName)'
call _GenerateLine Tab1 || '{'
call _GenerateCmt Tab2, 'Are there any cookies at all (this document)'
call _GenerateLine Tab2 || 'var AllCookies=document.cookie'
call _GenerateLine Tab2 || 'if(AllCookies=="")'
call _GenerateLine Tab3 || 'return("")'
call _GenerateLine ''
call _GenerateCmt Tab2, 'There are some cookies, look for our specific one'
call _GenerateLine Tab2 || 'var LookFor=CookieName+"="'
call _GenerateLine Tab2 || 'var Posn=AllCookies.indexOf(LookFor)'
call _GenerateLine Tab2 || 'if(Posn==-1)'
call _GenerateLine Tab3 || 'return("")'
call _GenerateLine ''
call _GenerateCmt Tab2, 'Point past the "=" to start of cookies value'
call _GenerateLine Tab2 || 'Posn+=LookFor.length'
call _GenerateLine ''
call _GenerateCmt Tab2, 'Find end of value'
call _GenerateLine Tab2 || 'var EndPosn=AllCookies.indexOf(";",Posn)'
call _GenerateLine Tab2 || 'if(EndPosn==-1)'
call _GenerateLine Tab3 || 'EndPosn=AllCookies.length'
call _GenerateLine ''
call _GenerateCmt Tab2, 'Extract the cookie'
call _GenerateLine Tab2 || 'var ItsValue=AllCookies.substring(Posn,EndPosn)'
call _GenerateLine Tab2 || 'return(ItsValue)'
call _GenerateLine Tab1 || '}'
call _GenerateLine ''
call _GenerateCmt Tab1, 'Given a word index, generate links'
call _GenerateLine Tab1 || 'function GenerateWordInfo(WordIndex)'
call _GenerateLine Tab1 || '{'
call _GenerateLine Tab2 || 'var CommaPosn'
call _GenerateLine ''
call _GenerateCmt Tab2, 'Output the word'
call _GenerateLine Tab2 || 'document.write("<TR><TD>" + W[WordIndex] + "<TD>")'
call _GenerateLine ''
call _GenerateCmt Tab2, 'Output match locations'
if OptionUseFileOffsetCodes = 'Y' then
call _GenerateLine Tab2 || 'FileIndexes=Code2List(O[WordIndex])'
else
call _GenerateLine Tab2 || 'FileIndexes=O[WordIndex]'
call _GenerateLine ''
call _GenerateCmt Tab2, 'Split out files'
call _GenerateLine Tab2 || 'while((CommaPosn=FileIndexes.indexOf(",")) !' || '=-1)'
call _GenerateLine Tab2 || '{'
call _GenerateCmt Tab3, 'Extract File Index'
call _GenerateLine Tab3 || 'FileIndex=FileIndexes.substring(0,CommaPosn)'
call _GenerateLine Tab3 || 'FileIndexes=FileIndexes.substring(CommaPosn+1)'
call _GenerateLine ''
call _GenerateCmt Tab3, 'Add File'
call _GenerateLine Tab3 || 'GenerateFileInfo(FileIndex)'
call _GenerateLine Tab2 || '}'
call _GenerateLine Tab2 || 'GenerateFileInfo(FileIndexes)'
call _GenerateLine Tab2 || 'document.write("</TR>")'
call _GenerateLine Tab1 || '}'
call _GenerateLine ''
call _GenerateCmt Tab1, 'Generate search results (if required)'
call _GenerateLine Tab1 || 'if(CookieValue!' || '="")'
call _GenerateLine Tab1 || '{'
call _GenerateCmt Tab2, 'Start of Table'
call _GenerateLine Tab2 || 'document.write("<HR><H1>Search Results for `"+CookieValue+"`</H1><BR>")'
call _GenerateLine Tab2 || 'document.write("<TABLE BORDER=3 CELLSPACING=1>")'
call _GenerateLine Tab2 || 'document.write("<TR><TH ALIGN=CENTER>Match<TH ALIGN=CENTER>Location</TR>")'
call _GenerateLine Tab1 || ''
call _GenerateCmt Tab2, 'Output all matching words'
call _GenerateLine Tab2 || 'FoundMatch=false'
call _GenerateLine Tab2 || 'for(Count=1;Count<=W.length;Count++)'
call _GenerateLine Tab2 || '{'
call _GenerateCmt Tab3, 'Search words'
call _GenerateLine Tab3 || 'if(CookieValue=="*"||W[Count].indexOf(CookieValue)!' || '=-1)'
call _GenerateLine Tab3 || '{'
call _GenerateCmt Tab4, 'We have a match so output the word info'
call _GenerateLine Tab4 || 'GenerateWordInfo(Count)'
call _GenerateLine Tab4 || 'FoundMatch=true'
call _GenerateLine Tab3 || '}'
call _GenerateLine Tab2 || '}'
call _GenerateCmt Tab2, 'Handle no match'
call _GenerateLine Tab2 || 'if(!FoundMatch)'
call _GenerateLine Tab2 || '{'
if OptionDisplayAllOnNoMatch = 'N' then
do
call _GenerateCmt Tab3, 'No matches, (not listing all files)'
call _GenerateLine Tab3 || 'document.write("<TR><TD ALIGN=CENTER COLSPAN=2>No matches!</TR>")'
end
else
do
call _GenerateCmt Tab3, 'No matches, output list of all files'
call _GenerateLine Tab3 || 'document.write("<TR><TD VALIGN=TOP>No matches!<TD ALIGN=LEFT>")'
call _GenerateLine Tab3 || 'for(FCount=1;FCount<=F.length;FCount++)'
call _GenerateLine Tab4 || 'GenerateFileInfo(FCount)'
call _GenerateLine Tab3 || 'document.write("</TR>")'
end
call _GenerateLine Tab2 || '}'
call _GenerateLine ''
call _GenerateCmt Tab2, 'End of TABLE'
call _GenerateLine Tab2 || 'document.write("</TABLE>")'
call _GenerateLine Tab2 || 'document.SearchForm.SearchText.select()'
call _GenerateLine Tab1 || '}'
call _GenerateLine Tab1 || 'document.write("</CENTER>")'
call _GenerateLine ''
call _GenerateCmt Tab1, 'Output footer'
call _GenerateLine Tab1 || 'document.write("<BR><BR><HR><TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0 FRAME=VOID><TR><TD ALIGH=LEFT><FONT SIZE=-2>")'
call _GenerateLine Tab1 || 'document.write("")'
call _GenerateLine Tab1 || 'document.write("<!--- A condition of use of this program is to leave the link to my homepage as is --->")'
call _GenerateLine Tab1 || 'document.write("<A HREF=`' || HttpSourcePage || '` TARGET=_top>Client Side Search Engine<BR>(C)opyright by Dennis Bareis.<BR>The OS/2 generator is FREE.</A>")'
call _GenerateLine Tab1 || 'document.write("<!--- A condition of use of this program is to leave the link to my homepage as is --->")'
call _GenerateLine Tab1 || 'document.write("")'
call _GenerateLine Tab1 || 'document.write("<TD ALIGN=RIGHT VALIGN=TOP><FONT SIZE=-2>")'
call _GenerateLine Tab1 || 'document.write("' || WordCount || ' words indexed - ' || IndexTime || '")'
call _GenerateLine Tab1 || 'document.write("</TR></TABLE>")'
call _GenerateLine Tab1 || ''
call _GenerateCmt Tab1, 'Set focus to input field'
call _GenerateLine Tab1 || 'document.SearchForm.SearchText.focus()'
call _GenerateLine "//-->"
call _GenerateLine "</SCRIPT>"
if OptionCompleteHtmlPage = 'Y' then
call _GenerateLine "</HTML>"
return
_InitializeArray:
ArrayFunction = arg(1)
CachedArrayElements = ""
PreviousElement = ''
return
_FlushArray:
if CachedArrayElements <> '' then
do
if length(CachedArrayElements) < MaxElementlength then
call _GenerateLine Tab2 || ArrayFunction || '("' || CachedArrayElements || '")'
else
do
call _GenerateLine Tab2 || ArrayFunction || '('
do forever
if length(CachedArrayElements) < MaxElementlength then
do
call _GenerateLine Tab3 || '"' || CachedArrayElements || '"'
leave
end
else
do
call _GenerateLine Tab3 || '"' || left(CachedArrayElements, MaxElementlength) || '"+'
CachedArrayElements = substr(CachedArrayElements, MaxElementlength+1)
end
end
call _GenerateLine Tab2 || ' )'
end
end
call _InitializeArray ArrayFunction
return
_AddToArray:
ItemAsPassed = arg(1)
Item2Add = ItemAsPassed
if OptionUseCodes = 'Y' then
do
if PreviousElement <> '' then
do
CharsThatMatch = compare(PreviousElement, ItemAsPassed)
if CharsThatMatch = 0 then
CharsThatMatch = length(PreviousElement)
else
CharsThatMatch = CharsThatMatch - 1
if CharsThatMatch > 1 then
do
if CharsThatMatch > MaxLeadingLengthCode then
CharsThatMatch = MaxLeadingLengthCode
if (CharsThatMatch-2) > LongestLeadingCodeUsed then
LongestLeadingCodeUsed = CharsThatMatch - 2
Item2Add = d2c(CodeFromAscii + CharsThatMatch - 2) || substr(ItemAsPassed, CharsThatMatch+1)
end
end
end
if CachedArrayElements = '' then
CachedArrayElements = Item2Add
else
do
NewValue = CachedArrayElements || '|' || Item2Add
if length(NewValue) < MaxElementlength then
CachedArrayElements = NewValue
else
do
call _FlushArray
CachedArrayElements = Item2Add
end
end
PreviousElement = ItemAsPassed
return
EndGenerateXh:
/*
* REPLSTR.XH Version 99.031 By Dennis Bareis
* http://www.labyrinth.net.au/~dbareis/index.htm (db0@anz.com)
*/
ReplaceCount = 0
signal EndREPLSTR
ReplaceString:
parse arg rs?TheString, rs?ChangeFrom
rs?FoundPosn = pos(rs?ChangeFrom, rs?TheString)
if rs?FoundPosn = 0 then
return(rs?TheString)
rs?ChangeTo = arg(3)
rs?ChangeFromLength = length(rs?ChangeFrom)
rs?LeftPart = ''
do until rs?FoundPosn = 0
rs?LeftPart = rs?LeftPart || left(rs?TheString, rs?FoundPosn-1) || rs?ChangeTo
rs?TheString = substr(rs?TheString, rs?FoundPosn+rs?ChangeFromLength)
ReplaceCount = ReplaceCount + 1
rs?FoundPosn = pos(rs?ChangeFrom, rs?TheString)
end
return(rs?LeftPart || rs?TheString)
EndREPLSTR:
OptionCompleteHtmlPage = 'Y'
OptionScanSubDir = ''
OptionJustWordList = 'N'
OptionNumbersAreOk = 'N'
OptionCompact = 'Y'
OptionDisplayAllOnNoMatch = 'Y'
OptionOutputFileName = ''
OptionDropWordPercent = 40
OptionLinkTarget = '_top'
NumberOfExcludedFiles = 0
OptionAdjustFileName = ''
OptionSearchButton = 'Y'
OptionUseCodes = 'Y'
OptionUseFileOffsetCodes = 'Y'
call SetColorCodes
call DisplayCopyright
signal on NOVALUE name RexxTrapUninitializedVariable
signal on SYNTAX name RexxTrapSyntaxError
signal on HALT name RexxCtrlC
Arguments = arg(1)
if Arguments = "" then
UserSyntaxError("Too few parameters (expected name of input file!)")
parse var Arguments InputMask OptionsCmdLine
OptionsCmdLine = strip(OptionsCmdLine)
OptionsEnvironment = GetEnv('JSEARCH_OPTIONS')
ExtraParms = OptionsEnvironment || ' ' || OptionsCmdLine
do while ExtraParms <> ''
parse var ExtraParms ThisParm ExtraParms
parse var ThisParm ThisCmd':'ThisCmdOptions
ThisCmd = translate(ThisCmd)
select
when ThisCmd = '/NOHIGHASCII' then
OptionUseCodes = 'N'
when ThisCmd = '/MAXPERCENT' then
OptionDropWordPercent = ThisCmdOptions
when ThisCmd = '/NOBUTTON' then
OptionSearchButton = 'N'
when ThisCmd = '/NOLISTONNOMATCH' then
OptionDisplayAllOnNoMatch = 'N'
when ThisCmd = '/OUTPUT' then
OptionOutputFileName = AdjustFileName(ThisCmdOptions)
when ThisCmd = '/TARGET' then
OptionLinkTarget = ThisCmdOptions
when ThisCmd = '/S' then
OptionScanSubDir = 'S'
when ThisCmd = '/#' then
OptionNumbersAreOk = 'Y'
when ThisCmd = '/PRETTY' then
OptionCompact = 'N'
when ThisCmd = '/JUSTWORDS' then
do
say 'ALL WORDS'
say '~~~~~~~~~'
OptionJustWordList = 'Y'
end
when ThisCmd = '/EXCLUDEWORDS' then
do
call LoadExcludeFile ThisCmdOptions
end
when ThisCmd = '/OKINWORD' then
call WordChars AllwaysInWord || ThisCmdOptions
when ThisCmd = '/EXCLUDEFILES' then
call ExcludeFilesMatching ThisCmdOptions
when ThisCmd = '/LOWER' then
OptionAdjustFileName = 'L'
when ThisCmd = '/UPPER' then
OptionAdjustFileName = 'U'
otherwise
UserSyntaxError('Unknown command of "' || ThisCmd || '" specified')
end
end
if OptionOutputFileName = '' then
OptionOutputFileName = 'JsSearch.htm'
if OptionLinkTarget <> '' then
OptionLinkTarget = 'TARGET=' || OptionLinkTarget || ' '
if OptionCompact = 'N' then
do
Tab1 = d2c(9)
Eol = d2c(13) || d2c(10)
end
else
do
Tab1 = ''
Eol = d2c(10)
end
Tab2 = Tab1 || Tab1
Tab3 = Tab1 || Tab2
Tab4 = Tab1 || Tab3
if left(OptionOutputFileName, 1) = '+' then
do
OptionCompleteHtmlPage = 'N'
OptionOutputFileName = substr(OptionOutputFileName, 2)
CloseRc = stream(OptionOutputFileName, 'c', 'close')
if stream(OptionOutputFileName, 'c', 'query exists') = '' then
UserSyntaxError('You requested an append onto "' || OptionOutputFileName || '" (it does not exist)!')
end
else
do
CloseRc = stream(OptionOutputFileName, 'c', 'close')
if stream(OptionOutputFileName, 'c', 'query exists') <> '' then
do
DosDelRc = SysFileDelete(OptionOutputFileName)
end
end
OutputPathCharL = '('
OutputPathCharR = ')'
DropTillChar = '~'
LeftPos = pos(OutputPathCharL, InputMask)
if LeftPos = 0 then
OutputFilePrefix = ""
else
do
OutputFilePrefix = substr(InputMask, LeftPos+1, length(InputMask)-LeftPos-1)
InputMask = left(InputMask, LeftPos-1)
end
InputMask2 = stream(InputMask, 'c', 'query exists')
if InputMask2 = '' then
UserSyntaxError('No input files matching "' || InputMask || '" were found.')
InputMask = InputMask2
LengthInputMaskPath = length(filespec('drive', InputMask) || filespec('path', InputMask))
if substr(OutputFilePrefix, 2, 1) = ':' then
OutputFilePrefix = '/' || OutputFilePrefix
WordCount = 0
ExitRc = 0
call SysFileTree InputMask, 'InputList', 'FO' || OptionScanSubDir
if InputList.0 = 0 then
UserSyntaxError('No input files matching "' || InputMask || '" were found!')
else
do
do InputIndex = 1 to InputList.0
GenerateRc = ProcessFile(InputList.InputIndex)
if GenerateRc <> 0 then
ExitRc = GenerateRc
end
end
say 'Found ' || AddCommasToDecimalNumber(WordCount) || ' words...'
if InputList.0 > 1 then
do
if OptionDropWordPercent <> 0 then
do
say 'Dropping any words that occur in ' || OptionDropWordPercent || '% or more of the files...'
if OptionDropWordPercent = 100 then
MaxNumberFiles = InputList.0 - 1
else
do
MaxNumberFiles = (InputList.0 * OptionDropWordPercent) % 100
if MaxNumberFiles < 1 then
MaxNumberFiles = 1
end
DropCount = 0
do Index = 1 to WordCount
NumFiles = words( translate(File.Index, ' ', Delimiter) )
if NumFiles > MaxNumberFiles then
do
Word.Index = ''
DropCount = DropCount + 1
end
end
say 'Dropped ' || AddCommasToDecimalNumber(DropCount) || ' words (left with ' || AddCommasToDecimalNumber(WordCount-DropCount) || ')...'
end
end
say 'Sorting results...'
dIndex = 0
do sIndex = 1 to WordCount
if Word.sIndex <> '' then
do
dIndex = dIndex + 1
WordFile.dIndex = Word.sIndex || Delimiter || File.sIndex
end
end
WordFile.0 = dIndex
WordCount = dIndex
call SortWordAndFiles
say 'Generating arrays...'
call CreateWordFileOccursArrays
if OptionJustWordList = 'Y' then
do
do Index = 1 to WordCount
say Word.Index
end
ThatsAllFolks(1)
end
say 'Generating JavaScript (' || OptionOutputFileName || ')...'
call GenerateJavaScript
say 'Longest leading code used was for ' || LongestLeadingCodeUsed+2 || ' bytes.'
say 'Successful (took ' || time('Elapsed') || ' seconds)'
ThatsAllFolks(ExitRc)
GenerateHtmlFileName:
ShortOutName = substr(arg(1), LengthInputMaskPath+1)
FullOutputName = OutputFilePrefix || ShortOutName
return(FullOutputName)
AdjustFileName:
if OptionAdjustFileName = '' then
return(arg(1))
else
do
if OptionAdjustFileName = 'U' then
return( translate(arg(1)) )
else
return( translate(arg(1), LowerCase, UpperCase) )
end
SetColorCodes:
EscapeChar = d2c(27)
Reset = EscapeChar || '[0m'
HighlightColor = EscapeChar || '[1;35m'
TitleColor = EscapeChar || '[0;32m'
ErrorColor = EscapeChar || '[1;31m'
ExcludingColor = EscapeChar || '[0;33m'
IncludingColor = EscapeChar || '[0;1m'
return
RemoveColorCodes:
Reset = ''
HighlightColor = ''
TitleColor = ''
ErrorColor = ''
ExcludingColor = ''
IncludingColor = ''
return
ExcludeFilesMatching:
Excluded.0 = 0
call SysFileTree arg(1), 'Excluded', 'FO' || OptionScanSubDir
do EIndex = 1 to Excluded.0
NumberOfExcludedFiles = NumberOfExcludedFiles + 1
ExcludedFiles.NumberOfExcludedFiles = AdjustFileName( stream(Excluded.EIndex, 'c', 'query exists') )
end
return
FindFile:
FindFile = arg(1)
do Index = 1 to FileCount
if FindFile = File.Index then
return(Index)
end
return(0)
AddFile:
ToAddFile = arg(1)
Index = FindFile(ToAddFile)
if Index = 0 then
do
FileCount = FileCount + 1
File.FileCount = ToAddFile
Index = FileCount
end
return(Index)
CreateWordFileOccursArrays:
FileCount = 0
do WIndex = 1 to WordCount
parse var WordFile.WIndex Word.WIndex(Delimiter)FileList
do while FileList <> ''
parse var FileList ThisFile(Delimiter)FileList
call AddFile GenerateHtmlFileName(strip(ThisFile))
end
end
File.0 = FileCount
call SortFiles
HighestOffsetUsed = 0
do WIndex = 1 to WordCount
parse var WordFile.WIndex .(Delimiter)FileList
do FIndex = 1 to FileCount
FileSort.FIndex = 'N'
end
do while FileList <> ''
parse var FileList ThisFile(Delimiter)FileList
FIndex = FindFile(GenerateHtmlFileName(strip(ThisFile)))
FileSort.FIndex = 'Y'
end
if OptionUseFileOffsetCodes = 'Y' then
do
FileOffsetArray = "123456789" || UpperCase || LowerCase || "~!@#$%^&*()_+=`{}[]:;<>,./?" || xrange('80'x, 'FF'x)
LastIndex = 0
if FileCount > length(FileOffsetArray) then
OptionUseFileOffsetCodes = 'N'
end
FileIndexes = ''
do FIndex = 1 to FileCount
if FileSort.FIndex = 'Y' then
do
if OptionUseFileOffsetCodes = 'Y' then
do
ThisOffset = FIndex - LastIndex
LastIndex = FIndex
if ThisOffset > HighestOffsetUsed then
HighestOffsetUsed = ThisOffset
FileIndexes = FileIndexes || substr(FileOffsetArray, ThisOffset, 1)
end
else
do
if FileIndexes <> '' then
FileIndexes = FileIndexes || ','
FileIndexes = FileIndexes || FIndex
end
end
end
Occurs.WIndex = FileIndexes
end
return
FindWord:
FoundIndex = KeyGetInfo("WordIndex", 'W_' || c2x(arg(1)))
if FoundIndex = "<KeyedVarUnknown>" then
return(0)
return(FoundIndex)
AddWordAndFile:
ToAddWord = translate(strip(arg(1)))
if length(ToAddWord) < 3 | length(ToAddWord) > 30 then
return
ToAddFile = arg(2)
Index = FindWord(ToAddWord)
if Index = 0 then
do
WordCount = WordCount + 1
Word.WordCount = ToAddWord
File.WordCount = ToAddFile
call KeySaveInfo "WordIndex", 'W_' || c2x(ToAddWord), WordCount
end
else
do
if pos(ToAddFile, File.Index) = 0 then
File.Index = File.Index || Delimiter || ToAddFile
end
return
ProcessFile:
FullName = AdjustFileName( stream(arg(1), 'c', 'query exists') )
if NumberOfExcludedFiles <> 0 then
do
do EIndex = 1 to NumberOfExcludedFiles
if FullName = ExcludedFiles.EIndex then
do
say ExcludingColor || 'Excluding : ' || FullName || Reset
return(0)
end
end
end
say IncludingColor || 'Processing: ' || FullName || Reset
say IncludingColor || ' => ' || GenerateHtmlFileName(FullName) || Reset
CloseRc = stream(FullName, 'c', 'close')
do while lines(FullName) <> 0
WordList = space(translate(linein(FullName), '', NotPartOfWordChars, ' '))
do while WordList <> ''
parse var WordList ThisWord' 'WordList
if ExcludeWord(ThisWord) = 'Y' then
iterate
if OptionNumbersAreOk = 'N' then
do
if datatype(ThisWord, 'Whole Number') then
iterate
end
call AddWordAndFile ThisWord, FullName
end
end
CloseRc = stream(FullName, 'c', 'close')
return(0)
CaseInsensitiveSort : PROCEDURE
a = translate(arg(1))
b = translate(arg(2))
select
when ( a < b ) then
return(-1)
when ( a > b ) then
return(1)
otherwise
return(0)
end
NormalSort: PROCEDURE
parse arg a, b
select
when ( a < b ) then
return(-1)
when ( a > b ) then
return(1)
otherwise
return(0)
end
GetAmPmTime: procedure
CivilTime = time('C'); if length(CivilTime) = 6 then CivilTime=' 'CivilTime
TheTime = time(); NumSeconds = ':'substr(TheTime, 7, 2)
return( insert(NumSeconds, CivilTime, 5) )
GetEnv:
return( value(arg(1),,'OS2ENVIRONMENT') )
AddCommasToDecimalNumber: procedure
NoComma = strip( arg(1) )
if pos(',', NoComma) <> 0 then
return(NoComma)
DotPos = pos('.', NoComma)
if DotPos = 0 then
AfterDecimal = ''
else
do
if DotPos = 1 then
return("0" || NoComma)
AfterDecimal = substr(NoComma, DotPos+1)
NoComma = left(NoComma, DotPos-1)
end
NoComma = reverse(NoComma)
ResultWithCommas = ""
do while length(NoComma) > 3
ResultWithCommas = ResultWithCommas || left(NoComma, 3) || ','
NoComma = substr(NoComma, 4)
end
ResultWithCommas = ResultWithCommas || NoComma
ResultWithCommas = reverse(ResultWithCommas)
if AfterDecimal <> '' then
ResultWithCommas = ResultWithCommas || '.' || AfterDecimal
return(ResultWithCommas)
WordChars:
AllValidWordChars = arg(1)
AllChars = xrange('00'x, 'FF'x)
NotPartOfWordChars = translate(AllChars, '', AllValidWordChars, ' ')
NotPartOfWordChars = space(NotPartOfWordChars, 0)
return
GetLineNumber:
return( SIGL )
RexxCtrlC:
LineCtrlC = SIGL
say ''
say HighlightColor || copies('=+', 39) || ErrorColor
say "Come on, you pressed Ctrl+C or Break didn't you!"
say HighlightColor || copies('=+', 39) || Reset
ThatsAllFolks(LineCtrlC)
CommonTrapHandler:
FailingLine = arg(1)
TrapHeading = 'BUG: ' || arg(2)
TextDescription = arg(3)
Text = arg(4)
SourceFileName = GetRexxSourceName()
say HighlightColor || copies('=+', 39) || ErrorColor
say TrapHeading
say copies('~', length(TrapHeading))
say substr(TextDescription, 1 , 16) || ': ' || Text
say 'Failing Module : ' || SourceFileName
say 'Failing Line # : ' || FailingLine
say 'Failing Command : ' || strip(SourceLine(FailingLine))
say HighlightColor || copies('=+', 39) || Reset
ThatsAllFolks(GetLineNumber())
RexxTrapUninitializedVariable:
TrappingLine = SIGL
call CommonTrapHandler TrappingLine, 'NoValue Abort!', 'Unknown Variable', condition('D')
RexxTrapSyntaxError:
TrappingLine = SIGL
call CommonTrapHandler TrappingLine, 'Syntax Error!', 'Reason', errortext(Rc)
ThatsAllFolks:
WantedExitRc = arg(1)
if OptionOutputFileName <> '' then
do
if WantedExitRc = 0 then
do
FileState = stream(OptionOutputFileName, 'Description')
if left(FileState,6) <> 'READY:' then
do
say 'IOERROR on "' || OptionOutputFileName || '", Reason = ' || FileState
WantedExitRc = GetLineNumber()
end
end
CloseRc = stream(OptionOutputFileName, 'c', 'close')
end
exit(WantedExitRc)
DisplayCopyright:
if CopyrightDisplayed = 'N' then
do
call charout ,HighlightColor
say '[]------------------------------------------------------------[]'
say '| JSSEARCH.CMD: Version ' || PgmVersion || ' (C)opyright Dennis Bareis 1998 |'
say '| http://www.labyrinth.net.au/~dbareis (db0@anz.com) |'
say '[]------------------------------------------------------------[]'
say Reset
CopyrightDisplayed = 'Y'
end
return
UserSyntaxError:
CallersLine = SIGL
call DisplayCopyright
say ErrorColor || "SYNTAX ERROR"
say "~~~~~~~~~~~~"
say ' ' || arg(1)
say ''
say 'CORRECT SYNTAX'
say '~~~~~~~~~~~~~~'
say ' JSSEARCH[.CMD] InputMask [Option1 ...]'
say ''
say 'OPTIONS'
say '~~~~~~~'
say '/OUTPUT:file /MAXPERCENT:% /TARGET:Window'
say '/EXCLUDEFILES:mask /EXCLUDEWORDS:file /OKINWORD:CharList'
say '/LOWER /UPPER /PRETTY'
say '/NOBUTTON /NOLISTONNOMATCH'
say '/S /# /JUSTWORDS'
say ''
say 'Please see "JSSEARCH.INF" for more details (and more options).' || Reset
ThatsAllFolks(CallersLine)
GetRexxSourceName:
parse source . . TmpRexxSrc .
return(TmpRexxSrc)