home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Java / Java.zip / sse99067.zip / JSSEARCH.CMD next >
OS/2 REXX Batch file  |  1999-03-08  |  38KB  |  1,133 lines

  1. /*
  2.  * Generator   : PPWIZARD version 99.067
  3.  *             : FREE tool for OS/2, Windows, DOS and UNIX by Dennis Bareis (db0@anz.com)
  4.  *             : http://www.labyrinth.net.au/~dbareis/ppwizard.htm
  5.  * Time        : Monday, 8 Mar 1999 12:24:57pm
  6.  * Input File  : E:\DB\PROJECTS\OS2\jssearch\JSSEARCH.x
  7.  * Output File : .\OUT\JSSEARCH.CMD
  8.  */
  9.  
  10. PgmVersion         = "99.067"
  11. call RxFuncAdd  'SysFileDelete', 'RexxUtil', 'SysFileDelete'
  12. call RxFuncAdd  'SysFileTree',   'RexxUtil', 'SysFileTree'
  13. call time('Reset')
  14. numeric digits 14
  15. trace off
  16. HttpSourcePage     = 'http://www.labyrinth.net.au/~dbareis/freeos2.htm'
  17. Delimiter          = d2c(29)
  18. CopyrightDisplayed = 'N'
  19. LowerCase          = "abcdefghijklmnopqrstuvwxyz"
  20. UpperCase          = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  21. DecimalDigits      = '0123456789'
  22. AllwaysInWord      = LowerCase || UpperCase || DecimalDigits
  23. call WordChars AllwaysInWord
  24. MaxLeadingLengthCode   = 50
  25. CodeFromAscii          = 130
  26. LongestLeadingCodeUsed = 0
  27. /*
  28. * QSORT.XH Version 98.158 by Dennis Bareis
  29. *            The base code was not written by me (not sure where it came from
  30. *            http://www.labyrinth.net.au/~dbareis/index.htm (db0@anz.com)
  31. */
  32. signal EndQsortXh_1
  33. _SortWordAndFiles: PROCEDURE EXPOSE WordFile.
  34. parse arg top, down
  35. if ( ( down-top ) < 2 ) then
  36. do
  37. if ( ( down - top ) > 0 ) then
  38. /* if ( WordFile.top > WordFile.down ) then */
  39. if ( NormalSort( WordFile.top, WordFile.down ) > 0 ) then
  40. do
  41. tmpval      = WordFile.top
  42. WordFile.top    = WordFile.down
  43. WordFile.down   = tmpval
  44. end
  45. end
  46. else
  47. do
  48. l = top
  49. r = down
  50. m = top + trunc( ( down-top )/2 )
  51. do while ( l<r )
  52. m_val = WordFile.m
  53. /* do while ( WordFile.l < m_val ) */
  54. do while ( NormalSort( WordFile.l, m_val ) < 0 )
  55. if  ( l < m ) then
  56. l=l+1
  57. else
  58. leave
  59. end
  60. /* do while ( WordFile.r > m_val ) */
  61. do while ( NormalSort( WordFile.r, m_val ) > 0 )
  62. if  ( m < r ) then
  63. r=r-1
  64. else
  65. leave
  66. end
  67. if ( l < r ) then
  68. do
  69. tmpval = WordFile.l
  70. WordFile.l = WordFile.r
  71. WordFile.r = tmpval
  72. select
  73. when ( m=r ) then
  74. do
  75. r = r-1
  76. m = l
  77. end
  78. when ( m=l ) then
  79. do
  80. l = l+1
  81. m = r
  82. end
  83. otherwise
  84. do
  85. l = l+1
  86. r = r-1
  87. end
  88. end
  89. end
  90. end
  91. if ( ( r-top ) < ( down-l ) ) then
  92. do
  93. call _SortWordAndFiles top, m-1
  94. call _SortWordAndFiles m+1, down
  95. end
  96. else
  97. do
  98. call _SortWordAndFiles m+1, down
  99. call _SortWordAndFiles top, m-1
  100. end
  101. end
  102. return
  103. SortWordAndFiles: PROCEDURE EXPOSE WordFile.
  104. call _SortWordAndFiles 1, WordFile.0
  105. return
  106. EndQSORTXh_1:
  107. signal EndQsortXh_2
  108. _SortFiles: PROCEDURE EXPOSE File.
  109. parse arg top, down
  110. if ( ( down-top ) < 2 ) then
  111. do
  112. if ( ( down - top ) > 0 ) then
  113. /* if ( File.top > File.down ) then */
  114. if ( CaseInsensitiveSort( File.top, File.down ) > 0 ) then
  115. do
  116. tmpval      = File.top
  117. File.top    = File.down
  118. File.down   = tmpval
  119. end
  120. end
  121. else
  122. do
  123. l = top
  124. r = down
  125. m = top + trunc( ( down-top )/2 )
  126. do while ( l<r )
  127. m_val = File.m
  128. /* do while ( File.l < m_val ) */
  129. do while ( CaseInsensitiveSort( File.l, m_val ) < 0 )
  130. if  ( l < m ) then
  131. l=l+1
  132. else
  133. leave
  134. end
  135. /* do while ( File.r > m_val ) */
  136. do while ( CaseInsensitiveSort( File.r, m_val ) > 0 )
  137. if  ( m < r ) then
  138. r=r-1
  139. else
  140. leave
  141. end
  142. if ( l < r ) then
  143. do
  144. tmpval = File.l
  145. File.l = File.r
  146. File.r = tmpval
  147. select
  148. when ( m=r ) then
  149. do
  150. r = r-1
  151. m = l
  152. end
  153. when ( m=l ) then
  154. do
  155. l = l+1
  156. m = r
  157. end
  158. otherwise
  159. do
  160. l = l+1
  161. r = r-1
  162. end
  163. end
  164. end
  165. end
  166. if ( ( r-top ) < ( down-l ) ) then
  167. do
  168. call _SortFiles top, m-1
  169. call _SortFiles m+1, down
  170. end
  171. else
  172. do
  173. call _SortFiles m+1, down
  174. call _SortFiles top, m-1
  175. end
  176. end
  177. return
  178. SortFiles: PROCEDURE EXPOSE File.
  179. call _SortFiles 1, File.0
  180. return
  181. EndQSORTXh_2:
  182. /*
  183. * KEYEDVAR.XH Version 98.169 by Dennis Bareis
  184. *            http://www.labyrinth.net.au/~dbareis/index.htm (db0@anz.com)
  185. */
  186. signal EndKeyedVarXH
  187. KeySaveInfo:
  188. interpret arg(1) || '_?.?_' || arg(2) || ' = arg(3)'
  189. return(0)
  190. KeyExists:
  191. if  symbol(arg(1) || '_?.?_' || arg(2)) = 'VAR' then
  192. return('Y')
  193. else
  194. return('N')
  195. KeyGetInfo:
  196. siSaveAs = arg(1) || '_?.?_' || arg(2)
  197. if  symbol(siSaveAs) <> 'VAR' then
  198. return("<KeyedVarUnknown>")
  199. interpret "siContents = " || siSaveAs
  200. return(siContents)
  201. EndKeyedVarXH:
  202. signal EndExcludeXH
  203. LoadExcludeFile:
  204. ExcludeFile = strip(arg(1))
  205. if  stream(ExcludeFile, 'c', 'query exists') = '' then
  206. do
  207. say 'ERROR: "' || ExcludeFile || '" does not exist'
  208. ThatsAllFolks(255)
  209. end
  210. CloseRc     = stream(ExcludeFile, 'c', 'close')
  211. do  while lines(ExcludeFile) <> 0
  212. CurrentWord = strip(linein(ExcludeFile))
  213. if  CurrentWord = '' then
  214. iterate
  215. if  left(CurrentWord, 1) = ';' then
  216. iterate
  217. call  KeySaveInfo  "X", CurrentWord
  218. end
  219. CloseRc = stream(ExcludeFile, 'c', 'close')
  220. return
  221. ExcludeWord:
  222. return( KeyExists("X", arg(1)) )
  223. EndExcludeXH:
  224. MaxElementlength = 245
  225. CookieName       = 'Cookie' || time('Seconds')
  226. signal EndGenerateXh
  227. _GenerateCmt:
  228. if  OptionCompact = 'N' then
  229. call _GenerateLine arg(1) || '<!--- ' || arg(2) || ' ------------------------------->'
  230. return
  231. _GenerateLine:
  232. TheLine = translate(arg(1), "'", "`")
  233. if  OptionCompact <> 'N' then
  234. TheLine = ReplaceString(TheLine, '', "")
  235. else
  236. TheLine = translate(TheLine, ' ', '')
  237. if  OptionCompact <> 'N' then
  238. do
  239. if  TheLine = '' then
  240. return
  241. end
  242. call charout OptionOutputFileName, TheLine || Eol
  243. return
  244. GenerateJavaScript:
  245. if  OptionCompleteHtmlPage = 'Y' then
  246. call _GenerateLine   "<HTML>"
  247. IndexTime = date('Weekday') || ', ' || date() || ' ' || GetAmPmTime()
  248. call _GenerateLine   "<!-------------------------------------------------------------->"
  249. call _GenerateLine   "<!--- This code was automatically generated by JSSEARCH.CMD  --->"
  250. call _GenerateLine   "<!--- version " || PgmVersion || ", this tool was written by Dennis Bareis --->"
  251. call _GenerateLine   "<!--- He has a homepage of free OS/2, DOS & Windows tools at --->"
  252. call _GenerateLine   "<!--- http://www.labyrinth.net.au/~dbareis  (db0@anz.com)    --->"
  253. call _GenerateLine   "<!-------------------------------------------------------------->"
  254. call _GenerateLine   "<NOSCRIPT>"
  255. call _GenerateLine   "<H1>Can't Perform Search</H1>"
  256. call _GenerateLine   "<P>Your browser does not support JavaScript or you don't have it available!<BR>"
  257. call _GenerateLine   "</NOSCRIPT>"
  258. call _GenerateLine   "<SCRIPT>"
  259. call _GenerateLine   "<!---"
  260. call _GenerateCmt  Tab1,   'Simply add the passed value to the array'
  261. call _GenerateLine Tab1 || 'function AddOneValue(Value)'
  262. call _GenerateLine Tab1 || '{'
  263. if    OptionUseCodes = 'Y' then
  264. do
  265. call _GenerateCmt  Tab2,   'Look for compression codes & expand'
  266. call _GenerateLine Tab2 ||  'FirstChar=Value.charAt(0)'
  267. call _GenerateLine Tab2 ||  'MatchPosn=CompCodes.indexOf(FirstChar)'
  268. call _GenerateLine Tab2 ||  'if(MatchPosn!' || '=-1)'
  269. call _GenerateLine Tab3 ||      'Value=A[A.length].substring(0,MatchPosn+2)+Value.substring(1)'
  270. call _GenerateLine ''
  271. end
  272. call _GenerateLine ''
  273. call _GenerateCmt  Tab2,        'Add the value to the end of the array'
  274. call _GenerateLine Tab2 ||      'A[++A.length]=Value'
  275. call _GenerateLine Tab1 || '}'
  276. call _GenerateLine ''
  277. call _GenerateCmt  Tab1,   'Add Listed Values to growing array - Items May Have Leading Codes'
  278. call _GenerateLine Tab1 || 'function L(List)'
  279. call _GenerateLine Tab1 || '{'
  280. call _GenerateCmt  Tab2,        'Seperate the value into individual parts'
  281. call _GenerateLine Tab2 ||      'while((Posn=List.indexOf("|"))!' || '=-1)'
  282. call _GenerateLine Tab2 ||      '{'
  283. call _GenerateCmt  Tab3,            'Extract the 1st value'
  284. call _GenerateLine Tab3 ||          'AddOneValue(List.substring(0,Posn))'
  285. call _GenerateLine ''
  286. call _GenerateCmt  Tab3,            'Prepare for next loop'
  287. call _GenerateLine Tab3 ||          'List=List.substring(Posn+1)'
  288. call _GenerateLine Tab2 ||      '}'
  289. call _GenerateLine ''
  290. call _GenerateCmt  Tab2,        'Handle the last word'
  291. call _GenerateLine Tab2 ||      'AddOneValue(List)'
  292. call _GenerateLine Tab1 || '}'
  293. call _GenerateLine ''
  294. if  OptionUseFileOffsetCodes  = 'Y' then
  295. do
  296. call _GenerateCmt  Tab1,   "Add Listed Values to occurs array - Items Don't Have Leading Codes but are compressed"
  297. call _GenerateLine Tab1 || 'function C(List)'
  298. call _GenerateLine Tab1 || '{'
  299. call _GenerateCmt  Tab2,        'Seperate the value into individual parts'
  300. call _GenerateLine Tab2 ||      'while((Posn=List.indexOf("|"))!' || '=-1)'
  301. call _GenerateLine Tab2 ||      '{'
  302. call _GenerateCmt  Tab3,            'Extract the 1st value (add to array)'
  303. call _GenerateLine Tab3 ||          'A[++A.length]=List.substring(0,Posn)'
  304. call _GenerateLine ''
  305. call _GenerateCmt  Tab3,            'Prepare for next loop'
  306. call _GenerateLine Tab3 ||          'List=List.substring(Posn+1)'
  307. call _GenerateLine Tab2 ||      '}'
  308. call _GenerateLine ''
  309. call _GenerateCmt  Tab2,        'Add last value to array'
  310. call _GenerateLine Tab2 ||      'A[++A.length]=List'
  311. call _GenerateLine Tab1 || '}'
  312. call _GenerateLine ''
  313. call _GenerateCmt  Tab1,   'Passed compressed form, return occurs list (comma seperated)'
  314. call _GenerateLine Tab1 || 'function Code2List(Code)'
  315. call _GenerateLine Tab1 || '{'
  316. call _GenerateLine Tab2 ||      'var FIndex=0'
  317. call _GenerateLine Tab2 ||      'var List=""'
  318. call _GenerateLine ''
  319. call _GenerateLine Tab2 ||      'while(Code!' || '="")'
  320. call _GenerateLine Tab2 ||      '{'
  321. call _GenerateCmt  Tab3,            'Seperate bits'
  322. call _GenerateLine Tab3 ||          'FirstChar=Code.charAt(0)'
  323. call _GenerateLine Tab3 ||          'Code=Code.substring(1)'
  324. call _GenerateLine ''
  325. call _GenerateCmt  Tab3,            'Work out Index'
  326. call _GenerateLine Tab3 ||          'FIndex=FIndex+OffsetCodes.indexOf(FirstChar)+1'
  327. call _GenerateLine ''
  328. call _GenerateCmt  Tab3,            'Save Value'
  329. call _GenerateLine Tab3 ||          'if(List=="")'
  330. call _GenerateLine Tab4 ||              'List=FIndex.toString()'
  331. call _GenerateLine Tab3 ||          'else'
  332. call _GenerateLine Tab4 ||              'List+=","+FIndex.toString()'
  333. call _GenerateLine Tab2 ||      '}'
  334. call _GenerateLine Tab2 ||      'return(List)'
  335. call _GenerateLine Tab1 || '}'
  336. call _GenerateLine ''
  337. end
  338. call _GenerateCmt  Tab1,   'Create FILE array (' || FileCount || ' files)'
  339. call _GenerateLine Tab1 || 'function CreateFileArray()'
  340. call _GenerateLine Tab1 || '{'
  341. call _GenerateLine Tab2 || 'A=this'
  342. call _GenerateLine Tab2 || 'A.length=0'
  343. call _InitializeArray 'L'
  344. do   Index = 1 to FileCount
  345. call _AddToArray  translate(File.Index, '/', '\')
  346. end
  347. call _FlushArray
  348. call _GenerateLine Tab1 || '}'
  349. call _GenerateLine ''
  350. call _GenerateCmt  Tab1,   'Create WORD array (' || WordCount || ' words)'
  351. call _GenerateLine Tab1 || 'function CreateWordArray()'
  352. call _GenerateLine Tab1 || '{'
  353. call _GenerateLine Tab2 || 'A=this'
  354. call _GenerateLine Tab2 || 'A.length=0'
  355. call _InitializeArray 'L'
  356. do   Index = 1 to WordCount
  357. call _AddToArray  Word.Index
  358. end
  359. call _FlushArray
  360. call _GenerateLine Tab1 || '}'
  361. call _GenerateLine ''
  362. call _GenerateCmt  Tab1,   'Create WORD OCCURS IN array (' || WordCount || ' words)'
  363. call _GenerateLine Tab1 || 'function CreateOccursArray()'
  364. call _GenerateLine Tab1 || '{'
  365. call _GenerateLine Tab2 || 'A=this'
  366. call _GenerateLine Tab2 || 'A.length=0'
  367. if  OptionUseFileOffsetCodes  = 'Y' then
  368. call _InitializeArray 'C'
  369. else
  370. call _InitializeArray 'L'
  371. do   Index = 1 to WordCount
  372. if  OptionUseFileOffsetCodes  = 'Y' then
  373. PreviousElement = ''
  374. call _AddToArray  Occurs.Index
  375. end
  376. call _FlushArray
  377. call _GenerateLine Tab1 || '}'
  378. call _GenerateLine ''
  379. if  OptionUseFileOffsetCodes  = 'Y' then
  380. do
  381. call _GenerateLine   Tab1 ||    'var OffsetCodes="' || left(FileOffsetArray, HighestOffsetUsed) || '"'
  382. end
  383. if    OptionUseCodes = 'Y' then
  384. do
  385. CodeFrom = d2c(CodeFromAscii)
  386. CodeTo   = d2c(CodeFromAscii + LongestLeadingCodeUsed)
  387. call _GenerateLine   Tab1 ||    'var CompCodes="' || xrange(CodeFrom, CodeTo) || '"'
  388. end
  389. call _GenerateLine ''
  390. call _GenerateCmt    Tab1,   'Are we displaying the results of a test?'
  391. call _GenerateLine   Tab1 || 'CookieValue=FindCookie("' || CookieName || '")'
  392. call _GenerateLine   ''
  393. call _GenerateCmt    Tab1,   'Generate the search form'
  394. call _GenerateLine   Tab1 || 'document.write("<CENTER>")'
  395. call _GenerateLine   Tab1 || 'document.write("<FORM NAME=`SearchForm` onSubmit=`return PerformSearch(SearchText.value.toUpperCase())`>")'
  396. if  OptionSearchButton = 'Y' then
  397. call _GenerateLine   Tab1 || 'document.write("<TABLE BORDER=0 CELLSPACING=10><TR><TD ALIGH=RIGHT>")'
  398. call _GenerateLine   Tab1 || 'document.write("Search Site For: <INPUT TYPE=`text` Name=`SearchText` SIZE=25 MAXLENGTH=50 VALUE=`"+CookieValue+"`>")'
  399. if  OptionSearchButton = 'Y' then
  400. do
  401. call _GenerateLine   Tab1 || 'document.write("<TD ALIGH=LEFT>")'
  402. call _GenerateLine   Tab1 || 'document.write("<INPUT TYPE=`submit` NAME=`PBUTTON` VALUE=`SEARCH`>")'
  403. call _GenerateLine   Tab1 || 'document.write("</TR></TABLE>")'
  404. end
  405. call _GenerateLine   Tab1 || 'document.write("</FORM><BR>")'
  406. call _GenerateLine   ''
  407. call _GenerateLine   Tab1 || 'if(CookieValue!' || '="")'
  408. call _GenerateLine   Tab1 || '{'
  409. call _GenerateLine   Tab2 ||    'F=new CreateFileArray()'
  410. call _GenerateLine   Tab2 ||    'W=new CreateWordArray()'
  411. call _GenerateLine   Tab2 ||    'O=new CreateOccursArray()'
  412. call _GenerateLine   Tab1 || '}'
  413. call _GenerateLine   ''
  414. call _GenerateCmt    Tab1,   'Cause search to be performed'
  415. call _GenerateLine   Tab1 || 'function PerformSearch(Find)'
  416. call _GenerateLine   Tab1 || '{'
  417. call _GenerateCmt    Tab2,      'Make sure no space was specified'
  418. call _GenerateLine   Tab2 ||    'if(Find.indexOf(" ")!' || '=-1)'
  419. call _GenerateLine   Tab3 ||        'alert("\n\nSPACES ARE NOT ALLOWED!\n\nYou can only search for one word (or part of).")'
  420. call _GenerateLine   Tab2 ||    'else'
  421. call _GenerateLine   Tab2 ||    '{'
  422. call _GenerateCmt    Tab3,          'Valid search specification'
  423. call _GenerateLine   Tab3 ||        'document.cookie="' || CookieName || '="+Find'
  424. call _GenerateLine   Tab3 ||        'if(Find!' || '=""&&CookieValue!' || '=Find)'
  425. call _GenerateLine   Tab4 ||            'location.reload(false)'
  426. call _GenerateLine   Tab2 ||    '}'
  427. call _GenerateLine   Tab2 ||    'return(false)'
  428. call _GenerateLine   Tab1 || '}'
  429. call _GenerateLine   ''
  430. call _GenerateCmt    Tab1,   'Generate file link'
  431. call _GenerateLine   Tab1 || 'function GenerateFileInfo(FileIndex)'
  432. call _GenerateLine   Tab1 || '{'
  433. call _GenerateLine   Tab2 ||     'document.write("<A ' || OptionLinkTarget || 'HREF=`" + F[FileIndex] + "`>" + F[FileIndex] + "</A><BR>")'
  434. call _GenerateLine   Tab1 || '}'
  435. call _GenerateLine   ''
  436. call _GenerateCmt    Tab1,   'Find a Cookie'
  437. call _GenerateLine   Tab1 || 'function FindCookie(CookieName)'
  438. call _GenerateLine   Tab1 || '{'
  439. call _GenerateCmt    Tab2,      'Are there any cookies at all (this document)'
  440. call _GenerateLine   Tab2 ||    'var AllCookies=document.cookie'
  441. call _GenerateLine   Tab2 ||    'if(AllCookies=="")'
  442. call _GenerateLine   Tab3 ||        'return("")'
  443. call _GenerateLine   ''
  444. call _GenerateCmt    Tab2,      'There are some cookies, look for our specific one'
  445. call _GenerateLine   Tab2 ||    'var LookFor=CookieName+"="'
  446. call _GenerateLine   Tab2 ||    'var Posn=AllCookies.indexOf(LookFor)'
  447. call _GenerateLine   Tab2 ||    'if(Posn==-1)'
  448. call _GenerateLine   Tab3 ||        'return("")'
  449. call _GenerateLine   ''
  450. call _GenerateCmt    Tab2,      'Point past the "=" to start of cookies value'
  451. call _GenerateLine   Tab2 ||    'Posn+=LookFor.length'
  452. call _GenerateLine   ''
  453. call _GenerateCmt    Tab2,      'Find end of value'
  454. call _GenerateLine   Tab2 ||    'var EndPosn=AllCookies.indexOf(";",Posn)'
  455. call _GenerateLine   Tab2 ||    'if(EndPosn==-1)'
  456. call _GenerateLine   Tab3 ||        'EndPosn=AllCookies.length'
  457. call _GenerateLine   ''
  458. call _GenerateCmt    Tab2,      'Extract the cookie'
  459. call _GenerateLine   Tab2 ||    'var ItsValue=AllCookies.substring(Posn,EndPosn)'
  460. call _GenerateLine   Tab2 ||    'return(ItsValue)'
  461. call _GenerateLine   Tab1 || '}'
  462. call _GenerateLine   ''
  463. call _GenerateCmt    Tab1,   'Given a word index, generate links'
  464. call _GenerateLine   Tab1 || 'function GenerateWordInfo(WordIndex)'
  465. call _GenerateLine   Tab1 || '{'
  466. call _GenerateLine   Tab2 ||     'var CommaPosn'
  467. call _GenerateLine   ''
  468. call _GenerateCmt    Tab2,       'Output the word'
  469. call _GenerateLine   Tab2 ||     'document.write("<TR><TD>" + W[WordIndex] + "<TD>")'
  470. call _GenerateLine   ''
  471. call _GenerateCmt    Tab2,       'Output match locations'
  472. if  OptionUseFileOffsetCodes = 'Y' then
  473. call _GenerateLine   Tab2 ||     'FileIndexes=Code2List(O[WordIndex])'
  474. else
  475. call _GenerateLine   Tab2 ||     'FileIndexes=O[WordIndex]'
  476. call _GenerateLine   ''
  477. call _GenerateCmt    Tab2,       'Split out files'
  478. call _GenerateLine   Tab2 ||     'while((CommaPosn=FileIndexes.indexOf(",")) !' || '=-1)'
  479. call _GenerateLine   Tab2 ||     '{'
  480. call _GenerateCmt    Tab3,            'Extract File Index'
  481. call _GenerateLine   Tab3 ||          'FileIndex=FileIndexes.substring(0,CommaPosn)'
  482. call _GenerateLine   Tab3 ||          'FileIndexes=FileIndexes.substring(CommaPosn+1)'
  483. call _GenerateLine   ''
  484. call _GenerateCmt    Tab3,            'Add File'
  485. call _GenerateLine   Tab3 ||          'GenerateFileInfo(FileIndex)'
  486. call _GenerateLine   Tab2 ||     '}'
  487. call _GenerateLine   Tab2 ||     'GenerateFileInfo(FileIndexes)'
  488. call _GenerateLine   Tab2 ||     'document.write("</TR>")'
  489. call _GenerateLine   Tab1 || '}'
  490. call _GenerateLine   ''
  491. call _GenerateCmt    Tab1,   'Generate search results (if required)'
  492. call _GenerateLine   Tab1 || 'if(CookieValue!' || '="")'
  493. call _GenerateLine   Tab1 || '{'
  494. call _GenerateCmt    Tab2,       'Start of Table'
  495. call _GenerateLine   Tab2 ||     'document.write("<HR><H1>Search Results for `"+CookieValue+"`</H1><BR>")'
  496. call _GenerateLine   Tab2 ||     'document.write("<TABLE BORDER=3 CELLSPACING=1>")'
  497. call _GenerateLine   Tab2 ||     'document.write("<TR><TH ALIGN=CENTER>Match<TH ALIGN=CENTER>Location</TR>")'
  498. call _GenerateLine   Tab1 ||     ''
  499. call _GenerateCmt    Tab2,       'Output all matching words'
  500. call _GenerateLine   Tab2 ||     'FoundMatch=false'
  501. call _GenerateLine   Tab2 ||     'for(Count=1;Count<=W.length;Count++)'
  502. call _GenerateLine   Tab2 ||     '{'
  503. call _GenerateCmt    Tab3,           'Search words'
  504. call _GenerateLine   Tab3 ||         'if(CookieValue=="*"||W[Count].indexOf(CookieValue)!' || '=-1)'
  505. call _GenerateLine   Tab3 ||         '{'
  506. call _GenerateCmt    Tab4,               'We have a match so output the word info'
  507. call _GenerateLine   Tab4 ||             'GenerateWordInfo(Count)'
  508. call _GenerateLine   Tab4 ||             'FoundMatch=true'
  509. call _GenerateLine   Tab3 ||         '}'
  510. call _GenerateLine   Tab2 ||     '}'
  511. call _GenerateCmt    Tab2,   'Handle no match'
  512. call _GenerateLine   Tab2 ||     'if(!FoundMatch)'
  513. call _GenerateLine   Tab2 ||     '{'
  514. if  OptionDisplayAllOnNoMatch = 'N' then
  515. do
  516. call _GenerateCmt    Tab3,        'No matches, (not listing all files)'
  517. call _GenerateLine   Tab3 ||      'document.write("<TR><TD ALIGN=CENTER COLSPAN=2>No matches!</TR>")'
  518. end
  519. else
  520. do
  521. call _GenerateCmt    Tab3,        'No matches, output list of all files'
  522. call _GenerateLine   Tab3 ||      'document.write("<TR><TD VALIGN=TOP>No matches!<TD ALIGN=LEFT>")'
  523. call _GenerateLine   Tab3 ||      'for(FCount=1;FCount<=F.length;FCount++)'
  524. call _GenerateLine   Tab4 ||           'GenerateFileInfo(FCount)'
  525. call _GenerateLine   Tab3 ||      'document.write("</TR>")'
  526. end
  527. call _GenerateLine   Tab2 ||     '}'
  528. call _GenerateLine   ''
  529. call _GenerateCmt    Tab2,       'End of TABLE'
  530. call _GenerateLine   Tab2 ||     'document.write("</TABLE>")'
  531. call _GenerateLine   Tab2 ||     'document.SearchForm.SearchText.select()'
  532. call _GenerateLine   Tab1 || '}'
  533. call _GenerateLine   Tab1 || 'document.write("</CENTER>")'
  534. call _GenerateLine   ''
  535. call _GenerateCmt    Tab1,   'Output footer'
  536. 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>")'
  537. call _GenerateLine   Tab1 || 'document.write("")'
  538. call _GenerateLine   Tab1 || 'document.write("<!--- A condition of use of this program is to leave the link to my homepage as is --->")'
  539. 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>")'
  540. call _GenerateLine   Tab1 || 'document.write("<!--- A condition of use of this program is to leave the link to my homepage as is --->")'
  541. call _GenerateLine   Tab1 || 'document.write("")'
  542. call _GenerateLine   Tab1 || 'document.write("<TD ALIGN=RIGHT VALIGN=TOP><FONT SIZE=-2>")'
  543. call _GenerateLine   Tab1 || 'document.write("' || WordCount || ' words indexed - ' || IndexTime || '")'
  544. call _GenerateLine   Tab1 || 'document.write("</TR></TABLE>")'
  545. call _GenerateLine   Tab1 || ''
  546. call _GenerateCmt    Tab1,   'Set focus to input field'
  547. call _GenerateLine   Tab1 || 'document.SearchForm.SearchText.focus()'
  548. call _GenerateLine   "//-->"
  549. call _GenerateLine   "</SCRIPT>"
  550. if  OptionCompleteHtmlPage = 'Y' then
  551. call _GenerateLine   "</HTML>"
  552. return
  553. _InitializeArray:
  554. ArrayFunction       = arg(1)
  555. CachedArrayElements = ""
  556. PreviousElement     = ''
  557. return
  558. _FlushArray:
  559. if  CachedArrayElements <> '' then
  560. do
  561. if  length(CachedArrayElements) < MaxElementlength then
  562. call _GenerateLine Tab2 || ArrayFunction || '("' || CachedArrayElements || '")'
  563. else
  564. do
  565. call _GenerateLine Tab2 || ArrayFunction || '('
  566. do  forever
  567. if  length(CachedArrayElements) < MaxElementlength then
  568. do
  569. call _GenerateLine Tab3 || '"' || CachedArrayElements || '"'
  570. leave
  571. end
  572. else
  573. do
  574. call _GenerateLine Tab3 || '"' || left(CachedArrayElements, MaxElementlength) || '"+'
  575. CachedArrayElements = substr(CachedArrayElements, MaxElementlength+1)
  576. end
  577. end
  578. call _GenerateLine Tab2 || ' )'
  579. end
  580. end
  581. call _InitializeArray ArrayFunction
  582. return
  583. _AddToArray:
  584. ItemAsPassed = arg(1)
  585. Item2Add = ItemAsPassed
  586. if  OptionUseCodes = 'Y' then
  587. do
  588. if  PreviousElement <> '' then
  589. do
  590. CharsThatMatch = compare(PreviousElement, ItemAsPassed)
  591. if  CharsThatMatch = 0 then
  592. CharsThatMatch = length(PreviousElement)
  593. else
  594. CharsThatMatch = CharsThatMatch - 1
  595. if  CharsThatMatch > 1 then
  596. do
  597. if  CharsThatMatch > MaxLeadingLengthCode then
  598. CharsThatMatch = MaxLeadingLengthCode
  599. if  (CharsThatMatch-2) > LongestLeadingCodeUsed then
  600. LongestLeadingCodeUsed = CharsThatMatch - 2
  601. Item2Add = d2c(CodeFromAscii + CharsThatMatch - 2) || substr(ItemAsPassed, CharsThatMatch+1)
  602. end
  603. end
  604. end
  605. if  CachedArrayElements = '' then
  606. CachedArrayElements = Item2Add
  607. else
  608. do
  609. NewValue = CachedArrayElements || '|' || Item2Add
  610. if  length(NewValue) < MaxElementlength then
  611. CachedArrayElements = NewValue
  612. else
  613. do
  614. call _FlushArray
  615. CachedArrayElements = Item2Add
  616. end
  617. end
  618. PreviousElement = ItemAsPassed
  619. return
  620. EndGenerateXh:
  621. /*
  622. * REPLSTR.XH Version 99.031 By Dennis Bareis
  623. *            http://www.labyrinth.net.au/~dbareis/index.htm (db0@anz.com)
  624. */
  625. ReplaceCount = 0
  626. signal EndREPLSTR
  627. ReplaceString: 
  628. parse arg rs?TheString, rs?ChangeFrom
  629. rs?FoundPosn = pos(rs?ChangeFrom, rs?TheString)
  630. if  rs?FoundPosn = 0 then
  631. return(rs?TheString)
  632. rs?ChangeTo = arg(3)
  633. rs?ChangeFromLength = length(rs?ChangeFrom)
  634. rs?LeftPart         = ''
  635. do  until rs?FoundPosn = 0
  636. rs?LeftPart      = rs?LeftPart || left(rs?TheString, rs?FoundPosn-1) || rs?ChangeTo
  637. rs?TheString     = substr(rs?TheString, rs?FoundPosn+rs?ChangeFromLength)
  638. ReplaceCount = ReplaceCount + 1
  639. rs?FoundPosn = pos(rs?ChangeFrom, rs?TheString)
  640. end
  641. return(rs?LeftPart || rs?TheString)
  642. EndREPLSTR:
  643. OptionCompleteHtmlPage    = 'Y'
  644. OptionScanSubDir          = ''
  645. OptionJustWordList        = 'N'
  646. OptionNumbersAreOk        = 'N'
  647. OptionCompact             = 'Y'
  648. OptionDisplayAllOnNoMatch = 'Y'
  649. OptionOutputFileName      = ''
  650. OptionDropWordPercent     = 40
  651. OptionLinkTarget          = '_top'
  652. NumberOfExcludedFiles     = 0
  653. OptionAdjustFileName      = ''
  654. OptionSearchButton        = 'Y'
  655. OptionUseCodes            = 'Y'
  656. OptionUseFileOffsetCodes  = 'Y'
  657. call SetColorCodes
  658. call DisplayCopyright
  659. signal on NOVALUE name RexxTrapUninitializedVariable
  660. signal on SYNTAX  name RexxTrapSyntaxError
  661. signal on HALT    name RexxCtrlC
  662. Arguments = arg(1)
  663. if Arguments = "" then
  664. UserSyntaxError("Too few parameters (expected name of input file!)")
  665. parse var Arguments InputMask OptionsCmdLine
  666. OptionsCmdLine     = strip(OptionsCmdLine)
  667. OptionsEnvironment = GetEnv('JSEARCH_OPTIONS')
  668. ExtraParms = OptionsEnvironment || ' ' || OptionsCmdLine
  669. do while  ExtraParms <> ''
  670. parse var ExtraParms ThisParm ExtraParms
  671. parse var ThisParm ThisCmd':'ThisCmdOptions
  672. ThisCmd = translate(ThisCmd)
  673. select
  674. when ThisCmd = '/NOHIGHASCII' then
  675. OptionUseCodes = 'N'
  676. when ThisCmd = '/MAXPERCENT' then
  677. OptionDropWordPercent = ThisCmdOptions
  678. when ThisCmd = '/NOBUTTON' then
  679. OptionSearchButton = 'N'
  680. when ThisCmd = '/NOLISTONNOMATCH' then
  681. OptionDisplayAllOnNoMatch = 'N'
  682. when ThisCmd = '/OUTPUT' then
  683. OptionOutputFileName = AdjustFileName(ThisCmdOptions)
  684. when ThisCmd = '/TARGET' then
  685. OptionLinkTarget = ThisCmdOptions
  686. when ThisCmd = '/S' then
  687. OptionScanSubDir = 'S'
  688. when ThisCmd = '/#' then
  689. OptionNumbersAreOk = 'Y'
  690. when ThisCmd = '/PRETTY' then
  691. OptionCompact = 'N'
  692. when ThisCmd = '/JUSTWORDS' then
  693. do
  694. say 'ALL WORDS'
  695. say '~~~~~~~~~'
  696. OptionJustWordList = 'Y'
  697. end
  698. when ThisCmd = '/EXCLUDEWORDS' then
  699. do
  700. call LoadExcludeFile ThisCmdOptions
  701. end
  702. when ThisCmd = '/OKINWORD' then
  703. call WordChars AllwaysInWord || ThisCmdOptions
  704. when ThisCmd = '/EXCLUDEFILES' then
  705. call ExcludeFilesMatching ThisCmdOptions
  706. when ThisCmd = '/LOWER' then
  707. OptionAdjustFileName = 'L'
  708. when ThisCmd = '/UPPER' then
  709. OptionAdjustFileName = 'U'
  710. otherwise
  711. UserSyntaxError('Unknown command of "' || ThisCmd || '" specified')
  712. end
  713. end
  714. if OptionOutputFileName = '' then
  715. OptionOutputFileName = 'JsSearch.htm'
  716. if OptionLinkTarget <> '' then
  717. OptionLinkTarget = 'TARGET=' || OptionLinkTarget || ' '
  718. if OptionCompact = 'N' then
  719. do
  720. Tab1 = d2c(9)
  721. Eol  = d2c(13) || d2c(10)
  722. end
  723. else
  724. do
  725. Tab1 = ''
  726. Eol  = d2c(10)
  727. end
  728. Tab2 = Tab1 || Tab1
  729. Tab3 = Tab1 || Tab2
  730. Tab4 = Tab1 || Tab3
  731. if left(OptionOutputFileName, 1) = '+' then
  732. do
  733. OptionCompleteHtmlPage = 'N'
  734. OptionOutputFileName = substr(OptionOutputFileName, 2)
  735. CloseRc = stream(OptionOutputFileName, 'c', 'close')
  736. if  stream(OptionOutputFileName, 'c', 'query exists') = '' then
  737. UserSyntaxError('You requested an append onto "' || OptionOutputFileName || '" (it does not exist)!')
  738. end
  739. else
  740. do
  741. CloseRc = stream(OptionOutputFileName, 'c', 'close')
  742. if stream(OptionOutputFileName, 'c', 'query exists') <> '' then
  743. do
  744. DosDelRc = SysFileDelete(OptionOutputFileName)
  745. end
  746. end
  747. OutputPathCharL = '('
  748. OutputPathCharR = ')'
  749. DropTillChar    = '~'
  750. LeftPos = pos(OutputPathCharL, InputMask)
  751. if LeftPos = 0 then
  752. OutputFilePrefix = ""
  753. else
  754. do
  755. OutputFilePrefix = substr(InputMask, LeftPos+1, length(InputMask)-LeftPos-1)
  756. InputMask        = left(InputMask, LeftPos-1)
  757. end
  758. InputMask2     = stream(InputMask, 'c', 'query exists')
  759. if  InputMask2 = '' then
  760. UserSyntaxError('No input files matching "' || InputMask || '" were found.')
  761. InputMask      = InputMask2
  762. LengthInputMaskPath = length(filespec('drive', InputMask) || filespec('path', InputMask))
  763. if substr(OutputFilePrefix, 2, 1) = ':' then
  764. OutputFilePrefix = '/' || OutputFilePrefix
  765. WordCount = 0
  766. ExitRc = 0
  767. call SysFileTree InputMask, 'InputList', 'FO' || OptionScanSubDir
  768. if InputList.0 = 0 then
  769. UserSyntaxError('No input files matching "' || InputMask || '" were found!')
  770. else
  771. do
  772. do  InputIndex = 1 to InputList.0
  773. GenerateRc = ProcessFile(InputList.InputIndex)
  774. if  GenerateRc <> 0 then
  775. ExitRc = GenerateRc
  776. end
  777. end
  778. say 'Found ' || AddCommasToDecimalNumber(WordCount) || ' words...'
  779. if InputList.0 > 1 then
  780. do
  781. if  OptionDropWordPercent <> 0 then
  782. do
  783. say 'Dropping any words that occur in ' || OptionDropWordPercent || '% or more of the files...'
  784. if  OptionDropWordPercent = 100 then
  785. MaxNumberFiles = InputList.0 - 1
  786. else
  787. do
  788. MaxNumberFiles = (InputList.0 * OptionDropWordPercent) % 100
  789. if  MaxNumberFiles < 1 then
  790. MaxNumberFiles = 1
  791. end
  792. DropCount = 0
  793. do  Index = 1 to WordCount
  794. NumFiles = words( translate(File.Index, ' ', Delimiter) )
  795. if  NumFiles > MaxNumberFiles then
  796. do
  797. Word.Index = ''
  798. DropCount = DropCount + 1
  799. end
  800. end
  801. say 'Dropped ' || AddCommasToDecimalNumber(DropCount) || ' words (left with ' || AddCommasToDecimalNumber(WordCount-DropCount) || ')...'
  802. end
  803. end
  804. say 'Sorting results...'
  805. dIndex = 0
  806. do  sIndex = 1 to WordCount
  807. if  Word.sIndex <> '' then
  808. do
  809. dIndex          = dIndex + 1
  810. WordFile.dIndex = Word.sIndex || Delimiter || File.sIndex
  811. end
  812. end
  813. WordFile.0 = dIndex
  814. WordCount  = dIndex
  815. call SortWordAndFiles
  816. say 'Generating arrays...'
  817. call CreateWordFileOccursArrays
  818. if OptionJustWordList = 'Y' then
  819. do
  820. do   Index = 1 to WordCount
  821. say Word.Index
  822. end
  823. ThatsAllFolks(1)
  824. end
  825. say 'Generating JavaScript (' || OptionOutputFileName || ')...'
  826. call GenerateJavaScript
  827. say 'Longest leading code used was for ' || LongestLeadingCodeUsed+2 || ' bytes.'
  828. say 'Successful (took ' || time('Elapsed') || ' seconds)'
  829. ThatsAllFolks(ExitRc)
  830. GenerateHtmlFileName:
  831. ShortOutName = substr(arg(1), LengthInputMaskPath+1)
  832. FullOutputName = OutputFilePrefix || ShortOutName
  833. return(FullOutputName)
  834. AdjustFileName:
  835. if  OptionAdjustFileName = '' then
  836. return(arg(1))
  837. else
  838. do
  839. if  OptionAdjustFileName = 'U' then
  840. return( translate(arg(1)) )
  841. else
  842. return( translate(arg(1), LowerCase, UpperCase) )
  843. end
  844. SetColorCodes:
  845. EscapeChar     = d2c(27)
  846. Reset          = EscapeChar || '[0m'
  847. HighlightColor = EscapeChar || '[1;35m'
  848. TitleColor     = EscapeChar || '[0;32m'
  849. ErrorColor     = EscapeChar || '[1;31m'
  850. ExcludingColor = EscapeChar || '[0;33m'
  851. IncludingColor = EscapeChar || '[0;1m'
  852. return
  853. RemoveColorCodes:
  854. Reset           = ''
  855. HighlightColor  = ''
  856. TitleColor      = ''
  857. ErrorColor      = ''
  858. ExcludingColor  = ''
  859. IncludingColor  = ''
  860. return
  861. ExcludeFilesMatching:
  862. Excluded.0 = 0
  863. call SysFileTree arg(1), 'Excluded', 'FO' || OptionScanSubDir
  864. do  EIndex = 1 to Excluded.0
  865. NumberOfExcludedFiles               = NumberOfExcludedFiles + 1
  866. ExcludedFiles.NumberOfExcludedFiles = AdjustFileName( stream(Excluded.EIndex, 'c', 'query exists') )
  867. end
  868. return
  869. FindFile:
  870. FindFile = arg(1)
  871. do  Index = 1 to FileCount
  872. if  FindFile = File.Index then
  873. return(Index)
  874. end
  875. return(0)
  876. AddFile:
  877. ToAddFile = arg(1)
  878. Index = FindFile(ToAddFile)
  879. if  Index = 0 then
  880. do
  881. FileCount      = FileCount + 1
  882. File.FileCount = ToAddFile
  883. Index          = FileCount
  884. end
  885. return(Index)
  886. CreateWordFileOccursArrays:
  887. FileCount = 0
  888. do  WIndex = 1 to WordCount
  889. parse var WordFile.WIndex Word.WIndex(Delimiter)FileList
  890. do  while FileList <> ''
  891. parse var FileList ThisFile(Delimiter)FileList
  892. call AddFile GenerateHtmlFileName(strip(ThisFile))
  893. end
  894. end
  895. File.0 = FileCount
  896. call SortFiles
  897. HighestOffsetUsed = 0
  898. do  WIndex = 1 to WordCount
  899. parse var WordFile.WIndex .(Delimiter)FileList
  900. do FIndex = 1 to FileCount
  901. FileSort.FIndex = 'N'
  902. end
  903. do  while FileList <> ''
  904. parse var FileList ThisFile(Delimiter)FileList
  905. FIndex          = FindFile(GenerateHtmlFileName(strip(ThisFile)))
  906. FileSort.FIndex = 'Y'
  907. end
  908. if  OptionUseFileOffsetCodes  = 'Y' then
  909. do
  910. FileOffsetArray    = "123456789" || UpperCase || LowerCase || "~!@#$%^&*()_+=`{}[]:;<>,./?" || xrange('80'x, 'FF'x)
  911. LastIndex          = 0
  912. if  FileCount > length(FileOffsetArray) then
  913. OptionUseFileOffsetCodes = 'N'
  914. end
  915. FileIndexes = ''
  916. do  FIndex = 1 to FileCount
  917. if  FileSort.FIndex = 'Y' then
  918. do
  919. if  OptionUseFileOffsetCodes  = 'Y' then
  920. do
  921. ThisOffset = FIndex - LastIndex
  922. LastIndex  = FIndex
  923. if  ThisOffset > HighestOffsetUsed then
  924. HighestOffsetUsed = ThisOffset
  925. FileIndexes = FileIndexes || substr(FileOffsetArray, ThisOffset, 1)
  926. end
  927. else
  928. do
  929. if  FileIndexes <> '' then
  930. FileIndexes = FileIndexes || ','
  931. FileIndexes = FileIndexes || FIndex
  932. end
  933. end
  934. end
  935. Occurs.WIndex = FileIndexes
  936. end
  937. return
  938. FindWord:
  939. FoundIndex = KeyGetInfo("WordIndex", 'W_' || c2x(arg(1)))
  940. if  FoundIndex = "<KeyedVarUnknown>" then
  941. return(0)
  942. return(FoundIndex)
  943. AddWordAndFile:
  944. ToAddWord = translate(strip(arg(1)))
  945. if  length(ToAddWord) < 3 | length(ToAddWord) > 30 then
  946. return
  947. ToAddFile = arg(2)
  948. Index = FindWord(ToAddWord)
  949. if  Index = 0 then
  950. do
  951. WordCount       = WordCount + 1
  952. Word.WordCount  = ToAddWord
  953. File.WordCount  = ToAddFile
  954. call  KeySaveInfo  "WordIndex", 'W_' || c2x(ToAddWord), WordCount
  955. end
  956. else
  957. do
  958. if  pos(ToAddFile, File.Index) = 0 then
  959. File.Index = File.Index || Delimiter || ToAddFile
  960. end
  961. return
  962. ProcessFile:
  963. FullName = AdjustFileName( stream(arg(1), 'c', 'query exists') )
  964. if  NumberOfExcludedFiles <> 0 then
  965. do
  966. do  EIndex = 1 to NumberOfExcludedFiles
  967. if  FullName = ExcludedFiles.EIndex then
  968. do
  969. say ExcludingColor || 'Excluding : ' || FullName || Reset
  970. return(0)
  971. end
  972. end
  973. end
  974. say IncludingColor || 'Processing: ' || FullName || Reset
  975. say IncludingColor || '         => ' || GenerateHtmlFileName(FullName) || Reset
  976. CloseRc = stream(FullName, 'c', 'close')
  977. do  while lines(FullName) <> 0
  978. WordList = space(translate(linein(FullName), '', NotPartOfWordChars, ' '))
  979. do  while   WordList <> ''
  980. parse var WordList ThisWord' 'WordList
  981. if  ExcludeWord(ThisWord) = 'Y' then
  982. iterate
  983. if  OptionNumbersAreOk = 'N' then
  984. do
  985. if  datatype(ThisWord, 'Whole Number') then
  986. iterate
  987. end
  988. call AddWordAndFile ThisWord, FullName
  989. end
  990. end
  991. CloseRc = stream(FullName, 'c', 'close')
  992. return(0)
  993. CaseInsensitiveSort : PROCEDURE
  994. a = translate(arg(1))
  995. b = translate(arg(2))
  996. select
  997. when ( a < b ) then
  998. return(-1)
  999. when ( a > b ) then
  1000. return(1)
  1001. otherwise
  1002. return(0)
  1003. end
  1004. NormalSort: PROCEDURE
  1005. parse arg a, b
  1006. select
  1007. when ( a < b ) then
  1008. return(-1)
  1009. when ( a > b ) then
  1010. return(1)
  1011. otherwise
  1012. return(0)
  1013. end
  1014. GetAmPmTime:  procedure
  1015. CivilTime  = time('C');  if length(CivilTime)  = 6 then CivilTime=' 'CivilTime
  1016. TheTime    = time();     NumSeconds = ':'substr(TheTime, 7, 2)
  1017. return( insert(NumSeconds, CivilTime, 5) )
  1018. GetEnv:
  1019. return( value(arg(1),,'OS2ENVIRONMENT') )
  1020. AddCommasToDecimalNumber: procedure
  1021. NoComma = strip( arg(1) )
  1022. if  pos(',', NoComma) <> 0 then
  1023. return(NoComma)
  1024. DotPos = pos('.', NoComma)
  1025. if  DotPos = 0 then
  1026. AfterDecimal = ''
  1027. else
  1028. do
  1029. if  DotPos = 1 then
  1030. return("0" || NoComma)
  1031. AfterDecimal = substr(NoComma, DotPos+1)
  1032. NoComma      = left(NoComma, DotPos-1)
  1033. end
  1034. NoComma = reverse(NoComma)
  1035. ResultWithCommas = ""
  1036. do  while length(NoComma) > 3
  1037. ResultWithCommas = ResultWithCommas || left(NoComma, 3) || ','
  1038. NoComma          = substr(NoComma, 4)
  1039. end
  1040. ResultWithCommas = ResultWithCommas || NoComma
  1041. ResultWithCommas = reverse(ResultWithCommas)
  1042. if  AfterDecimal <> '' then
  1043. ResultWithCommas = ResultWithCommas || '.' || AfterDecimal
  1044. return(ResultWithCommas)
  1045. WordChars:
  1046. AllValidWordChars  = arg(1)
  1047. AllChars           = xrange('00'x, 'FF'x)
  1048. NotPartOfWordChars = translate(AllChars, '', AllValidWordChars, ' ')
  1049. NotPartOfWordChars = space(NotPartOfWordChars, 0)
  1050. return
  1051. GetLineNumber:
  1052. return( SIGL )
  1053. RexxCtrlC:
  1054. LineCtrlC = SIGL
  1055. say ''
  1056. say HighlightColor || copies('=+', 39) || ErrorColor
  1057. say "Come on, you pressed Ctrl+C or Break didn't you!"
  1058. say HighlightColor || copies('=+', 39) || Reset
  1059. ThatsAllFolks(LineCtrlC)
  1060. CommonTrapHandler:
  1061. FailingLine     = arg(1)
  1062. TrapHeading     = 'BUG: ' || arg(2)
  1063. TextDescription = arg(3)
  1064. Text            = arg(4)
  1065. SourceFileName = GetRexxSourceName()
  1066. say HighlightColor || copies('=+', 39) || ErrorColor
  1067. say TrapHeading
  1068. say copies('~', length(TrapHeading))
  1069. say substr(TextDescription, 1 , 16) || ': ' || Text
  1070. say 'Failing Module  : ' || SourceFileName
  1071. say 'Failing Line #  : ' || FailingLine
  1072. say 'Failing Command : ' || strip(SourceLine(FailingLine))
  1073. say HighlightColor || copies('=+', 39) || Reset
  1074. ThatsAllFolks(GetLineNumber())
  1075. RexxTrapUninitializedVariable:
  1076. TrappingLine = SIGL
  1077. call CommonTrapHandler TrappingLine, 'NoValue Abort!', 'Unknown Variable', condition('D')
  1078. RexxTrapSyntaxError:
  1079. TrappingLine = SIGL
  1080. call CommonTrapHandler TrappingLine, 'Syntax Error!', 'Reason', errortext(Rc)
  1081. ThatsAllFolks:
  1082. WantedExitRc = arg(1)
  1083. if  OptionOutputFileName <> '' then
  1084. do
  1085. if  WantedExitRc = 0 then
  1086. do
  1087. FileState = stream(OptionOutputFileName, 'Description')
  1088. if  left(FileState,6) <> 'READY:' then
  1089. do
  1090. say 'IOERROR on "' || OptionOutputFileName || '", Reason = ' || FileState
  1091. WantedExitRc = GetLineNumber()
  1092. end
  1093. end
  1094. CloseRc = stream(OptionOutputFileName, 'c', 'close')
  1095. end
  1096. exit(WantedExitRc)
  1097. DisplayCopyright:
  1098. if  CopyrightDisplayed = 'N' then
  1099. do
  1100. call charout ,HighlightColor
  1101. say '[]------------------------------------------------------------[]'
  1102. say '| JSSEARCH.CMD: Version ' || PgmVersion || ' (C)opyright Dennis Bareis 1998  |'
  1103. say '|           http://www.labyrinth.net.au/~dbareis (db0@anz.com) |'
  1104. say '[]------------------------------------------------------------[]'
  1105. say Reset
  1106. CopyrightDisplayed = 'Y'
  1107. end
  1108. return
  1109. UserSyntaxError:
  1110. CallersLine = SIGL
  1111. call DisplayCopyright
  1112. say ErrorColor || "SYNTAX ERROR"
  1113. say               "~~~~~~~~~~~~"
  1114. say '    ' || arg(1)
  1115. say ''
  1116. say 'CORRECT SYNTAX'
  1117. say '~~~~~~~~~~~~~~'
  1118. say '    JSSEARCH[.CMD] InputMask [Option1 ...]'
  1119. say ''
  1120. say 'OPTIONS'
  1121. say '~~~~~~~'
  1122. say '/OUTPUT:file         /MAXPERCENT:%           /TARGET:Window'
  1123. say '/EXCLUDEFILES:mask   /EXCLUDEWORDS:file      /OKINWORD:CharList'
  1124. say '/LOWER               /UPPER                  /PRETTY'
  1125. say '/NOBUTTON            /NOLISTONNOMATCH'
  1126. say '/S                   /#                      /JUSTWORDS'
  1127. say ''
  1128. say 'Please see "JSSEARCH.INF" for more details (and more options).' || Reset
  1129. ThatsAllFolks(CallersLine)
  1130. GetRexxSourceName:
  1131. parse source . . TmpRexxSrc .
  1132. return(TmpRexxSrc)
  1133.