home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / ppwizard.zip / ppwizard.cmd < prev    next >
OS/2 REXX Batch file  |  2000-02-23  |  280KB  |  10,410 lines

  1. /*
  2.  * Generator   : PPWIZARD version 2K.050
  3.  *             : FREE tool for OS/2, Windows, DOS and UNIX by Dennis Bareis (dbareis@labyrinth.net.au)
  4.  *             : http://www.labyrinth.net.au/~dbareis/ppwizard.htm
  5.  * Time        : Wednesday, 23 Feb 2000 6:34:05pm
  6.  * Input File  : E:\DB\PROJECTS\OS2\ppwizard\PPWIZARD.X
  7.  * Output File : .\OUT\ppwizard.cmd
  8.  */
  9.  
  10. if arg(1)="!CheckSyntax!" then exit(21924)
  11.  
  12. PgmVersion="2K.054"
  13. SupportedReginaVersions='0.08F, 0.08G or 0.08H'
  14. PpwStartSec=(time('S') || substr(time('L'),9,3))
  15. TrapHandler=''
  16. RedirMethod=''
  17. Dummy=time('Reset')
  18. b2rNewSingleQuote="' || " || '"' || "'" || '" || ' || "'"
  19. b2rAllHexCodes=''
  20. b2rAllAsciiCodes=''
  21. do b2rCharCode=0 to 31
  22. b2rAllHexCodes=b2rAllHexCodes||d2c(b2rCharCode)
  23. end
  24. do b2rCharCode=32 to 126
  25. b2rAllAsciiCodes=b2rAllAsciiCodes||d2c(b2rCharCode)
  26. end
  27. do b2rCharCode=127 to 255
  28. b2rAllHexCodes=b2rAllHexCodes||d2c(b2rCharCode)
  29. end
  30. signal EndBIN2REXPXh
  31.  
  32. _QuoteAscii:
  33. b2rAscii2Quote=arg(1)
  34. if pos("'",b2rAscii2Quote)=0 then
  35. return("'" || b2rAscii2Quote || "'")
  36. else
  37. do
  38. if pos('"',b2rAscii2Quote)=0 then
  39. return('"' || b2rAscii2Quote || '"')
  40. else
  41. do
  42. return("'" || ReplaceString(b2rAscii2Quote, "'", b2rNewSingleQuote) || "'")
  43. end
  44. end
  45.  
  46. _FormatHex:
  47. b2rHexString=arg(1)
  48. b2rLengthHex=length(b2rHexString)
  49. b2rFormattedHex="'"
  50. if b2rLengthHex>7 then
  51. do
  52. b2rLeft1=left(b2rHexString,1)
  53. b2rLeft1Pos=verify(b2rHexString,b2rLeft1)
  54. if b2rLeft1Pos=0 then
  55. return( "copies('" || c2x(b2rLeft1) || "'x, " || b2rLengthHex || ")" )
  56. else
  57. do
  58. if b2rLeft1Pos>7 then
  59. do
  60. b2rFormattedHex="copies('" || c2x(b2rLeft1) || "'x, " || b2rLeft1Pos-1 || ") || '"
  61. b2rHexString=substr(b2rHexString,b2rLeft1Pos)
  62. b2rLengthHex=b2rLengthHex-(b2rLeft1Pos-1)
  63. end
  64. end
  65. end
  66. do b2rCharPosn=1 to b2rLengthHex
  67. if(b2rCharPosn//8)=1 then
  68. do
  69. if b2rCharPosn<>1 then
  70. b2rFormattedHex=b2rFormattedHex|| ' '
  71. end
  72. b2rFormattedHex=b2rFormattedHex||c2x(substr(b2rHexString,b2rCharPosn,1))
  73. end
  74. b2rFormattedHex=b2rFormattedHex|| "'x"
  75. return(b2rFormattedHex)
  76.  
  77. _QuoteAsciiBreakIfRequired:
  78. qabAscii=arg(1)
  79. qabLength=length(qabAscii)
  80. qabReturn=''
  81. do while qabLength>256
  82. qabLeft=left(qabAscii,256)
  83. qabAscii=substr(qabAscii,256+1)
  84. qabLength=qabLength-256
  85. if qabReturn='' then
  86. qabReturn=_QuoteAscii(qabLeft)
  87. else
  88. qabReturn=qabReturn|| " || " ||_QuoteAscii(qabLeft)
  89. end
  90. if qabLength=0 then
  91. return(qabReturn)
  92. else
  93. do
  94. if qabReturn='' then
  95. return(_QuoteAscii(qabAscii))
  96. else
  97. return(qabReturn|| " || " ||_QuoteAscii(qabAscii))
  98. end
  99.  
  100. _FormatHexBreakIfRequired:
  101. fhbHex=arg(1)
  102. fhbLength=length(fhbHex)
  103. fhbReturn=''
  104. do while fhbLength>80
  105. fhbLeft=left(fhbHex,80)
  106. fhbHex=substr(fhbHex,80+1)
  107. fhbLength=fhbLength-80
  108. if fhbReturn='' then
  109. fhbReturn=_FormatHex(fhbLeft)
  110. else
  111. fhbReturn=fhbReturn|| " || " ||_FormatHex(fhbLeft)
  112. end
  113. if fhbLength=0 then
  114. return(fhbReturn)
  115. else
  116. do
  117. if fhbReturn='' then
  118. return(_FormatHex(fhbHex))
  119. else
  120. return(fhbReturn|| " || " ||_FormatHex(fhbHex))
  121. end
  122.  
  123. BIN2REXP:
  124. call BIN2REXP_START
  125. b2rValue=arg(1)
  126. b2rValueLength=length(b2rValue)
  127. if b2rValueLength=0 then
  128. call BIN2REXP_ONEBIT '""'
  129. else
  130. do
  131. do while b2rValue\==''
  132. b2rEndAsciiPos=verify(b2rValue,b2rAllAsciiCodes)
  133. if b2rEndAsciiPos=0 then
  134. do
  135. call BIN2REXP_ONEBIT _QuoteAsciiBreakIfRequired(b2rValue)
  136. b2rValue=''
  137. end
  138. else
  139. do
  140. if b2rEndAsciiPos<>1 then
  141. do
  142. call BIN2REXP_ONEBIT _QuoteAsciiBreakIfRequired(left(b2rValue,b2rEndAsciiPos-1))
  143. b2rValue=substr(b2rValue,b2rEndAsciiPos)
  144. end
  145. else
  146. do
  147. b2rEndBinaryPos=verify(b2rValue,b2rAllHexCodes)
  148. if b2rEndBinaryPos=0 then
  149. do
  150. call BIN2REXP_ONEBIT _FormatHexBreakIfRequired(b2rValue)
  151. b2rValue=''
  152. end
  153. else
  154. do
  155. call BIN2REXP_ONEBIT _FormatHexBreakIfRequired(left(b2rValue,b2rEndBinaryPos-1))
  156. b2rValue=substr(b2rValue,b2rEndBinaryPos)
  157. end
  158. end
  159. end
  160. end
  161. end
  162. call BIN2REXP_END
  163. return
  164.  
  165. EndBIN2REXPXh:
  166. signal EndDUMPVARXh
  167.  
  168. DumpVarsInExpression:
  169. dv_RexxExp=arg(1)
  170. dv_Stem=translate(arg(2))
  171. dv_VarHeading=arg(3)
  172. dv_LineRoutine=arg(4)
  173. if dv_Stem<> '' then
  174. do
  175. dv_AutoDump='N'
  176. dv_StemDot=dv_Stem|| '.'
  177. if symbol(dv_StemDot|| '0') = 'VAR' then
  178. dv_VarCount=value(dv_StemDot|| '0')
  179. else
  180. do
  181. call _DumpVarsLineOutput 'DumpVar: Could not find "' || dv_StemDot || '0' || '"'
  182. return(0)
  183. end
  184. end
  185. else
  186. do
  187. dv_AutoDump='Y'
  188. dv_Stem='DV_VARLIST'
  189. dv_StemDot=dv_Stem|| '.'
  190. dv_VarCount=0
  191. end
  192. if dv_VarCount=0 then
  193. dv_MaxVarLng=0
  194. do while dv_RexxExp<> ''
  195. parse value strip(dv_RexxExp, 'L')with dv_1stChar+1 dv_RexxExp
  196. select
  197. when datatype(dv_1stChar, 'S')then
  198. do
  199. dv_OneVar=dv_1stChar
  200. do while dv_RexxExp<> ''
  201. parse var dv_RexxExp dv_1stChar+1 dv_RexxExp
  202. if datatype(dv_1stChar, 'S')then
  203. dv_OneVar=dv_OneVar||dv_1stChar
  204. else
  205. do
  206. dv_RexxExp=dv_1stChar||dv_RexxExp
  207. leave
  208. end
  209. end
  210. call _RememberDumpedVar dv_OneVar
  211. if pos('.',dv_OneVar)<>0 then
  212. do
  213. do while dv_OneVar<> ''
  214. parse var dv_OneVar dv_ThisBit '.' dv_OneVar
  215. call _RememberDumpedVar dv_ThisBit
  216. end
  217. end
  218. end
  219. when dv_1stChar='"' | dv_1stChar = "'" then
  220. do
  221. dv_EndQuotePos=pos(dv_1stChar,dv_RexxExp)
  222. if dv_EndQuotePos=0 then
  223. dv_RexxExp=''
  224. else
  225. dv_RexxExp=substr(dv_RexxExp,dv_EndQuotePos+1)
  226. end
  227. otherwise
  228. nop
  229. end
  230. end
  231. call value dv_StemDot|| '0',dv_VarCount
  232. if dv_AutoDump='Y' then
  233. call DumpVarsInExpressionNow dv_Stem,dv_VarHeading,dv_LineRoutine
  234. return(dv_VarCount)
  235.  
  236. DumpVarsInExpressionNow:
  237. dv_StemDot=arg(1)|| '.'
  238. dv_VarHeading=arg(2)
  239. dv_LineRoutine=arg(3)
  240. if symbol(dv_StemDot|| '0') = 'VAR' then
  241. dv_VarCount=value(dv_StemDot|| '0')
  242. else
  243. do
  244. call _DumpVarsLineOutput 'DumpVar: could not find "' || dv_StemDot || '0' || '"'
  245. return(0)
  246. end
  247. if dv_VarCount<>0&dv_VarHeading<> '' then
  248. do
  249. call _DumpVarsLineOutput ''
  250. call _DumpVarsLineOutput dv_VarHeading
  251. call _DumpVarsLineOutput copies('~',length(dv_VarHeading))
  252. end
  253. dv_ShowVarLng=dv_MaxVarLng
  254. if dv_MaxVarLng>30 then
  255. dv_ShowVarLng=30
  256. do dv_Index=1 to dv_VarCount
  257. dv_OneVar=value(dv_StemDot||dv_Index)
  258. if length(dv_OneVar)>=dv_ShowVarLng then
  259. ShowVar=dv_OneVar
  260. else
  261. ShowVar=right(dv_OneVar,dv_ShowVarLng)
  262. dv_OneVarValue=value(translate(dv_OneVar))
  263. if datatype(dv_OneVarValue, 'N')=0 then
  264. do
  265. call BIN2REXP dv_OneVarValue
  266. dv_OneVarValue=dv_Value
  267. end
  268. call _DumpVarsLineOutput ShowVar|| ' = ' ||dv_OneVarValue
  269. end
  270. return
  271.  
  272. _RememberDumpedVar:
  273. dv_ThisVar=arg(1)
  274. if symbol(dv_ThisVar)='VAR' then
  275. do
  276. dv_AlreadyHave='N'
  277. dv_ThisVarUpper=translate(dv_ThisVar)
  278. do dv_Index=1 to dv_VarCount
  279. if dv_ThisVarUpper=translate(value(dv_StemDot||dv_Index))then
  280. do
  281. dv_AlreadyHave='Y'
  282. leave
  283. end
  284. end
  285. if dv_AlreadyHave='N' then
  286. do
  287. dv_VarCount=dv_VarCount+1
  288. call value dv_StemDot||dv_VarCount,dv_ThisVar
  289. if length(dv_ThisVar)>dv_MaxVarLng then
  290. dv_MaxVarLng=length(dv_ThisVar)
  291. end
  292. end
  293. return
  294.  
  295. _DumpVarsLineOutput:
  296. if dv_LineRoutine='' then
  297. say arg(1)
  298. else
  299. interpret 'call ' || dv_LineRoutine || ' arg(1)'
  300. return
  301.  
  302. BIN2REXP_START:
  303. dv_Value=''
  304. return
  305.  
  306. BIN2REXP_ONEBIT:
  307. if dv_Value<> '' then
  308. dv_Value=dv_Value|| ' || '
  309. dv_Value=dv_Value||arg(1)
  310. return
  311.  
  312. BIN2REXP_END:
  313. return
  314.  
  315. EndDUMPVARXh:
  316. HaveCapturedTrapDetails='N'
  317. MacroBeingExpanded=''
  318. LastLineAfterMacroRep=''
  319. LastFileLine=''
  320. LastLine=''
  321. ErrorHookCount=0
  322. call RexxHookInit
  323. signal on NOVALUE name SimpleRexxTrapUninitializedVariable
  324. signal on SYNTAX name SimpleRexxTrapSyntaxError
  325. TrapHandler='SIMPLE'
  326. MyBaseHomeDir="http://www.labyrinth.net.au/~dbareis/"
  327. PgmHomePage=MyBaseHomeDir|| "ppwizard.htm"
  328. PgmAuthorHomePage=MyBaseHomeDir|| "index.htm"
  329. PgmAuthor="Dennis Bareis"
  330. PgmAuthorEmail="dbareis@labyrinth.net.au"
  331. ExpressionKilledUs=''
  332. SyntaxOkRc=21924
  333. SyntaxOkText='!CheckSyntax!'
  334. CopyrightDisplayed='N'
  335. CurrentOutFile=''
  336. IncludeLevel=0
  337. CgiOutputFile=''
  338. OptionCgiModeOn='N'
  339. DoOnExit=''
  340. TryQuoteListAny='"' || "'" || '^~!@#$%&*-+=?./\|`:' || xrange('DB'x, 'FE'x) || xrange('80'x, 'DA'x)
  341. TryQuoteListSd="'" || '"'
  342. TryQuoteListDs='"' || "'"
  343. OnExitSleepFor=0
  344. call RemoveColorCodes
  345. call RemoveBeepCode
  346. if translate(strip(arg(1)))='DEBUG' then
  347. call DisplayCopyright
  348. /*
  349. *REXSYSTM.XH Version 00.048 By Dennis Bareis
  350. *http://www.labyrinth.net.au/~dbareis/index.htm(db0@anz.com)
  351. */
  352. parse version RexVersionInfo
  353. if pos('REGINA',translate(RexVersionInfo))<>0 then
  354. do
  355. RexWhich='REGINA'
  356. parse value translate(RexVersionInfo)with . 'REGINA_' RexVerRegina ' '
  357. RexVerRegina=translate(RexVerRegina, '.', '_')
  358. end
  359. else
  360. do
  361. RexVerRegina=''
  362. RexWhich='STANDARD_OS/2'
  363. end
  364. parse source RexSystemOpSys .
  365. if RexSystemOpSys="WIN32" then
  366. do
  367. parse value uname()with RexSystemOpSys .
  368. if RexSystemOpSys<> "WIN95" & RexSystemOpSys <> "WIN98" & RexSystemOpSys <> "WINNT" then
  369. do
  370. call RexSystemFailure 'Regina uname() returned "' || uname() || '" (expected WIN95, WIN98 or WINNT)'
  371. end
  372. end
  373. RexSystmRexxPgmName='?';RexSystmRexxPgmName=RexGetFullSourceName()
  374. if arg(2)<> '' then
  375. call RexSystemFailure 'ARG(2) contains unexpected data of ' || arg(2) || '.'
  376. if translate(strip(arg(1)))='DEBUG' then
  377. do
  378. call RexDumpSystemInfo
  379. exit(0)
  380. end
  381. if RexWhich='STANDARD_OS/2' then
  382. do
  383. call RxFuncAdd 'SysSleep',        'RexxUtil', 'SysSleep'
  384. call RxFuncAdd 'SysFileDelete',   'RexxUtil', 'SysFileDelete'
  385. call RxFuncAdd 'SysSearchPath',   'RexxUtil', 'SysSearchPath'
  386. call RxFuncAdd 'SysFileTree',     'RexxUtil', 'SysFileTree'
  387. call RxFuncAdd 'SysTempFileName', 'RexxUtil', 'SysTempFileName'
  388. call SetLocal
  389. RexEnvVarPool='OS2ENVIRONMENT'
  390. RexStdoutStream='STDOUT'
  391. RexStderrStream='STDERR'
  392. RexTmpFileCntr=random(90000)
  393. end
  394. else
  395. do
  396. OPTIONS 'NOEXT_COMMANDS_AS_FUNCS'
  397. numeric digits 11
  398. RexEnvVarPool='SYSTEM'
  399. RexStdoutStream='<stdout>'
  400. RexStderrStream='<stderr>'
  401. end
  402. if RexSystemOpSys<> "UNIX" then
  403. do
  404. RexDirChar='\'
  405. RexOptionChar='/'
  406. end
  407. else
  408. do
  409. RexDirChar='/'
  410. RexOptionChar='-'
  411. end
  412. signal REXSYSTM_1
  413.  
  414. RexDumpSystemInfo:
  415. say 'Program Name  : ' ||RexSystmRexxPgmName
  416. say 'Op System     : ' ||RexSystemOpSys
  417. say 'Rexx Ver      : ' ||RexVersionInfo
  418. say 'Which System  : ' ||RexWhich
  419. if RexWhich='REGINA' then
  420. say 'regina uname(): ' ||uname()
  421. return
  422.  
  423. RexNeedReginaWorkAround:
  424. if RexWhich='STANDARD_OS/2' then
  425. return('N')
  426. else
  427. return('Y')
  428.  
  429. RexGetFullSourceName:
  430. parse source . . TmpRexxSrc
  431. if RexWhich='REGINA' then
  432. TmpRexxSrc=stream(strip(TmpRexxSrc), 'c', 'query exists')
  433. if TmpRexxSrc='' then
  434. call RexSystemFailure 'Could not determine the name of the rexx program!'
  435. return(TmpRexxSrc)
  436.  
  437. RexQueryExists:
  438. if arg(1)='' then
  439. return('')
  440. else
  441. return(stream(arg(1), 'c', 'query exists'))
  442.  
  443. RexGetNameOfTmpDir:call TRACE "OFF"
  444. TmpDir=strip(GetEnv('TMP'))
  445. if TmpDir='' then
  446. TmpDir=strip(GetEnv('TEMP'))
  447. if TmpDir='' then
  448. do
  449. if RexSystemOpSys="UNIX" then
  450. TmpDir='/tmp'
  451. end
  452. if right(TmpDir,1)==RexDirChar then
  453. TmpDir=left(TmpDir,length(TmpDir)-1)
  454. return(TmpDir)
  455.  
  456. RedirectStdOutAndErr2:
  457. if RedirMethod<> '' then
  458. do
  459. select
  460. when RedirMethod="@bash" then
  461. return(' >' || arg(1) || ' 2>&1')
  462. when RedirMethod="@csh" then
  463. return(' >& ' ||arg(1))
  464. otherwise
  465. do
  466. r12Meth=RedirMethod
  467. r12Pos=pos('{?}',r12Meth)
  468. do while r12Pos<>0
  469. r12Meth=left(r12Meth,r12Pos-1)||arg(1)||substr(r12Meth,r12Pos+3)
  470. r12Pos=pos('{?}',r12Meth)
  471. end
  472. end
  473. end
  474. return(' ' ||r12Meth)
  475. end
  476. if RexSystemOpSys="DOS" | RexSystemOpSys = "WIN95" | RexSystemOpSys = "WIN98" then
  477. do
  478. return(' >' ||arg(1))
  479. end
  480. else
  481. do
  482. return(' >' || arg(1) || ' 2>&1')
  483. end
  484.  
  485. NameOfNulDevice:
  486. if RexSystemOpSys="UNIX" then
  487. return('/dev/null')
  488. else
  489. return('nul')
  490.  
  491. AllCmdOutput2Nul:
  492. return(RedirectStdOutAndErr2(NameOfNulDevice()))
  493.  
  494. AddressCmd:call TRACE "OFF"
  495. SysCmd2Exec=arg(1)
  496. if RexWhich='STANDARD_OS/2' then
  497. SysCmd2Exec='@' ||SysCmd2Exec
  498. call DebugAddressCmdBefore SysCmd2Exec
  499. SysCmd2Exec
  500. SysCmdRc=Rc
  501. FileIndex=2
  502. SysCmdFile=arg(FileIndex)
  503. do while SysCmdFile<> ''
  504. call DebugAddressCmdOutput SysCmdFile, 'H1'
  505. call DebugAddressCmdOutput copies('~', length(SysCmdFile)), 'H2'
  506. if stream(SysCmdFile, 'c', 'query exists') = '' then
  507. call DebugAddressCmdOutput '*File does not exist*',     '!'
  508. else
  509. do
  510. SysCmdLine=0
  511. CloseRc=stream(SysCmdFile, 'c', 'close')
  512. do while lines(SysCmdFile)<>0
  513. SysCmdLine=SysCmdLine+1
  514. call DebugAddressCmdOutput linein(SysCmdFile),SysCmdLine
  515. end
  516. CloseRc=stream(SysCmdFile, 'c', 'close')
  517. end
  518. FileIndex=FileIndex+1
  519. SysCmdFile=arg(FileIndex)
  520. end
  521. call DebugAddressCmdAfter SysCmdRc
  522. Rc=SysCmdRc
  523. return(SysCmdRc)
  524.  
  525. _filespec:call TRACE "OFF"
  526. fsCmd=translate(arg(1))
  527. select
  528. when fsCmd='D' | fsCmd = 'DRIVE' then
  529. do
  530. if RexSystemOpSys="UNIX" then
  531. return('')
  532. fsPos=pos(':',arg(2))
  533. if fsPos=0 then
  534. return('')
  535. else
  536. return(left(arg(2),fsPos))
  537. end
  538. when fsCmd='P' | fsCmd = 'PATH' then
  539. do
  540. fsStartWith=substr(arg(2),length(_filespec('D',arg(2)))+1)
  541. fsPos=lastpos(RexDirChar,fsStartWith)
  542. if fsPos=0 then
  543. return('')
  544. else
  545. return(left(fsStartWith,fsPos))
  546. end
  547. when fsCmd='N' | fsCmd = 'NAME' then
  548. do
  549. return(substr(arg(2),length(_filespec('L',arg(2)))+1))
  550. end
  551. when fsCmd='L' | fsCmd = 'LOCATION' then
  552. do
  553. return(_filespec('D', arg(2)) || _filespec('P',arg(2)))
  554. end
  555. when fsCmd='E' | fsCmd = 'EXTN' then
  556. do
  557. fsDotPos=lastpos('.',arg(2))
  558. if fsDotPos=0 then
  559. return('')
  560. else
  561. return(substr(arg(2),fsDotPos+1))
  562. end
  563. when fsCmd='W' | fsCmd = 'WITHOUTEXTN' then
  564. do
  565. fsDotPos=lastpos('.',arg(2))
  566. if fsDotPos=0 then
  567. return(arg(2))
  568. else
  569. return(left(arg(2),fsDotPos-1))
  570. end
  571. otherwise
  572. call RexSystemFailure 'Unknown _filespec() command of "' || arg(1) || '"'
  573. end
  574. return
  575.  
  576. _SysSleep:call TRACE "OFF"
  577. if RexWhich='STANDARD_OS/2' then
  578. do
  579. call SysSleep arg(1)
  580. return
  581. end
  582. call sleep arg(1)
  583. return
  584.  
  585. _SysSearchPath:call TRACE "OFF"
  586. if RexWhich='STANDARD_OS/2' then
  587. return(SysSearchPath(arg(1),arg(2)))
  588. SspPath=GetEnv(arg(1))
  589. if SspPath='' then
  590. return('')
  591. if RexSystemOpSys="UNIX" then
  592. SspChar=':'
  593. else
  594. SspChar=';'
  595. do while SspPath<> ''
  596. parse var SspPath SspThisFile (SspChar) SspPath
  597. if right(SspThisFile,1)<>RexDirChar then
  598. SspThisFile=SspThisFile||RexDirChar
  599. SspThisFile=RexQueryExists(SspThisFile||arg(2))
  600. if SspThisFile<> '' then
  601. return(SspThisFile)
  602. end
  603. return('')
  604.  
  605. _SysFileTree:call TRACE "OFF"
  606. if RexWhich='STANDARD_OS/2' then
  607. return(SysFileTree(arg(1),arg(2),arg(3),arg(4),arg(5)))
  608. if pos('D',arg(3))<>0 then
  609. stfType='D'
  610. else
  611. stfType='F'
  612. TmpDirFile=RexGetTmpFileName()
  613. if RexSystemOpSys<> "UNIX" then
  614. do
  615. DirCmd='dir /B '
  616. if pos('S',arg(3))<>0 then
  617. DirCmd=DirCmd|| "/S "
  618. if stfType='F' then
  619. DirCmd=DirCmd|| "/A-D "
  620. else
  621. DirCmd=DirCmd|| "/AD "
  622. DirCmd=DirCmd||arg(1)||RedirectStdOutAndErr2(TmpDirFile)
  623. end
  624. else
  625. do
  626. DirCmd='find ' || _filespec('L', arg(1)) || ' '
  627. if pos('FREEBSD',translate(uname()))=0 then
  628. DirCmd=DirCmd|| '-noleaf '
  629. if pos('S',arg(3))=0 then
  630. do
  631. if pos('FREEBSD',translate(uname()))=0 then
  632. DirCmd=DirCmd|| '-maxdepth 1 '
  633. else
  634. DirCmd=DirCmd|| '-prune '
  635. end
  636. if stfType='F' then
  637. DirCmd=DirCmd|| "-type f "
  638. else
  639. DirCmd=DirCmd|| "-type d "
  640. stfSName=_filespec('N',arg(1))
  641. if stfSName<> '' then
  642. DirCmd=DirCmd|| '-name "' || stfSName || '"'
  643. DirCmd=DirCmd||RedirectStdOutAndErr2(TmpDirFile)
  644. end
  645. Rc=AddressCmd(DirCmd,TmpDirFile)
  646. LastSlash=lastpos(RexDirChar,arg(1))
  647. CloseRc=stream(TmpDirFile, 'c', 'close')
  648. TmpLine=0
  649. do while lines(TmpDirFile)<>0
  650. AFile=linein(TmpDirFile)
  651. if AFile='' | AFile = '.' | AFile = '..' then
  652. iterate
  653. if RexSystemOpSys="UNIX" & stfType = 'D' then
  654. do
  655. if AFile=_filespec('L',arg(1))then
  656. iterate
  657. end
  658. if LastSlash<>0 then
  659. do
  660. if pos(RexDirChar,AFile)==0 then
  661. AFile=left(arg(1),LastSlash)||AFile
  662. end
  663. if stfType='F' then
  664. do
  665. AFile=stream(AFile, 'c', 'query exists')
  666. if AFile='' then
  667. iterate
  668. end
  669. else
  670. do
  671. if pos(' ',AFile)<>0 then
  672. iterate
  673. end
  674. TmpLine=TmpLine+1
  675. call _valueS arg(2)|| '.' ||TmpLine,strip(AFile)
  676. end
  677. CloseRc=stream(TmpDirFile, 'c', 'close')
  678. DeleteRc=_SysFileDelete(TmpDirFile)
  679. call _valueS arg(2)|| '.0',TmpLine
  680. return(0)
  681.  
  682. _SysFileDelete:call TRACE "OFF"
  683. if RexWhich='STANDARD_OS/2' then
  684. return(SysFileDelete(arg(1)))
  685. if RexSystemOpSys="DOS" | RexSystemOpSys = "WIN95" | RexSystemOpSys = "WIN98" then
  686. return(AddressCmd('if exist ' || arg(1) || ' del ' ||arg(1)||AllCmdOutput2Nul()))
  687. else
  688. do
  689. if RexSystemOpSys="UNIX" then
  690. return(AddressCmd('rm -f ' ||arg(1)||AllCmdOutput2Nul()))
  691. else
  692. return(AddressCmd('del ' ||arg(1)||AllCmdOutput2Nul()))
  693. end
  694.  
  695. RexGetTmpFileName:call TRACE "OFF"
  696. if arg(1)<> '' then
  697. TmpFileM=arg(1)
  698. else
  699. do
  700. if RexSystemOpSys<> "UNIX" then
  701. TmpFileM='RSTM????.TMP'
  702. else
  703. do
  704. TmpFileM=GetEnv('USER')
  705. if TmpFileM='' then
  706. TmpFileM=GetEnv('user')
  707. if TmpFileM='' then
  708. TmpFileM='?????.rstm'
  709. else
  710. TmpFileM=TmpFileM|| '_?????.rstm'
  711. end
  712. end
  713. TmpFileM=RexGetNameOfTmpDir()||RexDirChar||TmpFileM
  714. if RexWhich='STANDARD_OS/2' then
  715. do
  716. TmpFileF=SysTempFileName(TmpFileM)
  717. if TmpFileF='' then
  718. do
  719. RexTmpFileCntr=RexTmpFileCntr+1
  720. TmpFileF='C_' || right(RexTmpFileCntr, 6, '0') || '.TMP'
  721. end
  722. return(TmpFileF)
  723. end
  724. TmpRandom=right(time('S'),3)||random(99999)
  725. TmpRandomAdd=0
  726. do until stream(TmpFileA, 'c', 'query exists') = ''
  727. TmpRandomS=reverse(d2x(TmpRandom+TmpRandomAdd))
  728. TmpRandomAdd=TmpRandomAdd+1
  729. TmpFileA=TmpFileM
  730. TmpWhich=1
  731. QmPos=pos('?',TmpFileA)
  732. do while QmPos<>0
  733. TmpReplace=substr(TmpRandomS,TmpWhich,1)
  734. TmpWhich=TmpWhich+1
  735. if TmpReplace='' then
  736. TmpWhich=1
  737. else
  738. do
  739. TmpFileA=overlay(TmpReplace,TmpFileA,QmPos)
  740. QmPos=pos('?',TmpFileA)
  741. end
  742. end
  743. end
  744. return(TmpFileA)
  745.  
  746. GetEnv:call TRACE "OFF"
  747. rsGetEnv=value(arg(1),,RexEnvVarPool)
  748. if rsGetEnv=='' & arg(2) = 'Y' then
  749. call RexSystemFailure 'Could not find the environment variable "' || arg(1) || '"'
  750. return(rsGetEnv)
  751.  
  752. SetEnv:call TRACE "OFF"
  753. return(value(arg(1),arg(2),RexEnvVarPool))
  754.  
  755. _valueS:call TRACE "OFF"
  756. if RexWhich='STANDARD_OS/2' then
  757. return(value(arg(1),arg(2)))
  758. return(value(translate(arg(1)),arg(2)))
  759.  
  760. _valueG:call TRACE "OFF"
  761. if RexWhich='STANDARD_OS/2' then
  762. return(value(arg(1)))
  763. return(value(arg(1)))
  764.  
  765. REXSYSTM_1:
  766. PpWizardPgmName=RexSystmRexxPgmName
  767. PpWizardOpSys=RexSystemOpSys
  768. PpwUserDescription='PPWIZARD version ' || PgmVersion || ' on ' || PpWizardOpSys ||  ', FREE tool for OS/2, Windows, DOS and UNIX by ' || PgmAuthor || ' (' || PgmHomePage || ')'
  769. PgmDefaultHtmlMetaTags='<META NAME="GENERATOR" CONTENT="' || PpwUserDescription || '">'
  770. if RexSystemOpSys<> "UNIX" then
  771. do
  772. DebugNewline=d2c(25)
  773. DebugLeftArrow=d2c(174)
  774. DebugRightArrow=d2c(175)
  775. end
  776. else
  777. do
  778. DebugNewline=d2c(165)
  779. DebugLeftArrow='<'
  780. DebugRightArrow='>'
  781. end
  782. OptionCodeType=''
  783. LastSystemCmd="none"
  784. LastSystemCmdFull="none"
  785. LastSystemRc=999
  786. signal System_2
  787.  
  788. ProcessSystem:
  789. Rest=PerformReplacementsInCmdsParameters(arg(1))
  790. Log2File=GetQuotedText(Rest, "Rest")
  791. LastSystemCmd=GetQuotedRest(Rest)
  792. select
  793. when RexSystemOpSys="OS/2" then
  794. CmdProc='CMD.EXE /c '
  795. otherwise
  796. CmdProc=''
  797. end
  798. LastSystemCmdFull=CmdProc||LastSystemCmd
  799. DeleteFileAfter='N'
  800. select
  801. when translate(Log2File)='ASIS' then
  802. Log2File=''
  803. when Log2File='-' then
  804. Log2File=NameOfNulDevice()
  805. when Log2File='?' then
  806. do
  807. Log2File=RexGetTmpFileName()
  808. DeleteFileAfter='Y'
  809. end
  810. otherwise
  811. nop
  812. end
  813. if Log2File<> '' then
  814. LastSystemCmdFull=LastSystemCmdFull||RedirectStdOutAndErr2(Log2File)
  815. LastSystemRc=AddressCmd(LastSystemCmdFull,Log2File)
  816. if DeleteFileAfter='Y' then
  817. call _SysFileDelete(Log2File)
  818. return(0)
  819.  
  820. System_2:
  821. call InitTransformationCode
  822. signal Transfrm_3
  823.  
  824. InitTransformationCode:
  825. TransformCode=''
  826. return
  827.  
  828. ProcessTransform:
  829. HashDefRexx=arg(1)
  830. if HashDefRexx<> '' then
  831. do
  832. HashDefRexx=PerformReplacementsInCmdsParameters(HashDefRexx)
  833. HashDefRexx=GetQuotedText(HashDefRexx)
  834. end
  835. if HashDefRexx<> '' then
  836. do
  837. if OptionDebugOn='Y' then
  838. call DebugLine 'Start of transformation block "' || HashDefRexx || '"'
  839. if TransformCode<> '' then
  840. CryAndDie("Already in tranformation block started at " ||TransformStartLoc)
  841. TransformStartLoc=CurrentSourceLocation()
  842. TransformCode=MacroGet(HashDefRexx)
  843. TransformCode=PerformReplacementsInCmdsParameters(TransformCode)
  844. end
  845. else
  846. do
  847. if OptionDebugOn='Y' then
  848. call DebugLine "End of transformation block"
  849. if TransformCode='' then
  850. CryAndDie('We were not in a tranformation block!')
  851. TransformCode=''
  852. end
  853. return(0)
  854.  
  855. Transfrm_3:
  856. OutputHoldLvl=0
  857. call InitOutputHold
  858. signal OutpHold_4
  859.  
  860. InitOutputHold:
  861. HoldingOutput='N'
  862. HeldOutput=''
  863. OutpHoldStartLoc=''
  864. return
  865.  
  866. OutputHoldPushAndClear:
  867. OutputHoldLvl=OutputHoldLvl+1
  868. OutHold_.OutputHoldLvl.!HoldingOutput=HoldingOutput
  869. OutHold_.OutputHoldLvl.!HeldOutput=HeldOutput
  870. OutHold_.OutputHoldLvl.!OutpHoldStartLoc=OutpHoldStartLoc
  871. call InitOutputHold
  872. return
  873.  
  874. OutputHoldPop:
  875. HoldingOutput=OutHold_.OutputHoldLvl.!HoldingOutput
  876. HeldOutput=OutHold_.OutputHoldLvl.!HeldOutput
  877. OutpHoldStartLoc=OutHold_.OutputHoldLvl.!OutpHoldStartLoc
  878. OutputHoldLvl=OutputHoldLvl-1
  879. return
  880.  
  881. DieIfHoldingOutput:
  882. if HoldingOutput='Y' then
  883. CryAndDie('Missing #OutputHold (end)', 'Block started at ' ||OutpHoldStartLoc)
  884. return
  885.  
  886. ProcessHashOutputHold:
  887. OrexxRexx=arg(1)
  888. if OrexxRexx='' then
  889. do
  890. if OptionDebugOn='Y' then
  891. call DebugLine 'Start of hold output block'
  892. if HoldingOutput='Y' then
  893. CryAndDie("Already in hold output block started at " ||OutpHoldStartLoc)
  894. call FlushQueuedOutput
  895. HoldingOutput='Y'
  896. OutpHoldStartLoc=CurrentSourceLocation()
  897. end
  898. else
  899. do
  900. if OptionDebugOn='Y' then
  901. call DebugLine "End of hold output block - Held " || length(HeldOutput) || ' byte(s)'
  902. if HoldingOutput='N' then
  903. CryAndDie('We were not in a hold output block!')
  904. call FlushQueuedOutput
  905. OrexxRexx=PerformReplacementsInCmdsParameters(OrexxRexx)
  906. OrexxRexx=GetQuotedText(OrexxRexx)
  907. if translate(OrexxRexx)='DROP' then
  908. HeldOutput=''
  909. else
  910. do
  911. OutputModCode=MacroGet(OrexxRexx)
  912. OutputModCode=PerformReplacementsInCmdsParameters(OutputModCode)
  913. call ExecRexxCmd OutputModCode
  914. end
  915. if HeldOutput\=='' then
  916. do
  917. if OptionDebugOn='Y' then
  918. call DebugLine 'Writing ' || length(HeldOutput) || ' byte(s) to output'
  919. call DirectToOutputFile HeldOutput
  920. end
  921. call InitOutputHold
  922. end
  923. return(0)
  924.  
  925. OutpHold_4:
  926. signal RexxHook_5
  927.  
  928. RexxHookSetBuildingParms:
  929. parse arg HookBuildParmInput,HookBuildParmOutput,HookBuildParmTemplate
  930. return
  931.  
  932. RexxHookInit:
  933. RexxHookBefore=''
  934. RexxHookAfter=''
  935. RexxHookWarning=''
  936. RexxHookError=''
  937. RexxHookGetFileList=''
  938. call RexxHookSetBuildingParms
  939. return
  940.  
  941. RexxHookSet:
  942. parse arg ThisCmd,ThisCmdOptions
  943. parse var ThisCmdOptions rhWhen';'rhCmd
  944. rhWhen=translate(rhWhen)
  945. do until rhWhen=''
  946. parse var rhWhen rhWhen1','rhWhen
  947. rhDone='N'
  948. if rhWhen1='' | abbrev("BEFORE",rhWhen1)then
  949. do
  950. rhDone='Y'
  951. RexxHookBefore=rhCmd
  952. end
  953. if rhWhen1='' | abbrev("AFTER",rhWhen1)then
  954. do
  955. rhDone='Y'
  956. RexxHookAfter=rhCmd
  957. end
  958. if rhWhen1='' | abbrev("WARNING",rhWhen1)then
  959. do
  960. rhDone='Y'
  961. RexxHookWarning=rhCmd
  962. end
  963. if rhWhen1='' | abbrev("ERROR",rhWhen1)then
  964. do
  965. rhDone='Y'
  966. RexxHookError=rhCmd
  967. end
  968. if rhWhen1='' | abbrev("GETFILELIST",rhWhen1)then
  969. do
  970. rhDone='Y'
  971. RexxHookGetFileList=rhCmd
  972. end
  973. if rhDone='N' then
  974. CryAndDie('The hook type of "' || rhWhen1 || '" is unknown')
  975. end
  976. return
  977.  
  978. CallHook:
  979. parse arg CallHook,CallHookOkParmsOk,Parm1,Parm2,Parm3,Parm4
  980. BuildDetailParms=', HookBuildParmInput, HookBuildParmOutput, HookBuildParmTemplate'
  981. HookSpecificParms=', Parm1, Parm2, Parm3, Parm4'
  982. select
  983. when CallHook="WARNING" then
  984. HookRexxCmd=RexxHookWarning
  985. when CallHook="BEFORE" then
  986. HookRexxCmd=RexxHookBefore
  987. when CallHook="AFTER" then
  988. HookRexxCmd=RexxHookAfter
  989. when CallHook="ERROR" then
  990. do
  991. ErrorHookCount=ErrorHookCount+1
  992. if ErrorHookCount>1 then
  993. return
  994. HookRexxCmd=RexxHookError
  995. end
  996. when CallHook="GETFILELIST" then
  997. do
  998. HookRexxCmd=RexxHookGetFileList
  999. BuildDetailParms=''
  1000. end
  1001. end
  1002. SrcLineLoc=CurrentSourceLocation('')
  1003. if OptionDebugOn='Y' then
  1004. do
  1005. call DebugLine 'Calling hook: ' || CallHook || ' - ' ||HookRexxCmd
  1006. call DebugIncrement 1
  1007. end
  1008. HookCmd='HookRc =  "' || HookRexxCmd || '"("00.050", SrcLineLoc, "' || CallHook || '"' || BuildDetailParms || HookSpecificParms || ')'
  1009. HookRc='?'
  1010. signal ON SYNTAX NAME SyntaxErrorInHook
  1011. Interpret HookCmd
  1012. if OptionDebugOn='Y' then
  1013. call DebugLine 'Rc = ' ||HookRc
  1014. if abbrev(HookRc, 'OK:')=0 then
  1015. do
  1016. call DumpVarsInExpression HookCmd,, 'HOOK VARIABLES', 'Line1'
  1017. CryAndDie('Hook Command Failed: ' || HookCmd, "Hook's Return Code : " ||HookRc)
  1018. end
  1019. OkParms=substr(HookRc,4)
  1020. if OkParms<> '' & CallHookOkParmsOk <> 'Y' then
  1021. CryAndDie('OK parameters not allowed on "' || CallHook || '" hooks.')
  1022. if OptionDebugOn='Y' then
  1023. call DebugIncrement-1
  1024. return(OkParms)
  1025.  
  1026. SyntaxErrorInHook:
  1027. CryAndDie('Hook Cmd Failed: ' ||HookCmd)
  1028.  
  1029. RexxHook_5:
  1030. WarningsToIgnore=''
  1031. signal Warning_6
  1032.  
  1033. OutputWarningToScreen:
  1034. WarningPrefix=strip( 'WARNING ' ||strip(arg(1)))
  1035. WarningTextP=arg(2)
  1036. if IncludeLevel=0 then
  1037. LineText=''
  1038. else
  1039. LineText='(@' || AddCommasToDecimalNumber(IncludeLineNumber) || ')'
  1040. WarningText=LineText||WarningPrefix|| ': ' ||WarningTextP
  1041. WarningTextU=translate(WarningText)
  1042. IgnoreList=WarningsToIgnore
  1043. do while IgnoreList<> ''
  1044. parse var IgnoreList IgnoreThis (PathDelimiterChar) IgnoreList
  1045. if IgnoreThis<> '' then
  1046. do
  1047. if pos(IgnoreThis,WarningTextU)<>0 then
  1048. do
  1049. if OptionDebugOn='Y' then
  1050. do
  1051. call DebugLine 'Ignoring => ' ||WarningText
  1052. call DebugIncrement 1
  1053. call DebugLine 'Warning contained ==> ' ||IgnoreThis
  1054. call DebugIncrement-1
  1055. end
  1056. return
  1057. end
  1058. end
  1059. end
  1060. if RexxHookWarning<> '' then
  1061. do
  1062. WarnHookRc=translate(CallHook("WARNING", 'Y',WarningTextP))
  1063. if WarnHookRc='IGNORE+' then
  1064. Warnings=Warnings+1
  1065. if WarnHookRc='IGNORE' | WarnHookRc = 'IGNORE+' then
  1066. do
  1067. if OptionDebugOn='Y' then
  1068. call DebugLine "HOOK said to drop warning: " ||WarningTextP
  1069. return
  1070. end
  1071. if WarnHookRc<> '' then
  1072. CryAndDie('Unknown warning hook return code of: ' ||WarnHookRc)
  1073. end
  1074. call Line1 copies("  ", IncludeLevel) || WarningColor || '   ' ||WarningText||Reset
  1075. Warnings=Warnings+1
  1076. return
  1077.  
  1078. WarnAboutDepreciatedFeature:
  1079. call OutputWarningToScreen 'DEP0', 'Replace OBSOLETE Feature ASAP -> ' ||arg(1)
  1080. return
  1081.  
  1082. ProcessHashWarning:
  1083. Rest=PerformReplacementsInCmdsParameters(arg(1))
  1084. WarningCde=GetQuotedText(Rest, "Rest")
  1085. WarningMsg=GetQuotedRest(Rest)
  1086. call OutputWarningToScreen WarningCde,WarningMsg
  1087. return(0)
  1088.  
  1089. Warning_6:
  1090. SrTypePre=d2c(254)||d2c(174)
  1091. SrTypeSuf=d2c(175)
  1092. call SrInit
  1093. signal SR_TYPE_7
  1094.  
  1095. SrInit:
  1096. SrCaseIns=SrTypePre|| 'CI' ||SrTypeSuf
  1097. SrCaseIns_P=length(SrCaseIns)+1
  1098. SrFixed=SrTypePre|| 'FiX' ||SrTypeSuf
  1099. SrFixed_P=length(SrFixed)+1
  1100. return
  1101.  
  1102. CompareReplaceFixed:call TRACE "OFF"
  1103.  
  1104. CompareReplaceFixed2:
  1105. sr_FromOrig=arg(1)
  1106. sr_SSpec=arg(2)
  1107. sr_CaseInSens='N'
  1108. sr_From=sr_FromOrig
  1109. sr_From_L=length(sr_From)
  1110. if arg(3, 'E')=1 then
  1111. sr_NoMatch=sr_From
  1112. else
  1113. sr_NoMatch=0
  1114. do while sr_SSpec<> ''
  1115. parse var sr_SSpec sr_CmdChar +1 sr_SSpec
  1116. select
  1117. when sr_CmdChar='@' then
  1118. do
  1119. parse var sr_SSpec sr_Operator ',' sr_Posn '=' +1 sr_Delim +1 sr_CompWith (sr_Delim) sr_SSpec
  1120. sr_Length=length(sr_CompWith)
  1121. if datatype(sr_Posn, 'W')=0 then
  1122. CryAndDie("CompareReplaceFixed()", "The position must be a whole number, '" || sr_Posn || "' is invalid")
  1123. if sr_Posn<0 then
  1124. do
  1125. sr_Posn=sr_From_L+sr_Posn+1
  1126. if sr_Posn<1 then
  1127. return(sr_NoMatch)
  1128. end
  1129. if sr_CaseInSens='N' then
  1130. sr_bit=substr(sr_From,sr_Posn,sr_Length)
  1131. else
  1132. sr_bit=translate(substr(sr_From,sr_Posn,sr_Length))
  1133. select
  1134. when sr_Operator='=' then
  1135. srCompRc=sr_bit=sr_CompWith
  1136. when sr_Operator='<>' then
  1137. srCompRc=sr_bit<>sr_CompWith
  1138. when sr_Operator='==' then
  1139. srCompRc=sr_bit==sr_CompWith
  1140. when sr_Operator='\==' then
  1141. srCompRc=sr_bit\==sr_CompWith
  1142. when sr_Operator='<' then
  1143. srCompRc=sr_bit<sr_CompWith
  1144. when sr_Operator='>' then
  1145. srCompRc=sr_bit>sr_CompWith
  1146. when sr_Operator='<=' then
  1147. srCompRc=sr_bit<=sr_CompWith
  1148. when sr_Operator='>=' then
  1149. srCompRc=sr_bit>=sr_CompWith
  1150. otherwise
  1151. CryAndDie("CompareReplaceFixed()", "Unsupported operator of '" || sr_Operator || "' used", '', 'ONLY "=, <>, ==, \==, <, >, <=, >=" are supported!')
  1152. end
  1153. if srCompRc=0 then
  1154. return(sr_NoMatch)
  1155. end
  1156. when sr_CmdChar='!' then
  1157. do
  1158. parse var sr_SSpec sr_CmdChar2 +1 sr_SSpec
  1159. select
  1160. when sr_CmdChar2='B' | sr_CmdChar2 = 'L' | sr_CmdChar2 = 'T' then
  1161. do
  1162. sr_From=strip(sr_From,sr_CmdChar2)
  1163. sr_From_L=length(sr_From)
  1164. end
  1165. when sr_CmdChar2='I' then
  1166. do
  1167. sr_From=space(sr_From)
  1168. sr_From_L=length(sr_From)
  1169. end
  1170. when sr_CmdChar2='S' then
  1171. sr_CaseInSens='N'
  1172. when sr_CmdChar2='i' then
  1173. sr_CaseInSens='Y'
  1174. otherwise
  1175. CryAndDie("CompareReplaceFixed()", 'Invalid "!" command of "' || sr_CmdChar2 || '"')
  1176. end
  1177. end
  1178. when sr_CmdChar='?' then
  1179. do
  1180. parse var sr_SSpec sr_Operator +1 sr_Delim +1 sr_LookFor (sr_Delim) sr_SSpec
  1181. if sr_CaseInSens='N' then
  1182. sr_Pos=pos(sr_LookFor,sr_From)
  1183. else
  1184. sr_Pos=pos(sr_LookFor,translate(sr_From))
  1185. if sr_Operator='=' then
  1186. do
  1187. if sr_Pos=0 then
  1188. return(sr_NoMatch)
  1189. end
  1190. else
  1191. do
  1192. if sr_Pos<>0 then
  1193. return(sr_NoMatch)
  1194. end
  1195. end
  1196. otherwise
  1197. CryAndDie("CompareReplaceFixed()", 'Invalid compare command of "' || sr_CmdChar || '"')
  1198. end
  1199. end
  1200. if arg(3, 'O')=1 then
  1201. return(1)
  1202. sr_RSpec=arg(3)
  1203. ReplaceCount=ReplaceCount+1
  1204. sr_From=sr_FromOrig
  1205. sr_From_L=length(sr_From)
  1206. sr_output=''
  1207. do forever
  1208. parse var sr_RSpec sr_Before '@' sr_RSpec
  1209. sr_Output = sr_Output || sr_Before
  1210. if sr_RSpec=='' then
  1211. return(sr_Output)
  1212. parse var sr_RSpec sr_CmdChar +1 sr_RSpec
  1213. select
  1214. when sr_CmdChar='$' then
  1215. do
  1216. parse var sr_RSpec sr_Posn ',' sr_Length ';' sr_RSpec
  1217. if sr_Posn<0 then
  1218. do
  1219. sr_Posn=sr_From_L+sr_Posn+1
  1220. if sr_Posn<1 then
  1221. return(sr_From)
  1222. end
  1223. if sr_Length='*' then
  1224. sr_Output=sr_Output||substr(sr_From,sr_Posn)
  1225. else
  1226. sr_Output=sr_Output||substr(sr_From,sr_Posn,sr_Length)
  1227. end
  1228. when sr_CmdChar='=' then
  1229. do
  1230. parse var sr_RSpec sr_Delim +1 sr_Exec (sr_Delim) sr_RSpec
  1231. CompareString=sr_From
  1232. call ExecRexxCmd('sr_Output = sr_Output || ' ||sr_Exec)
  1233. end
  1234. when sr_CmdChar='@' then
  1235. sr_Output=sr_Output|| '@'
  1236. otherwise
  1237. CryAndDie("CompareReplaceFixed()", 'Invalid replace command of "' || sr_CmdChar || '"')
  1238. end
  1239. end
  1240.  
  1241. SR_TYPE_7:
  1242. DependsOnFmtVer="FORMAT 99.289"
  1243. call ClearDependancyTimeStampCache
  1244. signal DEPENDON_8
  1245.  
  1246. _CheckedLineout:
  1247. Lineout.FileName=arg(1)
  1248. Lineout.TheLine=arg(2)
  1249. if 0<>lineout(Lineout.FileName,Lineout.TheLine)then
  1250. CryAndDie('Write to "' || Lineout.FileName || '" failed!')
  1251. return
  1252.  
  1253. NeedToRemake:
  1254. DepFile4=arg(1)
  1255. if OptionDependsOn='' then
  1256. do
  1257. call DebugLine 'No Dependancy file to check - Need to make'
  1258. DepFileName=''
  1259. return("Y")
  1260. end
  1261. DepFileName=GenerateFileName(DepFile4,OptionDependsOn, 'Y')
  1262. if _NeedToRemakeCheckDependencies()='N' then
  1263. do
  1264. if OptionSeeDependsProgress='Y' then
  1265. call Line1 ''
  1266. return('N')
  1267. end
  1268. call MustDeleteFile DepFileName
  1269. InputDepCount=0
  1270. OutputDepCount=0
  1271. return('Y')
  1272.  
  1273. ClearDependancyTimeStampCache:
  1274. TimeStampCount=0
  1275. return
  1276.  
  1277. GetFileDateTimeButDontWarnOnError:
  1278. tsFile=arg(1)
  1279. do TimeIndex=1 to TimeStampCount
  1280. if tsFile==TimeStamp.TimeIndex.TSNAME then
  1281. return(TimeStamp.TimeIndex.TSTIME)
  1282. end
  1283. if SafeQueryExists(tsFile)=='' then
  1284. Ts=-1
  1285. else
  1286. Ts=GetFileTimeStamp(tsFile)
  1287. TimeStampCount=TimeStampCount+1
  1288. TimeStamp.TimeStampCount.TSNAME=tsFile
  1289. TimeStamp.TimeStampCount.TSTIME=Ts
  1290. return(Ts)
  1291.  
  1292. _ShowDependancyCheckProgress:
  1293. if OptionSeeDependsProgress='Y' then
  1294. call Line1 '  ?> ' ||arg(1)
  1295. else
  1296. call DebugLine arg(1)
  1297. return
  1298.  
  1299. _NeedToRemakeCheckDependencies:
  1300. TitleText='Checking Dependencies - "' || _filespec('name', CurrentOutFile) || '"'
  1301. if OptionSeeDependsProgress='N' then
  1302. call DebugLine TitleText
  1303. else
  1304. do
  1305. call Line1 TitleColor||TitleText
  1306. call Line1 copies('~',length(TitleText))||Reset
  1307. end
  1308. OutputTime=GetFileDateTimeButDontWarnOnError(CurrentOutFile)
  1309. if OutputTime=-1 then
  1310. do
  1311. call _ShowDependancyCheckProgress CurrentOutFile|| ' does not exist.'
  1312. return('Y')
  1313. end
  1314. if SafeQueryExists(DepFileName)='' then
  1315. do
  1316. call _ShowDependancyCheckProgress DepFileName|| ' does not exist.'
  1317. return('Y')
  1318. end
  1319. CloseRc=stream(DepFileName, 'c', 'close')
  1320. OpenRc=stream(DepFileName, 'c', 'open read')
  1321. DependLine=linein(DepFileName)
  1322. if DependLine<>DependsOnFmtVer then
  1323. do
  1324. call _ShowDependancyCheckProgress 'Dependency formatting is not at current level'
  1325. CloseRc=stream(DepFileName, 'c', 'close')
  1326. return('Y')
  1327. end
  1328. ReMake='N'
  1329. do while lines(DepFileName)<>0
  1330. DependLine=linein(DepFileName)
  1331. if DependLine='' then
  1332. iterate
  1333. if left(DependLine,1)='' then
  1334. DepType='output'
  1335. else
  1336. DepType='input'
  1337. DependLine=substr(DependLine,2)
  1338. WhatStamped=GetQuotedText(DependLine, "DependLine")
  1339. LineStamp=GetQuotedRest(DependLine)
  1340. call _ShowDependancyCheckProgress 'Checking: "' || WhatStamped || '"'
  1341. ThisInputDepFile=WhatStamped
  1342. DependantTime=GetDependsStamp(WhatStamped)
  1343. if DependantTime=-1 then
  1344. do
  1345. call _ShowDependancyCheckProgress "Can't locate the dependant file (" || DepType || ")!"
  1346. ReMake='Y'
  1347. leave
  1348. end
  1349. if DependantTime<>LineStamp then
  1350. do
  1351. call _ShowDependancyCheckProgress "The stamp of " || DepType || " differs from last make."
  1352. ReMake='Y'
  1353. leave
  1354. end
  1355. end
  1356. CloseRc=stream(DepFileName, 'c', 'close')
  1357. if ReMake='N' then
  1358. call _ShowDependancyCheckProgress 'No need to remake...'
  1359. return(ReMake)
  1360.  
  1361. GetDependsStamp:
  1362. if left(ThisInputDepFile,1)='*' then
  1363. do
  1364. Stamp4U=translate(ThisInputDepFile)
  1365. select
  1366. when abbrev(Stamp4U, "*EXEC=")then
  1367. do
  1368. TheCmd=substr(ThisInputDepFile,7)
  1369. TmpFile=RexGetTmpFileName("DEPON???.???")
  1370. call AddressCmd TheCmd|| ' >' || TmpFile || ' 2>&1'
  1371. ExecRc=Rc
  1372. call DebugLine 'Depend value is result of (Rc=' || ExecRc || '): ' ||TheCmd
  1373. CloseRc=stream(TmpFile, 'c', 'close')
  1374. TheCmdVal=charin(TmpFile,,999999)
  1375. CloseRc=stream(TmpFile, 'c', 'close')
  1376. TheCmdVal=translate(TheCmdVal,, '0D0A1A'x, ' ')
  1377. TheCmdVal='RC=' || ExecRc || '->' ||TheCmdVal
  1378. return(TheCmdVal)
  1379. end
  1380. when abbrev(Stamp4U, "*FILES=")then
  1381. do
  1382. TheMask=substr(ThisInputDepFile,8)
  1383. if left(TheMask,1)<> '+' then
  1384. sdDo='N'
  1385. else
  1386. do
  1387. sdDo='Y'
  1388. TheMask=substr(TheMask,2)
  1389. end
  1390. call GetListOfFiles TheMask, 'DepDirList',sdDo
  1391. DirStamp=DepDirList.0|| ' files'
  1392. do DepIndex=1 to DepDirList.0
  1393. DirStamp=DirStamp|| '; ' || DepDirList.DepIndex || '=' ||GetFileDateTimeButDontWarnOnError(DepDirList.DepIndex)
  1394. end
  1395. return(DirStamp)
  1396. end
  1397. otherwise
  1398. nop
  1399. end
  1400. end
  1401. if RexSystemOpSys<> "UNIX" then
  1402. ThisInputDepFile=translate(ThisInputDepFile)
  1403. return(GetFileDateTimeButDontWarnOnError(ThisInputDepFile))
  1404.  
  1405. AddInputFileToDependancyList:call TRACE "OFF"
  1406. if DepFileName='' then
  1407. return('N')
  1408. ThisInputDepFile=arg(1)
  1409. InputFileStamp=arg(2)
  1410. if InputFileStamp='' then
  1411. InputFileStamp=GetDependsStamp()
  1412. do LookIndex=1 to InputDepCount
  1413. if ThisInputDepFile=InputDepFile.LookIndex then
  1414. return('N')
  1415. end
  1416. InputDepCount=InputDepCount+1
  1417. InputDepFile.InputDepCount=ThisInputDepFile
  1418. InputDepStamp.InputDepCount=InputFileStamp
  1419. return('Y')
  1420.  
  1421. AddOutputFileToDependancyList:call TRACE "OFF"
  1422. if DepFileName='' then
  1423. return('N')
  1424. ThisOutputDepFile=arg(1)
  1425. do LookIndex=1 to OutputDepCount
  1426. if ThisOutputDepFile=OutputDepFile.LookIndex then
  1427. return('N')
  1428. end
  1429. OutputDepCount=OutputDepCount+1
  1430. OutputDepFile.OutputDepCount=ThisOutputDepFile
  1431. return('Y')
  1432.  
  1433. _OutputDepWhatToFile:
  1434. DepWhat=arg(1)
  1435. DepWhatQ=QuoteIt(DepWhat)
  1436. DepWhat=DepWhatQ||DepWhat||DepWhatQ
  1437. return(DepWhat)
  1438.  
  1439. CreateDependancyFileFromLists:
  1440. if DepFileName='' then
  1441. return
  1442. call DebugLine 'Making the dependancy file (' || DepFileName || ')'
  1443. call DebugIncrement 1
  1444. call MakeDirectoryTree _filespec('drive', DepFileName) || _filespec('path',DepFileName)
  1445. call ClearDependancyTimeStampCache
  1446. call _CheckedLineout DepFileName,DependsOnFmtVer
  1447. call _CheckedLineout DepFileName, ''
  1448. DepWhatPad=0
  1449. do LookIndex=1 to OutputDepCount
  1450. call DebugLine 'Add OUTPUT dependancy : ' ||OutputDepFile.LookIndex
  1451. OutputFileTs=GetFileDateTimeButDontWarnOnError(OutputDepFile.LookIndex)
  1452. call _CheckedLineout DepFileName, ' ' || _OutputDepWhatToFile(OutputDepFile.LookIndex) || '   ~' || OutputFileTs || '~'
  1453. end
  1454. call _CheckedLineout DepFileName, ''
  1455. do LookIndex=1 to InputDepCount
  1456. call DebugLine 'Add INPUT  dependancy : ' ||InputDepFile.LookIndex
  1457. call _CheckedLineout DepFileName, ' ' || _OutputDepWhatToFile(InputDepFile.LookIndex) || '   ~' || InputDepStamp.LookIndex || '~'
  1458. end
  1459. CloseRc=stream(DepFileName, 'c', 'close')
  1460. call DebugIncrement-1
  1461. return
  1462.  
  1463. ProcessDependsOn:
  1464. Rest=PerformReplacementsInCmdsParameters(arg(1))
  1465. DepType=translate(GetQuotedText(Rest, "DependsOnList"))
  1466. if DepType<> 'INPUT' & DepType <> 'OUTPUT' then
  1467. CryAndDie('Expected either "INPUT" or "OUTPUT" for dependancy type (not "' || DepType || '")!')
  1468. if DependsOnList='' then
  1469. CryAndDie('No files supplied on "#DependsOn ' || DepType || '" command!')
  1470. do while DependsOnList<> ''
  1471. ThisOne=GetQuotedText(DependsOnList, "DependsOnList")
  1472. if DepType='OUTPUT' then
  1473. Added=AddOutputFileToDependancyList(ThisOne)
  1474. else
  1475. Added=AddInputFileToDependancyList(ThisOne)
  1476. if Added='Y' then
  1477. call DebugLine DepType|| ' dependancy : ' ||ThisOne
  1478. end
  1479. return(0)
  1480.  
  1481. DEPENDON_8:
  1482. SpellDelChars=d2c(9)|| ',.=:;<>&-%()!/~' || '?#${}[]"'
  1483. SpellDictFileCount=0
  1484. SpellDelChangeCount=0
  1485. SpellingPrompts='N'
  1486. SpellShowEachError='N'
  1487. SpellingAddFile=''
  1488. SpellWordCount=0
  1489. SpellMistakeCount=0
  1490. SpellingAddCount=0
  1491. BadlySpellWordCount=0
  1492. CheckSpelling='N';
  1493. signal SPELLING_9
  1494.  
  1495. PrepareSpellingForThisBuild:
  1496. if OptionCompleteAddToToDepFile='Y' then
  1497. do
  1498. do DictIndex=1 to SpellDictFileCount
  1499. call AddInputFileToDependancyList SpellDictFile.DictIndex,SpellDictTime.DictIndex
  1500. end
  1501. end
  1502. Drop ?BADWORDEB.
  1503. return
  1504.  
  1505. LoadSpellingDictionary:
  1506. DictFileS=arg(1)
  1507. call DebugLine_SPELLING 'User wants the dictionary "' || DictFileS || '"'
  1508. DictFile=FindIncludeFile(DictFileS)
  1509. if DictFile='' then
  1510. CryAndDie('The dictionary file "' || DictFileS || '" does not exist!')
  1511. call DebugLine_SPELLING 'Loading "' || DictFile || '"'
  1512. SpellDictFileCount=SpellDictFileCount+1
  1513. SpellDictFile.SpellDictFileCount=DictFile
  1514. SpellDictTime.SpellDictFileCount=GetFileDateTimeButDontWarnOnError(DictFile)
  1515. CloseRc=stream(DictFile, 'c', 'close')
  1516. do while lines(DictFile)<>0
  1517. ThisWord=translate(strip(linein(DictFile)))
  1518. if ThisWord='' then
  1519. iterate
  1520. if left(ThisWord,1)=';' then
  1521. iterate
  1522. if left(ThisWord,1)<> '$' then
  1523. do
  1524. SpellWordCount=SpellWordCount+1
  1525. call _valueS '?SPELLDICT.?' || c2x(ThisWord), ''
  1526. end
  1527. else
  1528. do
  1529. parse var ThisWord DictCmd Rest
  1530. select
  1531. when DictCmd='$MISTAKE' then
  1532. do
  1533. parse var Rest SpeltWrong SpeltCorrectly .
  1534. SpellMistakeCount=SpellMistakeCount+1
  1535. call _valueS '?SPELLERR.?' ||c2x(SpeltWrong),SpeltCorrectly
  1536. end
  1537. when DictCmd='$DELIMITERS' then
  1538. do
  1539. call DebugLine_SPELLING 'Dictionary is changing spelling delimiters'
  1540. SpellDelChangeCount=SpellDelChangeCount+1
  1541. if SpellDelChangeCount>1 then
  1542. call OutputWarningToScreen 'SPL9', 'Spell check delimiters already modified!'
  1543. call ExecRexxCmd "SpellDelChars = " ||strip(Rest)
  1544. end
  1545. otherwise
  1546. do
  1547. SpellWordCount=SpellWordCount+1
  1548. call _valueS '?SPELLDICT.?' || c2x(ThisWord), ''
  1549. end
  1550. end
  1551. end
  1552. end
  1553. CloseRc=stream(DictFile, 'c', 'close')
  1554. call DebugLine_SPELLING 'Now have ' || AddCommasToDecimalNumber(SpellWordCount) || ' word(s) in dictionary and ' || AddCommasToDecimalNumber(SpellMistakeCount) || ' common mistakes noted!'
  1555. CheckSpelling='Y';
  1556. return
  1557.  
  1558. SpellCheckOneLine:
  1559. SpellLine=space(arg(1))
  1560. if 1=1 then
  1561. do
  1562. RightBit=SpellLine
  1563. SpellLine=''
  1564. StartPos=pos('<',RightBit)
  1565. do while StartPos<>0
  1566. EndPos=pos('>',RightBit,StartPos+1)
  1567. if EndPos=0 then
  1568. EndPos=StartPos
  1569. SpellLine=SpellLine||left(RightBit,StartPos-1)|| ' '
  1570. RightBit=substr(RightBit,EndPos+1)
  1571. StartPos=pos('<',RightBit)
  1572. end
  1573. SpellLine=SpellLine||RightBit
  1574. if SpellLine='' then
  1575. return
  1576. end
  1577. SpellLine=translate(translate(SpellLine), '', SpellDelChars, ' ')
  1578. do WordIndex=1 to words(SpellLine)
  1579. ThisWord=Word(SpellLine,WordIndex)
  1580. if left(ThisWord,1)="'" then
  1581. ThisWord=substr(ThisWord,2)
  1582. if right(ThisWord,1)="'" then
  1583. ThisWord=left(ThisWord,length(ThisWord)-1)
  1584. if length(ThisWord)>100 then
  1585. do
  1586. if OptionDebugOn='Y' then
  1587. call DebugLine_SPELLING 'Word too big to safely handle "' || ThisWord || '"'
  1588. iterate
  1589. end
  1590. ThisWordC2X=c2x(ThisWord)
  1591. if SpellMistakeCount<>0 then
  1592. do
  1593. MistakeId='?SPELLERR.?' ||ThisWordC2X
  1594. if symbol(MistakeId)='VAR' then
  1595. do
  1596. if SpellShowEachError='Y' then
  1597. ShowThisError='Y'
  1598. else
  1599. do
  1600. DuplicatedId='?BADWORDEB.?' ||ThisWordC2X
  1601. if symbol(DuplicatedId)='VAR' then
  1602. ShowThisError='N'
  1603. else
  1604. do
  1605. ShowThisError='Y'
  1606. call _valueS DuplicatedId, ''
  1607. end
  1608. end
  1609. if ShowThisError='Y' then
  1610. do
  1611. CorrectWord=_valueG(MistakeId)
  1612. if CorrectWord='' then
  1613. call OutputWarningToScreen 'SPL0', 'Common Mistake: ' ||ThisWord
  1614. else
  1615. call OutputWarningToScreen 'SPL0', 'Common Mistake: ' || ThisWord || ' (use "' || CorrectWord || '" instead)'
  1616. end
  1617. iterate
  1618. end
  1619. end
  1620. if SpellWordCount=0&SpellingPrompts='N' then
  1621. iterate
  1622. ValidId='?SPELLDICT.?' ||ThisWordC2X
  1623. if symbol(ValidId)<> 'VAR' then
  1624. do
  1625. if datatype(ThisWord)<> 'NUM' then
  1626. do
  1627. WordWarningId=''
  1628. WordWarningMsg=''
  1629. if SpellingPrompts<> 'N' then
  1630. do
  1631. DuplicatedId='?BADWORDPI.?' ||ThisWordC2X
  1632. if symbol(DuplicatedId)='VAR' then
  1633. do
  1634. BadIndex=_valueG(DuplicatedId)
  1635. if BadIndex<> '' then
  1636. do
  1637. WordWarningId='SPL1'
  1638. WordWarningMsg='Added "' || ThisWord || '" to "' || SpellingAddFile || '"'
  1639. SpellingAddOccurs.BadIndex=SpellingAddOccurs.BadIndex+1
  1640. end
  1641. end
  1642. else
  1643. do
  1644. DuplicatedIdValue=''
  1645. if SpellingAddFile<> '' & SpellingPrompts <> 'N' then
  1646. do
  1647. if SpellingPrompts='OK' then
  1648. UserResp='Y'
  1649. else
  1650. do
  1651. do until UserResp='Y' | UserResp = 'N' | UserResp = 'Q' | UserResp = 'A'
  1652. call charout,ThisWord|| ' <- OK (Yes/yes All/No/Quit asking)?'
  1653. UserResp=translate(left(linein(),1))
  1654. end
  1655. end
  1656. if UserResp='A' then
  1657. do
  1658. SpellingPrompts='OK'
  1659. UserResp='Y'
  1660. end
  1661. if UserResp='Y' then
  1662. do
  1663. SpellingAddCount=SpellingAddCount+1
  1664. DuplicatedIdValue=SpellingAddCount
  1665. SpellingAddWord.SpellingAddCount=ThisWord
  1666. SpellingAddOccurs.SpellingAddCount=1
  1667. if SpellingPrompts='OK' then
  1668. do
  1669. WordWarningId='SPL1'
  1670. WordWarningMsg='Added "' || ThisWord || '" to "' || SpellingAddFile || '"'
  1671. end
  1672. end
  1673. else
  1674. do
  1675. if UserResp='Q' then
  1676. SpellingPrompts='N'
  1677. end
  1678. end
  1679. BadlySpellWordCount=BadlySpellWordCount+1
  1680. call _valueS DuplicatedId,DuplicatedIdValue
  1681. end
  1682. end
  1683. if SpellShowEachError='Y' then
  1684. ShowThisError='Y'
  1685. else
  1686. do
  1687. DuplicatedId='?BADWORDEB.?' ||ThisWordC2X
  1688. if symbol(DuplicatedId)='VAR' then
  1689. ShowThisError='N'
  1690. else
  1691. do
  1692. ShowThisError='Y'
  1693. call _valueS DuplicatedId, ''
  1694. end
  1695. end
  1696. if ShowThisError='Y' then
  1697. do
  1698. if WordWarningId='' then
  1699. do
  1700. WordWarningId='SPL1'
  1701. WordWarningMsg='Spelling? : ' ||ThisWord
  1702. end
  1703. call OutputWarningToScreen WordWarningId,WordWarningMsg
  1704. end
  1705. end
  1706. end
  1707. end
  1708. return
  1709.  
  1710. OutputAnySpellingAdditions:
  1711. if SpellingAddCount=0 then
  1712. return
  1713. call DebugLine_SPELLING 'Adding spelling words to file "' || SpellingAddFile || '"'
  1714. call DebugIncrement 1
  1715. if VariableExists("PPWIZARD_DONT_SORT_ADD_WORDS") = 'N' then
  1716. do
  1717. call DebugLine_SPELLING 'Sorting ' || SpellingAddCount || ' "bad" word(s) by number of occurences!'
  1718. SpellingAddWord.0=SpellingAddCount
  1719. SpellingAddOccurs.0=SpellingAddCount
  1720. SrtM=1
  1721. SrtCount=SpellingAddOccurs.0
  1722. do while(9*SrtM+4)<SrtCount
  1723. SrtM=SrtM*3+1
  1724. end
  1725. do while SrtM>0
  1726. SrtK=SrtCount-SrtM
  1727. do SrtJ=1 to SrtK
  1728. SrtIndex1=SrtJ
  1729. do while SrtIndex1>0
  1730. SrtIndex2=SrtIndex1+SrtM
  1731. SrtGreater=SpellingAddOccurs.SrtIndex1>SpellingAddOccurs.SrtIndex2
  1732. if SrtGreater then
  1733. do
  1734. SrtTemp=SpellingAddOccurs.SrtIndex1;SpellingAddOccurs.SrtIndex1=SpellingAddOccurs.SrtIndex2;SpellingAddOccurs.SrtIndex2=SrtTemp;SrtTemp=SpellingAddWord.SrtIndex1;SpellingAddWord.SrtIndex1=SpellingAddWord.SrtIndex2;SpellingAddWord.SrtIndex2=SrtTemp
  1735. end
  1736. else
  1737. leave
  1738. SrtIndex1=SrtIndex1-SrtM
  1739. end
  1740. end
  1741. SrtM=SrtM%3
  1742. end
  1743. call ReverseArray "SpellingAddWord"
  1744. call ReverseArray "SpellingAddOccurs"
  1745. end
  1746. call Stream SpellingAddFile, 'c', 'Close'
  1747. if SafeQueryExists(SpellingAddFile)<> "" then
  1748. do
  1749. call DebugLine_SPELLING 'Deleting existing "' || SpellingAddFile || '"'
  1750. call MustDeleteFile SpellingAddFile
  1751. end
  1752. call DebugLine_SPELLING 'Writing words to file'
  1753. call DebugIncrement 1
  1754. do WordIndex=1 to SpellingAddCount
  1755. call lineout SpellingAddFile,SpellingAddWord.WordIndex
  1756. if OptionDebugOn='Y' then
  1757. call DebugLine_SPELLING 'The word "' || SpellingAddWord.WordIndex || '" occured ' || SpellingAddOccurs.WordIndex || ' time(s).'
  1758. end
  1759. call DebugIncrement-1
  1760. call DieIfIoErrorOccurred SpellingAddFile
  1761. call Stream SpellingAddFile, 'c', 'Close'
  1762. call OutputInformationToScreen AddCommasToDecimalNumber(SpellingAddCount)|| ' word(s) added to "' || SpellingAddFile || '"'
  1763. call DebugIncrement-1
  1764. return
  1765.  
  1766. SPELLING_9:
  1767. OptionDebugOn='N'
  1768. if RexWhich='REGINA' then
  1769. OptionDebugTime='L'
  1770. else
  1771. OptionDebugTime='S'
  1772. call DebugIncrementInit
  1773. signal Debug_10
  1774.  
  1775. Debug:call TRACE "OFF"
  1776.  
  1777. DebugLine:
  1778. if OptionDebugOn='N' then
  1779. return
  1780.  
  1781. DebugLine2:
  1782. call Line1 _DebugPrefix()|| '         >' ||translate(arg(1),DebugNewline,MarksNewLine)
  1783. return
  1784.  
  1785. _DebugPrefix:
  1786. if OptionDebugTime='N' then
  1787. return(copies("  ",IncludeLevel+DebugIndent))
  1788. else
  1789. do
  1790. if OptionDebugTime='L' then
  1791. return( '[' || left(time('L'),11)               || ']' || copies("  ",IncludeLevel+DebugIndent))
  1792. else
  1793. return( '[' || (time('S') || substr(time('L'), 9, 3)) - PpwStartSec || ']' || copies("  ",IncludeLevel+DebugIndent))
  1794. end
  1795.  
  1796. YorN2OnorOff:
  1797. if arg(1)='Y' then
  1798. return('ON')
  1799. else
  1800. return('OFF')
  1801.  
  1802. DebugShowCurrentLineWithLineNumber:
  1803. if OptionDebugOn='Y' then
  1804. do
  1805. FmtLineNum=IncludeLineNumber
  1806. if length(FmtLineNum)<4 then
  1807. FmtLineNum=right(FmtLineNum,4, '0')
  1808. if arg(2)<> '' then
  1809. FmtLineNum=copies(arg(2),length(FmtLineNum))
  1810. if IncludeMemHandle='' then
  1811. FmtLineNum='{' || DebugCurrentFileNumber || '}' ||FmtLineNum
  1812. else
  1813. FmtLineNum='[' || DebugCurrentFileNumber || ']' ||FmtLineNum
  1814. select
  1815. when AsIsModeOn='Y' & AutoTagOn = 'Y' then
  1816. DebugSym='> '
  1817. when AsIsModeOn='Y' then
  1818. DebugSym='} '
  1819. when AutoTagOn='Y' then
  1820. DebugSym=') '
  1821. otherwise
  1822. DebugSym=': '
  1823. end
  1824. if arg(1)=='' then
  1825. call Line1 _DebugPrefix()||FmtLineNum||DebugSym
  1826. else
  1827. call Line1 _DebugPrefix()||FmtLineNum||DebugSym||DebugRightArrow||translate(arg(1),DebugNewline,MarksNewLine)||DebugLeftArrow
  1828. end
  1829. return
  1830.  
  1831. DebugShowLineDropped:
  1832. if OptionDebugOn='Y' then
  1833. do
  1834. call Line1 _DebugPrefix()||left(arg(1),length(FmtLineNum), ' ') || '-'
  1835. end
  1836. return
  1837.  
  1838. DebugGetEnv:
  1839. if OptionDebugOn='N' then
  1840. return(GetEnv(arg(1)))
  1841. else
  1842. do
  1843. dgenv=GetEnv(arg(1))
  1844. call DebugLine 'EnvVar: GetEnv("' || arg(1) || '" = ' ||DebugRightArrow||dgenv||DebugLeftArrow
  1845. return(dgenv)
  1846. end
  1847.  
  1848. DebugSysSearchPath:
  1849. if OptionDebugOn='Y' then
  1850. call DebugLine 'EnvVar: Searching "' || arg(1) || '" for "' || arg(2) || '"'
  1851. return(_SysSearchPath(arg(1),arg(2)))
  1852.  
  1853. DebugWarning:
  1854. if OptionDebugOn='N' then
  1855. return
  1856. DbgWarning='!!! ' || arg(1) || ' !!!'
  1857. DbgLine=copies('!',length(DbgWarning))
  1858. call DebugLine2 ''
  1859. call DebugLine2 left('!!!![ DEBUG WARNING ]', length(DbgWarning), '!')
  1860. call DebugLine2 DbgWarning
  1861. call DebugLine2 left('', length(DbgWarning), '!')
  1862. call DebugLine2 ''
  1863. return
  1864.  
  1865. DebugOutputVariableInfo:
  1866. if OptionDebugOn='Y' then
  1867. call DebugLine2 '? ' ||translate(arg(1),DebugNewline,MarksNewLine)
  1868. return
  1869.  
  1870. DebugIndent:call TRACE "OFF"
  1871.  
  1872. DebugIncrement:
  1873. DebugIndent=DebugIndent+(arg(1)*2)
  1874. if DebugIndent<0 then
  1875. DebugIndent=0
  1876. return
  1877.  
  1878. DebugIncrementInit:
  1879. DebugIndent=0
  1880. return
  1881.  
  1882. DebugStateChanged:
  1883. if OptionDebugOn='Y' then
  1884. do
  1885. call DisplayCopyright
  1886. if DebugOnStuffOutputted='N' then
  1887. do
  1888. SourceTime=stream(PpWizardPgmName, 'c', 'query datetime')
  1889. call DebugLine 'Debug Header'
  1890. call DebugLine '~~~~~~~~~~~~'
  1891. call DebugIncrement 1
  1892. call DebugLine 'Program : "' || PpWizardPgmName    || '" (' || SourceTime || ')'
  1893. call DebugLine 'OptionE : "' || OptionsEnvironment || '"'
  1894. call DebugLine 'OptionC : "' || OptionsCmdLine     || '"'
  1895. call DebugLine 'Src Type: "' || OptionCodeType     || '"'
  1896. call DebugLine 'OpSystem: "' || PpWizardOpSys      || '"'
  1897. call DebugLine 'Rexx Ver: "' || RexVersionInfo     || '"'
  1898. call DebugLine 'Mode    : "' || RexWhich           || '"'
  1899. if RexWhich='REGINA' then
  1900. call DebugLine 'uname() : "' || uname()        || '"'
  1901. if OptionFilterIn<> '' then
  1902. call DebugLine 'Filter I: ' || FunctionFilterIn || '(' || InputInterfaceVer || ')'
  1903. if OptionFilterOut<> '' then
  1904. call DebugLine 'Filter O: "' || OptionFilterOut   || '" (interface version ' || OutputInterfaceVer || ')'
  1905. call Line1 ''
  1906. DebugOnStuffOutputted='Y'
  1907. call DebugIncrement-1
  1908. end
  1909. end
  1910. call SetEnv "PPWIZARD_DEBUG",OptionDebugOn
  1911. return
  1912.  
  1913. ProcessHashDebug:
  1914. if DebugSwitchUsed='Y' then
  1915. call DebugLine 'Command ignored as "/debug" used'
  1916. else
  1917. do
  1918. ReturnRc=SetOnorOffVariable(arg(1), 'OptionDebugOn')
  1919. call DebugStateChanged
  1920. end
  1921. return(0)
  1922.  
  1923. DebugShowAsMuchEnvironmentDetailAsPossible:
  1924. if OptionDebugOn='N' then
  1925. return
  1926. call DebugLine 'Dumping Environmental Info'
  1927. TmpSetFile=RexGetTmpFileName()
  1928. RedirBit=RedirectStdOutAndErr2(TmpSetFile)
  1929. call _EnvAddCmd 'set'
  1930. if RexSystemOpSys<> "UNIX" then
  1931. do
  1932. select
  1933. when RexSystemOpSys="OS/2"  then VerCmd = 'VER /R'
  1934. otherwise VerCmd='VER'
  1935. end
  1936. call _EnvAddCmd VerCmd
  1937. end
  1938. if RexSystemOpSys<> "UNIX" then
  1939. call _SysFileDelete TmpSetFile
  1940. return
  1941.  
  1942. _EnvAddCmd:
  1943. call AddressCmd arg(1)||RedirBit,TmpSetFile
  1944. if RexSystemOpSys="UNIX" then
  1945. call _SysFileDelete TmpSetFile
  1946. return
  1947.  
  1948. Debug_10:
  1949. AllBitsOff='000000'x
  1950. AllBitsOn='FFFFFF'x
  1951. UserBitsOn='000003'x
  1952. AllBitsOnExceptUser=bitxor(AllBitsOn,UserBitsOn)
  1953. DebugLevel=AllBitsOnExceptUser
  1954. DebugLevelCnt=0
  1955. SeeLevelAll=_SaveDebugLevel("ALL",           "FFFFFF")
  1956. DummyUser1=_SaveDebugLevel("USER1",         "000001")
  1957. DummyUser2=_SaveDebugLevel("USER2",         "000002")
  1958. SeeLevelConditional=_SaveDebugLevel("CONDITIONAL",   "000004")
  1959. SeeFoundVar=_SaveDebugLevel("FOUNDVAR",      "000008")
  1960. SeeFoundVarParms=_SaveDebugLevel("FOUNDVARPARMS", "000010")
  1961. SeeFoundStdVar=_SaveDebugLevel("FOUNDSTDVAR",   "000020")
  1962. SeeAfterReplace=_SaveDebugLevel("AFTERREPLACE",  "000040")
  1963. SeeOptions=_SaveDebugLevel("OPTIONS",       "000080")
  1964. SeeOpSys=_SaveDebugLevel("OPSYS",         "000100")
  1965. SeeDefining=_SaveDebugLevel("DEFINING",      "000200")
  1966. SeeDefaultOrMacroValue=_SaveDebugLevel("MACROVALORDEF", "000400")
  1967. SeeAsIs=_SaveDebugLevel("ASIS",          "000800")
  1968. SeeAutoTag=_SaveDebugLevel("AUTOTAG",       "001000")
  1969. SeeRexxVar=_SaveDebugLevel("REXXVAR",       "002000")
  1970. SeeRexxTrace=_SaveDebugLevel("REXXTRACE",     "004000")
  1971. SeeInterpret=_SaveDebugLevel("INTERPRET",     "008000")
  1972. SeeEvaluate=_SaveDebugLevel("EVALUATE",      "010000")
  1973. SeeImport=_SaveDebugLevel("IMPORT",        "020000")
  1974. SeeSpelling=_SaveDebugLevel("SPELLING",      "040000")
  1975. SeeQuoting=_SaveDebugLevel("QUOTING",       "080000")
  1976. SeeImport=bitand(SeeImport,SeeDefaultOrMacroValue)
  1977. signal DebugOpt_11
  1978.  
  1979. IsDebugOn:call TRACE "OFF"
  1980. ido1=arg(1)
  1981. if ido1='' then
  1982. return(OptionDebugOn)
  1983. else
  1984. do
  1985. if OptionDebugOn='N' then
  1986. return(0)
  1987. else
  1988. do
  1989. idoUBits=bitand(DebugLevel,UserBitsOn)
  1990. idoUBits=bitand(idoUBits,x2c(right(ido1,6, '0')))
  1991. return(c2d(idoUBits))
  1992. end
  1993. end
  1994.  
  1995. DebugAddressCmdBefore:
  1996. if OptionDebugOn='Y' then
  1997. do
  1998. if bitand(DebugLevel,SeeOpSys)==SeeOpSys then
  1999. do
  2000. call DebugIncrement 1
  2001. call DebugLine 'Executing: ' ||arg(1)
  2002. call DebugIncrement-1
  2003. end
  2004. end
  2005. return
  2006.  
  2007. DebugAddressCmdOutput:
  2008. if OptionDebugOn='Y' then
  2009. do
  2010. if bitand(DebugLevel,SeeOpSys)==SeeOpSys then
  2011. do
  2012. call DebugIncrement 2
  2013. DbgLineNumber=arg(2)
  2014. if datatype(DbgLineNumber, 'W')=0 then
  2015. call DebugLine '> ' ||arg(1)
  2016. else
  2017. do
  2018. if DbgLineNumber<999 then
  2019. DbgLineNumber=right(DbgLineNumber,3, '0')
  2020. call DebugLine '> ' || DbgLineNumber || ': ' ||arg(1)
  2021. end
  2022. call DebugIncrement-2
  2023. end
  2024. end
  2025. return
  2026.  
  2027. DebugAddressCmdAfter:
  2028. if OptionDebugOn='Y' then
  2029. do
  2030. if bitand(DebugLevel,SeeOpSys)==SeeOpSys then
  2031. do
  2032. call DebugIncrement 2
  2033. call DebugLine '  Rc = ' ||arg(1)
  2034. call DebugIncrement-2
  2035. end
  2036. end
  2037. return
  2038.  
  2039. DebugOutputAfterReplacement:
  2040. if OptionDebugOn='N' then
  2041. return
  2042. if bitand(DebugLevel,SeeAfterReplace)==SeeAfterReplace then
  2043. call DebugLine2 arg(2)||DebugRightArrow||translate(arg(1),DebugNewline,MarksNewLine)||DebugLeftArrow
  2044. return
  2045.  
  2046. DebugLine_DEFINING:
  2047. if bitand(DebugLevel,SeeDefining)==SeeDefining then
  2048. call DebugLine arg(1)
  2049. return
  2050.  
  2051. DebugLine_ASIS:
  2052. if bitand(DebugLevel,SeeAsIs)==SeeAsIs then
  2053. call DebugLine arg(1)
  2054. return
  2055.  
  2056. DebugLine_REXXVAR:
  2057. if bitand(DebugLevel,SeeRexxVar)==SeeRexxVar then
  2058. call DebugLine arg(1)
  2059. return
  2060.  
  2061. DebugLine_INTERPRET:
  2062. if bitand(DebugLevel,SeeInterpret)==SeeInterpret then
  2063. call DebugLine arg(1)
  2064. return
  2065.  
  2066. DebugLine_EVALUATE:
  2067. if bitand(DebugLevel,SeeEvaluate)==SeeEvaluate then
  2068. call DebugLine arg(1)
  2069. return
  2070.  
  2071. DebugLine_SPELLING:
  2072. if bitand(DebugLevel,SeeSpelling)==SeeSpelling then
  2073. call DebugLine arg(1)
  2074. return
  2075.  
  2076. DebugLine_QUOTING:
  2077. if bitand(DebugLevel,SeeQuoting)==SeeQuoting then
  2078. call DebugLine arg(1)
  2079. return
  2080.  
  2081. DebugLine_IMPORT:
  2082. if bitand(DebugLevel,SeeImport)==SeeImport then
  2083. call DebugLine arg(1)
  2084. return
  2085.  
  2086. DebugLine_AUTOTAG:
  2087. if bitand(DebugLevel,SeeAutoTag)==SeeAutoTag then
  2088. call DebugLine arg(1)
  2089. return
  2090.  
  2091. DebugLine_MACROVALORDEF:
  2092. if bitand(DebugLevel,SeeDefaultOrMacroValue)==SeeDefaultOrMacroValue then
  2093. call DebugLine arg(1)
  2094. return
  2095.  
  2096. DebugLine_OPTIONS:
  2097. if bitand(DebugLevel,SeeOptions)==SeeOptions then
  2098. call DebugLine arg(1)
  2099. return
  2100.  
  2101. DebugLine_CONDITIONAL:
  2102. if bitand(DebugLevel,SeeLevelConditional)==SeeLevelConditional then
  2103. call DebugLine arg(1)
  2104. return
  2105.  
  2106. DebugOutputVariableInfo_FOUNDSTDVAR:
  2107. if bitand(DebugLevel,SeeFoundStdVar)==SeeFoundStdVar then
  2108. call DebugOutputVariableInfo arg(1)
  2109. return
  2110.  
  2111. DebugOutputVariableInfo_FOUNDVAR:
  2112. if bitand(DebugLevel,SeeFoundVar)==SeeFoundVar then
  2113. call DebugOutputVariableInfo arg(1)
  2114. return
  2115.  
  2116. DebugOutputVariableInfo_FOUNDVARPARMS:
  2117. if bitand(DebugLevel,SeeFoundVarParms)==SeeFoundVarParms then
  2118. call DebugOutputVariableInfo arg(1)
  2119. return
  2120.  
  2121. DebugOutputVariableInfo_FOUNDSTDVAR:
  2122. if bitand(DebugLevel,SeeFoundVar)==SeeFoundVar then
  2123. call DebugOutputVariableInfo arg(1)
  2124. return
  2125.  
  2126. _SaveDebugLevel:
  2127. DebugLevelCnt=DebugLevelCnt+1
  2128. DebugLevelNme.DebugLevelCnt=translate(arg(1))
  2129. DebugLevelVal.DebugLevelCnt=arg(2)
  2130. return(x2c(arg(2)))
  2131.  
  2132. GetDebugLevel:
  2133. WantedName=translate(arg(1))
  2134. do DbgIndex=1 to DebugLevelCnt
  2135. if WantedName=DebugLevelNme.DbgIndex then
  2136. return(DebugLevelVal.DbgIndex)
  2137. end
  2138. return('')
  2139.  
  2140. _WorkOutDebugLevelText:
  2141. DbgLvlTxt="ALL"
  2142. do DbgIndex=1 to DebugLevelCnt
  2143. if bitand(DebugLevel,x2c(DebugLevelVal.DbgIndex))=AllBitsOff then
  2144. DbgLvlTxt=DbgLvlTxt|| ',-' ||DebugLevelNme.DbgIndex
  2145. end
  2146. return(DbgLvlTxt)
  2147.  
  2148. DEBUGLEVEL_DEBUG:
  2149. if OptionDebugOn='Y' then
  2150. call OptionDebugShow 'DEBUGLEVEL', 'Debug level (when on) is ' ||_WorkOutDebugLevelText()
  2151. return
  2152.  
  2153. DEBUGLEVEL_GET:
  2154. call DEBUGLEVEL_DEBUG
  2155. return(_WorkOutDebugLevelText())
  2156.  
  2157. DEBUGLEVEL_SET:
  2158. DebugCmdsIn=arg(1)
  2159. DebugCmds=DebugCmdsIn
  2160. do while DebugCmds<> ''
  2161. parse var DebugCmds OneDebugOpt','DebugCmds
  2162. OptionAction=left(OneDebugOpt,1)
  2163. if OptionAction='+' then
  2164. OneDebugOpt=substr(OneDebugOpt,2)
  2165. else
  2166. do
  2167. if OptionAction='-' then
  2168. OneDebugOpt=substr(OneDebugOpt,2)
  2169. else
  2170. OptionAction='+'
  2171. end
  2172. OptionBinary=x2c(GetDebugLevel(OneDebugOpt))
  2173. if OptionBinary='' then
  2174. CryAndDie('Invalid debug option of "' || OneDebugOpt || '"')
  2175. if OptionAction='+' then
  2176. DebugLevel=bitor(DebugLevel,OptionBinary)
  2177. else
  2178. DebugLevel=bitxor(DebugLevel,OptionBinary)
  2179. end
  2180. if ProcessedCmdLine='N' then
  2181. do
  2182. call OptionDebugShow 'DEBUGLEVEL', 'Setting default value of debug level to "' || _WorkOutDebugLevelText() || '"'
  2183. Default4_DebugLevel=DebugLevel
  2184. return(0)
  2185. end
  2186. if DebugCmdsIn='' then
  2187. DebugLevel=Default4_DebugLevel
  2188. call DEBUGLEVEL_DEBUG
  2189. return
  2190.  
  2191. DebugOpt_11:
  2192. OptionCgiModeOn='N'
  2193. CgiOutputFile=''
  2194. CgiFatalError='N'
  2195. signal CGI_12
  2196.  
  2197. Line1:
  2198. if OptionCgiModeOn='N' then
  2199. say arg(1)
  2200. else
  2201. do
  2202. if CgiOutputFile<> '' then
  2203. call lineout CgiOutputFile,arg(1)
  2204. if CgiFatalError='Y' then
  2205. say _MustSeeAsIsInHtmlViewer(arg(1))
  2206. end
  2207. return
  2208.  
  2209. Char1:
  2210. if OptionCgiModeOn='N' then
  2211. call charout,arg(1)
  2212. else
  2213. do
  2214. if CgiOutputFile<> '' then
  2215. call charout CgiOutputFile,arg(1)
  2216. if CgiFatalError='Y' then
  2217. call charout,_MustSeeAsIsInHtmlViewer(arg(1))
  2218. end
  2219. return
  2220.  
  2221. DieIfCgiModeOn:
  2222. if OptionCgiModeOn='Y' then
  2223. call CryAndDie "This feature is not allowed in CGI mode"
  2224. return
  2225.  
  2226. TurnCgiModeOn:
  2227. OptionCgiModeOn='Y'
  2228. CgiOutputFile=ThisCmdOptions
  2229. if pos('?',CgiOutputFile)<>0 then
  2230. do
  2231. PartSecond=time('Long')
  2232. parse var PartSecond .'.'PartSecond
  2233. RandomBit=right(time('Seconds'), 5, '0')
  2234. RandomBit=RandomBit||left(strip(PartSecond),3)
  2235. RandomBit=RandomBit|| '.' || right( date('Days'), 3, '0')
  2236. CgiOutputFile=ReplaceString(CgiOutputFile, '?',RandomBit)
  2237. end
  2238. if CgiOutputFile<> '' then
  2239. do
  2240. if stream(CgiOutputFile, 'c', 'query exists') <> '' then
  2241. do
  2242. call Stream CgiOutputFile, 'c', 'Close'
  2243. DeleteRc=_SysFileDelete(CgiOutputFile)
  2244. if DeleteRc<>0 then
  2245. call DebugLine 'Could not delete "' || CgiOutputFile || '" (Rc = ' || DeleteRc || ')'
  2246. end
  2247. end
  2248. call RemoveColorCodes
  2249. call RemoveBeepCode
  2250. return
  2251.  
  2252. CloseCgiFileIfOpen:
  2253. if CgiOutputFile<> '' then
  2254. CloseRc=stream(CgiOutputFile, 'c', 'close')
  2255. return
  2256.  
  2257. CgiStartFatalError:
  2258. if OptionCgiModeOn='N' then
  2259. return
  2260. CgiDoVar='CGI_FATAL_MY_MESSAGE_ONLY'
  2261. if VariableExists(CgiDoVar)='Y' then
  2262. do
  2263. CgiErrorCodes=GetDefineValueOrUseDefault(CgiDoVar, '')
  2264. if CgiErrorCodes='' then
  2265. call DebugLine 'We do not want any error indication in user output'
  2266. else
  2267. call DebugLine 'Displaying user message only (no error details)'
  2268. say CgiErrorCodes
  2269. return
  2270. end
  2271. call DebugLine 'Will show user error output as "' || CgiDoVar || '" was not defined'
  2272. CgiErrDefault='<P><HR><FONT SIZE=+1 COLOR=RED><CENTER><H1>FATAL ERROR</H1></CENTER><P><PRE>'
  2273. CgiErrorCodes=GetDefineValueOrUseDefault("CGI_FATAL_HEADER",CgiErrDefault)
  2274. say CgiErrorCodes
  2275. CgiErrDefault='</PRE><HR></FONT>'
  2276. CgiErrorCodes=GetDefineValueOrUseDefault("CGI_FATAL_TRAILER",CgiErrDefault)
  2277. CgiFatalError='Y'
  2278. return
  2279.  
  2280. CgiEndFatalError:
  2281. if OptionCgiModeOn='N' then
  2282. return
  2283. if CgiFatalError='N' then
  2284. return
  2285. say CgiErrorCodes
  2286. CgiFatalError='N'
  2287. return
  2288.  
  2289. _MustSeeAsIsInHtmlViewer:
  2290. BrowserOk=ReplaceString(arg(1), "<",          "<")
  2291. BrowserOk=ReplaceString(BrowserOk, ">",          ">")
  2292. return(BrowserOk)
  2293.  
  2294. CGI_12:
  2295. signal EndLineCrLfXH
  2296.  
  2297. CrLfClose:
  2298. _CrlfBuffer=''
  2299. return(stream(arg(1), 'c', 'close'))
  2300.  
  2301. CrLfOpen:
  2302. call CrLfClose arg(1)
  2303. _CrLfEOL=d2c(13)||d2c(10)
  2304. _CrLfEOLLng=2
  2305. if arg(2)<> '' then
  2306. do
  2307. if chars(arg(1))<>0 then
  2308. do
  2309. _CrLf2Read=arg(2)
  2310. if _CrLf2Read<5000 then
  2311. _CrLf2Read=5000
  2312. _CrlfBuffer=charin(arg(1),,_CrLf2Read)
  2313. if pos(_CrLfEOL,_CrlfBuffer)=0 then
  2314. do
  2315. if pos(d2c(10),_CrlfBuffer)<>0 then
  2316. do
  2317. _CrLfEOL=d2c(10)
  2318. _CrLfEOLLng=1
  2319. end
  2320. end
  2321. end
  2322. end
  2323. return(0)
  2324.  
  2325. CrLfLines:
  2326. if _CrlfBuffer<> '' then
  2327. return(1)
  2328. else
  2329. do
  2330. if chars(arg(1))=0 then
  2331. return(0)
  2332. else
  2333. return(1)
  2334. end
  2335.  
  2336. CrLfLineIn:
  2337. _CrLfPos=pos(_CrLfEOL,_CrlfBuffer)
  2338. do while _CrLfPos=0
  2339. if chars(arg(1))=0 then
  2340. leave
  2341. _CrlfBuffer=_CrlfBuffer||charin(arg(1),,5000)
  2342. _CrLfPos=pos(_CrLfEOL,_CrlfBuffer)
  2343. end
  2344. if _CrLfPos=0 then
  2345. do
  2346. _CrLfReturn=_CrlfBuffer
  2347. _CrlfBuffer=''
  2348. end
  2349. else
  2350. do
  2351. _CrLfReturn=left(_CrlfBuffer,_CrLfPos-1)
  2352. _CrlfBuffer=substr(_CrlfBuffer,_CrLfPos+_CrLfEOLLng)
  2353. end
  2354. return(_CrLfReturn)
  2355.  
  2356. EndLineCrLfXH:
  2357. ReplaceCount=0
  2358. CiSelfRef="{*}"
  2359. signal EndREPLSTR
  2360.  
  2361. ReplaceString:call TRACE "OFF"
  2362. parse arg rs?TheString,rs?ChangeFrom
  2363. rs?FoundPosn=pos(rs?ChangeFrom,rs?TheString)
  2364. if rs?FoundPosn=0 then
  2365. return(rs?TheString)
  2366. rs?ChangeTo=arg(3)
  2367. rs?ChangeFromLength=length(rs?ChangeFrom)
  2368. rs?LeftPart=''
  2369. do until rs?FoundPosn=0
  2370. rs?LeftPart=rs?LeftPart||left(rs?TheString,rs?FoundPosn-1)||rs?ChangeTo
  2371. rs?TheString=substr(rs?TheString,rs?FoundPosn+rs?ChangeFromLength)
  2372. ReplaceCount=ReplaceCount+1
  2373. rs?FoundPosn=pos(rs?ChangeFrom,rs?TheString)
  2374. end
  2375. return(rs?LeftPart||rs?TheString)
  2376.  
  2377. ReplaceStringCi:call TRACE "OFF"
  2378. rsi?TheString=arg(1)
  2379. rsi?TheStringU=translate(rsi?TheString)
  2380. rsi?ChangeFrom=translate(arg(2))
  2381. rsi?FoundPosn=pos(rsi?ChangeFrom,rsi?TheStringU)
  2382. if rsi?FoundPosn=0 then
  2383. return(rsi?TheString)
  2384. rsi?ChangeTo=arg(3)
  2385. if pos(CiSelfRef,rsi?ChangeTo)=0 then
  2386. rsi?Ref='N'
  2387. else
  2388. rsi?Ref='Y'
  2389. rsi?ChangeFromLength=length(rsi?ChangeFrom)
  2390. rsi?LeftPart=''
  2391. do until rsi?FoundPosn=0
  2392. if rsi?Ref='N' then
  2393. rsi?SubWith=rsi?ChangeTo
  2394. else
  2395. do
  2396. rsi?SaveCount=ReplaceCount
  2397. rsi?SubWith=ReplaceString(rsi?ChangeTo,CiSelfRef,substr(rsi?TheString,rsi?FoundPosn,rsi?ChangeFromLength))
  2398. ReplaceCount=rsi?SaveCount
  2399. end
  2400. rsi?LeftPart=rsi?LeftPart||left(rsi?TheString,rsi?FoundPosn-1)||rsi?SubWith
  2401. rsi?TheString=substr(rsi?TheString,rsi?FoundPosn+rsi?ChangeFromLength)
  2402. rsi?TheStringU=substr(rsi?TheStringU,rsi?FoundPosn+rsi?ChangeFromLength)
  2403. ReplaceCount=ReplaceCount+1
  2404. rsi?FoundPosn=pos(rsi?ChangeFrom,rsi?TheStringU)
  2405. end
  2406. return(rsi?LeftPart||rsi?TheString)
  2407.  
  2408. EndREPLSTR:
  2409. ReplaceCount=0
  2410. signal EndBULK_C2S
  2411.  
  2412. BulkChar2String:call TRACE "OFF"
  2413. parse arg brRightBit,brArray
  2414. brModifyThese=value(brArray)
  2415. brPos=verify(brRightBit,brModifyThese, 'M')
  2416. if brPos=0 then
  2417. return(brRightBit)
  2418. brLeftBit=''
  2419. brArray=brArray|| '.'
  2420. do until brPos=0
  2421. brLeftBit=brLeftBit||left(brRightBit,brPos-1)||value(brArray||pos(substr(brRightBit,brPos,1),brModifyThese))
  2422. brRightBit=substr(brRightBit,brPos+1)
  2423. ReplaceCount=ReplaceCount+1
  2424. brPos=verify(brRightBit,brModifyThese, 'M')
  2425. end
  2426. return(brLeftBit||brRightBit)
  2427.  
  2428. BulkChangePrepare:call TRACE "OFF"
  2429. parse arg brArray,brChar,brString
  2430. if brChar=='' then
  2431. call value brArray, ''
  2432. else
  2433. do
  2434. brValue=value(brArray)||BrChar
  2435. call value brArray,brValue
  2436. call value brArray|| '.' ||length(brValue),brString
  2437. end
  2438. return
  2439.  
  2440. EndBULK_C2S:
  2441. signal PREFIX_13
  2442.  
  2443. HASHPREFIX_DEBUG:
  2444. if OptionDebugOn='Y' then
  2445. call OptionDebugShow 'HASHPREFIX', 'Hash prefix is now "' || HashPrefix || '" (' || HashPrefix || 'define etc)'
  2446. return
  2447.  
  2448. HASHPREFIX_GET:
  2449. call HASHPREFIX_DEBUG
  2450. return(HashPrefix)
  2451.  
  2452. HASHPREFIX_SET:
  2453. HashPrefix=arg(1)
  2454. if ProcessedCmdLine='N' then
  2455. do
  2456. call OptionDebugShow 'HASHPREFIX', 'Setting default value of hash Prefix to "' || HashPrefix || '"'
  2457. Default4_HashPrefix=HashPrefix
  2458. return(0)
  2459. end
  2460. if HashPrefix=='' then
  2461. HashPrefix=Default4_HashPrefix
  2462. AfterPrefix=translate(HashPrefix, '',LowerCase)
  2463. if AfterPrefix<>HashPrefix then
  2464. CryAndDie('A hash prefix should not include lower case characters!')
  2465. HashPrefixLng=length(HashPrefix)
  2466. call HASHPREFIX_DEBUG
  2467. CmdHashAsIs=HashPrefix|| 'ASIS'
  2468. CmdHashAutoTag=HashPrefix|| 'AUTOTAG'
  2469. CmdHashAutoTagClear=HashPrefix|| 'AUTOTAGCLEAR'
  2470. CmdHashAutoTagState=HashPrefix|| 'AUTOTAGSTATE'
  2471. CmdHashLoopBreak=HashPrefix|| 'BREAK'
  2472. CmdHashLoopContinue=HashPrefix|| 'CONTINUE'
  2473. CmdHashDebug=HashPrefix|| 'DEBUG'
  2474. CmdHashDefine=HashPrefix|| 'DEFINE'
  2475. CmdHashDefinePlus=HashPrefix|| 'DEFINE+'
  2476. CmdHashDefineRexx=HashPrefix|| 'DEFINEREXX'
  2477. CmdHashDefineRexxPlus=HashPrefix|| 'DEFINEREXX+'
  2478. CmdHashDependsOn=HashPrefix|| 'DEPENDSON'
  2479. CmdHashElseifL=HashPrefix|| 'ELSEIF'
  2480. CmdHashEndifL=HashPrefix|| 'ENDIF'
  2481. CmdHashEof=HashPrefix|| 'EOF'
  2482. CmdHashErrorL=HashPrefix|| 'ERROR'
  2483. CmdHashEvaluateL=HashPrefix|| 'EVALUATE'
  2484. CmdHashEvaluatePlusL=HashPrefix|| 'EVALUATE+'
  2485. CmdHashIf=HashPrefix|| 'IF'
  2486. CmdHashIfdef=HashPrefix|| 'IFDEF'
  2487. CmdHashIfndef=HashPrefix|| 'IFNDEF'
  2488. CmdHashImport=HashPrefix|| 'IMPORT'
  2489. CmdHashInclude=HashPrefix|| 'INCLUDE'
  2490. CmdHashInfo=HashPrefix|| 'INFO'
  2491. CmdHashMacroSpace=HashPrefix|| 'MACROSPACE'
  2492. CmdHashOneLine=HashPrefix|| 'ONELINE'
  2493. CmdHashOnExit=HashPrefix|| 'ONEXIT'
  2494. CmdHashOption=HashPrefix|| 'OPTION'
  2495. CmdHashOutput=HashPrefix|| 'OUTPUT'
  2496. CmdHashOutputHold=HashPrefix|| 'OUTPUTHOLD'
  2497. CmdHashRequire=HashPrefix|| 'REQUIRE'
  2498. CmdHashSystem=HashPrefix|| 'SYSTEM'
  2499. CmdHashTransform=HashPrefix|| 'TRANSFORM'
  2500. CmdHashRexxVar=HashPrefix|| 'REXXVAR'
  2501. CmdHashUndefL=HashPrefix|| 'UNDEF'
  2502. CmdHashWarningL=HashPrefix|| 'WARNING'
  2503. CmdHashLoopS=HashPrefix|| '{'
  2504. CmdHashLoopE=HashPrefix|| '}'
  2505. CmdHashEvaluateS=HashPrefix|| 'E'
  2506. CmdHashEvaluatePlusS=HashPrefix|| 'E+'
  2507. CmdHashUndefS=HashPrefix|| 'U'
  2508. CmdHashElseifS=HashPrefix|| 'ELSE'
  2509. CmdHashEndifS=HashPrefix|| 'END'
  2510. CmdHashErrorS=HashPrefix|| '!'
  2511. CmdHashWarningS=HashPrefix|| 'W'
  2512. return
  2513.  
  2514. PREFIX_13:
  2515. signal LineCmt_14
  2516.  
  2517. LINECOMMENT_DEBUG:
  2518. if OptionDebugOn='Y' then
  2519. do
  2520. if LineComment<>NullChar then
  2521. call OptionDebugShow 'LINECOMMENT', 'Lines starting with "' || LineComment || '" are comments ("' || InLineComment || '" for inline comments)'
  2522. else
  2523. call OptionDebugShow 'LINECOMMENT', 'Comment removal has been turned off'
  2524. end
  2525. return
  2526.  
  2527. LINECOMMENT_GET:
  2528. call LINECOMMENT_DEBUG
  2529. return(LineCommentSet2)
  2530.  
  2531. LINECOMMENT_SET:
  2532. LineComment=arg(1)
  2533. LineCommentSet2=LineComment
  2534. if ProcessedCmdLine='N' then
  2535. do
  2536. call OptionDebugShow 'LINECOMMENT', 'Setting default value of line comment to "' || LineComment || '"'
  2537. Default4_LineComment=LineComment
  2538. return(0)
  2539. end
  2540. if LineComment=='' then
  2541. LineComment=Default4_LineComment
  2542. if translate(LineComment)='NULL' then
  2543. LineComment=NullChar
  2544. else
  2545. do
  2546. if length(LineComment)<>1 then
  2547. CryAndDie('A comment char should be one character long')
  2548. end
  2549. InLineComment=LineComment||LineComment
  2550. call LINECOMMENT_DEBUG
  2551. return
  2552.  
  2553. LineCmt_14:
  2554. signal WhiteSpc_15
  2555.  
  2556. _WsFmt:
  2557. dbgExtra=''
  2558. do CharIndex=1 to length(ExtraWhiteSpace)
  2559. if CharIndex<>1 then
  2560. dbgExtra=dbgExtra|| ', '
  2561. dbgExtra=dbgExtra||c2x(substr(ExtraWhiteSpace,CharIndex,1))
  2562. end
  2563. return(dbgExtra)
  2564.  
  2565. WHITESPACE_DEBUG:
  2566. if OptionDebugOn='Y' then
  2567. do
  2568. if ExtraWhiteSpace=='' then
  2569. call OptionDebugShow 'WHITESPACE', 'No extra whitespace characters defined'
  2570. else
  2571. call OptionDebugShow 'WHITESPACE', 'Extra whitespace characters are hexadecimal ' ||_WsFmt()
  2572. end
  2573. return
  2574.  
  2575. WHITESPACE_GET:
  2576. call WHITESPACE_DEBUG
  2577. return(ExtraWhiteSpace)
  2578.  
  2579. WHITESPACE_SET:
  2580. ExtraWhiteSpace=arg(1)
  2581. if ProcessedCmdLine='N' then
  2582. do
  2583. Default4_ExtraWhiteSpace=ExtraWhiteSpace
  2584. if ExtraWhiteSpace=='' then
  2585. call OptionDebugShow 'WHITESPACE', 'Setting default to no extra whitespace'
  2586. else
  2587. call OptionDebugShow 'WHITESPACE', 'Setting default to extra whitespace characters are hexadecimal ' ||_WsFmt()
  2588. return(0)
  2589. end
  2590. if ExtraWhiteSpace=='NULL' then
  2591. ExtraWhiteSpace=Default4_ExtraWhiteSpace
  2592. call WHITESPACE_DEBUG
  2593. return
  2594.  
  2595. WhiteSpc_15:
  2596. signal LineCont_16
  2597.  
  2598. LINECONTINUATION_DEBUG:
  2599. if OptionDebugOn='Y' then
  2600. do
  2601. if LineContChar=NullChar then
  2602. call OptionDebugShow 'LINECONTINUATION', 'Line continuation handling has been turned off'
  2603. else
  2604. do
  2605. call OptionDebugShow 'LINECONTINUATION', 'The line continuation character is now "' || LineContChar || '"'
  2606. if symbol('CodexNewLine') = 'VAR' then
  2607. DbgText='"' CodexNewLine || '"'
  2608. else
  2609. DbgText="'X' code for newline"
  2610. call DebugIncrement 1
  2611. call DebugLine '"' || LineContAddNewLine   || '" = Join with    ' ||DbgText
  2612. call DebugLine '"' || LineContWithoutSpace || '" = Join without space'
  2613. call DebugLine '"' || LineContWithSpace    || '" = Join with    space'
  2614. call DebugLine '"' || LineContDefault      || '" = Join with    space'
  2615. call DebugIncrement-1
  2616. end
  2617. end
  2618. return
  2619.  
  2620. LINECONTINUATION_GET:
  2621. call LINECONTINUATION_DEBUG
  2622. return(LineContCharList)
  2623.  
  2624. LINECONTINUATION_SET:
  2625. LineContParm=arg(1)
  2626. LineContParmSet2=LineContParm
  2627. if ProcessedCmdLine='N' then
  2628. do
  2629. call OptionDebugShow 'LINECONTINUATION', 'Setting default value of line continuation chars to "' || LineContParm || '"'
  2630. Default4_LineContParm=LineContParm
  2631. LineContCharList=LineContParm
  2632. return(0)
  2633. end
  2634. if LineContParm=='' then
  2635. LineContParm=Default4_LineContParm
  2636. if translate(LineContParm)='NULL' then
  2637. LineContParm=NullChar
  2638. else
  2639. do
  2640. if length(LineContParm)<>1&length(LineContParm)<>5 then
  2641. CryAndDie('Invalid line continuation spec of "' || LineContParm || '"')
  2642. end
  2643. LineContCharList=overlay(LineContParm,LineContCharList)
  2644. LineContChar=substr(LineContCharList,1,1)
  2645. LineContAddNewLine=substr(LineContCharList,2,1)||LineContChar
  2646. LineContAddNewLineObs=d2c(25)||LineContChar
  2647. LineContWithoutSpace=substr(LineContCharList,3,1)||LineContChar
  2648. LineContWithSpace=substr(LineContCharList,4,1)||LineContChar
  2649. LineContDefault=substr(LineContCharList,5,1)||LineContChar
  2650. call LINECONTINUATION_DEBUG
  2651. return
  2652.  
  2653. LineCont_16:
  2654. AsIsCount=0
  2655. AsIsUsing=''
  2656. signal AsIs_17
  2657.  
  2658. AsIsPrepare:call TRACE "OFF"
  2659. AsIsParms=space(arg(1))
  2660. AsIsUsing=AsIsParms
  2661. AsIsCount=0
  2662. AsIsIndex=0
  2663. AsIsCollecting=''
  2664. call DebugLine_ASIS 'AsIsPrepare(): Cleared memory. Processing "' || AsIsUsing || '"'
  2665. call DebugIncrement 1
  2666. aiOptCnt=0
  2667. do while AsIsParms<> ''
  2668. call _SetUpAsIsTagging translate(GetQuotedText(AsIsParms, "AsIsParms"))
  2669. end
  2670. if AsIsCount<>0 then
  2671. do
  2672. if aiOptCnt=0 then
  2673. aiMsg='none'
  2674. else
  2675. do
  2676. if aiOptCnt=AsIsCount then
  2677. aiMsg='all'
  2678. else
  2679. aiMsg=aiOptCnt
  2680. end
  2681. call DebugLine_ASIS 'Have ' || AsIsCount || ' "as is" tags (' || aiMsg || ' optimised)'
  2682. end
  2683. call DebugIncrement-1
  2684. return(AsIsCount)
  2685.  
  2686. ExpandAsIsTags:
  2687. if AsIsModeOn='N' then
  2688. return(arg(1))
  2689.  
  2690. AsIs:call TRACE "OFF"
  2691. if AsIsCount=0 then
  2692. return(arg(1))
  2693. EaiString=arg(1)
  2694. AsIsCnt=ReplaceCount
  2695. do Tag=1 to AsIsIndex
  2696. if AsIsBef.Tag=='' then
  2697. EaiString=BulkChar2String(EaiString,AsIsAft.Tag)
  2698. else
  2699. do
  2700. if left(AsIsBef.Tag,2)<>SrTypePre then
  2701. EaiString=ReplaceString(EaiString,AsIsBef.Tag,AsIsAft.Tag)
  2702. else
  2703. do
  2704. select
  2705. when abbrev(AsIsBef.Tag,SrCaseIns)then
  2706. EaiString=ReplaceStringCI(EaiString,substr(AsIsBef.Tag,SrCaseIns_P),AsIsAft.Tag)
  2707. when abbrev(AsIsBef.Tag,SrFixed)then
  2708. EaiString=CompareReplaceFixed2(EaiString,substr(AsIsBef.Tag,SrFixed_P),AsIsAft.Tag)
  2709. otherwise
  2710. EaiString=ReplaceString(EaiString,AsIsBef.Tag,AsIsAft.Tag)
  2711. end
  2712. end
  2713. end
  2714. end
  2715. if OptionDebugOn='Y' then
  2716. do
  2717. if AsIsCnt<>ReplaceCount then
  2718. call DebugOutputAfterReplacement EaiString, 'ASIS'
  2719. end
  2720. return(EaiString)
  2721.  
  2722. ProcessAsIs:
  2723. HashCmdParms=PerformReplacementsInCmdsParameters(arg(1))
  2724. AsIsCmd=translate(GetQuotedText(HashCmdParms, "AsIsParms"))
  2725. if AsIsCmd='SETUP' then
  2726. do
  2727. AsIsPrepCache='?'
  2728. call SetupNamedAsIsStorage GetQuotedText(AsIsParms)
  2729. return(0)
  2730. end
  2731. call SetOnorOffVariable AsIsCmd, 'AsIsModeOn'
  2732. if AsIsModeOn='N' then
  2733. do
  2734. AsIsCount=0
  2735. if AsIsParms<> '' then
  2736. CryAndDie('Did not expect more than the "OFF" parameter')
  2737. call OptionsPop
  2738. end
  2739. else
  2740. do
  2741. call OptionsPush
  2742. call OptionOnOrOff_SET "KEEPINDENT",      "KeepIndent",      "ON"
  2743. call OptionOnOrOff_SET "LEAVEBLANKLINES", "LeaveBlankLines", "ON"
  2744. call LINECOMMENT_SET "NULL"
  2745. call LINECONTINUATION_SET "NULL"
  2746. call AsIsPrepare AsIsParms
  2747. end
  2748. if OptionDebugOn='Y' then
  2749. do
  2750. if AsIsCount=0 then
  2751. call DebugLine_ASIS 'AsIs mode is ' || YorN2OnorOff(AsIsModeOn) || '.  No tags prepared.'
  2752. else
  2753. call DebugLine_ASIS 'AsIs mode is ' || YorN2OnorOff(AsIsModeOn) || '.  Have ' || AsIsCount || ' tags from "' || AsIsUsing || '"'
  2754. end
  2755. return(0)
  2756.  
  2757. SetupNamedAsIsStorage:
  2758. AsIsNameU=translate(arg(1))
  2759. AsIsName='AI_' ||c2x(AsIsNameU)
  2760. AsIsAltCnt=arg(2)
  2761. AsIsCounter=0
  2762. if AsIsAltCnt='' then
  2763. do
  2764. TagFrom=AutoTagFirst
  2765. TagTo=AutoTagLast
  2766. end
  2767. else
  2768. do
  2769. TagFrom=1
  2770. TagTo=AsIsAltCnt
  2771. end
  2772. do Tag=TagFrom to TagTo
  2773. AsIsCounter=AsIsCounter+1
  2774. if AsIsAltCnt='' then
  2775. do
  2776. AsIsBef.AsIsCounter.AsIsName=AutoTagOnB.Tag
  2777. AsIsAft.AsIsCounter.AsIsName=AutoTagOnA.Tag
  2778. end
  2779. else
  2780. do
  2781. AsIsBef.AsIsCounter.AsIsName=ImportB.Tag
  2782. AsIsAft.AsIsCounter.AsIsName=ImportA.Tag
  2783. end
  2784. end
  2785. call _valueS AsIsName,AsIsCounter
  2786. if AsIsAltCnt='' then
  2787. call ClearAutoTags 'N'
  2788. call DebugLine_ASIS 'Captured ' || AsIsCounter || ' tags as "' || AsIsNameU || '"'
  2789. return
  2790.  
  2791. _SetUpAsIsTagging:
  2792. AsIsNameU=translate(arg(1))
  2793. AsIsName='AI_' ||c2x(AsIsNameU)
  2794. call DebugLine_ASIS 'Getting tags from storage named "' || AsIsNameU || '"'
  2795. call DebugIncrement 1
  2796. if symbol(AsIsName)<> 'VAR' then
  2797. CryAndDie('#AsIs "SETUP" has not been run for "' || AsIsNameU || '"')
  2798. AsIsCopyCount=_valueG(AsIsName)
  2799. do Index=1 to AsIsCopyCount
  2800. ThisBefore=AsIsBef.Index.AsIsName
  2801. ThisAfter=AsIsAft.Index.AsIsName
  2802. AsIsCount=AsIsCount+1
  2803. call DebugLine_ASIS 'AsIs #' || AsIsCount || ': From=' || DebugRightArrow || ThisBefore || DebugLeftArrow || ',  To=' ||DebugRightArrow||ThisAfter||DebugLeftArrow
  2804. if length(ThisBefore)<>1 then
  2805. do
  2806. AsIsCollecting=''
  2807. AsIsIndex=AsIsIndex+1
  2808. AsIsBef.AsIsIndex=ThisBefore
  2809. AsIsAft.AsIsIndex=ThisAfter
  2810. end
  2811. else
  2812. do
  2813. if AsIsCollecting=='' then
  2814. do
  2815. AsIsCollecting='OptAsIs' ||AsIsIndex
  2816. call _valueS AsIsCollecting, ''
  2817. AsIsIndex=AsIsIndex+1
  2818. AsIsBef.AsIsIndex=''
  2819. AsIsAft.AsIsIndex=AsIsCollecting
  2820. end
  2821. aiOptCnt=aiOptCnt+1
  2822. aiOptList=_valueG(AsIsCollecting)||ThisBefore
  2823. aiIndex=length(aiOptList)
  2824. call _valueS AsIsCollecting,aiOptList
  2825. call _valueS AsIsCollecting|| '.' ||aiIndex,ThisAfter
  2826. end
  2827. end
  2828. call DebugLine_ASIS 'Copied ' || AsIsCopyCount || ' tags'
  2829. call DebugIncrement-1
  2830. return
  2831.  
  2832. AsIs_17:
  2833. AtChangeType=''
  2834. AtChangeTypeDesc="CASESENSITIVE"
  2835. signal AutoTag_18
  2836.  
  2837. ShowAutoTagStateWhenDebugOn:
  2838. if OptionDebugOn='Y' then
  2839. do
  2840. if AutoTagName='' then
  2841. DbgText1=''
  2842. else
  2843. DbgText1=' (named "' || AutoTagName || '")'
  2844. call DebugLine_AUTOTAG 'AutoTagging is ' || YorN2OnorOff(AutoTagOn) || '.  Have ' || ((AutoTagLast - AutoTagFirst) + 1) || ' tags available in state #' ||AutoTagStateCnt||DbgText1
  2845. if arg(1)='Y' then
  2846. do
  2847. call DebugIncrement 1
  2848. do Tag=AutoTagFirst to AutoTagLast
  2849. call DebugLine_AUTOTAG 'AutoTag #' || Tag || ': From=' || DebugRightArrow || AutoTagOnB.Tag || DebugLeftArrow || ',  To=' ||DebugRightArrow||AutoTagOnA.Tag||DebugLeftArrow
  2850. end
  2851. call DebugIncrement-1
  2852. end
  2853. end
  2854. return
  2855.  
  2856. CompletelyInitializeAutoTagState:
  2857. AutoTagOn='N'
  2858. call ClearAutoTags 'Y'
  2859. return
  2860.  
  2861. ClearAutoTags:
  2862. if arg(1)='N' then
  2863. do
  2864. if AutoTagStateCnt=0 then
  2865. AutoTagLast=0
  2866. else
  2867. AutoTagLast=AutoTagState.AutoTagStateCnt.Last
  2868. end
  2869. else
  2870. do
  2871. AutoTagLast=0
  2872. AutoTagStateCnt=0
  2873. AutoTagFirst=1
  2874. AutoTagName=''
  2875. end
  2876. if OptionDebugOn='Y' then
  2877. do
  2878. if AutoTagStateCnt=0 then
  2879. call DebugLine_AUTOTAG 'Cleared ALL autotags (no state information saved - State #0).'
  2880. else
  2881. call ShowAutoTagStateWhenDebugOn
  2882. end
  2883. return
  2884.  
  2885. AutoTag:call TRACE "OFF"
  2886. EatString=arg(1)
  2887. if AutoTagFirst>AutoTagLast then
  2888. return(EatString)
  2889. AtCnt=ReplaceCount
  2890. do Tag=AutoTagFirst to AutoTagLast
  2891. if left(AutoTagOnB.Tag,2)<>SrTypePre then
  2892. EatString=ReplaceString(EatString,AutoTagOnB.Tag,AutoTagOnA.Tag)
  2893. else
  2894. do
  2895. select
  2896. when abbrev(AutoTagOnB.Tag,SrCaseIns)then
  2897. EatString=ReplaceStringCI(EatString,substr(AutoTagOnB.Tag,SrCaseIns_P),AutoTagOnA.Tag)
  2898. when abbrev(AutoTagOnB.Tag,SrFixed)then
  2899. EatString=CompareReplaceFixed2(EatString,substr(AutoTagOnB.Tag,SrFixed_P),AutoTagOnA.Tag)
  2900. otherwise
  2901. EatString=ReplaceString(EatString,AutoTagOnB.Tag,AutoTagOnA.Tag)
  2902. end
  2903. end
  2904. end
  2905. if OptionDebugOn='Y' then
  2906. do
  2907. if AtCnt<>ReplaceCount then
  2908. call DebugOutputAfterReplacement EatString, 'ATAG'
  2909. end
  2910. return(EatString)
  2911.  
  2912. ProcessAutoTagClear:
  2913. if arg(1)='' then
  2914. AtClearAll='N'
  2915. else
  2916. do
  2917. AtParm=GetQuotedText(arg(1))
  2918. if translate(AtParm)<> 'ALL' then
  2919. CryAndDie('Invalid parameter of "' || AtParm || '" specified!')
  2920. AtClearAll='Y'
  2921. end
  2922. call ClearAutoTags AtClearAll
  2923. return(0)
  2924.  
  2925. _GetStateIndexForNameOrDie:
  2926. gsiName=arg(1)
  2927. do NameIndex=1 to AutoTagStateCnt
  2928. if gsiName=AutoTagState.NameIndex.Name then
  2929. return(NameIndex)
  2930. end
  2931. CryAndDie('There is no state known as "' || gsiName(1) || '"')
  2932.  
  2933. MatchesAutoTagStateIncDebugText:
  2934. MatchIndex=arg(1)
  2935. if MatchIndex<=0 then
  2936. return('')
  2937. else
  2938. return(' (matches "#AutoTagState +" at ' || AutoTagState.MatchIndex.AtLine || ')')
  2939.  
  2940. ProcessAutoTagState:
  2941. Rest=strip(arg(1))
  2942. Ats1stParm=left(Rest,1)
  2943. if Ats1stParm='+' | Ats1stParm = '-' then
  2944. Rest=substr(Rest,2)
  2945. else
  2946. Ats1stParm=GetQuotedText(arg(1), "Rest")
  2947. select
  2948. when Ats1stParm='+' then
  2949. do
  2950. AutoTagStateCnt=AutoTagStateCnt+1
  2951. AutoTagState.AutoTagStateCnt.First=AutoTagFirst
  2952. AutoTagState.AutoTagStateCnt.Last=AutoTagLast
  2953. AutoTagState.AutoTagStateCnt.Name=AutoTagName
  2954. AutoTagState.AutoTagStateCnt.AtOnOff=AutoTagOn
  2955. AutoTagState.AutoTagStateCnt.AtLine=CurrentSourceLocation()
  2956. BeforeFirst=AutoTagFirst
  2957. BeforeLast=AutoTagLast
  2958. AutoTagFirst=AutoTagLast+1
  2959. AutoTagName=''
  2960. do while Rest<> ''
  2961. StateAlias=translate(GetQuotedText(Rest, "Rest"))
  2962. if StateAlias="REMEMBER" then
  2963. do
  2964. CopyFrom=BeforeFirst
  2965. Copyto=BeforeLast
  2966. end
  2967. else
  2968. do
  2969. NameIndex=_GetStateIndexForNameOrDie(StateAlias)
  2970. CopyFrom=AutoTagState.NameIndex.First
  2971. Copyto=AutoTagState.NameIndex.Last
  2972. end
  2973. do AddTagIndex=CopyFrom to CopyTo
  2974. call _AddAutoTag AutoTagOnB.AddTagIndex,AutoTagOnA.AddTagIndex
  2975. end
  2976. end
  2977. if OptionDebugOn='Y' then
  2978. call DebugLine_AUTOTAG 'Remembering current #AutoTag state, now in state #' ||AutoTagStateCnt
  2979. end
  2980. when Ats1stParm='-' then
  2981. do
  2982. if AutoTagStateCnt<=0 then
  2983. CryAndDie('No #autotag states memorised!')
  2984. if OptionDebugOn='Y' then
  2985. call DebugLine_AUTOTAG 'This restore matches the setup at ' ||AutoTagState.AutoTagStateCnt.AtLine
  2986. BeforeFirst=AutoTagFirst
  2987. BeforeLast=AutoTagLast
  2988. AutoTagFirst=AutoTagState.AutoTagStateCnt.First
  2989. AutoTagLast=AutoTagState.AutoTagStateCnt.Last
  2990. AutoTagOn=AutoTagState.AutoTagStateCnt.AtOnOff
  2991. AutoTagName=AutoTagState.AutoTagStateCnt.Name
  2992. AutoTagStateCnt=AutoTagStateCnt-1
  2993. if Rest='' then
  2994. Remember='N'
  2995. else
  2996. do
  2997. Rest=translate(GetQuotedText(Rest, "Rest"))
  2998. if Rest="REMEMBER" then
  2999. Remember='Y'
  3000. else
  3001. CryAndDie('Invalid parameter of "' || Rest || '" specified (expected "REMEMBER")')
  3002. end
  3003. if Rest='' then
  3004. DbgWord='dropping'
  3005. else
  3006. do
  3007. Rest=translate(GetQuotedText(Rest))
  3008. if Rest<> "REMEMBER" then
  3009. CryAndDie('Invalid parameter of "' || Rest || '" specified (expected "REMEMBER")')
  3010. DbgWord='remembering'
  3011. AutoTagLast=AutoTagFirst-1
  3012. do AddTagIndex=BeforeFirst to BeforeLast
  3013. call _AddAutoTag AutoTagOnB.AddTagIndex,AutoTagOnA.AddTagIndex
  3014. end
  3015. end
  3016. if OptionDebugOn='Y' then
  3017. call DebugLine_AUTOTAG 'Restoring #AutoTag state #' || AutoTagStateCnt || ', we are ' || DbgWord || ' any new tags you may have defined'
  3018. end
  3019. otherwise
  3020. AutoTagName=translate(Ats1stParm)
  3021. if Rest<> '' then
  3022. call DieIfExtraUnexpectedParms Rest
  3023. if OptionDebugOn='Y' then
  3024. call DebugLine_AUTOTAG 'This state is now named "' || AutoTagName || '"'
  3025. end
  3026. call ShowAutoTagStateWhenDebugOn AutoTagOn
  3027. return(0)
  3028.  
  3029. _AddAutoTag:
  3030. TheTagB=arg(1)
  3031. TheTagA=arg(2)
  3032. ThePosn=arg(3)
  3033. if ThePosn='' then
  3034. ThePosn='999999'
  3035. ThePosn=(ThePosn+AutoTagFirst)-1
  3036. if ThePosn>AutoTagLast then
  3037. do
  3038. AutoTagLast=AutoTagLast+1
  3039. SlotIndex=AutoTagLast
  3040. end
  3041. else
  3042. do
  3043. ToIndex=AutoTagLast+2
  3044. do MoveIndex=ThePosn to AutoTagLast
  3045. ToIndex=ToIndex-1
  3046. FromIndex=ToIndex-1
  3047. AutoTagOnB.ToIndex=AutoTagOnB.FromIndex
  3048. AutoTagOnA.ToIndex=AutoTagOnA.FromIndex
  3049. end
  3050. SlotIndex=ThePosn
  3051. AutoTagLast=AutoTagLast+1
  3052. end
  3053. AutoTagOnB.SlotIndex=TheTagB
  3054. AutoTagOnA.SlotIndex=TheTagA
  3055. return
  3056.  
  3057. _DeleteAutoTag:
  3058. TheTagB=arg(1)
  3059. do Tag=AutoTagFirst to AutoTagLast
  3060. if TheTagB=AutoTagOnB.Tag then
  3061. do
  3062. AutoTagLast=AutoTagLast-1
  3063. do ToIndex=Tag to AutoTagLast
  3064. FromIndex=ToIndex+1
  3065. AutoTagOnB.ToIndex=AutoTagOnB.FromIndex
  3066. AutoTagOnA.ToIndex=AutoTagOnA.FromIndex
  3067. end
  3068. return('Y')
  3069. end
  3070. end
  3071. if OptionDebugOn='Y' then
  3072. call DebugLine_AUTOTAG 'No need to delete the tag (it does not exist)'
  3073. return('N')
  3074.  
  3075. ProcessAutoTag:
  3076. AtBefore=GetQuotedText(arg(1), "Rest")
  3077. if AtBefore='' then
  3078. CryAndDie("You did not supply text to be replaced (can't replace empty string)!")
  3079. AtDumpList='N'
  3080. OnOrOff=IsStringOnOrOffCmd(AtBefore)
  3081. if OnOrOff<> '' & Rest = '' then
  3082. do
  3083. AutoTagOn=OnOrOff
  3084. if AutoTagOn='Y' then
  3085. AtDumpList='Y'
  3086. end
  3087. else
  3088. do
  3089. AtBefore_NoCT=AtBefore
  3090. AtBefore=AtChangeType||AtBefore
  3091. if Rest='' then
  3092. call _DeleteAutoTag AtBefore
  3093. else
  3094. do
  3095. AtAfter=ReplaceString(GetQuotedText(Rest, "Rest"),AutoTagSelf,AtBefore_NoCT)
  3096. if ReplacementsAllowed='Y' then
  3097. do
  3098. do while pos(StartsMacroReplacement,AtAfter)<>0
  3099. BeforeCount=ReplaceCount
  3100. AtAfterR=_ReplaceAllHashDefinedVariables(AtAfter)
  3101. if pos(MarksNewLine,AtAfterR)<>0 then
  3102. leave
  3103. AtAfter=AtAfterR
  3104. if OptionDebugOn='Y' then
  3105. do
  3106. if BeforeCount<>ReplaceCount then
  3107. call DebugOutputAfterReplacement AtAfter, 'VP2O'
  3108. end
  3109. end
  3110. if pos(StartsStdSymbolReplacement,AtAfter)<>0 then
  3111. do
  3112. if pos(MarksNewLine,AtAfter)=0 then
  3113. do
  3114. BeforeCount=ReplaceCount
  3115. AtAfterR=ReplaceStandardDefinitions(AtAfter)
  3116. if BeforeCount<>ReplaceCount then
  3117. do
  3118. if pos(MarksNewLine,AtAfterR)=0 then
  3119. do
  3120. AtAfter=AtAfterR
  3121. if OptionDebugOn='Y' then
  3122. call DebugOutputAfterReplacement AtAfter, 'SP2O'
  3123. end
  3124. end
  3125. end
  3126. end
  3127. end
  3128. AtSlot=''
  3129. if Rest<> '' then
  3130. do
  3131. SlotSpec=word(rest,1)
  3132. Rest=subword(rest,2)
  3133. if left(SlotSpec,1)<> '#' then
  3134. CryAndDie('Invalid slot specification of "' || SlotSpec || '" supplied, must begin with a "#"!')
  3135. AtSlot=substr(SlotSpec,2)
  3136. end
  3137. if OptionDebugOn='Y' then
  3138. call DebugLine_AUTOTAG 'Assigning ' || DebugRightArrow || AtBefore_NoCT || DebugLeftArrow || ' = ' || DebugRightArrow || AtAfter || DebugLeftArrow || ' (TYPE=' || AtChangeTypeDesc || ')'
  3139. call _AddAutoTag AtBefore,AtAfter,AtSlot
  3140. end
  3141. end
  3142. call ShowAutoTagStateWhenDebugOn AtDumpList
  3143. if Rest<> '' then
  3144. CryAndDie('Too many parameters!')
  3145. return(0)
  3146.  
  3147. ATCHANGETYPE_DEBUG:
  3148. if OptionDebugOn='Y' then
  3149. call OptionDebugShow 'ATCHANGETYPE', 'AutoTag change type is "' || AtChangeTypeDesc || '"'
  3150. return
  3151.  
  3152. ATCHANGETYPE_GET:
  3153. call ATCHANGETYPE_DEBUG
  3154. return(AtChangeTypeDesc)
  3155.  
  3156. ATCHANGETYPE_SET:
  3157. AtChangeTypeDesc=translate(arg(1))
  3158. if ProcessedCmdLine='N' then
  3159. do
  3160. call OptionDebugShow 'ATCHANGETYPE', 'Setting default change type to "' || AtChangeTypeDesc || '"'
  3161. Default4_ATCHANGETYPEDESC=AtChangeTypeDesc
  3162. return(0)
  3163. end
  3164. if AtChangeTypeDesc=='' then
  3165. AtChangeTypeDesc=Default4_ATCHANGETYPEDESC
  3166. SelectOn=translate(AtChangeTypeDesc)
  3167. select
  3168. when SelectOn="CASESENSITIVE" then
  3169. AtChangeType=''
  3170. when SelectOn="CASEINSENSITIVE" then
  3171. AtChangeType=SrCaseIns
  3172. when SelectOn="FIXED" then
  3173. AtChangeType=SrFixed
  3174. otherwise
  3175. CryAndDie('Unknown ATCHANGETYPE option of "' || AtChangeTypeDesc || '"')
  3176. end
  3177. call ATCHANGETYPE_DEBUG
  3178. return
  3179.  
  3180. AutoTag_18:
  3181. OptionCount=0
  3182. LongestPpwOptionLng=0
  3183. call _OptionsAdd "ALLOWPACK"
  3184. call _OptionsAdd "ALLOWSPELL"
  3185. call _OptionsAdd "CSREPLACEMENT"
  3186. call _OptionsAdd "DEFINEMACROREPLACE"
  3187. call _OptionsAdd "KEEPINDENT"
  3188. call _OptionsAdd "LEAVEBLANKLINES"
  3189. call _OptionsAdd "REPLACE"
  3190. call _OptionsAdd "ATCHANGETYPE"
  3191. call _OptionsAdd "DEBUGLEVEL"
  3192. call _OptionsAdd "EXTRAINDENT"
  3193. call _OptionsAdd "EXPANDX"
  3194. call _OptionsAdd "HASHPREFIX"
  3195. call _OptionsAdd "LINECOMMENT"
  3196. call _OptionsAdd "LINECONTINUATION"
  3197. call _OptionsAdd "MACROPARMTAGS"
  3198. call _OptionsAdd "REPLACEMENTTAGS"
  3199. call _OptionsAdd "WHITESPACE"
  3200. signal OPTION_19
  3201.  
  3202. _OptionsAdd:
  3203. OptionCount=OptionCount+1
  3204. OptionList.OptionCount=arg(1)
  3205. ThisLng=length(arg(1))
  3206. if ThisLng>LongestPpwOptionLng then
  3207. LongestPpwOptionLng=ThisLng
  3208. return
  3209.  
  3210. SetUpPpwizardOptionDefaults:
  3211. if RexSystemOpSys<> "UNIX" then
  3212. DefWhite=d2c(26)||d2c(27)
  3213. else
  3214. DefWhite=d2c(13)||d2c(26)||d2c(27)
  3215. ProcessedCmdLine='N'
  3216. call DebugLine_OPTIONS 'Setting PPWIZARD defaults (may be overriden with ' || RexOptionChar || 'option switch)'
  3217. call DebugIncrement 1
  3218. call OptionOnOrOff_SET "ALLOWPACK",          "AllowPack",           "ON"
  3219. call OptionOnOrOff_SET "ALLOWSPELL",         "AllowSpell",          "ON"
  3220. call ATCHANGETYPE_SET "CASESENSITIVE"
  3221. call OptionOnOrOff_SET "CSREPLACEMENT",      "CsReplacement",       "OFF"
  3222. call DEBUGLEVEL_SET 'ALL,-USER1,-USER2'
  3223. call OptionOnOrOff_SET "DEFINEMACROREPLACE", "DefineMacroReplace",  "OFF"
  3224. call EXPANDX_SET 'LATE'
  3225. call EXTRAINDENT_SET 'NULL'
  3226. call HASHPREFIX_SET '#'
  3227. call OptionOnOrOff_SET "KEEPINDENT",         "KeepIndent",          "OFF"
  3228. call OptionOnOrOff_SET "LEAVEBLANKLINES",    "LeaveBlankLines",     "OFF"
  3229. call LINECOMMENT_SET ';'
  3230. call LINECONTINUATION_SET '\%-+ '
  3231. call MACROPARMTAGS_SET '{}$'
  3232. call OptionOnOrOff_SET "REPLACE",            "ReplacementsAllowed", "ON"
  3233. call REPLACEMENTTAGS_SET '<>$?'
  3234. call WHITESPACE_SET DefWhite
  3235. call DebugIncrement-1
  3236. return
  3237.  
  3238. SetUpOptionsForThisBuild:
  3239. ProcessedCmdLine='Y'
  3240. call DebugLine_OPTIONS 'Initializing #options for this build of ' ||CurrentOutFile
  3241. call DebugIncrement 1
  3242. call OptionOnOrOff_SET "ALLOWPACK",          "AllowPack",           ""
  3243. call OptionOnOrOff_SET "ALLOWSPELL",         "AllowSpell",          ""
  3244. call ATCHANGETYPE_SET ''
  3245. call OptionOnOrOff_SET "CSREPLACEMENT",      "CsReplacement",       ""
  3246. call DEBUGLEVEL_SET ''
  3247. call OptionOnOrOff_SET "DEFINEMACROREPLACE", "DefineMacroReplace",  ""
  3248. call EXPANDX_SET ''
  3249. call EXTRAINDENT_SET ''
  3250. call HASHPREFIX_SET ''
  3251. call OptionOnOrOff_SET "KEEPINDENT",         "KeepIndent",          ""
  3252. call OptionOnOrOff_SET "LEAVEBLANKLINES",    "LeaveBlankLines",     ""
  3253. call LINECOMMENT_SET ''
  3254. call LINECONTINUATION_SET ''
  3255. call MACROPARMTAGS_SET ''
  3256. call OptionOnOrOff_SET "REPLACE",            "ReplacementsAllowed", ""
  3257. call REPLACEMENTTAGS_SET ''
  3258. call WHITESPACE_SET 'NULL'
  3259. call DebugIncrement-1
  3260. return
  3261.  
  3262. MatchesOptionStackPushDebugText:
  3263. MatchIndex=arg(1)
  3264. if MatchIndex<=0 then
  3265. return('')
  3266. else
  3267. return(' (matches "#option PUSH" at ' || OptPush.MatchIndex || ')')
  3268.  
  3269. OptionsPush:
  3270. OptionStackCnt=OptionStackCnt+1
  3271. OptPush.OptionStackCnt=CurrentSourceLocation()
  3272. PushName='OptPush' ||OptionStackCnt
  3273. if OptionDebugOn='Y' then
  3274. call DebugLine_OPTIONS 'Saving current options on stack as #' ||OptionStackCnt
  3275. call DebugIncrement 1
  3276. do OptionIndex=1 to OptionCount
  3277. call _valueS PushName|| '.' ||OptionIndex,OptionGetValue(OptionList.OptionIndex)
  3278. end
  3279. call DebugIncrement-1
  3280. return
  3281.  
  3282. OptionsPop:
  3283. if OptionStackCnt<=0 then
  3284. CryAndDie('There are no options on the stack to pop!')
  3285. if OptionDebugOn='Y' then
  3286. call DebugLine_OPTIONS 'Restoring current options from #' || OptionStackCnt || ' (pushed at ' || OptPush.OptionStackCnt || ')'
  3287. call DebugIncrement 1
  3288. PushName='OptPush' ||OptionStackCnt
  3289. do OptionIndex=1 to OptionCount
  3290. call OptionSetValue OptionList.OptionIndex,_valueG(PushName|| '.' ||OptionIndex)
  3291. end
  3292. call DebugIncrement-1
  3293. OptionStackCnt=OptionStackCnt-1
  3294. return
  3295.  
  3296. ProcessOption:
  3297. Options=arg(1)
  3298. if ProcessedCmdLine='Y' then
  3299. Options=PerformReplacementsInCmdsParameters(Options)
  3300. if Options='' then
  3301. CryAndDie('No options specified!')
  3302. do while Options<> ''
  3303. parse var Options Word1' 'RestOptions
  3304. Word1=translate(word1)
  3305. select
  3306. when Word1="PUSH" | Word1 = "+" then
  3307. do
  3308. Options=RestOptions
  3309. call OptionsPush
  3310. end
  3311. when Word1="POP" | Word1 = "-" then
  3312. do
  3313. Options=RestOptions
  3314. call OptionsPop
  3315. end
  3316. otherwise
  3317. do
  3318. if pos('=',Options)=0 then
  3319. CryAndDie('Could not find an "=" sign in "' || Options || '"')
  3320. parse var Options ThisOption'='Options
  3321. ThisOption=translate(strip(ThisOption))
  3322. ThisValue=GetQuotedText(Options, "Options")
  3323. call OptionSetValue ThisOption,ThisValue
  3324. end
  3325. end
  3326. end
  3327. return(0)
  3328.  
  3329. OptionDebugShow:
  3330. if OptionDebugOn='Y' then
  3331. call DebugLine_OPTIONS left(arg(1),LongestPpwOptionLng)|| ': ' ||arg(2)
  3332. return
  3333.  
  3334. OptionOnOrOff_DEBUG:
  3335. if OptionDebugOn='Y' then
  3336. call OptionDebugShow arg(1), 'Currently set to ' ||YorN2OnorOff(_valueG(arg(2)))
  3337. return
  3338.  
  3339. OptionOnOrOff_SET:
  3340. parse arg OptionName,OnOffVar2Set,OnOffValue
  3341. if ProcessedCmdLine='N' then
  3342. do
  3343. call OptionDebugShow OptionName, 'Setting default to "' || OnOffValue || '"'
  3344. call _valueS "Default4_" ||OnOffVar2Set,OnOffValue
  3345. return(0)
  3346. end
  3347. if OnOffValue=='' then
  3348. OnOffValue=_valueG("Default4_" ||OnOffVar2Set)
  3349. OnOrOff=IsStringOnOrOffCmd(OnOffValue)
  3350. if OnOrOff='' then
  3351. CryAndDie('Tried to set "' || OnOffVar2Set || '" to an invalid value of "' || OnOffValue || '"')
  3352. call _valueS OnOffVar2Set,OnOrOff
  3353. call OptionOnOrOff_DEBUG OptionName,OnOffVar2Set
  3354. return(0)
  3355.  
  3356. OptionOnOrOff_GET:
  3357. parse arg OptionName,OnOffVar2Get
  3358. VarState=YorN2OnorOff(_valueG(OnOffVar2Get))
  3359. call OptionOnOrOff_DEBUG OptionName,OnOffVar2Get
  3360. return(VarState)
  3361.  
  3362. OptionSetValue:
  3363. parse arg sOption,sValue
  3364. select
  3365. when sOption="ALLOWPACK" then
  3366. call OptionOnOrOff_SET "ALLOWPACK", "AllowPack",sValue
  3367. when sOption="ALLOWSPELL" then
  3368. call OptionOnOrOff_SET "ALLOWSPELL", "AllowSpell",sValue
  3369. when sOption="ATCHANGETYPE" then
  3370. call ATCHANGETYPE_SET sValue,sOption
  3371. when sOption="CSREPLACEMENT" then
  3372. call OptionOnOrOff_SET "CSREPLACEMENT", "CsReplacement",sValue
  3373. when sOption="DEBUGLEVEL" then
  3374. call DEBUGLEVEL_SET sValue,sOption
  3375. when sOption="DEFINEMACROREPLACE" then
  3376. call OptionOnOrOff_SET "DEFINEMACROREPLACE", "DefineMacroReplace",sValue
  3377. when sOption="EXPANDX" then
  3378. call EXPANDX_SET sValue,sOption
  3379. when sOption="EXTRAINDENT" then
  3380. call EXTRAINDENT_SET sValue,sOption
  3381. when sOption="HASHPREFIX" then
  3382. call HASHPREFIX_SET sValue,sOption
  3383. when sOption="KEEPINDENT" then
  3384. call OptionOnOrOff_SET "KEEPINDENT", "KeepIndent",sValue
  3385. when sOption="LEAVEBLANKLINES" then
  3386. call OptionOnOrOff_SET "LEAVEBLANKLINES", "LeaveBlankLines",sValue
  3387. when sOption="LINECOMMENT" then
  3388. call LINECOMMENT_SET sValue,sOption
  3389. when sOption="LINECONTINUATION" then
  3390. call LINECONTINUATION_SET sValue,sOption
  3391. when sOption="MACROPARMTAGS" then
  3392. call MACROPARMTAGS_SET sValue,sOption
  3393. when sOption="REPLACE" then
  3394. call OptionOnOrOff_SET "REPLACE", "ReplacementsAllowed",sValue
  3395. when sOption="REPLACEMENTTAGS" then
  3396. call REPLACEMENTTAGS_SET sValue,sOption
  3397. when sOption="WHITESPACE" then
  3398. call WHITESPACE_SET sValue,sOption
  3399. otherwise
  3400. CryAndDie("Can't set '" || sOption || "' as this option is unknown")
  3401. end
  3402. return
  3403.  
  3404. OptionGetValue:
  3405. parse arg gOption
  3406. select
  3407. when gOption="ALLOWPACK" then
  3408. return(OptionOnOrOff_GET("ALLOWPACK", "AllowPack"))
  3409. when gOption="ALLOWSPELL" then
  3410. return(OptionOnOrOff_GET("ALLOWSPELL", "AllowSpell"))
  3411. when gOption="ATCHANGETYPE" then
  3412. return(ATCHANGETYPE_GET(gOption))
  3413. when gOption="CSREPLACEMENT" then
  3414. return(OptionOnOrOff_GET("CSREPLACEMENT", "CsReplacement"))
  3415. when gOption="DEBUGLEVEL" then
  3416. return(DEBUGLEVEL_GET(gOption))
  3417. when gOption="DEFINEMACROREPLACE" then
  3418. return(OptionOnOrOff_GET("DEFINEMACROREPLACE", "DefineMacroReplace"))
  3419. when gOption="EXPANDX" then
  3420. return(EXPANDX_GET(gOption))
  3421. when gOption="EXTRAINDENT" then
  3422. return(EXTRAINDENT_GET(gOption))
  3423. when gOption="HASHPREFIX" then
  3424. return(HASHPREFIX_GET(gOption))
  3425. when gOption="KEEPINDENT" then
  3426. return(OptionOnOrOff_GET("KEEPINDENT", "KeepIndent"))
  3427. when gOption="LEAVEBLANKLINES" then
  3428. return(OptionOnOrOff_GET("LEAVEBLANKLINES", "LeaveBlankLines"))
  3429. when gOption="LINECOMMENT" then
  3430. return(LINECOMMENT_GET(gOption))
  3431. when gOption="LINECONTINUATION" then
  3432. return(LINECONTINUATION_GET(gOption))
  3433. when gOption="MACROPARMTAGS" then
  3434. return(MACROPARMTAGS_GET(gOption))
  3435. when gOption="REPLACE" then
  3436. return(OptionOnOrOff_GET("REPLACE", "ReplacementsAllowed"))
  3437. when gOption="REPLACEMENTTAGS" then
  3438. return(REPLACEMENTTAGS_GET(gOption))
  3439. when gOption="WHITESPACE" then
  3440. return(WHITESPACE_GET(gOption))
  3441. otherwise
  3442. CryAndDie("Can't get '" || gOption || "' as this option is unknown")
  3443. end
  3444. return
  3445.  
  3446. OPTION_19:
  3447. DefRexxSpecialSepTag='<' || '?xRexxEos>'
  3448. call SetDollarTraceState 'N'
  3449. call InitializeDefineRexx
  3450. signal Def_Rexx_20
  3451.  
  3452. SetDollarTraceState:
  3453. DefRexxDolTrace=arg(1)
  3454. return
  3455.  
  3456. InitializeDefineRexx:
  3457. DefRexxVar=''
  3458. DefRexxAddType=''
  3459. DefRexxCode=''
  3460. DefRexxStartLoc=''
  3461. DefRexxPack='Y'
  3462. DefRexxTraceNext='N'
  3463. DefRexxLineCnt=0
  3464. DefRexxTraceAll=DefRexxDolTrace
  3465. DefRexxNumTrace=0
  3466. DefRexxTraceAllowed='Y'
  3467. return
  3468.  
  3469. ProcessDefineRexx:
  3470. if arg(1)='' then
  3471. do
  3472. if DefRexxVar='' then
  3473. CryAndDie("Not currently defining rexx code!", 'To execute you need to specify a parameter of ""')
  3474. if DefRexxNumTrace<>0 then
  3475. do
  3476. if OptionDebugOn='Y' then
  3477. do
  3478. if DefRexxVar<> '?JustExec?';then
  3479. EndCmt='@Finished@ (Executing rexx from macro "' || DefRexxVar || '")'
  3480. else
  3481. EndCmt="@Finished@"
  3482. call DefRexxAddLine "call RexxTrace '" || EndCmt || "','?'"
  3483. DefRexxNumTrace=DefRexxNumTrace+1
  3484. end
  3485. call DebugLine_DEFINING DefRexxNumTrace|| ' $trace statements inserted'
  3486. end
  3487. if DefineMacroReplace='Y' then
  3488. DefRexxCode=PerformReplacementsInCmdsParameters(DefRexxCode)
  3489. if DefRexxVar<> '?JustExec?';then
  3490. do
  3491. call AddHashDefine DefRexxVar,DefRexxCode,DefRexxAddType
  3492. end
  3493. else
  3494. do
  3495. if OptionDebugOn='Y' then
  3496. call DebugLine_DEFINING 'Rexx code will be immediately executed but not saved'
  3497. DefRexxCode=PerformReplacementsInCmdsParameters(DefRexxCode)
  3498. call ExecRexxCmd DefRexxCode
  3499. end
  3500. call InitializeDefineRexx
  3501. end
  3502. else
  3503. do
  3504. if DefRexxVar<> '' then
  3505. CryAndDie("Already in rexx code block started at " ||DefRexxStartLoc)
  3506. call InitializeDefineRexx
  3507. DefRexxStartLoc=CurrentSourceLocation()
  3508. DefRexxAddType=arg(2)
  3509. DefRexxVar=GetQuotedText(PerformReplacementsInCmdsParameters(arg(1)), "Rest")
  3510. if DefRexxVar='' then
  3511. DefRexxVar='?JustExec?';
  3512. if Rest<> '' then
  3513. do
  3514. Rest=translate(Rest)
  3515. do until Rest=''
  3516. DefSpec=GetQuotedText(Rest, "Rest")
  3517. select
  3518. when DefSpec='NOPACK' then
  3519. DefRexxPack='N'
  3520. when DefSpec='$TRACE' then
  3521. DefRexxTraceAll='Y'
  3522. when DefSpec='$TRACE_OFF' then
  3523. DefRexxTraceAll='N'
  3524. otherwise
  3525. CryAndDie('Invalid option of "' || DefSpec || '" used')
  3526. end
  3527. end
  3528. end
  3529. if OptionDebugOn='Y' then
  3530. do
  3531. if DefRexxPack='Y' then
  3532. call DebugLine_DEFINING "AllowPack option is currently " ||YorN2OnorOff(AllowPack)
  3533. if DefRexxTraceAll='Y' then
  3534. call DebugLine_DEFINING '$Trace statements are being added!'
  3535. else
  3536. call DebugLine_DEFINING '$Trace statements are NOT being added!'
  3537. end
  3538. end
  3539. return(0)
  3540.  
  3541. AddDefineRexxLine:
  3542. NewRexxLine=strip(arg(1))
  3543. DefRexxLineCnt=DefRexxLineCnt+1
  3544. if right(NewRexxLine,2)=RexxCmtEnd then
  3545. do
  3546. StartCmtPos=lastpos(RexxCmtStart,NewRexxLine)
  3547. if StartCmtPos<>0 then
  3548. do
  3549. if StartCmtPos=0 then
  3550. NewRexxLine=''
  3551. else
  3552. NewRexxLine=strip(left(NewRexxLine,StartCmtPos-1), 'T')
  3553. end
  3554. end
  3555. do while right(NewRexxLine,1)=';'
  3556. NewRexxLine=strip(left(NewRexxLine,length(NewRexxLine)-1), 'T')
  3557. end
  3558. if NewRexxLine='' then
  3559. return
  3560. UnpackedLine=space(NewRexxLine)
  3561. if DefRexxPack='Y' then
  3562. do
  3563. if AllowPack='Y' then
  3564. NewRexxLine=CompressRexxLine(NewRexxLine)
  3565. end
  3566. DropLine='N'
  3567. if translate(word(NewRexxLine,1))="$TRACE" then
  3568. do
  3569. Rest=translate(subword(NewRexxLine,2))
  3570. select
  3571. when Rest="ON" then
  3572. do
  3573. DefRexxTraceAllowed='Y'
  3574. DropLine='Y'
  3575. end
  3576. when Rest="OFF" then
  3577. do
  3578. DefRexxTraceAllowed='N'
  3579. DropLine='Y'
  3580. end
  3581. otherwise
  3582. do
  3583. if OptionDebugOn='Y' then
  3584. do
  3585. UserTraceCmt=subword(NewRexxLine,2)
  3586. DropLine='Y'
  3587. if UserTraceCmt='' then
  3588. DefRexxTraceNext="Y"
  3589. else
  3590. do
  3591. call DebugLine_DEFINING '$tracing comment: ' ||UserTraceCmt
  3592. DefRexxTraceNext="N"
  3593. UserTraceCmt=ReplaceString(UserTraceCmt, "'", "''")
  3594. NewRexxLine="call RexxTrace '" || UserTraceCmt || "','?'"
  3595. call DefRexxAddLine NewRexxLine
  3596. DefRexxNumTrace=DefRexxNumTrace+1
  3597. end
  3598. end
  3599. end
  3600. end
  3601. end
  3602. if DropLine='Y' then
  3603. DropLine='N'
  3604. else
  3605. do
  3606. if DefRexxTraceNext="Y" then
  3607. TraceThis='Y'
  3608. else
  3609. do
  3610. if DefRexxTraceAll='N' then
  3611. TraceThis='N'
  3612. else
  3613. do
  3614. if pos('/' || translate(NewRexxLine) || '/', "/THEN/DO/ELSE/")=0 then
  3615. TraceThis='Y'
  3616. else
  3617. TraceThis='N'
  3618. end
  3619. end
  3620. if TraceThis='Y' then
  3621. do
  3622. DefRexxTraceNext="N"
  3623. if OptionDebugOn='Y' then
  3624. do
  3625. if DefRexxTraceAllowed='Y' then
  3626. do
  3627. call DebugLine_DEFINING '$tracing: ' ||UnpackedLine
  3628. TraceThis=ReplaceString(UnpackedLine, "'", "''")
  3629. NewRexxLine="call RexxTrace '@" || DefRexxLineCnt || " -> " || TraceThis || "',,'Y'" ||DefRexxSpecialSepTag||NewRexxLine
  3630. DefRexxNumTrace=DefRexxNumTrace+1
  3631. end
  3632. end
  3633. end
  3634. call DefRexxAddLine NewRexxLine
  3635. end
  3636. return
  3637.  
  3638. DefRexxAddLine:
  3639. if DefRexxCode='' then
  3640. DefRexxCode=arg(1)
  3641. else
  3642. DefRexxCode=DefRexxCode||DefRexxSpecialSepTag||arg(1)
  3643. return
  3644.  
  3645. Def_Rexx_20:
  3646. NameOfOs2ReginaRexxInterpreter=""
  3647. signal Rexx_21
  3648.  
  3649. _GetNameOfMacroSpaceExe:
  3650. if Symbol('MacroSpaceExe') <> 'VAR' then
  3651. do
  3652. MacroSpaceExeBase='MacroSpc.EXE'
  3653. MacroSpaceExe=_filespec('drive', PpWizardPgmName) || _filespec('Path',PpWizardPgmName)||MacroSpaceExeBase
  3654. if SafeQueryExists(MacroSpaceExe)='' then
  3655. do
  3656. MacroSpaceExe=DebugSysSearchPath('PATH',MacroSpaceExeBase)
  3657. if MacroSpaceExe="" then
  3658. MacroSpaceExe=DebugSysSearchPath('DPATH',MacroSpaceExeBase)
  3659. end
  3660. call DebugLine 'Macro Space Pgm: ' ||MacroSpaceExe
  3661. end
  3662. return(MacroSpaceExe)
  3663.  
  3664. _GetNameOfOs2ReginaExe:
  3665. if Symbol('Os2ReginaExe') <> 'VAR' then
  3666. do
  3667. Os2ReginaExeBase='ROS2REXX.EXE'
  3668. Os2ReginaExe=_filespec('drive', PpWizardPgmName) || _filespec('Path',PpWizardPgmName)||Os2ReginaExeBase
  3669. if SafeQueryExists(Os2ReginaExe)='' then
  3670. do
  3671. Os2ReginaExe=DebugSysSearchPath('PATH',Os2ReginaExeBase)
  3672. end
  3673. end
  3674. return(Os2ReginaExe)
  3675.  
  3676. DoMacroSpaceOperation:
  3677. parse arg MsCommand,MsFile,MsFunction,MsQuiet
  3678. CallersLine=SIGL
  3679. call DebugLine 'Trying to macrospace "' || MsCommand || '" "' || MsFile || '" alias (' || MsFunction || ')'
  3680. TmpFile=RexGetTmpFileName()
  3681. CheckPgm=_GetNameOfMacroSpaceExe()
  3682. if CheckPgm='' then
  3683. do
  3684. if MsQuiet="QUIET" then
  3685. return
  3686. else
  3687. CryAndDie("Can't perform macro space command as " || MacroSpaceExeBase || ' is unavailable.')
  3688. end
  3689. FailMsg='MACRO SPACE COMMAND FAILED'
  3690. call AddressCmd CheckPgm|| ' ' || MsCommand || ' ' || MsFile || ' ' || MsFunction || ' >' || TmpFile || ' 2>&1'
  3691. if MsQuiet="QUIET" then
  3692. return
  3693. else
  3694. signal CheckMacroSpaceRc
  3695.  
  3696. CheckRexxModuleForSyntaxErrors:
  3697. call DebugLine 'CheckRexxModuleForSyntaxErrors()'
  3698. if RexWhich='REGINA' then
  3699. do
  3700. call CallStubInGeneratedCodeToCheckSyntax
  3701. return
  3702. end
  3703. CallersLine=SIGL
  3704. TmpFile=RexGetTmpFileName()
  3705. CheckPgm=_GetNameOfMacroSpaceExe()
  3706. if CheckPgm='' then
  3707. do
  3708. call DebugLine "Can't use normal validation method on the rexx syntax - " || MacroSpaceExeBase || ' file not found!'
  3709. call CallStubInGeneratedCodeToCheckSyntax
  3710. return
  3711. end
  3712. FailMsg='INVALID SYNTAX'
  3713. call AddressCmd CheckPgm|| ' CheckSyntax ' || Output.1.File || ' >' || NameOfNulDevice() || ' 2>' ||TmpFile
  3714.  
  3715. CheckMacroSpaceRc:
  3716. CheckRc=Rc
  3717. if CheckRc=0 then
  3718. do
  3719. DosDelRc=_SysFileDelete(TmpFile)
  3720. call UseOs2ReginaToDoubleCheckSyntax
  3721. return
  3722. end
  3723. call Line1 ''
  3724. call Char1 ErrorColor
  3725. call Line1 FailMsg
  3726. call Line1 copies('~',length(FailMsg))
  3727. do while lines(TmpFile)<>0
  3728. call Line1 linein(TmpFile)
  3729. end
  3730. call Char1 Reset|| ''
  3731. CloseRc=stream(TmpFile, 'c', 'close')
  3732. DosDelRc=_SysFileDelete(TmpFile)
  3733. AbnormalExit(CallersLine, "Syntax Error in generated rexx code")
  3734.  
  3735. CallStubInGeneratedCodeToCheckSyntax:
  3736. CheckingFile=Output.1.File
  3737. call DebugIncrement 1
  3738. call DebugLine 'Calling stub in generated code'
  3739. signal ON SYNTAX NAME SyntaxErrorInGeneratedCode
  3740. CheckRc='*?*'
  3741. interpret 'CheckRc =  "' || CheckingFile || '"("' || SyntaxOkText || '")'
  3742. if CheckRc<>SyntaxOkRc then
  3743. CryAndDie('Probably Syntax Error, got unexpected RC of "' || CheckRc || '"')
  3744. call DebugIncrement-1
  3745. return
  3746.  
  3747. SyntaxErrorInGeneratedCode:
  3748. CryAndDie('Faulty syntax in generated "' || CheckingFile || '"!')
  3749.  
  3750. UseOs2ReginaToDoubleCheckSyntax:
  3751. if RexWhich='REGINA' then
  3752. return
  3753. if NameOfOs2ReginaRexxInterpreter='-' then
  3754. return
  3755. call DebugLine 'OS/2 rexx already passed code, can we double check using OS/2 regina?'
  3756. UseExe=NameOfOs2ReginaRexxInterpreter
  3757. if UseExe='' then
  3758. UseExe=_GetNameOfOs2ReginaExe()
  3759. if UseExe='' then
  3760. return
  3761. CheckingFile=Output.1.File
  3762. call DebugIncrement 1
  3763. call DebugLine 'Checking using "' || UseExe || '"'
  3764. call AddressCmd UseExe|| ' ' || CheckingFile || ' ' ||SyntaxOkText
  3765. if Rc<>SyntaxOkRc&Rc<>255 then
  3766. CryAndDie('Probably syntax error in "' || Output.1.File || '"', 'Got unexpected RC of "' || Rc || '" from ' ||UseExe)
  3767. call DebugIncrement-1
  3768. return
  3769.  
  3770. Rexx_21:
  3771. InfiniteLoopDetected='N'
  3772. InfiniteLoopWhen=0
  3773. InfiniteIncludeLoopWhen=0
  3774. RexxSkipCounter=0
  3775. ArePositionalChars='"' || "'="
  3776. signal Define_22
  3777.  
  3778. InitCondNlCount:
  3779. CondNlCount=0
  3780. return
  3781.  
  3782. _MacroBitNotFoundText:
  3783. if CsReplacement='N' then
  3784. return('')
  3785. else
  3786. return('Macro names & parameters are case sensitive (check case)')
  3787.  
  3788. InitializeHashDefinesForThisCompile:
  3789. call DebugLine_DEFINING 'Initializing all #defines, got ' || OptionDefineCount || ' /define definitions to load up.'
  3790. drop MACRO?.
  3791. call AddHashDefine '_PPWIZARD_', ''
  3792. if OptionDefineCount<>0 then
  3793. do
  3794. do Index=1 to OptionDefineCount
  3795. call AddHashDefine OptionDefine.Index.Var,OptionDefine.Index.Cont
  3796. end
  3797. end
  3798. call _GetUserOptionsViaDefineSwitch
  3799. return
  3800.  
  3801. _GetUserOptionsViaDefineSwitch:
  3802. call DebugLine_MACROVALORDEF 'Getting some lesser options (not worth specific commands)'
  3803. call DebugIncrement 1
  3804. if RexSystemOpSys="UNIX" then
  3805. PathDelimiterChar=':'
  3806. else
  3807. PathDelimiterChar=';'
  3808. PathDelimiterChar=GetDefineValueOrUseDefault("PATH_DELIMITER_CHAR",PathDelimiterChar)
  3809. if length(PathDelimiterChar)<>1 then
  3810. CryAndDie("Invalid path delimiter (expected 1 only character)")
  3811. RexxLocalVar=GetDefineValueOrUseDefault("REXX_MAKE_LOCAL_VAR", '@' || '@')
  3812. InfiniteLoopWhen=GetDefineValueOrUseDefault("INFINITE_MACRO_LOOP_WHEN",20)
  3813. InfiniteIncludeLoopWhen=GetDefineValueOrUseDefault("INFINITE_INCLUDE_LOOP_WHEN",20)
  3814. call DebugIncrement-1
  3815. return
  3816.  
  3817. REPLACEMENTTAGS_DEBUG:
  3818. if OptionDebugOn='Y' then
  3819. call OptionDebugShow 'REPLACEMENTTAGS', 'Replace tags now look like "' || StartsMacroReplacement || 'MacroVar' || EndsMacroReplacement || '" and "' || StartsStdSymbolReplacement || 'StandardMacroVar' || EndsMacroReplacement || '"'
  3820. return
  3821.  
  3822. REPLACEMENTTAGS_SET:
  3823. Tags=arg(1)
  3824. if ProcessedCmdLine='N' then
  3825. do
  3826. call OptionDebugShow 'REPLACEMENTTAGS', 'Setting default value of replacement tags to "' || Tags || '"'
  3827. Default4_ReplacementTags=Tags
  3828. return(0)
  3829. end
  3830. if Tags=='' then
  3831. Tags=Default4_ReplacementTags
  3832. if length(Tags)<>4 then
  3833. CryAndDie('Tried to set invalid replace tags of "' || Tags || '"')
  3834. StartsMacroReplacement=substr(Tags,1,1)||substr(Tags,3,1)
  3835. StdSymbolReplacementChar=substr(Tags,4,1)
  3836. StartsStdSymbolReplacement=substr(Tags,1,1)||StdSymbolReplacementChar
  3837. EndsMacroReplacement=substr(Tags,2,1)
  3838. EndsVar=' ' ||EndsMacroReplacement
  3839. StartsStdSymbolReplacement_x=StartsStdSymbolReplacement|| 'x'
  3840. CodexNewLine=StartsStdSymbolReplacement|| "NewLine" ||EndsMacroReplacement
  3841. CodexHexNewLine=StartsStdSymbolReplacement_x|| "0A" ||EndsMacroReplacement
  3842. CodexHexSpace=StartsStdSymbolReplacement_x|| "20" ||EndsMacroReplacement
  3843. CodexHexHash=StartsStdSymbolReplacement_x|| "23" ||EndsMacroReplacement
  3844. CodexHexDollar=StartsStdSymbolReplacement_x|| "24" ||EndsMacroReplacement
  3845. CodexHexQuestionMark=StartsStdSymbolReplacement_x|| "3F" ||EndsMacroReplacement
  3846. CodexHexLessThan=StartsStdSymbolReplacement_x|| "3C" ||EndsMacroReplacement
  3847. call REPLACEMENTTAGS_DEBUG
  3848. return
  3849.  
  3850. REPLACEMENTTAGS_GET:
  3851. call REPLACEMENTTAGS_DEBUG
  3852. return(substr(StartsMacroReplacement,1,1)||EndsMacroReplacement||substr(StartsMacroReplacement,2,1)||substr(StartsStdSymbolReplacement,2,1))
  3853.  
  3854. MACROPARMTAGS_DEBUG:
  3855. if OptionDebugOn='Y' then
  3856. call OptionDebugShow 'MACROPARMTAGS', 'Macro parameters now look like "' || StartsMacroParm || 'MacroParameter' || EndsMacroParm || '"'
  3857. return
  3858.  
  3859. MACROPARMTAGS_SET:
  3860. Tags=arg(1)
  3861. if ProcessedCmdLine='N' then
  3862. do
  3863. call OptionDebugShow 'MACROPARMTAGS', 'Setting default value of macro parameter tags to "' || Tags || '"'
  3864. Default4_MacroParameterTags=Tags
  3865. return(0)
  3866. end
  3867. if Tags=='' then
  3868. Tags=Default4_MacroParameterTags
  3869. if length(Tags)<>3 then
  3870. CryAndDie('Tried to set invalid macro parameter tags of "' || Tags || '"')
  3871. StartsMacroParm=substr(Tags,1,1)||substr(Tags,3,1)
  3872. EndsMacroParm=substr(Tags,2,1)
  3873. HidesMacroParm=substr(Tags,1,1)|| '_' ||substr(Tags,3,1)
  3874. AutoTagSelf=StartsMacroParm|| 'AT' ||EndsMacroParm
  3875. call MACROPARMTAGS_DEBUG
  3876. return
  3877.  
  3878. MACROPARMTAGS_GET:
  3879. call MACROPARMTAGS_DEBUG
  3880. return(substr(StartsMacroParm,1,1)||EndsMacroParm||substr(StartsMacroParm,2,1))
  3881.  
  3882. ProcessDefine:
  3883. Rest=arg(1)
  3884. if DefineMacroReplace='Y' then
  3885. Rest=PerformReplacementsInCmdsParameters(Rest)
  3886. if pos(MarksNewLineInHashDefine,Rest)<>0 then
  3887. do
  3888. Rest=ReplaceString(arg(1),MarksNewLineInHashDefine2,MarksNewLine)
  3889. Rest=ReplaceString(Rest,MarksNewLineInHashDefine,MarksNewLine)
  3890. end
  3891. parse var Rest HashDefineV HashDefineC
  3892. return(AddHashDefine(HashDefineV,strip(HashDefineC),arg(2)))
  3893.  
  3894. ProcessEvaluate:
  3895. Rest=PerformReplacementsInCmdsParameters(arg(1))
  3896. HashDefineAnswerName=GetQuotedText(Rest, "Rest")
  3897. if Rest='' then
  3898. CryAndDie('Evaluate what command?')
  3899. CmdToEvaluate=GetQuotedRest(Rest)
  3900. HashDefineRc=0
  3901. if HashDefineAnswerName='' then
  3902. call ExecRexxCmd CmdToEvaluate
  3903. else
  3904. do
  3905. CmdToEvaluate='EvaluateAnswer = ' ||CmdToEvaluate
  3906. call ExecRexxCmd CmdToEvaluate
  3907. HashDefineRc=AddHashDefine(HashDefineAnswerName,EvaluateAnswer,arg(2))
  3908. end
  3909. return(HashDefineRc)
  3910.  
  3911. VariableExists:
  3912. if CsReplacement='N' then
  3913. VarNme=c2x(translate(arg(1)))
  3914. else
  3915. VarNme=c2x(arg(1))
  3916. if symbol('MACRO?.M?' || VarNme) = 'VAR' then
  3917. return('Y')
  3918. else
  3919. return('N')
  3920.  
  3921. HandleUndefCommand:
  3922. UndefVar=PerformReplacementsInCmdsParameters(arg(1))
  3923. if verify(UndefVar,EndsVar, 'M') <> 0 then CryAndDie('The macro name "' || UndefVar || '" is invalid (Any of "' || EndsVar || '" are invalid)')
  3924. if CsReplacement='N' then
  3925. UndefVar=c2x(translate(UndefVar))
  3926. else
  3927. UndefVar=c2x(UndefVar)
  3928. SavedAs='MACRO?.M?' ||UndefVar
  3929. if symbol(SavedAs)='VAR' then
  3930. drop(SavedAs)
  3931. return(0)
  3932.  
  3933. MacroSet:call TRACE "OFF"
  3934.  
  3935. AddHashDefine:
  3936. parse arg HashDefineU,HashDefineC,OkToRedefine
  3937. if verify(HashDefineU,EndsVar, 'M') <> 0 then CryAndDie('The macro name "' || HashDefineU || '" is invalid (Any of "' || EndsVar || '" are invalid)')
  3938. if CsReplacement='N' then
  3939. HashDefineV=c2x(translate(HashDefineU))
  3940. else
  3941. HashDefineV=c2x(HashDefineU)
  3942. if OptionDebugOn='Y' then
  3943. do
  3944. call DebugLine_DEFINING 'Defining "' || HashDefineU || '" as ' ||DebugRightArrow||HashDefineC||DebugLeftArrow
  3945. call DebugIncrement 1
  3946. end
  3947. SavedAs='MACRO?.M?' ||HashDefineV
  3948. if symbol(SavedAs)='VAR' then
  3949. do
  3950. if OkToRedefine='Y' then
  3951. do
  3952. if OptionDebugOn='Y' then
  3953. call DebugLine_DEFINING 'User said OK to redefine so no warning'
  3954. end
  3955. else
  3956. do
  3957. call OutputWarningToScreen 'R000', 'Redefine of "' || HashDefineU || '".'
  3958. end
  3959. end
  3960. call _valueS SavedAs,HashDefineC
  3961. if OptionDebugOn='Y' then
  3962. call DebugIncrement-1
  3963. return(0)
  3964.  
  3965. PerformReplacementsInCmdsParameters:
  3966. cpParms=ReplaceHashAndStandardDefines(arg(1), "PRM")
  3967. if ExpandXCmd='Y' then
  3968. do
  3969. if pos(StartsStdSymbolReplacement_x,cpParms)<>0 then
  3970. cpParms=ReplaceTheXCodesWeKnowExist(cpParms)
  3971. end
  3972. if pos(MarksNewLine,cpParms)<>0 then
  3973. do
  3974. Line1='The commands parameters expanded a macro that generated multiple lines!'
  3975. Line2='The parameters are now:'
  3976. Line3=copies(' ',8)||translate(cpParms,DebugNewline,MarksNewLine)
  3977. CryAndDie(Line1,Line2,Line3)
  3978. end
  3979. return(cpParms)
  3980.  
  3981. ReplaceMacros:call TRACE "OFF"
  3982. signal _ReplaceMacros
  3983.  
  3984. ReplaceHashAndStandardDefines:
  3985. if ReplacementsAllowed='N' then
  3986. return(arg(1))
  3987.  
  3988. _ReplaceMacros:
  3989. parse arg HashDefineString,HashDefPrefix,HashDefRecord
  3990. ReplLoop=0
  3991. do while pos(StartsMacroReplacement,HashDefineString)<>0
  3992. BeforeCount=ReplaceCount
  3993. HashDefineString=_ReplaceAllHashDefinedVariables(HashDefineString)
  3994. if HashDefRecord='Y' then
  3995. LastLineAfterMacroRep=HashDefineString
  3996. if OptionDebugOn='Y' then
  3997. do
  3998. if BeforeCount<>ReplaceCount then
  3999. do
  4000. if HashDefPrefix='' then
  4001. call DebugOutputAfterReplacement HashDefineString, 'VCMD'
  4002. else
  4003. call DebugOutputAfterReplacement HashDefineString, 'V' ||HashDefPrefix
  4004. end
  4005. end
  4006. if pos(MarksNewLine,HashDefineString)<>0 then
  4007. leave
  4008. if ReplLoop>=InfiniteLoopWhen then
  4009. do
  4010. if InfiniteLoopWhen<>0 then
  4011. do
  4012. InfiniteLoopDetected='Y'
  4013. if ReplLoop=InfiniteLoopWhen then
  4014. do
  4015. OptionDebugOn='Y'
  4016. call DebugLine 'Infinite loop detected, debug forced on for a few loops'
  4017. call DebugIncrement 1
  4018. call DebugLine InfiniteLoopWhen|| ' loops detected, possible actions:'
  4019. call DebugIncrement 1
  4020. call DebugLine 'Have have you forgotten to use "#option DefineMacroReplace=ON" somewhere?'
  4021. call DebugLine 'Use "/define:INFINITE_MACRO_LOOP_WHEN=0"    to turn off detection'
  4022. call DebugLine 'Use "/define:INFINITE_MACRO_LOOP_WHEN=1000" to increase detection threshold'
  4023. call DebugIncrement-2
  4024. say ''
  4025. call DebugStateChanged
  4026. end
  4027. say ''
  4028. if ReplLoop>InfiniteLoopWhen+50 then
  4029. CryAndDie("Infinite loop detected (debug turned on above), current line now:", "",HashDefineString)
  4030. end
  4031. end
  4032. ReplLoop=ReplLoop+1
  4033. end
  4034. if InfiniteLoopDetected='Y' then
  4035. CryAndDie("Increase your loop detection value from " || InfiniteLoopWhen || ' with "/define:INFINITE_MACRO_LOOP_WHEN=Value"', "Increase to at least " || ReplLoop || '!')
  4036. if pos(StartsStdSymbolReplacement,HashDefineString)<>0 then
  4037. do
  4038. BeforeCount=ReplaceCount
  4039. HashDefineString=ReplaceStandardDefinitions(HashDefineString)
  4040. if HashDefRecord='Y' then
  4041. LastLineAfterMacroRep=HashDefineString
  4042. if OptionDebugOn='Y' then
  4043. do
  4044. if BeforeCount<>ReplaceCount then
  4045. do
  4046. if HashDefPrefix='' then
  4047. call DebugOutputAfterReplacement HashDefineString, 'SCMD'
  4048. else
  4049. call DebugOutputAfterReplacement HashDefineString, 'S' ||HashDefPrefix
  4050. end
  4051. end
  4052. end
  4053. return(HashDefineString)
  4054.  
  4055. _UnknownStandardSymbol:
  4056. call CryAndDie 'The standard symbol "' || StartsStdSymbolReplacement || SymbolName || EndsMacroReplacement || '" is unknown!'
  4057.  
  4058. ReplaceStandardDefinitions:
  4059. RightBit=arg(1)
  4060. if pos(MarksNewLine,RightBit)<>0 then
  4061. return(RightBit)
  4062. LeftBit=''
  4063. StartPos=pos(StartsStdSymbolReplacement,RightBit)
  4064. do while StartPos<>0
  4065. EndPos=pos(EndsMacroReplacement,RightBit,StartPos+1)
  4066. if EndPos=0 then
  4067. CryAndDie('Could not find the "' || EndsMacroReplacement || '" end of variable started at: ' ||substr(RightBit,StartPos))
  4068. LeftBit=LeftBit||left(RightBit,StartPos-1)
  4069. SymbolNameC=substr(RightBit,StartPos+2,(EndPos-StartPos)-2)
  4070. RightBit=substr(RightBit,EndPos+1)
  4071. if left(SymbolNameC,1)='x' then
  4072. do
  4073. ReplaceCount=ReplaceCount-1
  4074. SymbolValue=StartsStdSymbolReplacement||SymbolNameC||EndsMacroReplacement
  4075. end
  4076. else
  4077. do
  4078. if OptionDebugOn='Y' then
  4079. call DebugOutputVariableInfo_FOUNDSTDVAR 'Found : ' ||StartsStdSymbolReplacement||SymbolNameC||EndsMacroReplacement
  4080. SymbolName=translate(SymbolNameC)
  4081. Left1=left(SymbolName,1)
  4082. if Left1='=' then
  4083. DdCodes=''
  4084. else
  4085. do
  4086. SpcPos=pos(' ',SymbolName)
  4087. if SpcPos=0 then
  4088. DdCodes=''
  4089. else
  4090. do
  4091. DdCodes=substr(SymbolName,SpcPos+1)
  4092. SymbolName=left(SymbolName,SpcPos-1)
  4093. end
  4094. end
  4095. select
  4096. when Left1='?' then
  4097. do
  4098. SymbolName=substr(SymbolName,2)
  4099. if symbol(SymbolName)<> 'VAR' then
  4100. do
  4101. call DumpVarsIfCompoundVariable SymbolName
  4102. call CryAndDie 'The rexx variable "' || SymbolName || '" is unknown!'
  4103. end
  4104. SymbolValue=_valueG(SymbolName)
  4105. end
  4106. when Left1='I' then
  4107. do
  4108. select
  4109. when SymbolName="INPUTFILE" then
  4110. SymbolValue=InputFileFull
  4111. when SymbolName="INPUTCOMPONENT" then
  4112. SymbolValue=IncludeFileName
  4113. when SymbolName="INPUTCOMPONENTLINE" then
  4114. SymbolValue=IncludeLineNumber
  4115. when SymbolName="INCLUDELEVEL" then
  4116. SymbolValue=IncludeLevel
  4117. otherwise
  4118. call _UnknownStandardSymbol
  4119. end
  4120. end
  4121. when Left1='S' then
  4122. do
  4123. select
  4124. when SymbolName="SPACE" then
  4125. SymbolValue=CodexHexSpace
  4126. when SymbolName="SEMICOLON" then
  4127. SymbolValue=';'
  4128. otherwise
  4129. call _UnknownStandardSymbol
  4130. end
  4131. end
  4132. when Left1='O' then
  4133. do
  4134. select
  4135. when SymbolName="OUTPUTLINE" then
  4136. SymbolValue=CurrentOutLine+1
  4137. when SymbolName="OUTPUTLEVEL" then
  4138. SymbolValue=OutputLevel
  4139. when SymbolName="OPSYS" then
  4140. SymbolValue=PpWizardOpSys
  4141. when SymbolName="OUTPUTFILE" then
  4142. do
  4143. CloseRc=stream(CurrentOutFile, 'c', 'close')
  4144. SymbolValue=SafeQueryExists(CurrentOutFile)
  4145. if SymbolValue='' then
  4146. CryAndDie('Could not obtain file name information for the "' || StartsStdSymbolReplacement || 'OutputFile>" variable!')
  4147. end
  4148. otherwise
  4149. call _UnknownStandardSymbol
  4150. end
  4151. end
  4152. when Left1='P' then
  4153. do
  4154. select
  4155. when SymbolName='PROCESSINGMODE' then
  4156. SymbolValue=OptionCodeType
  4157. when SymbolName='PROTECTFROMPPWSTART' then
  4158. SymbolValue=MarksNewLine||HashPrefix||ProtectFromPpwS||MarksNewLine
  4159. when SymbolName='PROTECTFROMPPWEND' then
  4160. SymbolValue=MarksNewLine||ProtectFromPpwE||MarksNewLine
  4161. when SymbolName='PPWIZARDAUTHORHOMEPAGE' then
  4162. SymbolValue=PgmAuthorHomePage
  4163. when SymbolName='PPWIZARDAUTHOR' then
  4164. SymbolValue=PgmAuthor
  4165. when SymbolName='PPWIZARDAUTHOREMAIL' then
  4166. SymbolValue=PgmAuthorEmail
  4167. when SymbolName='PPWIZARDHOMEPAGE' then
  4168. SymbolValue=PgmHomePage
  4169. when SymbolName='PPWIZARDGENERATORMETATAGS' then
  4170. SymbolValue=PgmDefaultHtmlMetaTags
  4171. otherwise
  4172. call _UnknownStandardSymbol
  4173. end
  4174. end
  4175. when Left1='D' then
  4176. do
  4177. select
  4178. when SymbolName='DEBUGON' then
  4179. SymbolValue=OptionDebugOn
  4180. when SymbolName='DOLLAR' then
  4181. SymbolValue=CodexHexDollar
  4182. when SymbolName='DIRSLASH' then
  4183. SymbolValue=RexDirChar
  4184. otherwise
  4185. call _UnknownStandardSymbol
  4186. end
  4187. end
  4188. when SymbolName='NEWLINE' then
  4189. SymbolValue=CodexHexNewLine
  4190. when SymbolName='NEWLINE?' then
  4191. do
  4192. CondNlCount=CondNlCount+1
  4193. SymbolValue="{?WaNtNl?}"
  4194. end
  4195. when SymbolName='COMPILETIME' then
  4196. SymbolValue=CompileTime
  4197. when SymbolName='VERSION' then
  4198. SymbolValue=PgmVersion
  4199. when SymbolName='HASH' then
  4200. SymbolValue=CodexHexHash
  4201. when SymbolName='HASHPREFIX' then
  4202. SymbolValue=HashPrefix
  4203. when SymbolName='RESTARTLINE' then
  4204. SymbolValue=MarksNewLine
  4205. when SymbolName='TOTALOUTPUTLINES' then
  4206. SymbolValue=GeneratedLines+1
  4207. when SymbolName='NEWESTFILEDATETIME' then
  4208. SymbolValue=NewestSourcefile
  4209. when SymbolName='LESSTHAN' then
  4210. SymbolValue=CodexHexLessThan
  4211. when SymbolName='QUESTIONMARK' then
  4212. SymbolValue=CodexHexQuestionMark
  4213. when SymbolName='UNIQUE' then
  4214. do
  4215. PPwizardUnique=PPwizardUnique+1
  4216. SymbolValue=PPwizardUnique
  4217. end
  4218. when SymbolName='TEMPLATEDATAFILE' then
  4219. SymbolValue=TemplateDataFile
  4220. when SymbolName='CGISTART' then
  4221. SymbolValue='Content-type: text/html' ||CodexHexNewLine||CodexHexNewLine
  4222. when SymbolName='REXXSKIP' then
  4223. do
  4224. RexxSkipCounter=RexxSkipCounter+1
  4225. RexxLbl=_filespec("WITHOUTEXTN", _filespec("NAME", IncludeFileName)) || '_' ||RexxSkipCounter
  4226. SymbolValue=MarksNewLine||HashPrefix|| 'RexxVar "RexxSkipLbl" = "' || RexxLbl || '"' ||MarksNewLine
  4227. SymbolValue=SymbolValue|| 'signal ' || RexxLbl || ';' ||MarksNewLine
  4228. SymbolValue=SymbolValue||MarksNewLine||HashPrefix|| 'RexxVar "RexxSkipLbl" PUSH' ||MarksNewLine
  4229. end
  4230. when SymbolName='REXXSKIPTO' then
  4231. do
  4232. SymbolValue=MarksNewLine||HashPrefix|| 'RexxVar "RexxSkipLbl" POP' ||MarksNewLine
  4233. SymbolValue=SymbolValue||RexxSkipLbl|| ':' ||MarksNewLine
  4234. end
  4235. when Left1='=' then
  4236. do
  4237. if OptionDebugOn='Y' then
  4238. call DebugIncrement 1
  4239. call ExecRexxCmd 'SymbolValue = ' ||substr(SymbolName,2)
  4240. if OptionDebugOn='Y' then
  4241. call DebugIncrement-1
  4242. end
  4243. otherwise
  4244. call _UnknownStandardSymbol
  4245. end
  4246. if DdCodes<> '' then
  4247. do
  4248. do until DdCodes=''
  4249. parse var DdCodes DdCode DdCodes
  4250. if OptionDebugOn='Y' then
  4251. do
  4252. call DebugOutputVariableInfo_FOUNDSTDVAR '$$Bef : ' ||SymbolValue
  4253. call DebugOutputVariableInfo_FOUNDSTDVAR '$$Cmd : ' ||DdCode
  4254. end
  4255. select
  4256.  
  4257. when DdCode='$$DSQ' then
  4258. do
  4259. QChar=QuoteIt(SymbolValue,TryQuoteListDs)
  4260. SymbolValue=QChar||SymbolValue||QChar
  4261. end
  4262.  
  4263. when DdCode='$$SDQ' then
  4264. do
  4265. QChar=QuoteIt(SymbolValue,TryQuoteListSd)
  4266. SymbolValue=QChar||SymbolValue||QChar
  4267. end
  4268.  
  4269. when DdCode='$$AQ' then
  4270. do
  4271. QChar=QuoteIt(SymbolValue,TryQuoteListAny)
  4272. SymbolValue=QChar||SymbolValue||QChar
  4273. end
  4274.  
  4275. when DdCode='$$UPPER' then
  4276. SymbolValue=translate(SymbolValue)
  4277.  
  4278. when DdCode='$$LOWER' then
  4279. SymbolValue=ToLowerCase(SymbolValue)
  4280.  
  4281. when DdCode='$$ADDCOMMA' then
  4282. SymbolValue=AddCommasToDecimalNumber(SymbolValue)
  4283.  
  4284. when DdCode='$$HTMLQ' then
  4285. SymbolValue=ReplaceString(SymbolValue, '"', '"')
  4286.  
  4287. when DdCode='$$SQX2' then
  4288. SymbolValue=ReplaceString(SymbolValue, "'" , "''")
  4289.  
  4290. when DdCode='$$SPCPLUS' then
  4291. do
  4292. if SymbolValue\=='' then
  4293. SymbolValue=' ' ||SymbolValue
  4294. end
  4295.  
  4296. otherwise
  4297. do
  4298. UserRexx=GetDefineValueOrUseDefault("REXX_" || DdCode, '')
  4299. if UserRexx='' then
  4300. CryAndDie('The $$ replacement command of "' || DdCode || '" is unknown!')
  4301. TheMacro=""
  4302. TheName=SymbolName
  4303. TheValue=SymbolValue
  4304. call ExecRexxCmd UserRexx
  4305. if OptionDebugOn='Y' then
  4306. do
  4307. if SymbolValue=TheValue then
  4308. do
  4309. call DebugIncrement 1
  4310. call DebugOutputVariableInfo_FOUNDVARPARMS 'The user rexx code did not modify the "TheValue" variable'
  4311. call DebugIncrement-1
  4312. end
  4313. end
  4314. SymbolValue=TheValue
  4315. end
  4316. end
  4317. end
  4318. end
  4319. if OptionDebugOn='Y' then
  4320. call DebugOutputVariableInfo_FOUNDSTDVAR 'Value : ' ||DebugRightArrow||SymbolValue||DebugLeftArrow
  4321. end
  4322. LeftBit=LeftBit||SymbolValue
  4323. ReplaceCount=ReplaceCount+1
  4324. if pos(MarksNewLine,SymbolValue)<>0 then
  4325. leave
  4326. StartPos=pos(StartsStdSymbolReplacement,RightBit)
  4327. end
  4328. return(LeftBit||RightBit)
  4329.  
  4330. GetDefineContents:
  4331. if CsReplacement='N' then
  4332. VarNme=c2x(translate(arg(1)))
  4333. else
  4334. VarNme=c2x(arg(1))
  4335. SavedAs='MACRO?.M?' ||VarNme
  4336. if symbol(SavedAs)='VAR' then
  4337. return(_valueG(SavedAs))
  4338. call DebugLine 'The unknown symbols ALIAS is "' || VarNme || '"'
  4339. CryAndDie('Macro named "' || arg(1) || '" does not exist!',_MacroBitNotFoundText())
  4340.  
  4341. ReplaceDefinitionsParameters:
  4342. do ParmIndex=1 to ParmCount
  4343. ParmUsed.ParmIndex='N'
  4344. end
  4345. DefaultCnt=0
  4346. ParmLeftBit=''
  4347. ParmRightBit=VariableCont
  4348. ParmPos=pos(StartsMacroParm,ParmRightBit)
  4349. do while ParmPos<>0
  4350. ParmLeftBit=ParmLeftBit||left(ParmRightBit,ParmPos-1)
  4351. ParmRightBit=substr(ParmRightBit,ParmPos+2)
  4352. EqualPos=pos('=',ParmRightBit)
  4353. MaybeEndPos=pos(EndsMacroParm,ParmRightBit)
  4354. if MaybeEndPos=0 then
  4355. CryAndDie('Incorrect use of macro parameter, no matching "' || EndsMacroParm || '" for "' || StartsMacroParm || '"')
  4356. if EqualPos<>0&EqualPos<MaybeEndPos then
  4357. do
  4358. if CsReplacement='N' then
  4359. ThisParmName=translate(strip(left(ParmRightBit,EqualPos-1)))
  4360. else
  4361. ThisParmName=strip(left(ParmRightBit,EqualPos-1))
  4362. ParmRightBit=substr(ParmRightBit,EqualPos+1)
  4363. ParmDefault=GetQuotedText(ParmRightBit, "ParmRightBit",EndsMacroParm)
  4364. HaveDefault='Y'
  4365. CurlyPos=pos(EndsMacroParm,ParmRightBit)
  4366. if CurlyPos=0 then
  4367. CryAndDie("Expected to find '" || EndsMacroParm || "' " || 'after the parameter default of "' || ParmDefault || '"!')
  4368. ParmCmds=left(ParmRightBit,CurlyPos-1)
  4369. ParmRightBit=substr(ParmRightBit,CurlyPos+1)
  4370. FoundIndex=0
  4371. do DefaultIndex=1 to DefaultCnt
  4372. if ThisParmName=PrmDefaultName.DefaultIndex then
  4373. do
  4374. FoundIndex=DefaultIndex
  4375. leave
  4376. end
  4377. end
  4378. if FoundIndex=0 then
  4379. do
  4380. DefaultCnt=DefaultCnt+1
  4381. FoundIndex=DefaultCnt
  4382. end
  4383. PrmDefaultName.FoundIndex=ThisParmName
  4384. PrmDefaultValue.FoundIndex=ParmDefault
  4385. end
  4386. else
  4387. do
  4388. HaveDefault='N'
  4389. if CsReplacement='N' then
  4390. ThisParmName=translate(strip(left(ParmRightBit,MaybeEndPos-1)))
  4391. else
  4392. ThisParmName=strip(left(ParmRightBit,MaybeEndPos-1))
  4393. SpcPos=pos(' ',ThisParmName)
  4394. if SpcPos=0 then
  4395. ParmCmds=''
  4396. else
  4397. do
  4398. ParmCmds=substr(ThisParmName,SpcPos+1)
  4399. ThisParmName=left(ThisParmName,SpcPos-1)
  4400. end
  4401. ParmRightBit=substr(ParmRightBit,MaybeEndPos+1)
  4402. end
  4403. if OptionDebugOn='Y' then
  4404. call DebugOutputVariableInfo_FOUNDVARPARMS 'Parm : ' ||ThisParmName
  4405. FndVarIndex=0
  4406. do ParmIndex=1 to ParmCount
  4407. if ParmName.ParmIndex<> '' then
  4408. do
  4409. if ThisParmName=ParmName.ParmIndex then
  4410. do
  4411. ParmUsed.ParmIndex='Y'
  4412. FndVarIndex=ParmIndex
  4413. end
  4414. end
  4415. end
  4416. if FndVarIndex<>0 then
  4417. ReplaceParmWith=ParmValue.FndVarIndex
  4418. else
  4419. do
  4420. if HaveDefault='Y' then
  4421. ReplaceParmWith=ParmDefault
  4422. else
  4423. do
  4424. if OptionDebugOn='Y' then
  4425. do
  4426. call DebugIncrement 1
  4427. call DebugOutputVariableInfo_FOUNDVARPARMS 'Parameter not supplied. No default given. Default value stored?'
  4428. end
  4429. do DefaultIndex=1 to DefaultCnt
  4430. if ThisParmName=PrmDefaultName.DefaultIndex then
  4431. do
  4432. ReplaceParmWith=PrmDefaultValue.DefaultIndex
  4433. HaveDefault='Y'
  4434. leave
  4435. end
  4436. end
  4437. if OptionDebugOn='Y' then
  4438. do
  4439. if HaveDefault='N' then
  4440. Ans='Oops - not user defined!'
  4441. else
  4442. Ans='Lucky!'
  4443. call DebugOutputVariableInfo_FOUNDVARPARMS Ans
  4444. call DebugIncrement-1
  4445. end
  4446. if HaveDefault='N' then
  4447. do
  4448. if ThisParmName<> '?' then
  4449. CryAndDie('The "' || StartsMacroParm || ThisParmName || EndsMacroParm || '" parameter was not supplied (and there is no default value)', '', 'Did you mean to use "' || HidesMacroParm || ThisParmName || EndsMacroParm || '" to hide the reference?',_MacroBitNotFoundText())
  4450. if OptionDebugOn='Y' then
  4451. call DebugOutputVariableInfo_FOUNDVARPARMS 'This is a special variable, value is all unused parms'
  4452. ReplaceParmWith=''
  4453. do ParmIndex=1 to ParmCount
  4454. if ParmName.ParmIndex<> '' then
  4455. do
  4456. if ParmUsed.ParmIndex='N' then
  4457. do
  4458. if ReplaceParmWith=='' then
  4459. LSPC=''
  4460. else
  4461. LSPC=' '
  4462. if ParmValueT.ParmIndex='nv' then
  4463. ReplaceParmWith=ReplaceParmWith||LSPC||ParmNameC.ParmIndex
  4464. else
  4465. do
  4466. if ParmCmds='' then
  4467. do
  4468. QChar=QuoteIt(ParmValue.ParmIndex)
  4469. ReplaceParmWith=ReplaceParmWith||LSPC||ParmNameC.ParmIndex|| '=' ||QChar||ParmValue.ParmIndex||QChar
  4470. end
  4471. else
  4472. do
  4473. ReplaceParmWith=ReplaceParmWith||LSPC||StartsMacroParm||ParmNameC.ParmIndex|| ' ' ||ParmCmds||EndsMacroParm
  4474. end
  4475. end
  4476. ParmUsed.ParmIndex='Y'
  4477. end
  4478. end
  4479. end
  4480. ParmCmds=''
  4481. end
  4482. end
  4483. end
  4484. if ParmCmds<> '' then
  4485. do
  4486. ParmCmds=translate(strip(ParmCmds))
  4487. do until ParmCmds=''
  4488. parse var ParmCmds ParmCmd ParmCmds
  4489. if OptionDebugOn='Y' then
  4490. do
  4491. call DebugIncrement 1
  4492. call DebugOutputVariableInfo_FOUNDVARPARMS '$Bef: ' ||ReplaceParmWith
  4493. call DebugOutputVariableInfo_FOUNDVARPARMS '$Cmd: ' ||ParmCmd
  4494. call DebugIncrement-1
  4495. end
  4496. select
  4497. when ParmCmd='$$PASSAQ' then
  4498. do
  4499. QChar=QuoteIt(ReplaceParmWith,TryQuoteListAny)
  4500. ReplaceParmWith=ThisParmName|| '=' ||QChar||ReplaceParmWith||QChar
  4501. end
  4502. when ParmCmd='$$PASSDSQ' then
  4503. do
  4504. QChar=QuoteIt(ReplaceParmWith,TryQuoteListDs)
  4505. ReplaceParmWith=ThisParmName|| '=' ||QChar||ReplaceParmWith||QChar
  4506. end
  4507. when ParmCmd='$$IGNORE' then
  4508. ReplaceParmWith=''
  4509.  
  4510. when ParmCmd='$$DSQ' then
  4511. do
  4512. QChar=QuoteIt(ReplaceParmWith,TryQuoteListDs)
  4513. ReplaceParmWith=QChar||ReplaceParmWith||QChar
  4514. end
  4515.  
  4516. when ParmCmd='$$SDQ' then
  4517. do
  4518. QChar=QuoteIt(ReplaceParmWith,TryQuoteListSd)
  4519. ReplaceParmWith=QChar||ReplaceParmWith||QChar
  4520. end
  4521.  
  4522. when ParmCmd='$$AQ' then
  4523. do
  4524. QChar=QuoteIt(ReplaceParmWith,TryQuoteListAny)
  4525. ReplaceParmWith=QChar||ReplaceParmWith||QChar
  4526. end
  4527.  
  4528. when ParmCmd='$$UPPER' then
  4529. ReplaceParmWith=translate(ReplaceParmWith)
  4530.  
  4531. when ParmCmd='$$LOWER' then
  4532. ReplaceParmWith=ToLowerCase(ReplaceParmWith)
  4533.  
  4534. when ParmCmd='$$ADDCOMMA' then
  4535. ReplaceParmWith=AddCommasToDecimalNumber(ReplaceParmWith)
  4536.  
  4537. when ParmCmd='$$HTMLQ' then
  4538. ReplaceParmWith=ReplaceString(ReplaceParmWith, '"', '"')
  4539.  
  4540. when ParmCmd='$$SQX2' then
  4541. ReplaceParmWith=ReplaceString(ReplaceParmWith, "'" , "''")
  4542.  
  4543. when ParmCmd='$$SPCPLUS' then
  4544. do
  4545. if ReplaceParmWith\=='' then
  4546. ReplaceParmWith=' ' ||ReplaceParmWith
  4547. end
  4548.  
  4549. otherwise
  4550. do
  4551. UserRexx=GetDefineValueOrUseDefault("REXX_" || ParmCmd, '')
  4552. if UserRexx='' then
  4553. CryAndDie('The $$ replacement command of "' || ParmCmd || '" is unknown!')
  4554. TheMacro=VariableName
  4555. TheName=ThisParmName
  4556. TheValue=ReplaceParmWith
  4557. call ExecRexxCmd UserRexx
  4558. if OptionDebugOn='Y' then
  4559. do
  4560. if ReplaceParmWith=TheValue then
  4561. do
  4562. call DebugIncrement 1
  4563. call DebugOutputVariableInfo_FOUNDVARPARMS 'The user rexx code did not modify the "TheValue" variable'
  4564. call DebugIncrement-1
  4565. end
  4566. end
  4567. ReplaceParmWith=TheValue
  4568. end
  4569. end
  4570. end
  4571. end
  4572. if OptionDebugOn='Y' then
  4573. do
  4574. call DebugIncrement 1
  4575. call DebugOutputVariableInfo_FOUNDVARPARMS 'Use : ' ||ReplaceParmWith
  4576. call DebugIncrement-1
  4577. end
  4578. ParmRightBit=ReplaceParmWith||ParmRightBit
  4579. ParmPos=pos(StartsMacroParm,ParmRightBit)
  4580. end
  4581. ParmLeftBit=ParmLeftBit||ParmRightBit
  4582. if OptionDebugOn='Y' then
  4583. do
  4584. do ParmIndex=1 to ParmCount
  4585. if ParmUsed.ParmIndex='N' then
  4586. call DebugOutputVariableInfo_FOUNDVARPARMS 'The "' || ParmName.ParmIndex  || '" parameter was not referred to by the "' || VariableName || '" macro (either invalid or referenced only in unused default value of another parameter).'
  4587. end
  4588. end
  4589. if pos('{',ParmLeftBit)<>0 then
  4590. do
  4591. if pos(StartsMacroParm,ParmLeftBit)<>0 then
  4592. CryAndDie('Not all "' || VariableName || '" parameters replaced!')
  4593. ParmLeftBit=ReplaceString(ParmLeftBit,HidesMacroParm,StartsMacroParm)
  4594. end
  4595. return(ParmLeftBit)
  4596.  
  4597. _ReplaceAllHashDefinedVariables:
  4598. RightBit=arg(1)
  4599. LeftBit=''
  4600. ChangesMade='N'
  4601. VarPos=pos(StartsMacroReplacement,RightBit)
  4602. do while VarPos<>0
  4603. LeftBit=LeftBit||left(RightBit,VarPos-1)
  4604. RightBit=substr(RightBit,VarPos+2)
  4605. DelPos=verify(RightBit,EndsVar, 'M')
  4606. if DelPos=0 then
  4607. CryAndDie("Can't find the end of the macro reference at " ||DebugRightArrow||StartsMacroReplacement||RightBit||DebugLeftArrow)
  4608. VariableName=left(RightBit,DelPos-1)
  4609. MacroBeingExpanded=VariableName
  4610. RightBit=strip(substr(RightBit,DelPos), 'L')
  4611. if OptionDebugOn='Y' then
  4612. do
  4613. call DebugOutputVariableInfo_FOUNDVAR 'Found : ' || StartsMacroReplacement || VariableName || ' ...' ||EndsMacroReplacement
  4614. call DebugIncrement 1
  4615. end
  4616. DefnAsIs='N'
  4617. VariableCont=GetDefineContents(VariableName)
  4618. if OptionDebugOn='Y' then
  4619. do
  4620. call DebugOutputVariableInfo_FOUNDVAR 'Value : ' ||DebugRightArrow||VariableCont||DebugLeftArrow
  4621. call DebugIncrement 1
  4622. end
  4623. ParmCount=0
  4624. PositionalParmCount=0
  4625. EndParmDelimiters=EndsMacroReplacement|| '= '
  4626. Left1=left(RightBit,1)
  4627. do while Left1<>EndsMacroReplacement
  4628. if pos(Left1,ArePositionalChars)<>0 then
  4629. do
  4630. PositionalParmCount=PositionalParmCount+1
  4631. ThisParmNameC='#' ||PositionalParmCount
  4632. if CsReplacement='N' then
  4633. ThisParmName=translate(ThisParmNameC)
  4634. else
  4635. ThisParmName=ThisParmNameC
  4636. ThisParmValType='v'
  4637. if Left1='=' then
  4638. ThisParmVal=GetQuotedText(substr(RightBit,2), "RightBit",EndsMacroReplacement)
  4639. else
  4640. ThisParmVal=GetQuotedText(RightBit, "RightBit",EndsMacroReplacement)
  4641. end
  4642. else
  4643. do
  4644. DelPos=verify(RightBit,EndParmDelimiters, 'M')
  4645. if DelPos=0 then
  4646. CryAndDie('Macro reference incorrectly formatted, missing "' || EndsMacroReplacement || '"?')
  4647. ThisParmNameC=strip(left(RightBit,DelPos-1))
  4648. if CsReplacement='N' then
  4649. ThisParmName=translate(ThisParmNameC)
  4650. else
  4651. ThisParmName=ThisParmNameC
  4652. DelChar=substr(RightBit,DelPos,1)
  4653. if DelChar='=' then
  4654. do
  4655. ThisParmVal=GetQuotedText(substr(RightBit,DelPos+1), "RightBit",EndsMacroReplacement)
  4656. ThisParmValType='v'
  4657. end
  4658. else
  4659. do
  4660. RightBit=strip(substr(RightBit,DelPos), 'L')
  4661. if left(ThisParmName,2)<> '$$' then
  4662. do
  4663. ThisParmVal=ThisParmName
  4664. ThisParmValType='nv'
  4665. end
  4666. else
  4667. do
  4668. if OptionDebugOn='Y' then
  4669. call DebugOutputVariableInfo_FOUNDVARPARMS '$$Cmd: ' ||ThisParmName
  4670. select
  4671. when ThisParmName='$$ASIS' then
  4672. DefnAsIs='Y'
  4673.  
  4674. when ThisParmName='$$DSQ' then
  4675. do
  4676. QChar=QuoteIt(VariableCont,TryQuoteListDs)
  4677. VariableCont=QChar||VariableCont||QChar
  4678. end
  4679.  
  4680. when ThisParmName='$$SDQ' then
  4681. do
  4682. QChar=QuoteIt(VariableCont,TryQuoteListSd)
  4683. VariableCont=QChar||VariableCont||QChar
  4684. end
  4685.  
  4686. when ThisParmName='$$AQ' then
  4687. do
  4688. QChar=QuoteIt(VariableCont,TryQuoteListAny)
  4689. VariableCont=QChar||VariableCont||QChar
  4690. end
  4691.  
  4692. when ThisParmName='$$UPPER' then
  4693. VariableCont=translate(VariableCont)
  4694.  
  4695. when ThisParmName='$$LOWER' then
  4696. VariableCont=ToLowerCase(VariableCont)
  4697.  
  4698. when ThisParmName='$$ADDCOMMA' then
  4699. VariableCont=AddCommasToDecimalNumber(VariableCont)
  4700.  
  4701. when ThisParmName='$$HTMLQ' then
  4702. VariableCont=ReplaceString(VariableCont, '"', '"')
  4703.  
  4704. when ThisParmName='$$SQX2' then
  4705. VariableCont=ReplaceString(VariableCont, "'" , "''")
  4706.  
  4707. when ThisParmName='$$SPCPLUS' then
  4708. do
  4709. if VariableCont\=='' then
  4710. VariableCont=' ' ||VariableCont
  4711. end
  4712.  
  4713. otherwise
  4714. do
  4715. UserRexx=GetDefineValueOrUseDefault("REXX_" || ThisParmName, '')
  4716. if UserRexx='' then
  4717. CryAndDie('The $$ replacement command of "' || ThisParmName || '" is unknown!')
  4718. TheMacro=""
  4719. TheName=VariableName
  4720. TheValue=VariableCont
  4721. call ExecRexxCmd UserRexx
  4722. if OptionDebugOn='Y' then
  4723. do
  4724. if VariableCont=TheValue then
  4725. do
  4726. call DebugIncrement 1
  4727. call DebugOutputVariableInfo_FOUNDVARPARMS 'The user rexx code did not modify the "TheValue" variable'
  4728. call DebugIncrement-1
  4729. end
  4730. end
  4731. VariableCont=TheValue
  4732. end
  4733. end
  4734. iterate
  4735. end
  4736. end
  4737. end
  4738. do ChkIndex=1 to ParmCount
  4739. if ThisParmName=ParmName.ChkIndex then
  4740. CryAndDie('The macro parameter "' || ThisParmName || '" was specified more than once!')
  4741. end
  4742. ParmCount=ParmCount+1
  4743. ParmName.ParmCount=ThisParmName
  4744. ParmNameC.ParmCount=ThisParmNameC
  4745. ParmValue.ParmCount=ThisParmVal
  4746. ParmValueT.ParmCount=ThisParmValType
  4747. Left1=left(RightBit,1)
  4748. end
  4749. if DefnAsIs='Y' then
  4750. do
  4751. if ParmCount<>0 then
  4752. CryAndDie('You wanted "' || VariableName || '" subsituted ASIS but then specified parameters!')
  4753. end
  4754. else
  4755. do
  4756. if ParmCount<>0 then
  4757. VariableCont=ReplaceDefinitionsParameters()
  4758. else
  4759. do
  4760. if pos(StartsMacroParm,VariableCont)<>0 then
  4761. VariableCont=ReplaceDefinitionsParameters()
  4762. else
  4763. VariableCont=ReplaceString(VariableCont,HidesMacroParm,StartsMacroParm)
  4764. end
  4765. end
  4766. if OptionDebugOn='Y' then
  4767. call DebugIncrement-2
  4768. RightBit=substr(RightBit,2)
  4769. LeftBit=LeftBit||VariableCont
  4770. ReplaceCount=ReplaceCount+1
  4771. if pos(MarksNewLine,LeftBit)<>0 then
  4772. leave
  4773. VarPos=pos(StartsMacroReplacement,RightBit)
  4774. end
  4775. MacroBeingExpanded=''
  4776. TheString=LeftBit||RightBit
  4777. return(TheString)
  4778.  
  4779. GetDefineValueOrUseDefault:
  4780. DefVar=arg(1)
  4781. if VariableExists(DefVar)='N' then
  4782. do
  4783. DefValue=arg(2)
  4784. DefDbgWrd='not'
  4785. end
  4786. else
  4787. do
  4788. DefValue=GetDefineContents(DefVar)
  4789. DefDbgWrd='was'
  4790. end
  4791. if OptionDebugOn='Y' then
  4792. call DebugLine_MACROVALORDEF 'Option(Macro) "' || DefVar || '" ' || DefDbgWrd || ' found. Using ' ||DebugRightArrow||DefValue||DebugLeftArrow
  4793. return(DefValue)
  4794.  
  4795. Define_22:
  4796. RexxTokens='|=+-/%*<>\,;:()&'
  4797. signal LineOut_23
  4798.  
  4799. GenerateOneLine:
  4800. if CondNlCount=0 then
  4801. call GenerateOneLineAsIs arg(1)
  4802. else
  4803. do
  4804. if OptionDebugOn='Y' then
  4805. call DebugLine 'Looking for Conditional newline codes'
  4806. BefCodeCount=ReplaceCount
  4807. Line2Gen=ReplaceString(arg(1), "{?WaNtNl?}",MarksNewLine)
  4808. if BefCodeCount<>ReplaceCount then
  4809. do
  4810. if OptionDebugOn='Y' then
  4811. call DebugLine 'Found ' ReplaceCount - BefCodeCount || ' conditional newline codes'
  4812. CondNlCount=CondNlCount-(ReplaceCount-BefCodeCount)
  4813. do until BefCodeCount=ReplaceCount
  4814. BefCodeCount=ReplaceCount
  4815. Line2Gen=ReplaceString(Line2Gen,MarksNewLine||MarksNewLine,MarksNewLine)
  4816. end
  4817. if left(Line2Gen,1)=MarksNewLine then
  4818. Line2Gen=substr(Line2Gen,2)
  4819. if right(Line2Gen,1)=MarksNewLine then
  4820. Line2Gen=left(Line2Gen,length(Line2Gen)-1)
  4821. end
  4822. do until Line2Gen==''
  4823. parse var Line2Gen This1 (MarksNewLine) Line2Gen
  4824. call GenerateOneLineAsIs This1
  4825. end
  4826. end
  4827. return
  4828.  
  4829. GenerateOneLineAsIs:
  4830. Line2Gen2=arg(1)
  4831. if CheckSpelling='Y';then
  4832. do
  4833. if AllowSpell='Y' & Line2Gen2 <> '' then
  4834. call SpellCheckOneLine Line2Gen2
  4835. end
  4836. if OptionFilterOut='' then
  4837. do
  4838. if HoldingOutput='N' then
  4839. call DirectToOutputFile Line2Gen2||NewLineChars
  4840. else
  4841. HeldOutput=HeldOutput||Line2Gen2||NewLineChars
  4842. GeneratedLines=GeneratedLines+1
  4843. CurrentOutLine=CurrentOutLine+1
  4844. end
  4845. else
  4846. do
  4847. FilterRc=HtmlFilterOut("O",Line2Gen2,CurrentOutFile,CurrentOutLine,GeneratedLines,NewLineChars)
  4848. if Left(FilterRc,3)<> "OK:" then
  4849. CryAndDie(FilterRc)
  4850. else
  4851. do
  4852. NumWritten=substr(FilterRc,4)
  4853. GeneratedLines=GeneratedLines+NumWritten
  4854. CurrentOutLine=CurrentOutLine+NumWritten
  4855. end
  4856. end
  4857. return
  4858.  
  4859. DirectToOutputFile:
  4860. if 0=charout(CurrentOutFile,arg(1))then
  4861. return
  4862. IoReason=stream(CurrentOutFile, 'Description')
  4863. CryAndDie('Write to "' || CurrentOutFile || '" failed (' || IoReason || ')!')
  4864.  
  4865. OutputRexxLine:
  4866. RexxLine=arg(1)
  4867. if right(RexxLine,1)=';' then
  4868. RexxLine=left(RexxLine,length(RexxLine)-1)
  4869. if OptionPack='Y' & KeepIndent = 'N' then
  4870. do
  4871. if AllowPack='Y' then
  4872. RexxLine=CompressRexxLine(RexxLine)
  4873. else
  4874. do
  4875. if OptionDebugOn='Y' then
  4876. call DebugLine 'Not allowed to pack this line'
  4877. end
  4878. end
  4879. ElPos=pos(':',RexxLine)
  4880. if ElPos<>0 then
  4881. do
  4882. PossLabel=strip(left(RexxLine,ElPos-1))
  4883. if datatype(PossLabel, 'S')=1 then
  4884. call GenerateOneLine ''
  4885. end
  4886. if pos(NotEqualInC,RexxLine)<>0 then
  4887. call OutputInformationToScreen '"' || NotEqualInC || '" found.  Did you mean to use "<>" or "\="?'
  4888. call GenerateOneLine RexxLine
  4889. return
  4890.  
  4891. CompressRexxLine:
  4892. RexxLine=arg(1)
  4893. Spos=lastpos("'",RexxLine)
  4894. Dpos=lastpos('"',RexxLine)
  4895. EndPos=max(Spos,Dpos)
  4896. if EndPos=0 then
  4897. return(_CompressRexx(RexxLine))
  4898. else
  4899. do
  4900. Spos=pos("'",RexxLine)
  4901. Dpos=pos('"',RexxLine)
  4902. StartPos=min(Spos,Dpos)
  4903. if StartPos=0 then
  4904. StartPos=max(Spos,Dpos)
  4905. LeftBit=left(RexxLine,StartPos-1)
  4906. RightBit=substr(RexxLine,EndPos+1)
  4907. if right(LeftBit,1, "*") == ' ' then
  4908. LeftSpace=' '
  4909. else
  4910. LeftSpace=''
  4911. if left(RightBit,1, "*") == ' ' then
  4912. RightSpace=' '
  4913. else
  4914. RightSpace=''
  4915. LeftBit=_CompressRexx(LeftBit)
  4916. RightBit=_CompressRexx(RightBit)
  4917. if LeftSpace==' ' then
  4918. do
  4919. if right(LeftBit,1)='=' then
  4920. LeftSpace=''
  4921. end
  4922. LeftBit=_CompressRexx(LeftBit)
  4923. RightBit=_CompressRexx(RightBit)
  4924. return(LeftBit||LeftSpace||substr(RexxLine,StartPos,(EndPos-StartPos)+1)||RightSpace||RightBit)
  4925. end
  4926.  
  4927. _CompressRexx:
  4928. ToCompress=space(arg(1))
  4929. Compressed=''
  4930. TokenPos=verify(ToCompress,RexxTokens, 'M')
  4931. do while TokenPos<>0
  4932. Compressed=Compressed||strip(left(ToCompress,TokenPos-1), 'T')||substr(ToCompress,TokenPos,1)
  4933. ToCompress=strip(substr(ToCompress,TokenPos+1), 'L')
  4934. TokenPos=verify(ToCompress,RexxTokens, 'M')
  4935. end
  4936. return(Compressed||ToCompress)
  4937.  
  4938. LineOut_23:
  4939. call InitializeOneLine
  4940. signal OneLine_24
  4941.  
  4942. InitializeOneLine:
  4943. OneLineOn='N'
  4944. OneLineCount=0
  4945. OneLineBuffer=''
  4946. OneLineSeperator=''
  4947. OneLineStartLoc=''
  4948. OneLineStopper=''
  4949. OneLineStopperL=0
  4950. return
  4951.  
  4952. AddToOneLine:
  4953. _OneLineBit=arg(1)
  4954. _Word1=word(_OneLineBit,1)
  4955. if strip(_OneLineBit)<>OneLineStopper then
  4956. do
  4957. OneLineCount=OneLineCount+1
  4958. if OneLineCount=1 then
  4959. do
  4960. if translate(left(_Word1,length(CmdHashDefine)))=CmdHashDefine then
  4961. do
  4962. _OneLineBit=_OneLineBit|| ' '
  4963. PpwCmdDivider2=MarksNewLineInHashDefine
  4964. end
  4965. else
  4966. PpwCmdDivider2=MarksNewLine
  4967. OneLineBuffer=_OneLineBit
  4968. end
  4969. else
  4970. do
  4971. if left(_Word1,HashPrefixLng)<>HashPrefix then
  4972. OneLineBuffer=OneLineBuffer||OneLineSeperator||_OneLineBit
  4973. else
  4974. do
  4975. parse var _OneLineBit _ppwCmd _ppwCmdParm
  4976. _OneLineBit=_ppwCmd|| ' ' ||strip(_ppwCmdParm)
  4977. OneLineBuffer=OneLineBuffer||PpwCmdDivider2||_OneLineBit||PpwCmdDivider2
  4978. end
  4979. end
  4980. return('')
  4981. end
  4982. _OneLineBit=OneLineBuffer
  4983. if OptionDebugOn='Y' then
  4984. call DebugLine 'End of #OneLine block - ' || OneLineCount || ' line(s)'
  4985. call InitializeOneLine
  4986. return(_OneLineBit)
  4987.  
  4988. ProcessOneLine:
  4989. OneLineOn='Y'
  4990. OneLineStartLoc=CurrentSourceLocation()
  4991. Rest=PerformReplacementsInCmdsParameters(arg(1))
  4992. if Rest='' then
  4993. OneLineSeperator=' '
  4994. else
  4995. do
  4996. OneLineSeperator=GetQuotedText(Rest, "Rest")
  4997. end
  4998. if Rest='' then
  4999. OneLineStopper=HashPrefix|| 'OneLineEnd'
  5000. else
  5001. OneLineStopper=GetQuotedText(Rest)
  5002. OneLineStopperL=length(OneLineStopper)
  5003. if OptionDebugOn='Y' then
  5004. do
  5005. call DebugLine 'Line seperator      = ' ||DebugRightArrow||OneLineSeperator||DebugLeftArrow
  5006. call DebugLine 'End of block marker = ' || DebugRightArrow || OneLineStopper   || DebugLeftArrow || ' (case sensitive!)'
  5007. end
  5008. return(0)
  5009.  
  5010. OneLine_24:
  5011. signal Evaluate_25
  5012.  
  5013. _ScaleSide:
  5014. parse arg SideBefore,SideScale
  5015. PercentPos=pos('%',SideScale)
  5016. if PercentPos=0 then
  5017. return(SideScale)
  5018. else
  5019. return((SideBefore*left(SideScale,PercentPos-1))%100)
  5020.  
  5021. _GetSizeTags:
  5022. if OptionDebugOn='Y' then
  5023. do
  5024. call DebugIncrement 1
  5025. call DebugLine_EVALUATE 'Real size = ' || ImageWidth || 'x' ||ImageHeight
  5026. call DebugIncrement-1
  5027. end
  5028. if ImgScaleW='?' | ImgScaleH = '?' then
  5029. do
  5030. if ImgScaleW='?' then
  5031. do
  5032. NewHeight=_ScaleSide(ImageHeight,ImgScaleH)
  5033. ImgScaleW=(NewHeight*100)%ImageHeight|| '%'
  5034. NewWidth=_ScaleSide(ImageWidth,ImgScaleW)
  5035. end
  5036. else
  5037. do
  5038. NewWidth=_ScaleSide(ImageWidth,ImgScaleW)
  5039. ImgScaleH=(NewWidth*100)%ImageWidth|| '%'
  5040. NewHeight=_ScaleSide(ImageHeight,ImgScaleH)
  5041. end
  5042. end
  5043. else
  5044. do
  5045. NewWidth=_ScaleSide(ImageWidth,ImgScaleW)
  5046. NewHeight=_ScaleSide(ImageHeight,ImgScaleH)
  5047. end
  5048. return('WIDTH=' || NewWidth || ' HEIGHT=' ||NewHeight)
  5049.  
  5050. _GetGifSize:
  5051. parse arg GifFile,ImgScaleW,ImgScaleH
  5052. GifFormatId=charin(GifFile,1,6)
  5053. if left(GifFormatId,3)<> "GIF" then
  5054. do
  5055. CloseRc=stream(GifFile, 'c', 'close')
  5056. CryAndDie('"' || GifFile || '" is not a ".GIF" file.', 'ID=x' ||c2x(GifFormatId))
  5057. end
  5058. WidthLow=charin(GifFile,,1)
  5059. WidthHigh=charin(GifFile,,1)
  5060. ImageWidth=c2d(WidthHigh||WidthLow)
  5061. HeightLow=charin(GifFile,,1)
  5062. HeightHigh=charin(GifFile,,1)
  5063. ImageHeight=c2d(HeightHigh||HeightLow)
  5064. CloseRc=stream(GifFile, 'c', 'close')
  5065. return(_GetSizeTags())
  5066.  
  5067. _GetPngSize:
  5068. parse arg PngFile,ImgScaleW,ImgScaleH
  5069. PngFormatId=charin(PngFile,1,8)
  5070. if PngFormatId\='89'x || 'PNG' || '0D 0A 1A 0A'x then
  5071. do
  5072. CloseRc=stream(PngFile, 'c', 'close')
  5073. CryAndDie('"' || PngFile || '" is not a ".PNG" file.', 'ID#1=x' ||c2x(PngFormatId))
  5074. end
  5075. PngFormatId=charin(PngFile,,4)
  5076. PngFormatId=charin(PngFile,,4)
  5077. if PngFormatId\='IHDR' then
  5078. do
  5079. CloseRc=stream(PngFile, 'c', 'close')
  5080. CryAndDie('"' || PngFile || '" is not a ".PNG" file.', 'ID#2=x' ||c2x(PngFormatId))
  5081. end
  5082. ImageWidth=c2d(charin(PngFile,,4))
  5083. ImageHeight=c2d(charin(PngFile,,4))
  5084. CloseRc=stream(PngFile, 'c', 'close')
  5085. return(_GetSizeTags())
  5086.  
  5087. _GetJpgSize:
  5088. parse arg JpgFile,ImgScaleW,ImgScaleH
  5089. FileType=c2x(Charin(JpgFile,1,2))
  5090. if FileType<> "FFD8" then
  5091. do
  5092. CloseRc=stream(JpgFile, 'c', 'close')
  5093. CryAndDie('"' || JpgFile || '" is not a ".JPG" file.', 'ID=x' ||c2x(FileType))
  5094. end
  5095. NxtSeg=3
  5096. ImageHeight="IMAGEHEIGHT"
  5097. Type=''
  5098. do while(Type<> "D9") & (NxtSeg <> -1) & (Imageheight = "IMAGEHEIGHT")
  5099. NxtSeg=_ReadJpgSegment(NxtSeg)
  5100. end
  5101. CloseRc=stream(JpgFile, 'c', 'close')
  5102. return(_GetSizeTags())
  5103.  
  5104. _ReadJpgSegment:
  5105. SegPos=arg(1)
  5106. Marker=c2x(charIn(JpgFile,SegPos))
  5107. if Marker<> "FF" then
  5108. return(-1)
  5109. Type=c2x(charIn(JpgFile))
  5110. Res=SegPos+2
  5111. select
  5112. when Type="01" | Type >= "D0" & Type <= "D9" then
  5113. SegmentLength=0
  5114. otherwise
  5115. SegmentLength=c2d(CharIn(JpgFile,,2))
  5116. End
  5117. Res=Res+SegmentLength
  5118. if Type="C0" | Type = "C2" then
  5119. do
  5120. Imagebps=c2d(CharIn(JpgFile))
  5121. ImageHeight=c2d(CharIn(JpgFile,,2))
  5122. ImageWidth=c2d(CharIn(JpgFile,,2))
  5123. end
  5124. return(Res)
  5125.  
  5126. GetImageHeightWidth:call TRACE "OFF"
  5127. parse arg ImageFile,ImageScaleW,ImageScaleH
  5128. if ImageScaleW='' then
  5129. ImageScaleW='100%'
  5130. if ImageScaleH='' then
  5131. ImageScaleH='?'
  5132. if OptionDebugOn='Y' then
  5133. call DebugLine_EVALUATE 'GetImageHeightWidth("' || ImageFile || '", "' || ImageScaleW || '", "' || ImageScaleH || '")'
  5134. DotPos=lastpos('.',ImageFile)
  5135. if DotPos=0 then
  5136. CryAndDie('Unknown graphic file type on "' || ImageFile || '".')
  5137. ImageExtn=translate(substr(ImageFile,DotPos+1))
  5138. if SafeQueryExists(ImageFile)='' then
  5139. do
  5140. CryAndDie('Graphic file "' || ImageFile || '" does not exist.')
  5141. return('')
  5142. end
  5143. call DebugIncrement 1
  5144. select
  5145. when ImageExtn='GIF' then
  5146. SizeString=_GetGifSize(ImageFile,ImageScaleW,ImageScaleH)
  5147. when ImageExtn='PNG' then
  5148. SizeString=_GetPngSize(ImageFile,ImageScaleW,ImageScaleH)
  5149. when ImageExtn='JPG' then
  5150. SizeString=_GetJpgSize(ImageFile,ImageScaleW,ImageScaleH)
  5151. otherwise
  5152. CryAndDie('Currently only support ".GIF" & ".JPG" files.')
  5153. end
  5154. if OptionDebugOn='Y' then
  5155. call DebugLine_EVALUATE 'Returning "' || SizeString || '"'
  5156. call DebugIncrement-1
  5157. return(SizeString)
  5158.  
  5159. ToLowerCase:call TRACE "OFF"
  5160. return(translate(arg(1),LowerCase,UpperCase))
  5161.  
  5162. EnsureFileHasCorrectCase:call TRACE "OFF"
  5163. cFileI=arg(1)
  5164. if OptionTranslateFileNames='N' then
  5165. return(cFileI)
  5166. if OptionTranslateFileNames='UPPER' then
  5167. cFileO=translate(cFileI)
  5168. else
  5169. cFileO=ToLowerCase(cFileI)
  5170. if OptionDebugOn='Y' then
  5171. do
  5172. if cFileI<>cFileO then
  5173. do
  5174. call DebugLine_EVALUATE 'A files case was adjusted'
  5175. call DebugIncrement 1
  5176. call DebugLine_EVALUATE 'FROM: "' || cFileI || '"'
  5177. call DebugLine_EVALUATE '  TO: "' || cFileO || '"'
  5178. call DebugIncrement-1
  5179. end
  5180. end
  5181. return(cFileO)
  5182.  
  5183. MakeDirectoryTree:call TRACE "OFF"
  5184. WholeDirectory=arg(1)
  5185. if right(WholeDirectory,1)=RexDirChar then
  5186. WholeDirectory=left(WholeDirectory,length(WholeDirectory)-1)
  5187. if WholeDirectory='' then
  5188. return(0)
  5189. if OptionDebugOn='Y' then
  5190. do
  5191. call DebugLine 'MakeDirectoryTree("' || WholeDirectory || '")'
  5192. call DebugIncrement 1
  5193. end
  5194. if RexWhich='REGINA' then
  5195. do
  5196. if stream(WholeDirectory|| '\.', 'c', 'query exists') <> '' then
  5197. do
  5198. if OptionDebugOn='Y' then
  5199. do
  5200. call DebugLine 'Directory already exists (no need to make)'
  5201. call DebugIncrement-1
  5202. end
  5203. return(0)
  5204. end
  5205. end
  5206. else
  5207. do
  5208. if OptionDebugOn='Y' then
  5209. call DebugLine "Don't know if directory already exists"
  5210. end
  5211. if RexSystemOpSys="UNIX" then
  5212. MakeDirCmd='mkdir '
  5213. else
  5214. MakeDirCmd='md '
  5215. SearchFromPosn=1
  5216. do until SlashPosn=0
  5217. SlashPosn=pos(RexDirChar,WholeDirectory,SearchFromPosn)
  5218. if SlashPosn<>1 then
  5219. do
  5220. if SlashPosn=0 then
  5221. MakeDir=WholeDirectory
  5222. else
  5223. MakeDir=left(WholeDirectory,SlashPosn-1)
  5224. if right(MakeDir,1)<> ':' then
  5225. do
  5226. if OptionDebugOn='N' then
  5227. call AddressCmd MakeDirCmd||MakeDir||AllCmdOutput2Nul()
  5228. else
  5229. do
  5230. TmpMkDirFile=RexGetTmpFileName()
  5231. call AddressCmd MakeDirCmd||MakeDir||RedirectStdOutAndErr2(TmpMkDirFile),TmpMkDirFile
  5232. if Rc=0 then
  5233. call DebugLine 'Made Directory "' || MakeDir || '"'
  5234. call _SysFileDelete TmpMkDirFile
  5235. end
  5236. end
  5237. end
  5238. SearchFromPosn=SlashPosn+1
  5239. end
  5240. if OptionDebugOn='Y' then
  5241. call DebugIncrement-1
  5242. return(0)
  5243.  
  5244. GetAmPmTime:call TRACE "OFF"
  5245. CivilTime=time('C');  if length(CivilTime)  = 6 then CivilTime=' 'CivilTime
  5246. TheTime=time();NumSeconds=':'substr(TheTime,7,2)
  5247. return(insert(NumSeconds,CivilTime,5))
  5248.  
  5249. AddCommasToDecimalNumber:procedure;call TRACE "OFF"
  5250. NoComma=strip(arg(1))
  5251. if pos(',',NoComma)<>0 then
  5252. return(NoComma)
  5253. DotPos=pos('.',NoComma)
  5254. if DotPos=0 then
  5255. AfterDecimal=''
  5256. else
  5257. do
  5258. if DotPos=1 then
  5259. return("0" ||NoComma)
  5260. AfterDecimal=substr(NoComma,DotPos+1)
  5261. NoComma=left(NoComma,DotPos-1)
  5262. end
  5263. NoComma=reverse(NoComma)
  5264. ResultWithCommas=""
  5265. do while length(NoComma)>3
  5266. ResultWithCommas=ResultWithCommas||left(NoComma,3)|| ','
  5267. NoComma=substr(NoComma,4)
  5268. end
  5269. ResultWithCommas=ResultWithCommas||NoComma
  5270. ResultWithCommas=reverse(ResultWithCommas)
  5271. if AfterDecimal<> '' then
  5272. ResultWithCommas=ResultWithCommas|| '.' ||AfterDecimal
  5273. return(ResultWithCommas)
  5274.  
  5275. PadString:procedure;call TRACE "OFF"
  5276. parse arg TheString,TheMaxSize,PadType
  5277. StringSize=length(TheString)
  5278. if StringSize>=TheMaxSize then
  5279. return(TheString)
  5280. SpacesRequired=TheMaxSize-StringSize
  5281. if PadType='R' then
  5282. return(copies(' ',SpacesRequired)||TheString)
  5283. else
  5284. do
  5285. if PadType<> 'C' then
  5286. return(TheString||copies(' ',SpacesRequired))
  5287. else
  5288. do
  5289. SpacesOnLeft=SpacesRequired%2
  5290. return(copies(' ', SpacesOnLeft) || TheString || copies(' ',SpacesRequired-SpacesOnLeft))
  5291. end
  5292. end
  5293.  
  5294. BreakAt:call TRACE "OFF"
  5295. parse arg baMaxSize,baString,baChars,baBreakWith
  5296. if baChars='' then
  5297. baChars='./:#'
  5298. if baBreakWith='' then
  5299. baBreakWith='<BR>'
  5300. baPos=pos('-',baMaxSize)
  5301. if baPos=0 then
  5302. baMinSize=baMaxSize%3
  5303. else
  5304. parse var baMaxSize baMinSize'-'baMaxSize
  5305. baReturn=''
  5306. do while length(baString)>baMaxSize
  5307. baLeftBit=left(baString,baMaxSize)
  5308. baString=substr(baString,baMaxSize+1)
  5309. baBestPos=0
  5310. baCharList=baChars
  5311. do while baCharList<> ''
  5312. baThisChar=left(baCharList,1)
  5313. baCharList=substr(baCharList,2)
  5314. baThisPos=lastpos(baThisChar,baLeftBit)
  5315. if baThisPos>baBestPos then
  5316. do
  5317. baBestPos=baThisPos
  5318. end
  5319. end
  5320. if baReturn<> '' then
  5321. baReturn=baReturn||baBreakWith
  5322. if baBestPos=0 then
  5323. baReturn=baReturn||baLeftBit
  5324. else
  5325. do
  5326. baReturn=baReturn||left(baLeftBit,baBestPos)
  5327. baString=substr(baLeftBit,baBestPos+1)||baString
  5328. end
  5329. end
  5330. if baReturn<> '' then
  5331. return(baReturn||baBreakWith||baString)
  5332. else
  5333. return(baReturn||baString)
  5334.  
  5335. GetMacro:call TRACE "OFF"
  5336. call WarnAboutDepreciatedFeature 'GetMacro(). Replace with "MacroGet()"'
  5337.  
  5338. MacroGet:call TRACE "OFF"
  5339. GotValue=GetDefineContents(arg(1))
  5340. if OptionDebugOn='Y' then
  5341. call DebugLine_EVALUATE 'MacroGet("' || arg(1) || '") = ' ||DebugRightArrow||GotValue||DebugLeftArrow
  5342. return(GotValue)
  5343.  
  5344. Defined:call TRACE "OFF"
  5345. DefinedAnswer=VariableExists(arg(1))
  5346. if OptionDebugOn='Y' then
  5347. call DebugLine_EVALUATE 'Defined("' || arg(1) || '") = "' || DefinedAnswer || '"'
  5348. return(DefinedAnswer)
  5349.  
  5350. DataSave:call TRACE "OFF"
  5351. parse arg StoreApp,StoreKey,StoreData
  5352. call _valueS "AP?" || c2x(StoreApp) || '.KY?' ||c2x(StoreKey),StoreData
  5353. return
  5354.  
  5355. DataGet:call TRACE "OFF"
  5356. parse arg StoreApp,StoreKey,StoreDefault
  5357. DataVarName="AP?" || c2x(StoreApp) || '.KY' ||c2x(StoreKey)
  5358. if symbol(DataVarName)<> 'VAR' then
  5359. return(StoreDefault)
  5360. else
  5361. return(_valueG(DataVarName))
  5362.  
  5363. UrlEncode:call TRACE "OFF"
  5364. UrlIn=arg(1)
  5365. ueCmd=translate(arg(2))
  5366. SpaceToPlus='N'
  5367. select
  5368. when ueCmd='TO%' then
  5369. do
  5370. UrlBadChars=arg(3)
  5371. if UrlBadChars=='' then
  5372. UrlBadChars='+<>%"/?# '
  5373. end
  5374. when ueCmd='ENCODEALL' then
  5375. UrlBadChars=xrange('00'x, 'FF'x)
  5376. otherwise
  5377. CryAndDie('Invalid UrlEncode() command of "' || ueCmd || '"')
  5378. end
  5379. UrlOut=''
  5380. UrlCount=length(UrlIn)
  5381. do CharPosn=1 to UrlCount
  5382. ThisChar=substr(UrlIn,CharPosn,1)
  5383. if pos(ThisChar,UrlBadChars)=0 then
  5384. UrlOut=UrlOut||ThisChar
  5385. else
  5386. do
  5387. if ThisChar==' ' & SpaceToPlus = 'Y' then
  5388. UrlOut=UrlOut|| '+'
  5389. else
  5390. UrlOut=UrlOut|| '%' || right(c2x(ThisChar), 2, '0')
  5391. end
  5392. end
  5393. return(UrlOut)
  5394.  
  5395. UrlDecode:call TRACE "OFF"
  5396. parse arg UrlIn,udCmd
  5397. UrlPlusIsSpace='Y'
  5398. if udCmd<> '' then
  5399. do
  5400. if translate(udCmd)='LEAVE+' then
  5401. UrlPlusIsSpace='N'
  5402. else
  5403. CryAndDie('Invalid UrlDecode() command of "' || udCmd || '"')
  5404. end
  5405. UrlOut=''
  5406. CharPosn=1
  5407. UrlCount=length(UrlIn)
  5408. do while CharPosn<=UrlCount
  5409. ThisChar=substr(UrlIn,CharPosn,1)
  5410. CharPosn=CharPosn+1
  5411. if UrlPlusIsSpace<> 'N' & ThisChar = '+' then
  5412. ThisChar=' '
  5413. else
  5414. do
  5415. if ThisChar='%' then
  5416. do
  5417. ThisChar=substr(UrlIn,CharPosn,2)
  5418. CharPosn=CharPosn+2
  5419. if CharPosn>(UrlCount+1)then
  5420. CryAndDie('Invalid URL encoding of "%' || strip(ThisChar) || '" at end of URL')
  5421. ThisChar=x2c(ThisChar)
  5422. end
  5423. end
  5424. UrlOut=UrlOut||ThisChar
  5425. end
  5426. return(UrlOut)
  5427.  
  5428. QuoteIt:call TRACE "OFF"
  5429. parse arg Quote4,TryQuotes
  5430. if TryQuotes='' then
  5431. TryQuotes='"' || "'"
  5432. TryQuoteLng=length(TryQuotes)
  5433. do QuoteIndex=1 to TryQuoteLng
  5434. PossibleQuote=substr(TryQuotes,QuoteIndex,1)
  5435. if pos(PossibleQuote,Quote4)=0 then
  5436. return(PossibleQuote)
  5437. end
  5438. CryAndDie('QuoteIt(): Could not find safe quote for ' ||DebugRightArrow||Quote4||DebugLeftArrow)
  5439.  
  5440. GetFileTimeStamp:call TRACE "OFF"
  5441. FileName=arg(1)
  5442. if OptionDebugOn='Y' then
  5443. do
  5444. call DebugLine_EVALUATE 'GetFileTimeStamp("' || FileName || '")'
  5445. call DebugIncrement 1
  5446. end
  5447. SortableTime=FileInMemoryTimeStamp(FileName)
  5448. if SortableTime='' then
  5449. do
  5450. FileTime=stream(FileName, 'c', 'query datetime')
  5451. if OptionDebugOn='Y' then
  5452. call DebugLine_EVALUATE 'Is time stamped : "' || FileTime || '"'
  5453. if FileTime='' then
  5454. do
  5455. call OutputWarningToScreen 'TS00', '"' || FileName || '" does not exist.'
  5456. if OptionDebugOn='Y' then
  5457. call DebugIncrement-1
  5458. return(-1)
  5459. end
  5460. FileTime=space(FileTime)
  5461. parse var FileTime Month'-'Day'-'Year' 'Hour':'Minute':'Second
  5462. if Year<80 then
  5463. Year=100+Year
  5464. Year=1900+Year
  5465. SortableTime=Year||Month||Day||Hour||Minute||Second
  5466. end
  5467. if OptionDebugOn='Y' then
  5468. do
  5469. call DebugLine_EVALUATE 'Returning       : "' || SortableTime || '"'
  5470. call DebugIncrement-1
  5471. end
  5472. return(SortableTime)
  5473.  
  5474. BaseDate:Procedure;call TRACE "OFF"
  5475. TheDate=translate(arg(1), ' ', '/-')
  5476. if TheDate='' then
  5477. TheDate=date('Sorted')
  5478. parse var TheDate Year MM DD
  5479. if length(Year)>=8 then
  5480. do
  5481. DD=substr(Year,7,2)
  5482. MM=substr(Year,5,2)
  5483. Year=left(Year,4)
  5484. end
  5485. DaysInMonth='31  28  31  30  31  30  31  31  30  31  30  31'
  5486. if datatype(Year, 'WholeNumber')<>1 then
  5487. return(-10)
  5488. if datatype(MM, 'WholeNumber')<>1 then
  5489. return(-20)
  5490. if datatype(DD, 'WholeNumber')<>1 then
  5491. return(-30)
  5492. if MM<0|MM>12 then
  5493. return(-21)
  5494. DaysThisMonth=word(DaysInMonth,MM)
  5495. if MM=2 then
  5496. DaysThisMonth=DaysThisMonth+1
  5497. if DD<0|DD>DaysThisMonth then
  5498. return(-31)
  5499. if length(strip(Year))=2 then
  5500. do
  5501. if Year>=80 then
  5502. Year='19' ||Year
  5503. else
  5504. Year='20' ||Year
  5505. end
  5506. y=Year-0001
  5507. b=y*365
  5508. b=b+y%4
  5509. b=b-y%100
  5510. b=b+y%400
  5511. m=mm-01
  5512. do i=1 to m
  5513. b=b+word(DaysInMonth,i)
  5514. end
  5515. if mm>2 then
  5516. do
  5517. if 0=Year//4 then
  5518. do
  5519. if 0=Year//100 then
  5520. do
  5521. if 0=Year//400 then
  5522. b=b+1
  5523. end
  5524. else
  5525. b=b+1
  5526. end
  5527. end
  5528. d=dd-01
  5529. b=b+d
  5530. return(b)
  5531.  
  5532. ReverseArray:call TRACE "OFF"
  5533. riArray=translate(arg(1))|| '.'
  5534. riCount=_valueG(riArray||0)
  5535. riHalfWay=riCount%2
  5536. do riFrom=1 to riHalfWay
  5537. riTo=(riCount-riFrom)+1
  5538. riTemp=_valueG(riArray||riFrom)
  5539. call _valueS riArray||riFrom,_valueG(riArray||riTo)
  5540. call _valueS riArray||riTo,riTemp
  5541. end
  5542. return(riCount)
  5543.  
  5544. Warning:call TRACE "OFF"
  5545. call OutputWarningToScreen arg(1),arg(2)
  5546. return(0)
  5547.  
  5548. Error:call TRACE "OFF"
  5549. call CryAndDie 'Rexx code called Error()', '------------------------',arg(1),arg(2),arg(3),arg(4),arg(5),arg(6),arg(7),arg(8),arg(9),arg(10)
  5550. return(0)
  5551.  
  5552. Info:call TRACE "OFF"
  5553. call OutputInformationToScreen arg(1)
  5554. return(0)
  5555.  
  5556. DieIfIoErrorOccurred:call TRACE "OFF"
  5557. FileState=stream(arg(1), 'State')
  5558. if FileState='READY' then
  5559. return
  5560. IoReason=stream(arg(1), 'Description')
  5561. if IoReason\=='NOTREADY:EOF' then
  5562. do
  5563. if RexWhich='REGINA' & IoReason = '' then
  5564. do
  5565. if OptionDebugOn='Y' then
  5566. do
  5567. call DebugLine 'DieIfIoErrorOccurred(): Bug first reported to Mark Hessling 3/10/99 for 0.08h beta'
  5568. call DebugIncrement 1
  5569. call DebugLine 'I/O failure on "' || arg(1) || '" (' || IoReason || ').'
  5570. call DebugIncrement-1
  5571. end
  5572. return
  5573. end
  5574. call CryAndDie 'I/O failure on "' || arg(1) || '" (' || IoReason || ').'
  5575. end
  5576. return
  5577.  
  5578. _ValidateIcLevel:
  5579. icLevel=arg(1)
  5580. if icLevel='' then
  5581. icLevel=IncludeLevel
  5582. if datatype(icLevel, 'WholeNumber')<>1 then
  5583. return(0)
  5584. if icLevel<1|icLevel>IncludeLevel then
  5585. return(0)
  5586. return(icLevel)
  5587.  
  5588. InputComponentLevel:call TRACE "OFF"
  5589. icLevel=_ValidateIcLevel(arg(1))
  5590. if icLevel=0 then
  5591. return('')
  5592. else
  5593. return(IncludeFileName.icLevel)
  5594.  
  5595. InputComponentLineLevel:call TRACE "OFF"
  5596. icLevel=_ValidateIcLevel(arg(1))
  5597. if icLevel=0 then
  5598. return('')
  5599. else
  5600. do
  5601. if icLevel=IncludeLevel then
  5602. return(IncludeLineNumber)
  5603. else
  5604. return(_IncludeLineNumber.icLevel)
  5605. end
  5606.  
  5607. GenerateFileName:call TRACE "OFF"
  5608. parse arg SrcFile,ConversionSpec,RelPathAllowed
  5609. if OptionDebugOn='Y' then
  5610. do
  5611. call DebugLine 'GenerateFileName(' || SrcFile || ') using "' || ConversionSpec || '"'
  5612. call DebugLine 'Current directory is "' || GetCurrentDirectory() || '"'
  5613. call DebugIncrement 1
  5614. end
  5615. ShortName=_filespec('name',SrcFile)
  5616. InputPath=_filespec('drive', SrcFile) || _filespec('path',SrcFile)
  5617. ExtnPos=lastpos('.',ShortName)
  5618. if ExtnPos<>0 then
  5619. ShortName=left(ShortName,ExtnPos-1)
  5620. FullFileName=ReplaceString(ConversionSpec, "?",InputPath)
  5621. FullFileName=ReplaceString(FullFileName, "*",ShortName)
  5622. FullFileName=ReplaceString(FullFileName, "{$PATH}",InputPath)
  5623. FullFileName=ReplaceString(FullFileName, "{$BASE}",ShortName)
  5624. if pos('{$path}',FullFileName)<>0 then
  5625. do
  5626. if RelPathAllowed<> 'Y' then
  5627. CryAndDie('"{$path}" found, you are only allowed to use this on cmd line...')
  5628. call DebugLine '{$path} found, original mask was "' || MaskUsedForCurrentInputFile || '"'
  5629. MaskPath=_filespec('Location',MaskUsedForCurrentInputFile)
  5630. MaskPathLng=length(MaskPath)
  5631. InputFilePath=_filespec('Location',SrcFile)
  5632. StartInpPath=left(InputFilePath,MaskPathLng)
  5633. if translate(StartInpPath)<>translate(MaskPath)then
  5634. CryAndDie("Can't handle '{$path}' (maybe mask not absolute)")
  5635. DollarPath=substr(InputFilePath,MaskPathLng+1)
  5636. call DebugLine '{$path} = "' || DollarPath || '"'
  5637. FullFileName=ReplaceString(FullFileName, "{$path}",DollarPath)
  5638. end
  5639. FullFileName=EnsureFileHasCorrectCase(FullFileName)
  5640. if OptionDebugOn='Y' then
  5641. call DebugLine 'Generated Name = "' || FullFileName || '"'
  5642. call MakeDirectoryTree _filespec('drive', FullFileName) || _filespec('path',FullFileName)
  5643. if OptionDebugOn='Y' then
  5644. call DebugIncrement-1
  5645. return(FullFileName)
  5646.  
  5647. ProcessNext:call TRACE "OFF"
  5648. if IncludeMemBufferNextLine=='' then
  5649. IncludeMemBufferNextLine=arg(1)
  5650. else
  5651. IncludeMemBufferNextLine=arg(1)||MarksNewLine||IncludeMemBufferNextLine
  5652. return
  5653.  
  5654. RexxVarDefined:call TRACE "OFF"
  5655. vsValue=symbol(arg(1))
  5656. if vsValue='BAD' then
  5657. do
  5658. vsLength=length(arg(1))
  5659. if symbol(copies('A', vsLength)) <> 'BAD' then
  5660. Reason=''
  5661. else
  5662. Reason='A symbol length of "' || vsLength || ' bytes seems to be too long for your rexx interpreter!'
  5663. CryAndDie('RexxVarDefined()', 'Invalid symbol of "' || arg(1) || '" passed.',Reason)
  5664. end
  5665. if vsValue='VAR' then
  5666. return(1)
  5667. else
  5668. return(0)
  5669.  
  5670. SortArray:call TRACE "OFF"
  5671. parse arg bsArray,bsStartCol,bsEndCol,bsStrict
  5672. bsArray=translate(bsArray)|| '.'
  5673. if bsStartCol='' then
  5674. bsStartCol=0
  5675. else
  5676. do
  5677. if bsEndCol='' then
  5678. bsLength=0
  5679. else
  5680. bsLength=bsEndCol-bsStartCol
  5681. end
  5682. bsM=1
  5683. bsCount=_valueG(bsArray||0)
  5684. do while(9*bsM+4)<bsCount
  5685. bsM=bsM*3+1
  5686. end
  5687. do while bsM>0
  5688. bsK=bsCount-bsM
  5689. do bsJ=1 to bsK
  5690. bsIndex1=bsJ
  5691. do while bsIndex1>0
  5692. bsIndex2=bsIndex1+bsM
  5693. if bsStartCol=0 then
  5694. do
  5695. bsVal1=_valueG(bsArray||BSINDEX1)
  5696. bsVal2=_valueG(bsArray||BSINDEX2)
  5697. end
  5698. else
  5699. do
  5700. if bsLength=0 then
  5701. do
  5702. bsVal1=substr(_valueG(bsArray||BSINDEX1),bsStartCol)
  5703. bsVal2=substr(_valueG(bsArray||BSINDEX2),bsStartCol)
  5704. end
  5705. else
  5706. do
  5707. bsVal1=substr(_valueG(bsArray||BSINDEX1),bsStartCol,bsLength)
  5708. bsVal2=substr(_valueG(bsArray||BSINDEX2),bsStartCol,bsLength)
  5709. end
  5710. end
  5711. if bsStrict='Y' then
  5712. bsGreater=bsVal1>>bsVal2
  5713. else
  5714. bsGreater=bsVal1>bsVal2
  5715. if bsGreater then
  5716. do
  5717. bsTemp=_valueG(bsArray||BSINDEX1)
  5718. call _valueS bsArray||BSINDEX1,_valueG(bsArray||BSINDEX2)
  5719. call _valueS bsArray||BSINDEX2,bsTemp
  5720. end
  5721. else
  5722. leave
  5723. bsIndex1=bsIndex1-bsM
  5724. end
  5725. end
  5726. bsM=bsM%3
  5727. end
  5728. return(bsCount)
  5729.  
  5730. Evaluate_25:
  5731. DoingImport=''
  5732. signal IMPORT_26
  5733.  
  5734. ProcessImport:
  5735. if DoingImport<> '' then
  5736. CryAndDie("Can't nest #import (started at " || DoingImport || ')')
  5737. else
  5738. DoingImport=CurrentSourceLocation()
  5739. ImportParms=PerformReplacementsInCmdsParameters(arg(1))
  5740. if AsIsModeOn='Y' then
  5741. CryAndDie("Please turn off #AsIs mode before importing.")
  5742. call _InitImportAsIsMemories
  5743. ImportFileName=GetQuotedText(ImportParms, "ImportParms")
  5744. if ImportFileName='' then
  5745. CryAndDie('#import has no parameters!')
  5746. CloseRc=stream(ImportFileName, 'c', 'close')
  5747. FullImportName=stream(ImportFileName, 'c', 'query exists')
  5748. if FullImportName='' then
  5749. CryAndDie('The #import file "' || ImportFileName || '" does not exist!')
  5750. call OutputProcessingFileStringToScreen FullImportName
  5751. call AddInputFileToDependancyList FullImportName
  5752. if ImportParms='' then
  5753. CryAndDie('#import is missing import type (parm #2)!')
  5754. ImportFileType=translate(GetQuotedText(ImportParms, "ImportParms"))
  5755. if substr(ImportFileType,4)<> '-' then
  5756. DropLine=0
  5757. else
  5758. do
  5759. ImportFileType=left(ImportFileType,3)
  5760. DropLine=1
  5761. end
  5762. FirstChar=left(ImportFileType,1)
  5763. DelimiterSpec=FirstChar||FirstChar||FirstChar
  5764. CustomDelimiter='NO'
  5765. if(ImportFileType==DelimiterSpec)|(ImportFileType==DelimiterSpec|| '-')then
  5766. do
  5767. CustomDelimiter=FirstChar
  5768. TmpFilePart=''
  5769. end
  5770. else
  5771. do
  5772. TmpFilePart=ImportFileType
  5773. if pos('*' || ImportFileType || '*', '*TAB*CMA*FIX*WRAP*T2H*ML*')=0 then
  5774. CryAndDie('Invalid #import type of "' || ImportFileType || '" specified!')
  5775. end
  5776. ToInclude=RexGetTmpFileName('I_' || left(TmpFilePart, 4, '_') || '??.???')
  5777. call MustDeleteFile ToInclude
  5778. if ImportParms='' then
  5779. CryAndDie('#import is missing macro name (parm #3)!')
  5780. MacroName=GetQuotedText(ImportParms, "ImportParms")
  5781. if MacroName='' then
  5782. do
  5783. select
  5784. when ImportFileType='WRAP' then
  5785. MacroName='WRAP'
  5786. when ImportFileType='T2H' then
  5787. MacroName='T2H'
  5788. when ImportFileType='ML' then
  5789. MacroName='ML'
  5790. otherwise
  5791. MacroName='IMPORT'
  5792. end
  5793. end
  5794. call AsIsPrepare ''
  5795. if OptionDebugOn='Y' then
  5796. call DebugLine_IMPORT 'Generating "' || ToInclude || '" for later inclusion (#include).'
  5797. ReplaceNewLineChar=''
  5798. ReplaceTabChar=''
  5799. DisplayingFields=''
  5800. ReplaceNewLineChar=''
  5801. ReplaceTabChar=''
  5802. select
  5803. when ImportFileType='WRAP' then
  5804. ImpLinCnt=HandleLineWrapping()
  5805. when ImportFileType='T2H' then
  5806. ImpLinCnt=HandleTextToHtmlImport()
  5807. otherwise
  5808. do
  5809. call ImportTablePreparation
  5810. select
  5811. when ImportFileType='ML' then
  5812. ImpLinCnt=HandleMultiLineImport()
  5813. when CustomDelimiter<> 'NO' then
  5814. ImpLinCnt=HandleSimpleCharDelimitedFile(CustomDelimiter)
  5815. when ImportFileType='TAB' then
  5816. ImpLinCnt=HandleSimpleCharDelimitedFile(TabChar)
  5817. when ImportFileType='CMA' then
  5818. ImpLinCnt=HandleSimpleCharDelimitedFile(',')
  5819. when ImportFileType='FIX' then
  5820. ImpLinCnt=HandleFixedFieldFile()
  5821. otherwise
  5822. CryAndDie('Unknown import type of "' || ImportFileType || '"')
  5823. end
  5824. call ImportTableTermination
  5825. end
  5826. end
  5827. CloseRc=stream(FullImportName, 'c', 'close')
  5828. if OptionDebugOn='Y' then
  5829. call DebugLine_IMPORT 'Imported ' || AddCommasToDecimalNumber(ImpLinCnt) || ' line(s) in "' || ImportFileType || '" mode.'
  5830. CloseRc=stream(ToInclude, 'c', 'close')
  5831. call AsIsPrepare ''
  5832. if OptionDebugOn='Y' then
  5833. call DebugLine_IMPORT 'Now #include the generated temporary file ("' || ToInclude || '").'
  5834. call RecursiveIncludeSave
  5835. call ProcessInputFile ToInclude,, 'N', 'N'
  5836. call RecursiveIncludeRestore
  5837. call OutputProcessingFileStringToScreen
  5838. if OptionDebugOn='N' then
  5839. DeleteRc=_SysFileDelete(ToInclude)
  5840. DoingImport=''
  5841. return(0)
  5842.  
  5843. _ImportValueSpacer:
  5844. if OptionDebugOn='Y' then
  5845. do
  5846. call DebugLine_MACROVALORDEF ''
  5847. if arg(1)<> '' then
  5848. call DebugLine_MACROVALORDEF arg(1)
  5849. end
  5850. return
  5851.  
  5852. ImportValueExists:
  5853. ImportVar=MacroName|| '_' ||arg(1)
  5854. iveAnswer=VariableExists(ImportVar)
  5855. if OptionDebugOn='Y' then
  5856. call DebugLine_MACROVALORDEF 'Option(Macro) "' || ImportVar || '" Exists? : ' ||iveAnswer
  5857. return(iveAnswer)
  5858.  
  5859. GetImportValue:
  5860. ImportVar=MacroName|| '_' ||arg(1)
  5861. if VariableExists(ImportVar)='N' then
  5862. do
  5863. ImportMask=arg(2)
  5864. DebugWord='not'
  5865. end
  5866. else
  5867. do
  5868. ImportMask=GetDefineContents(ImportVar)
  5869. DebugWord='was'
  5870. end
  5871. if OptionDebugOn='Y' then
  5872. call DebugLine_MACROVALORDEF 'Option(Macro) "' || ImportVar || '" ' || DebugWord || ' found. Using ' ||DebugRightArrow||ImportMask||DebugLeftArrow
  5873. if ImportFileType<> "WRAP" & ImportFileType <> "T2H" then
  5874. ImportMask=ReplaceString(ImportMask,StartsMacroParm|| 'Columns' ||EndsMacroParm,DisplayingFields)
  5875. return(ImportMask)
  5876.  
  5877. GetImportValue_Tabs:
  5878. ReplaceTabChar=GetImportValue('TAB_CHAR', '')
  5879. return
  5880.  
  5881. GetImportValue_RecordFilter:
  5882. return(GetImportValue('RECORD_FILTER', ''))
  5883.  
  5884. GetImportValue_Comments:
  5885. call _ImportValueSpacer 'Get comment options'
  5886. call DebugIncrement 1
  5887. ImportLineCmtChars=GetImportValue( 'LINECMT_CHARS',arg(1))
  5888. ImportInlineCmtChars=GetImportValue('INLINECMT_CHARS',arg(2))
  5889. call DebugIncrement-1
  5890. return
  5891.  
  5892. IsCmtLine:
  5893. if ImportLineCmtChars='' then
  5894. return(0)
  5895. else
  5896. return(abbrev(arg(1),ImportLineCmtChars))
  5897.  
  5898. ImportOneLine:
  5899. if arg(1)='Y' then
  5900. FileLine=CrLflinein(FullImportName)
  5901. else
  5902. FileLine=linein(FullImportName)
  5903. if ImportInlineCmtChars<> '' then
  5904. do
  5905. ilcPos=pos(ImportInlineCmtChars,FileLine)
  5906. if ilcPos<>0 then
  5907. FileLine=strip(left(FileLine,ilcPos-1), 'Trailing')
  5908. end
  5909. if arg(2)='Y' then
  5910. FileLine=AsIs(translate(FileLine, '',EofChar))
  5911. else
  5912. FileLine=translate(FileLine, '',EofChar)
  5913. if ReplaceNewLineChar\=='' then
  5914. FileLine=ReplaceString(FileLine,MarksNewLine,ReplaceNewLineChar)
  5915. if ReplaceTabChar\=='' then
  5916. FileLine=ReplaceString(FileLine,TabChar,ReplaceTabChar)
  5917. return(FileLine)
  5918.  
  5919. PpwLineout:
  5920. parse arg gFile,gLine
  5921. do until gLine==''
  5922. parse var gLine This1 (MarksNewLine) gLine
  5923. if 0<>charout(gFile,This1||NewLineChars)then
  5924. do
  5925. IoReason=stream(gFile, 'Description')
  5926. CryAndDie('Write to "' || gFile || '" failed (' || IoReason || ')!')
  5927. end
  5928. end
  5929. return
  5930.  
  5931. GenerateTagsIfNonEmpty:
  5932. OptionalTags=GetImportValue(arg(1),arg(2))
  5933. if OptionalTags\=='' then
  5934. call PpwLineout ToInclude,OptionalTags
  5935. return
  5936.  
  5937. GenerateProtectStartTags:
  5938. call GenerateTagsIfNonEmpty 'PROTECT_START', StartsStdSymbolReplacement || 'ProtectFromPpwStart' ||EndsMacroReplacement
  5939. return
  5940.  
  5941. GenerateProtectEndTags:
  5942. call GenerateTagsIfNonEmpty 'PROTECT_END',   StartsStdSymbolReplacement || 'ProtectFromPpwEnd' ||EndsMacroReplacement
  5943. return
  5944.  
  5945. GenerateBeforeTags:
  5946. call GenerateTagsIfNonEmpty 'BEFORE',arg(1)
  5947. return
  5948.  
  5949. GenerateAfterTags:
  5950. call GenerateTagsIfNonEmpty 'AFTER',arg(1)
  5951. return
  5952.  
  5953. HandleImportAsIsOptions:
  5954. call _ImportValueSpacer 'Prepare "AS IS" tagging'
  5955. call DebugIncrement 1
  5956. ImportAsIsMemory=GetImportValue('ASIS_TAGGING',arg(1))
  5957. call DebugIncrement 1
  5958. call AsIsPrepare ImportAsIsMemory
  5959. call DebugIncrement-2
  5960. return
  5961.  
  5962. _InitImportAsIsMemories:
  5963. if symbol('ImpMemInit') = 'VAR' then
  5964. return
  5965. ImpMemInit='Y'
  5966. call DebugLine_IMPORT 'Initializing named #AsIs tags for HTML Importing'
  5967. call DebugIncrement 1
  5968. call _ClearTempMemory
  5969. call _AddToTempMemory '&', '&'
  5970. call _AddToTempMemory '<', '<'
  5971. call _AddToTempMemory '>', '>'
  5972. call SetupNamedAsIsStorage 'IMPORT_HTML_BASIC',TmpAtCount
  5973. call _ClearTempMemory
  5974. call _AddToTempMemory '╔', '+'
  5975. call _AddToTempMemory '═', '-'
  5976. call _AddToTempMemory '╗', '+'
  5977. call _AddToTempMemory '║', '|'
  5978. call _AddToTempMemory '╝', '+'
  5979. call _AddToTempMemory '╚', '+'
  5980. call _AddToTempMemory '┌', '+'
  5981. call _AddToTempMemory '─', '-'
  5982. call _AddToTempMemory '┐', '+'
  5983. call _AddToTempMemory '│', '|'
  5984. call _AddToTempMemory '┘', '+'
  5985. call _AddToTempMemory '└', '+'
  5986. call SetupNamedAsIsStorage 'IMPORT_HTML_BOXGRAPHIC_TO_BOXTEXT',TmpAtCount
  5987. call DebugIncrement-1
  5988. return
  5989.  
  5990. _ClearTempMemory:
  5991. TmpAtCount=0
  5992. return
  5993.  
  5994. _AddToTempMemory:
  5995. TmpAtCount=TmpAtCount+1
  5996. ImportB.TmpAtCount=arg(1)
  5997. ImportA.TmpAtCount=arg(2)
  5998. return
  5999.  
  6000. WriteLineToTmpImportFile:call TRACE "OFF"
  6001. call PpwLineout ToInclude,arg(1)
  6002. return
  6003.  
  6004. IMPORT_26:
  6005. signal IMPORTT_27
  6006.  
  6007. ImportTablePreparation:
  6008. if ImportParms='' then
  6009. CryAndDie('#import is missing field names (parm #4 onwards)!')
  6010. NumberOfFields=0
  6011. DisplayingFields=0
  6012. do while ImportParms<> ''
  6013. NumberOfFields=NumberOfFields+1
  6014. HeadingInfo=GetQuotedText(ImportParms, "ImportParms")
  6015. ColumnNumber=DisplayingFields+1
  6016. ExtraInfo=''
  6017. if left(HeadingInfo,1)='{' then
  6018. do
  6019. EndPosn=pos('}',HeadingInfo)
  6020. if EndPosn=0 then
  6021. CryAndDie('Leading field codes on heading "' || HeadingInfo || '" invalid (expected "}")')
  6022. HeadingCodes=substr(HeadingInfo,2,EndPosn-2)
  6023. HeadingInfo=substr(HeadingInfo,EndPosn+1)
  6024. parse var HeadingCodes MaybeColumnNumber','ExtraInfo
  6025. if MaybeColumnNumber<> '' & MaybeColumnNumber <> '*' then
  6026. ColumnNumber=MaybeColumnNumber
  6027. end
  6028. FieldHeading.NumberOfFields=HeadingInfo
  6029. FieldExtra.NumberOfFields=ExtraInfo
  6030. if HeadingInfo<> '' then
  6031. do
  6032. FieldColumn.NumberOfFields=ColumnNumber
  6033. DisplayingFields=DisplayingFields+1
  6034. end
  6035. end
  6036. call _ImportValueSpacer 'Assorted options'
  6037. call DebugIncrement 1
  6038. DropBlankLines=translate(GetImportValue('DROP_BLANK_LINES',  'Y'))
  6039. DropLine=GetImportValue('DROP_LINE_COUNT',DropLine)
  6040. ReplaceNewLineChar=GetImportValue('NEWLINE_CHAR', '<BR>')
  6041. call GetImportValue_Tabs
  6042. RecordFilter=GetImportValue_RecordFilter()
  6043. call DebugIncrement-1
  6044. call _ImportValueSpacer 'What happens to blank fields?'
  6045. call DebugIncrement 1
  6046. ReplaceBlankFields=GetImportValue('BLANK_FIELD',  '')
  6047. do Index=1 to DisplayingFields
  6048. RepBlankCol.Index=GetImportValue('BLANK_COLUMN_' ||Index,ReplaceBlankFields)
  6049. end
  6050. call DebugIncrement-1
  6051. call _ImportValueSpacer 'What do we do with column titles?'
  6052. call DebugIncrement 1
  6053. if ImportValueExists('HEADER') = 'Y' then
  6054. ForHeader=GetImportValue('HEADER', '!BUG!')
  6055. else
  6056. do
  6057. DefaultColFormatting=GetImportValue('HEADING_COLUMNS',     'ALIGN=CENTER')
  6058. DefaultBeforeData=GetImportValue('HEADING_BEFORE_DATA', '')
  6059. DefaultAfterData=GetImportValue('HEADING_AFTER_DATA',  '')
  6060. ForHeader='<TR>'
  6061. do Index=1 to DisplayingFields
  6062. ThisColFormatting=GetImportValue('HEADING_COLUMN_' ||Index,DefaultColFormatting)
  6063. ThisBeforeData=GetImportValue('HEADING_BEFORE_DATA_' ||Index,DefaultBeforeData)
  6064. ThisAfterData=GetImportValue('HEADING_AFTER_DATA_' ||Index,DefaultAfterData)
  6065. ForHeader=ForHeader|| '<TH ' || ThisColFormatting || '>' || ThisBeforeData || StartsMacroParm || 'Column' || Index || EndsMacroParm || ThisAfterData || '</TH>'
  6066. end
  6067. ForHeader=ForHeader|| '</TR>'
  6068. end
  6069. call DebugIncrement-1
  6070. call _ImportValueSpacer 'Working out what table data row looks like'
  6071. call DebugIncrement 1
  6072. if ImportValueExists('RECORD') = 'Y' then
  6073. ForEachRecord=GetImportValue('RECORD', '!BUG!')
  6074. else
  6075. do
  6076. DefaultColFormatting=GetImportValue('RECORD_COLUMNS',     'ALIGN=CENTER')
  6077. DefaultBeforeData=GetImportValue('RECORD_BEFORE_DATA', '')
  6078. DefaultAfterData=GetImportValue('RECORD_AFTER_DATA',  '')
  6079. ForEachRecord='<TR>'
  6080. do Index=1 to DisplayingFields
  6081. ThisColFormatting=GetImportValue('RECORD_COLUMN_' ||Index,DefaultColFormatting)
  6082. ThisBeforeData=GetImportValue('RECORD_BEFORE_DATA_' ||Index,DefaultBeforeData)
  6083. ThisAfterData=GetImportValue('RECORD_AFTER_DATA_' ||Index,DefaultAfterData)
  6084. ForEachRecord=ForEachRecord|| '<TD ' || ThisColFormatting || '>' || ThisBeforeData || StartsMacroParm || 'Column' || Index || EndsMacroParm  || ThisAfterData || '</TD>'
  6085. end
  6086. ForEachRecord=ForEachRecord|| '</TR>'
  6087. end
  6088. call DebugIncrement-1
  6089. call _ImportValueSpacer 'Start output'
  6090. call DebugIncrement 1
  6091. call GenerateProtectStartTags
  6092. TableAttribs=GetImportValue('TABLE_ATTRIBS', 'BORDER=5 CELLSPACING=5')
  6093. if TableAttribs<> '' then
  6094. TableAttribs=' ' ||strip(TableAttribs)
  6095. BeforeRecordsDefault='<TABLE' || TableAttribs || '>'
  6096. call GenerateBeforeTags BeforeRecordsDefault
  6097. call DebugLine_IMPORT 'Outputting heading fields'
  6098. call DebugIncrement 1
  6099. call _NewRecord 'H'
  6100. do FieldIndex=1 to NumberOfFields
  6101. call _AddField2Record FieldHeading.FieldIndex
  6102. end
  6103. call GenerateRecordFromFields
  6104. call DebugIncrement-2
  6105. call GetImportValue_Comments ';', ';' || ';'
  6106. if OptionCodeType='HTML' then
  6107. call HandleImportAsIsOptions "IMPORT_HTML_BASIC"
  6108. return
  6109.  
  6110. ImportTableTermination:
  6111. call GenerateAfterTags '</TABLE>'
  6112. call GenerateProtectEndTags
  6113. return
  6114.  
  6115. HandleFixedFieldFile:
  6116. if OptionDebugOn='Y' then
  6117. call DebugLine_IMPORT 'Importing fixed field file'
  6118. do FieldIndex=1 to NumberOfFields
  6119. parse var FieldExtra.FieldIndex StartCol'-'EndCol
  6120. if EndCol='' | EndCol = '*' then
  6121. FieldLength=''
  6122. else
  6123. FieldLength=(EndCol-StartCol)+1
  6124. FieldStartCol.FieldIndex=StartCol
  6125. FieldLength.FieldIndex=FieldLength
  6126. end
  6127. ImportFileLine=0
  6128. call DebugLine_IMPORT 'Reading "' || FullImportName || '"...'
  6129. do while lines(FullImportName)<>0
  6130. CurrentRecord=ImportOneLine('Y', 'Y')
  6131. ImportFileLine=ImportFileLine+1
  6132. if CurrentRecord='' then
  6133. iterate
  6134. if ImportFileLine<=DropLine then
  6135. iterate
  6136. if IsCmtLine(ImportFileLine)then
  6137. iterate
  6138. call _NewRecord
  6139. do FieldIndex=1 to NumberOfFields
  6140. if FieldLength.FieldIndex='' then
  6141. ThisField=substr(CurrentRecord,FieldStartCol.FieldIndex)
  6142. else
  6143. ThisField=substr(CurrentRecord,FieldStartCol.FieldIndex,FieldLength.FieldIndex)
  6144. call _AddField2Record strip(ThisField)
  6145. end
  6146. if GenerateRecordFromFields()then
  6147. leave
  6148. end
  6149. return(ImportFileLine)
  6150.  
  6151. HandleSimpleCharDelimitedFile:
  6152. FieldDelimiter=arg(1)
  6153. FieldQuote='"'
  6154. FieldQuote2=FieldQuote||FieldQuote
  6155. if OptionDebugOn='Y' then
  6156. do
  6157. DelimiterText=c2d(FieldDelimiter)
  6158. if DelimiterText> '32' then
  6159. DelimiterText=DelimiterText|| ' ("' || FieldDelimiter || '")'
  6160. call DebugLine_IMPORT 'Importing simple delimited file - delimiter = ASCII ' ||DelimiterText
  6161. end
  6162. UseCrLfRoutines=GetImportValue('HANDLE_IMBEDDED_NEWLINES', 'N')
  6163. if UseCrLfRoutines='N' then
  6164. call DebugLine_IMPORT 'Special imbedded newline detecting code is not being used'
  6165. else
  6166. do
  6167. UseCrLfRoutines='Y'
  6168. call DebugLine_IMPORT 'We are using special imbedded newline detecting code'
  6169. end
  6170. call DebugLine_IMPORT 'Reading "' || FullImportName || '"...'
  6171. if UseCrLfRoutines='Y' then
  6172. OpenRc=CrlfOpen(FullImportName,10000)
  6173. ImportFileLine=0
  6174. do forever
  6175. if UseCrLfRoutines='Y' then
  6176. EofIf0=CrLflines(FullImportName)
  6177. else
  6178. EofIf0=lines(FullImportName)
  6179. if EofIf0=0 then
  6180. leave
  6181. CurrentRecord=ImportOneLine(UseCrLfRoutines, 'Y')
  6182. ImportFileLine=ImportFileLine+1
  6183. if CurrentRecord='' then
  6184. do
  6185. if DropBlankLines='Y' then
  6186. iterate
  6187. end
  6188. if ImportFileLine<=DropLine then
  6189. iterate
  6190. if IsCmtLine(CurrentRecord)then
  6191. iterate
  6192. call _NewRecord
  6193. do while CurrentRecord<> ''
  6194. if left(CurrentRecord,1)<>FieldQuote then
  6195. do
  6196. DelPos=pos(FieldDelimiter,CurrentRecord)
  6197. if DelPos<>0 then
  6198. do
  6199. call _AddField2Record left(CurrentRecord,DelPos-1)
  6200. CurrentRecord=substr(CurrentRecord,DelPos+1)
  6201. end
  6202. else
  6203. do
  6204. call _AddField2Record CurrentRecord
  6205. CurrentRecord=''
  6206. end
  6207. end
  6208. else
  6209. do
  6210. LookFrom=2
  6211. do forever
  6212. QuotePos=pos(FieldQuote,CurrentRecord,LookFrom)
  6213. if QuotePos=0 then
  6214. CryAndDie('No ending quote on field #' || FieldCounter+1 || ' of line #' || ImportFileLine || ', Failed at ' ||DebugRightArrow||CurrentRecord||DebugLeftArrow)
  6215. if substr(CurrentRecord,QuotePos+1,1)=FieldQuote then
  6216. LookFrom=QuotePos+2
  6217. else
  6218. leave
  6219. end
  6220. call _AddField2Record ReplaceString(substr(CurrentRecord,2,QuotePos-2),FieldQuote2,FieldQuote)
  6221. CurrentRecord=substr(CurrentRecord,QuotePos+1)
  6222. if CurrentRecord<> '' then
  6223. do
  6224. if left(CurrentRecord,1)<>FieldDelimiter then
  6225. CryAndDie('Expected delimiter after field #' || FieldCounter || ' of line #' || ImportFileLine || ', Failed at ' ||DebugRightArrow||CurrentRecord||DebugLeftArrow)
  6226. CurrentRecord=substr(CurrentRecord,2)
  6227. end
  6228. end
  6229. if FieldCounter>=NumberOfFields then
  6230. leave
  6231. end
  6232. if FieldCounter<NumberOfFields then
  6233. do
  6234. do while FieldCounter<NumberOfFields
  6235. call _AddField2Record ''
  6236. end
  6237. end
  6238. if GenerateRecordFromFields()then
  6239. leave
  6240. end
  6241. if UseCrLfRoutines='Y' then
  6242. CloseRc=CrlfClose(FullImportName)
  6243. return(ImportFileLine)
  6244.  
  6245. _NewRecord:
  6246. RecordType=arg(1)
  6247. if RecordType='H' then
  6248. ThisRecordsCodes=ForHeader
  6249. else
  6250. ThisRecordsCodes=ForEachRecord
  6251. FieldCounter=0
  6252. ColumnCounter=0
  6253. DroppedCounter=0
  6254. NonBlankFieldCounter=0
  6255. return
  6256.  
  6257. _AddField2Record:
  6258. FieldCounter=FieldCounter+1
  6259. if FieldHeading.FieldCounter='' then
  6260. do
  6261. DroppedCounter=DroppedCounter+1
  6262. Dropped.DroppedCounter=arg(1)
  6263. end
  6264. else
  6265. do
  6266. ColumnCounter=ColumnCounter+1
  6267. NewValue=arg(1)
  6268. if NewValue='' then
  6269. NewValue=RepBlankCol.ColumnCounter
  6270. else
  6271. NonBlankFieldCounter=NonBlankFieldCounter+1
  6272. SaveAsIndex=FieldColumn.FieldCounter
  6273. Column.SaveAsIndex=NewValue
  6274. end
  6275. return
  6276.  
  6277. GenerateRecordFromFields:
  6278. call DebugIncrement 1
  6279. if DropBlankLines='Y' then
  6280. do
  6281. if NonBlankFieldCounter=0 then
  6282. do
  6283. call DebugLine_IMPORT 'Dropping record as all fields were blank'
  6284. call DebugIncrement-1
  6285. return(0)
  6286. end
  6287. end
  6288. if RecordFilter<> '' then
  6289. do
  6290. if RecordType<> 'H' then
  6291. do
  6292. Column.0=ColumnCounter
  6293. Dropped.0=DroppedCounter
  6294. call DebugLine_IMPORT 'Calling specified filter'
  6295. call DebugIncrement 1
  6296. Remove=''
  6297. call ExecRexxCmd RecordFilter
  6298. if Remove<> '' then
  6299. do
  6300. if abbrev(Remove, "EOF:")then
  6301. do
  6302. call DebugLine_IMPORT 'This Record and all following dropped ==> ' ||Remove
  6303. call DebugIncrement-2
  6304. return(1)
  6305. end
  6306. else
  6307. do
  6308. call DebugLine_IMPORT 'Record dropped ==> ' ||Remove
  6309. call DebugIncrement-2
  6310. return(0)
  6311. end
  6312. end
  6313. call DebugIncrement-1
  6314. end
  6315. end
  6316. do ThisOne=1 to ColumnCounter
  6317. ThisRecordsCodes=ReplaceString(ThisRecordsCodes,StartsMacroParm|| 'Column' ||ThisOne||EndsMacroParm,Column.ThisOne)
  6318. end
  6319. call DebugLine_IMPORT 'Generating: ' ||ThisRecordsCodes
  6320. call PpwLineout ToInclude,ThisRecordsCodes
  6321. call DebugIncrement-1
  6322. return(0)
  6323.  
  6324. IMPORTT_27:
  6325. signal IMPORTTX_28
  6326.  
  6327. HandleTextToHtmlImport:
  6328. if OptionCodeType<> 'HTML' then
  6329. CryAndDie("Text to html file importing is only allowed when generating HTML")
  6330. if ImportParms<> '' then
  6331. CryAndDie('There are too many parameters on the T2H #import!')
  6332. UrlNameVar=StartsMacroParm|| 'Url' ||EndsMacroParm
  6333. UrlTypeVar=StartsMacroParm|| 'UrlType' ||EndsMacroParm
  6334. HeadingVar=StartsMacroParm|| 'Heading' ||EndsMacroParm
  6335. call GenerateProtectStartTags
  6336. call GenerateBeforeTags '<PRE><FONT SIZE=-1>'
  6337. T2hFilter=GetImportValue_RecordFilter()
  6338. call GetImportValue_Tabs
  6339. BlankLinesTo=GetImportValue('BLANK_LINES_TO', '')
  6340. HttpLink=GetImportValue('HTTP_LINK',   '<A HREF="' || UrlTypeVar || UrlNameVar || '" TARGET=_top>' || UrlTypeVar || UrlNameVar || '</A>')
  6341. FtpLink=GetImportValue('FTP_LINK',    '<A HREF="' || UrlTypeVar || UrlNameVar || '">' || UrlTypeVar || UrlNameVar || '</A>')
  6342. MailLink=GetImportValue('MAILTO_LINK', '<A HREF="mailto:' || UrlNameVar || '">' || UrlNameVar || '</A>')
  6343. DefaultAllStd=UpperCase||LowerCase||DecimalDigits
  6344. AlwaysOkInUrl=GetImportValue('ALWAYS_OK_IN_URL_CHARS',DefaultAllStd)
  6345. if AlwaysOkInUrl\=='' then
  6346. DefaultAllStd=''
  6347. ExtraValidHttpChar=GetImportValue('EXTRA_VALID_HTTP_CHARS',         DefaultAllStd || './?%+:~_')
  6348. ExtraValidFtpChar=GetImportValue('EXTRA_VALID_FTP_CHARS',ExtraValidHttpChar)
  6349. ExtraValidEmailName=GetImportValue('EXTRA_VALID_EMAIL_NAME_CHARS',   DefaultAllStd || '_')
  6350. ExtraValidEmailSvr=GetImportValue('EXTRA_VALID_EMAIL_SVR_CHARS',    DefaultAllStd || '_.')
  6351. ValidInHttpUrl=AlwaysOkInUrl||ExtraValidHttpChar
  6352. ValidInFtpUrl=AlwaysOkInUrl||ExtraValidFtpChar
  6353. ValidInEmailL=AlwaysOkInUrl||ExtraValidEmailName
  6354. ValidInEmailR=AlwaysOkInUrl||ExtraValidEmailSvr
  6355. call GetImportValue_Comments '', ''
  6356. if OptionCodeType='HTML' then
  6357. call HandleImportAsIsOptions "IMPORT_HTML_BASIC IMPORT_HTML_BOXGRAPHIC_TO_BOXTEXT"
  6358. T2hLineNumber=0
  6359. call DebugLine_IMPORT 'Reading "' || FullImportName || '"...'
  6360. do while lines(FullImportName)<>0
  6361. T2hFileLine=ImportOneLine('N', 'Y')
  6362. T2hLineNumber=T2hLineNumber+1
  6363. if IsCmtLine(T2hFileLine)then
  6364. iterate
  6365. if T2hFileLine='' then
  6366. do
  6367. if BlankLinesTo\=='' then
  6368. T2hNewLine=BlankLinesTo
  6369. else
  6370. T2hNewLine=''
  6371. end
  6372. else
  6373. do
  6374. T2hNewLine=T2hFileLine
  6375. if MailLink\=='' then
  6376. T2hNewLine=_MakeTextImportEmailChanges(T2hNewLine,ValidInEmailL,ValidInEmailR,MailLink)
  6377. if HttpLink\=='' then
  6378. T2hNewLine=_MakeTextImportLinkChanges(T2hNewLine, 'http:',ValidInHttpUrl,HttpLink)
  6379. if FtpLink\=='' then
  6380. T2hNewLine=_MakeTextImportLinkChanges(T2hNewLine, 'ftp:',ValidInFtpUrl,FtpLink)
  6381. end
  6382. if T2hFilter<> '' then
  6383. do
  6384. call DebugLine_IMPORT 'Calling specified filter'
  6385. call DebugIncrement 1
  6386. Remove=''
  6387. call ExecRexxCmd T2hFilter
  6388. if Remove<> '' then
  6389. do
  6390. if abbrev(Remove, "EOF:")then
  6391. do
  6392. call DebugLine_IMPORT 'This Record and all following dropped ==> ' ||Remove
  6393. call DebugIncrement-1
  6394. leave
  6395. end
  6396. else
  6397. do
  6398. call DebugLine_IMPORT 'Record dropped ==> ' ||Remove
  6399. call DebugIncrement-1
  6400. iterate
  6401. end
  6402. end
  6403. call DebugIncrement-1
  6404. end
  6405. call PpwLineout ToInclude,T2hNewLine
  6406. end
  6407. call GenerateAfterTags '</FONT></PRE>'
  6408. call GenerateProtectEndTags
  6409. return(T2hLineNumber)
  6410.  
  6411. _MakeTextImportLinkChanges:
  6412. parse arg RightBit,UrlType,tlOkInUrl,tlTransformSpec
  6413. LeftBit=''
  6414. UrlPos=pos(UrlType,RightBit)
  6415. lUrlType=length(UrlType)
  6416. do while UrlPos<>0
  6417. LeftBit=LeftBit||left(RightBit,UrlPos-1)
  6418. RightBit=substr(RightBit,UrlPos+lUrlType)
  6419. NotUrlCharPos=verify(RightBit,tlOkInUrl)
  6420. if NotUrlCharPos=0 then
  6421. do
  6422. TheUrl=RightBit
  6423. RightBit=''
  6424. end
  6425. else
  6426. do
  6427. TheUrl=left(RightBit,NotUrlCharPos-1)
  6428. RightBit=substr(RightBit,NotUrlCharPos)
  6429. end
  6430. UrlBit=ReplaceString(tlTransformSpec,UrlTypeVar,UrlType)
  6431. UrlBit=ReplaceString(UrlBit,UrlNameVar,TheUrl)
  6432. LeftBit=LeftBit||UrlBit
  6433. UrlPos=pos(UrlType,RightBit)
  6434. end
  6435. return(LeftBit||RightBit)
  6436.  
  6437. _MakeTextImportEmailChanges:
  6438. parse arg RightBit,tlOkInEmailName,tlOkInEmailSvr,tlTransformSpec
  6439. LeftBit=''
  6440. SnailPos=pos('@',RightBit)
  6441. do while SnailPos<>0
  6442. lRightBit=length(RightBit)
  6443. if SnailPos=1|SnailPos=lRightBit then
  6444. do
  6445. LeftBit=LeftBit||left(RightBit,SnailPos)
  6446. RightBit=substr(RightBit,SnailPos+1)
  6447. end
  6448. else
  6449. do
  6450. LeftPos=SnailPos-1
  6451. do until LeftPos=0
  6452. OneChar=substr(RightBit,LeftPos,1)
  6453. if OneChar=' ' | OneChar = '"'  | OneChar = "'" then
  6454. do
  6455. LeftPos=LeftPos+1
  6456. leave
  6457. end
  6458. LeftPos=LeftPos-1
  6459. end
  6460. if LeftPos=0 then
  6461. LeftPos=LeftPos+1
  6462. EmailLeftBit=substr(RightBit,LeftPos,SnailPos-LeftPos)
  6463. RightPos=SnailPos+1
  6464. do until RightPos>lRightBit
  6465. OneChar=substr(RightBit,RightPos,1)
  6466. if OneChar=' ' | OneChar = '"'  | OneChar = "'" then
  6467. do
  6468. RightPos=RightPos-1
  6469. leave
  6470. end
  6471. RightPos=RightPos+1
  6472. end
  6473. if RightPos>lRightBit then
  6474. RightPos=lRightBit
  6475. EmailRightBit=substr(RightBit,SnailPos+1,RightPos-SnailPos)
  6476. if verify(EmailLeftBit,tlOkInEmailName)<>0|verify(EmailRightBit,tlOkInEmailSvr)<>0|pos('.',EmailRightBit)=0 then
  6477. do
  6478. LeftBit=LeftBit||left(RightBit,SnailPos)
  6479. RightBit=substr(RightBit,SnailPos+1)
  6480. end
  6481. else
  6482. do
  6483. EmailBit=ReplaceString(tlTransformSpec,UrlTypeVar, 'mailto:')
  6484. EmailBit=ReplaceString(EmailBit,UrlNameVar,EmailLeftBit|| '@' ||EmailRightBit)
  6485. LeftBit=LeftBit||left(RightBit,LeftPos-1)||EmailBit
  6486. RightBit=substr(RightBit,RightPos+1)
  6487. end
  6488. end
  6489. SnailPos=pos('@',RightBit)
  6490. end
  6491. return(LeftBit||RightBit)
  6492.  
  6493. IMPORTTX_28:
  6494. signal IMPORTWR_29
  6495.  
  6496. HandleLineWrapping:
  6497. if ImportParms<> '' then
  6498. CryAndDie('There are too many parameters on the WRAP #import!')
  6499. DropBlankLines=translate(GetImportValue('DROP_BLANK_LINES',  'Y'))
  6500. call GetImportValue_Tabs
  6501. WrapFilter=GetImportValue_RecordFilter()
  6502. call GetImportValue_Comments ';', ';' || ';'
  6503. if OptionCodeType='HTML' then
  6504. call HandleImportAsIsOptions ""
  6505. WrapLineNumber=0
  6506. NewDoubleQuote='" || d2c(34) || "'
  6507. call DebugLine_IMPORT 'Reading "' || FullImportName || '"...'
  6508. do while lines(FullImportName)<>0
  6509. WrapLine=ImportOneLine('N', 'Y')
  6510. WrapLineNumber=WrapLineNumber+1
  6511. if WrapLine='' then
  6512. do
  6513. if DropBlankLines='Y' then
  6514. iterate
  6515. end
  6516. if IsCmtLine(WrapLine)then
  6517. iterate
  6518. if WrapFilter='' then
  6519. do
  6520. RebuildCmd='"' || ReplaceString(WrapLine, '"', NewDoubleQuote) || '"'
  6521. SafeQuote=QuoteIt(RebuildCmd,TryQuoteListAny)
  6522. call PpwLineout ToInclude,StartsMacroReplacement||MacroName|| ' Line=' ||SafeQuote||RebuildCmd||SafeQuote||EndsMacroReplacement
  6523. end
  6524. else
  6525. do
  6526. call DebugLine_IMPORT 'Calling filter for line #' ||WrapLineNumber
  6527. call DebugIncrement 1
  6528. Remove=''
  6529. call ExecRexxCmd WrapFilter
  6530. if Remove<> '' then
  6531. do
  6532. if abbrev(Remove, "EOF:")then
  6533. do
  6534. call DebugLine_IMPORT 'This Record and all following dropped ==> ' ||Remove
  6535. call DebugIncrement-1
  6536. leave
  6537. end
  6538. else
  6539. do
  6540. call DebugLine_IMPORT 'Line dropped ==> ' ||Remove
  6541. call DebugIncrement-1
  6542. iterate
  6543. end
  6544. end
  6545. call DebugIncrement-1
  6546. call PpwLineout ToInclude,WrapLine
  6547. end
  6548. end
  6549. return(WrapLineNumber)
  6550.  
  6551. IMPORTWR_29:
  6552. MultiLineImportInProgress='N'
  6553. signal I_ML_30
  6554.  
  6555. HandleMultiLineImport:
  6556. if OptionDebugOn='Y' then
  6557. call DebugLine_IMPORT 'Importing multi line record file'
  6558. mlDelimiter=GetImportValue('DELIMITER',         '=')
  6559. mlLineCmtChar=GetImportValue('LINE_COMMENT_CHAR',LineComment)
  6560. if mlLineCmtChar='' then
  6561. mlLineCmtChar=' '
  6562. LineFilter=GetImportValue('LINE_FILTER', '')
  6563. drop mlFIndex?.
  6564. do FieldIndex=1 to NumberOfFields
  6565. parse value translate(FieldExtra.FieldIndex)with FieldName ',' FieldOptions
  6566. if FieldName='' then
  6567. CryAndDie('No {field name} supplied for field #' ||FieldIndex)
  6568. call _valueS 'mlFIndex?.mli?' ||c2x(FieldName),FieldOptions
  6569. MlFieldName.FieldIndex=FieldName
  6570. end
  6571. MultiLineImportInProgress='Y'
  6572. ImportFileLine=0
  6573. LastCommentLine=''
  6574. call DebugLine_IMPORT 'Reading "' || FullImportName || '"...'
  6575. call _MlNewRecord
  6576. do while lines(FullImportName)<>0
  6577. MultiLine=strip(ImportOneLine('N', 'N'))
  6578. ImportFileLine=ImportFileLine+1
  6579. if MultiLine='' then
  6580. do
  6581. if MlFieldCnt<>0 then
  6582. do
  6583. call _MlGenerateRecord
  6584. call _MlNewRecord
  6585. end
  6586. end
  6587. else
  6588. do
  6589. if left(MultiLine,1)=LineComment then
  6590. iterate
  6591. if LineFilter<> '' then
  6592. do
  6593. call DebugLine_IMPORT 'Calling specified multi line filter'
  6594. call DebugIncrement 1
  6595. Remove=''
  6596. call ExecRexxCmd LineFilter
  6597. if Remove<> '' then
  6598. do
  6599. if abbrev(Remove, "EOF:")then
  6600. do
  6601. call DebugLine_IMPORT 'Line #' || ImportFileLine || ' to EOF dropped ==> ' ||Remove
  6602. call DebugIncrement-1
  6603. leave
  6604. end
  6605. else
  6606. do
  6607. call DebugLine_IMPORT 'Line #' || ImportFileLine || ' dropped ==> ' ||Remove
  6608. call DebugIncrement-1
  6609. iterate
  6610. end
  6611. end
  6612. call DebugIncrement-1
  6613. end
  6614. parse var MultiLine MultiVar (mlDelimiter) MultiValue
  6615. call _MlRememberFieldsValue strip(MultiVar, 'T'), strip(MultiValue, 'L')
  6616. end
  6617. end
  6618. CloseRc=stream(FullImportName, 'c', 'close')
  6619. if MlFieldCnt<>0 then
  6620. call _MlGenerateRecord
  6621. MultiLineImportInProgress='N'
  6622. return(ImportFileLine)
  6623.  
  6624. _MlNewRecord:
  6625. call _NewRecord
  6626. MlFieldCnt=0
  6627. drop mlFValues?.
  6628. return
  6629.  
  6630. _MlRememberFieldsValue:
  6631. parse arg FieldN,FieldV
  6632. UFieldN=translate(FieldN)
  6633. StoredAs='mlFIndex?.mli?' ||c2x(UFieldN)
  6634. if symbol(StoredAs)<> 'VAR' then
  6635. CryAndDie('Line #' || ImportFileLine || ' - Unknown field name of "' || FieldN || '"')
  6636. FieldOptions=_valueG(StoredAs)
  6637. StoredAs='mlFValues?.mlv?' ||c2x(UFieldN)
  6638. if symbol(StoredAs)='VAR' then
  6639. CryAndDie('Line #' || ImportFileLine || ' - Field name of "' || FieldN || '" specified more than once')
  6640. if FieldV='' then
  6641. do
  6642. if pos('NONBLANK',FieldOptions)<>0 then
  6643. CryAndDie('Line #' || ImportFileLine || ' - Field "' || FieldN || '" contains a blank value')
  6644. end
  6645. if pos('NOASIS',FieldOptions)=0 then
  6646. call _valueS StoredAs,AsIs(FieldV)
  6647. else
  6648. call _valueS StoredAs,FieldV
  6649. MlFieldCnt=MlFieldCnt+1
  6650. return
  6651.  
  6652. _MlGenerateRecord:
  6653. do FieldIndex=1 to NumberOfFields
  6654. FieldName=MlFieldName.FieldIndex
  6655. StoredAs='mlFValues?.mlv?' ||c2x(FieldName)
  6656. if symbol(StoredAs)='VAR' then
  6657. call _AddField2Record _valueG(StoredAs)
  6658. else
  6659. do
  6660. FieldOptions=_valueG('mlFIndex?.mli?' ||c2x(FieldName))
  6661. if pos('REQUIRED',FieldOptions)<>0 then
  6662. CryAndDie('Line #' || ImportFileLine || ' - Required field "' || FieldName || '" was not specified')
  6663. call _AddField2Record ''
  6664. end
  6665. end
  6666. call GenerateRecordFromFields
  6667. return
  6668.  
  6669. GetMlField:call TRACE "OFF"
  6670. if MultiLineImportInProgress<> 'Y' then
  6671. CryAndDie('GetMlField(): Multi line import is not in progress!')
  6672. FieldName=translate(arg(1))
  6673. StoredAs='mlFValues?.mlv?' ||c2x(FieldName)
  6674. if symbol(StoredAs)='VAR' then
  6675. return(_valueG(StoredAs))
  6676. CryAndDie('Line #' || ImportFileLine || ' - GetMlField(): Field "' || FieldName || '" is unknown!')
  6677.  
  6678. I_ML_30:
  6679. call LoopInit
  6680. signal LOOP_31
  6681.  
  6682. LoopInit:
  6683. InLoop='N'
  6684. LoopCount=0
  6685. LoopLine=1
  6686. LoopFirstLineNumber=-1
  6687. LoopIfNesting=-1
  6688. LoopLinesFromFile=-1
  6689. return
  6690.  
  6691. LoopPush:
  6692. SavedAs=arg(1)
  6693. SFI_InLoop.SavedAs=InLoop
  6694. SFI_LoopCount.SavedAs=LoopCount
  6695. SFI_LoopLine.SavedAs=LoopLine
  6696. SFI_LoopLinesFromFile.SavedAs=LoopLinesFromFile
  6697. SFI_LoopFirstLineNumber.SavedAs=LoopFirstLineNumber
  6698. SFI_LoopIfNesting.SavedAs=LoopIfNesting
  6699. do SaveIndex=1 to LoopCount
  6700. SavedPpwLoop.SaveIndex.SavedAs=PpwLoop.SaveIndex
  6701. end
  6702. call LoopInit
  6703. return
  6704.  
  6705. LoopPop:
  6706. SavedAs=arg(1)
  6707. InLoop=SFI_InLoop.SavedAs
  6708. LoopCount=SFI_LoopCount.SavedAs
  6709. LoopLine=SFI_LoopLine.SavedAs
  6710. LoopLinesFromFile=SFI_LoopLinesFromFile.SavedAs
  6711. LoopFirstLineNumber=SFI_LoopFirstLineNumber.SavedAs
  6712. LoopIfNesting=SFI_LoopIfNesting.SavedAs
  6713. do SaveIndex=1 to LoopCount
  6714. PpwLoop.SaveIndex=SavedPpwLoop.SaveIndex.SavedAs
  6715. end
  6716. return
  6717.  
  6718. ProcessLoopStart:
  6719. if InLoop='Y' then
  6720. CryAndDie("Can't nest loops")
  6721. InLoop='Y'
  6722. LoopCount=0
  6723. LoopLine=1
  6724. LoopFirstLineNumber=IncludeLineNumber
  6725. LoopIfNesting=IfNesting
  6726. if IncludeMemBufferNextLine=='' then
  6727. LoopLinesFromFile=1
  6728. else
  6729. LoopLinesFromFile=0
  6730. LengthEndCmd=length(CmdHashLoopE)
  6731. FoundEnd='N'
  6732. do while IncludeFileLines()<>0
  6733. LoopCount=LoopCount+1
  6734. if LoopLinesFromFile=1 then
  6735. do
  6736. PpwLoop.LoopCount=IncludeFileLineIn()
  6737. InputLines=InputLines+1
  6738. end
  6739. else
  6740. do
  6741. if IncludeMemBufferNextLine=='' then
  6742. leave
  6743. parse var IncludeMemBufferNextLine PpwLoop.LoopCount (MarksNewLine) IncludeMemBufferNextLine
  6744. end
  6745. MaybeEndCmd=left(strip(PpwLoop.LoopCount, 'L'),LengthEndCmd)
  6746. if MaybeEndCmd=CmdHashLoopE then
  6747. do
  6748. FoundEnd='Y'
  6749. LoopCount=LoopCount-1
  6750. if LoopCount=0 then
  6751. CryAndDie("No commands found in body of loop!")
  6752. leave
  6753. end
  6754. end
  6755. if FoundEnd='N' then
  6756. do
  6757. if LoopLinesFromFile then
  6758. eLoop='EOF'
  6759. else
  6760. eLoop='end of macro'
  6761. CryAndDie('Could not find "' || CmdHashLoopE || '" before ' ||eLoop)
  6762. end
  6763. call DebugLine 'Loop is ' || LoopCount || ' line(s) long and ends on line ' ||AddCommasToDecimalNumber(IncludeLineNumber)
  6764. return(0)
  6765.  
  6766. GetLoopLineIntoFileLine:
  6767. FileLine=PpwLoop.LoopLine
  6768. if LoopLinesFromFile then
  6769. IncludeLineNumber=LoopFirstLineNumber+LoopLine
  6770. LoopLine=LoopLine+1
  6771. if LoopLine>LoopCount then
  6772. LoopLine=1
  6773. return(FileLine)
  6774.  
  6775. ProcessLoopBreak:
  6776. call DebugLine 'Exiting loop'
  6777. InLoop='N'
  6778. IfNesting=LoopIfNesting
  6779. if LoopLinesFromFile then
  6780. IncludeLineNumber=LoopFirstLineNumber+LoopCount+1
  6781. return(0)
  6782.  
  6783. ProcessLoopContinue:
  6784. call DebugLine 'Back to start of loop'
  6785. LoopLine=1
  6786. IfNesting=LoopIfNesting
  6787. return(0)
  6788.  
  6789. LOOP_31:
  6790. _RestrictKeyMinimum=xrange('A', 'Z') || xrange('a', 'z') || xrange('0', '9')
  6791. _giCounter=0
  6792. signal GetId_32
  6793.  
  6794. GetIdPrepare:call TRACE "OFF"
  6795. giHandle=arg(1)
  6796. giUniqueId=translate(arg(2))
  6797. interpret 'drop GI?'  || giHandle || '.'
  6798. call _valueS 'GI?'  || giHandle || '.GI?UID',giUniqueId
  6799. return
  6800.  
  6801. SetId:call TRACE "OFF"
  6802. giHandle=arg(1)
  6803. giName=arg(2)
  6804. giId=arg(3)
  6805. giSaveAsPrefix='GI?'  || giHandle || '.GI?'
  6806. if giName\=='' then
  6807. do
  6808. if _valueG(giSaveAsPrefix|| 'UID') = 'Y' then
  6809. CryAndDie("You have asked for UNIQUE ID's to be generated. Don't use SetId()!!!")
  6810. giKeySavedAs=giSaveAsPrefix|| 'KEY_' ||c2x(giName)
  6811. if symbol(giKeySavedAs)='VAR' then
  6812. CryAndDie('SetId(): The KEY of "' || giName || '" has already been used')
  6813. call _valueS giKeySavedAs,giId
  6814. end
  6815. IdSavedAs=giSaveAsPrefix|| 'ID_' ||c2x(giId)
  6816. if symbol(IdSavedAs)='VAR' then
  6817. CryAndDie('SetId(): The ID of "' || giId || '" has already been used')
  6818. call _valueS IdSavedAs, ''
  6819. return('')
  6820.  
  6821. GetId:call TRACE "OFF"
  6822. giHandle=arg(1)
  6823. giType=translate(arg(2))
  6824. giName=arg(3)
  6825. giSaveAsPrefix='GI?'  || giHandle || '.GI?'
  6826. giUniqueId=_valueG(giSaveAsPrefix|| 'UID')
  6827. if giUniqueId<> 'Y' then
  6828. do
  6829. giKeySavedAs=giSaveAsPrefix|| 'KEY_' ||c2x(giName)
  6830. if symbol(giKeySavedAs)='VAR' then
  6831. return(_valueG(giKeySavedAs))
  6832. end
  6833. GiMaxLength=''
  6834. select
  6835. when giType="MAXCHARS" then
  6836. do
  6837. CanBeDuplicated='Y'
  6838. GiMaxLength=arg(5)
  6839. if GiMaxLength='' then
  6840. GiMaxLength=8
  6841. giId=_Id_2_(giName,arg(4))
  6842. if length(giId)>GiMaxLength then
  6843. giId=left(giId,GiMaxLength)
  6844. end
  6845. when giType="C2X" then
  6846. do
  6847. CanBeDuplicated='N'
  6848. giId=_Id_c2x(giName,arg(4))
  6849. end
  6850. when giType="2_" then
  6851. do
  6852. CanBeDuplicated='Y'
  6853. giId=_Id_2_(giName,arg(4))
  6854. end
  6855. otherwise
  6856. CryAndDie('GetId(): Invalid type of "' || giType || '" specified')
  6857. end
  6858. if CanBeDuplicated='Y' then
  6859. do
  6860. IdSavedAs=giSaveAsPrefix|| 'ID_' ||c2x(giId)
  6861. if symbol(IdSavedAs)='VAR' then
  6862. do
  6863. GiIndex=1
  6864. do forever
  6865. if GiMaxLength='' then
  6866. giTryId=giId||GiIndex
  6867. else
  6868. do
  6869. giChopLength=GiMaxLength-length(GiIndex)
  6870. if length(giId)>giChopLength then
  6871. giTryId=left(giId,giChopLength)||GiIndex
  6872. else
  6873. giTryId=giId||GiIndex
  6874. end
  6875. GiIndex=GiIndex+1
  6876. IdSavedAs=giSaveAsPrefix|| 'ID_' ||c2x(giTryId)
  6877. if symbol(IdSavedAs)<> 'VAR' then
  6878. do
  6879. giId=giTryId
  6880. leave
  6881. end
  6882. end
  6883. end
  6884. call _valueS IdSavedAs, ''
  6885. end
  6886. if giUniqueId<> 'Y' then
  6887. call _valueS giKeySavedAs,giId
  6888. return(giId)
  6889.  
  6890. _Id_2_:
  6891. parse arg KeyR,RestrictTo
  6892. RestrictTo=_RestrictKeyMinimum||RestrictTo
  6893. KeyL=''
  6894. InvPos=verify(KeyR,RestrictTo)
  6895. do while InvPos<>0
  6896. KeyL=KeyL||left(KeyR,InvPos-1)|| '_'
  6897. KeyR=substr(KeyR,InvPos+1)
  6898. InvPos=verify(KeyR,RestrictTo)
  6899. end
  6900. KeyL=strip(KeyL||KeyR,, '_')
  6901. do until BeforeCount=ReplaceCount
  6902. BeforeCount=ReplaceCount
  6903. KeyL=ReplaceString(KeyL, "__", "_")
  6904. end
  6905. if KeyL='' then
  6906. return('_')
  6907. else
  6908. return(KeyL)
  6909.  
  6910. _Id_c2x:
  6911. parse arg KeyR,RestrictTo
  6912. RestrictTo=_RestrictKeyMinimum||RestrictTo
  6913. KeyL=''
  6914. InvPos=verify(KeyR,RestrictTo)
  6915. do while InvPos<>0
  6916. KeyL=KeyL||left(KeyR,InvPos-1)|| 'x' ||c2x(substr(KeyR,InvPos,1))
  6917. KeyR=substr(KeyR,InvPos+1)
  6918. InvPos=verify(KeyR,RestrictTo)
  6919. end
  6920. return(KeyL||KeyR)
  6921.  
  6922. GetId_32:
  6923. TraceBpListsLoaded=''
  6924. TraceAutoAliasCnt=0
  6925. TraceAutoAliasMax=0
  6926. signal ExecCmd_33
  6927.  
  6928. ExecRexxCmd:
  6929. InterpretThisC=arg(1)
  6930. if RexWhich='REGINA' then
  6931. UseEos=MarksNewLine
  6932. else
  6933. UseEos=';'
  6934. InterpretThisC=ReplaceEos(InterpretThisC)
  6935. InterpretThis=InterpretThisC
  6936. TraceBreakPoint=''
  6937. PrevTracedLine=''
  6938. if OptionDebugOn='Y' then
  6939. do
  6940. call DebugLine_INTERPRET 'Interpreting ' ||DebugRightArrow||InterpretThisC||DebugLeftArrow
  6941. call DebugLine_INTERPRET 'Rexx code is ' || AddCommasToDecimalNumber(length(InterpretThisC)) || ' bytes long'
  6942. if bitand(DebugLevel,SeeRexxTrace)==SeeRexxTrace then
  6943. do
  6944. TraceLevel4Rexx=translate(GetDefineValueOrUseDefault('REXXTRACE', 'INTERMEDIATES'))
  6945. if TraceLevel4Rexx<> 'OFF' then
  6946. InterpretThis='TRACE ' || TraceLevel4Rexx || ';' || InterpretThisC || ';call TRACE "OFF";'
  6947. TraceBreakPoint=strip(GetDefineValueOrUseDefault('REXX_BP', ''))
  6948. if TraceBreakPoint='' then
  6949. TraceBpList=''
  6950. else
  6951. do
  6952. if length(TraceBreakPoint)>1&left(TraceBreakPoint,1)='=' then
  6953. do
  6954. TraceBreakPoint='=' ||MacroGet(strip(substr(TraceBreakPoint,2)))
  6955. TraceBreakPoint=ReplaceEos(PerformReplacementsInCmdsParameters(TraceBreakPoint))
  6956. end
  6957. if TraceAutoAliasMax=0 then
  6958. do
  6959. TraceAutoAliasMax=GetDefineValueOrUseDefault('REXX_BP_MAX_AUTO_CMD',22)
  6960. if datatype(TraceAutoAliasMax, 'W')=0 then
  6961. TraceAutoAliasMax=22
  6962. if TraceAutoAliasMax<10 then
  6963. TraceAutoAliasMax=22
  6964. end
  6965. TraceBpList=GetDefineValueOrUseDefault('REXX_BP_ALIAS', '')
  6966. if TraceBpList<>TraceBpListsLoaded then
  6967. TraceBpListsLoaded=''
  6968. end
  6969. call Line1 ''
  6970. call Line1 '---------- REXX TRACE - START(' || TraceLevel4Rexx || ') ----------'
  6971. end
  6972. end
  6973. signal ON SYNTAX NAME _SyntaxErrorDuringInterpret
  6974. signal ON NOVALUE NAME _UnknownVariableDuringInterpret
  6975. interpret InterpretThis
  6976. TraceBreakPoint=''
  6977. if OptionDebugOn='Y' then
  6978. do
  6979. if bitand(DebugLevel,SeeRexxTrace)==SeeRexxTrace then
  6980. do
  6981. call Line1 '---------- REXX TRACE - END(' || TraceLevel4Rexx || ') ----------'
  6982. call Line1 ''
  6983. end
  6984. end
  6985. return
  6986.  
  6987. _UnknownVariableDuringInterpret:
  6988. TrappingLine=SIGL
  6989. call TRACE "OFF"
  6990. call CommonTrapHandler TrappingLine, 'NoValue Abort!', 'Unknown Variable', condition('D'),space(InterpretThisC),TraceBreakPoint
  6991.  
  6992. _SyntaxErrorDuringInterpret:
  6993. TrappingLine=SIGL
  6994. call TRACE "OFF"
  6995. call CommonTrapHandler TrappingLine, 'Syntax Error!', 'Reason',errortext(Rc),space(InterpretThisC),TraceBreakPoint
  6996.  
  6997. ReplaceEos:
  6998. return(ReplaceString(arg(1),DefRexxSpecialSepTag,UseEos))
  6999.  
  7000. AddToBpSearch:
  7001. RtSearchText=RtSearchText|| '{SOL}' || space(arg(1)) || '{EOL}'
  7002. return
  7003.  
  7004. RexxTrace:call TRACE "OFF"
  7005. if OptionDebugOn='N' then
  7006. return
  7007. if bitand(DebugLevel,SeeRexxTrace)\==SeeRexxTrace then
  7008. return
  7009. signal on NOVALUE name RexxTrapUninitializedVariable
  7010. signal on SYNTAX name RexxTrapSyntaxError
  7011. parse arg rtText,rtDumpList,rtDbgCmd,rtDbgTrapped
  7012. if rtDbgCmd<> 'Y' then
  7013. rtSay='  $SAY: ' ||rtText
  7014. else
  7015. rtSay='$TRACE: ' ||rtText
  7016. call Line1 PpwRexxTraceColor||rtSay||Reset
  7017. RtSearchText=''
  7018. call AddToBpSearch rtText
  7019. if rtDbgTrapped<> 'Y' then
  7020. do
  7021. rtThis=''
  7022. if rtDbgCmd='Y' then
  7023. do
  7024. rtThis=PrevTracedLine|| ' ' ||rtText
  7025. PrevTracedLine=rtText
  7026. end
  7027. else
  7028. rtThis=rtDumpList
  7029. if rtThis<> '' then
  7030. do
  7031. if rtThis<> '?' then
  7032. call DumpVarsInExpression rtThis, '', '', 'TraceVarSay'
  7033. else
  7034. do
  7035. call Line1 'ALL KNOWN VARIABLES'
  7036. call Line1 '~~~~~~~~~~~~~~~~~~~'
  7037. call DumpVarsInExpression InterpretThisC, '', '', 'TraceVarSay'
  7038. end
  7039. end
  7040. end
  7041. call Line1 ''
  7042. if rtDbgTrapped='Y' then
  7043. rtStop='Y'
  7044. else
  7045. do
  7046. if TraceBreakPoint='' then
  7047. rtStop='N'
  7048. else
  7049. do
  7050. select
  7051. when TraceBreakPoint='?' then
  7052. rtStop='Y'
  7053. when left(TraceBreakPoint,1)='=' then
  7054. do
  7055. rtStop='N'
  7056. call ExecuteUsersTraceCmd substr(TraceBreakPoint,2)
  7057. end
  7058. otherwise
  7059. do
  7060. if pos(TraceBreakPoint,RtSearchText)<>0 then
  7061. rtStop='Y'
  7062. else
  7063. rtStop='N'
  7064. end
  7065. end
  7066. end
  7067. end
  7068. if rtStop='N' then
  7069. return
  7070. call LoadBpLists
  7071. do forever
  7072. call charout,InfoColor|| '<' || '$TRACE, ' || BpAliasCnt || ' aliases> ' ||Reset
  7073. rtCmd=strip(linein())
  7074. if rtCmd='' then
  7075. return
  7076. rtCmdU=translate(rtCmd)
  7077. select
  7078. when left(rtCmd,1)='/' then
  7079. do
  7080. EqPos=pos('=',rtCmd)
  7081. if EqPos<>0 then
  7082. do
  7083. call AddBpAlias rtCmd, "user"
  7084. STo=SaveBpAliasFile()
  7085. if STo='' then
  7086. STxt='Done (not permanently saved)!'
  7087. else
  7088. STxt='Done, saved to "' || STo || '".'
  7089. call Line1 HighlightColor||STxt||Reset
  7090. end
  7091. else
  7092. do
  7093. rtAlias=strip(substr(rtCmd,2))
  7094. if left(rtAlias,1)='#' | datatype(rtAlias, 'W')then
  7095. do
  7096. if left(rtAlias,1)='#' then
  7097. rtAliasI=strip(substr(rtAlias,2))
  7098. else
  7099. rtAliasI=rtAlias
  7100. if rtAliasI>TraceAutoAliasCnt then
  7101. do
  7102. call Line1 ErrorColor|| '#Alias "#' || rtAliasI || '" does not exist!' ||Reset||Beep
  7103. iterate
  7104. end
  7105. rtAliasI=(TraceAutoAliasCnt-rtAliasI)+1
  7106. rtCmd=Aalias.rtAliasI
  7107. end
  7108. else
  7109. do
  7110. rtCmd=FindBpAlias(rtAlias)
  7111. if rtCmd='' then
  7112. do
  7113. call Line1 ErrorColor|| 'Alias "' || rtAlias || '" not found!' ||Reset||Beep
  7114. iterate
  7115. end
  7116. end
  7117. call Line1 HighlightColor||rtCmd||Reset
  7118. call ExecuteUsersTraceCmd rtCmd
  7119. end
  7120. end
  7121. when left(rtCmd,1)='?' then
  7122. do
  7123. rtCmdU=substr(rtCmdU,2)
  7124. call Char1 PpwRexxTraceColor
  7125. select
  7126. when rtCmdU='' then
  7127. do
  7128. call Line1 PpwRexxTraceColor||rtText||Reset
  7129. end
  7130. when abbrev('VARIABLES',rtCmdU)then
  7131. do
  7132. call Line1 'ALL KNOWN VARIABLES'
  7133. call Line1 '~~~~~~~~~~~~~~~~~~~'
  7134. call DumpVarsInExpression InterpretThisC, '', '', 'TraceVarSay'
  7135. end
  7136. when abbrev('ALIASES',rtCmdU)then
  7137. do
  7138. call Line1 'ALL ALIASES'
  7139. call Line1 '~~~~~~~~~~~'
  7140. do Index=1 to BpAliasCnt
  7141. call Line1 left(BpAlias.Index.BpAName,BpLongestAlias)|| ' = ' ||BpAlias.Index.BpAValue
  7142. end
  7143. end
  7144. when abbrev('#ALIASES',rtCmdU)then
  7145. do
  7146. if TraceAutoAliasCnt=0 then
  7147. call Line1 ErrorColor|| 'No commands have been remembered yet!' ||Reset||Beep
  7148. else
  7149. do
  7150. MaxLng=length(TraceAutoAliasCnt)
  7151. call Line1 'ALL # ALIASES'
  7152. call Line1 '~~~~~~~~~~~~~'
  7153. do Index=1 to TraceAutoAliasCnt
  7154. IndexR=(TraceAutoAliasCnt-Index)+1
  7155. call Line1 '/#' || left(IndexR, MaxLng)  || ' = ' ||Aalias.Index
  7156. end
  7157. end
  7158. end
  7159. otherwise
  7160. call Line1 ErrorColor|| 'Unknown ? command of "' || rtCmd || '"!' ||Reset||Beep
  7161. end
  7162. call Char1 Reset
  7163. end
  7164. when rtCmdU='BP' then
  7165. do
  7166. call charout,InfoColor|| "New Breakpoint (blank = none) => " ||Reset
  7167. TraceBreakPoint=strip(linein())
  7168. end
  7169. otherwise
  7170. do
  7171. if ExecuteUsersTraceCmd(rtCmd)=0 then
  7172. do
  7173. if AddAutoAlias(rtCmd)<>0 then
  7174. call SaveBpAliasFile
  7175. end
  7176. end
  7177. end
  7178. end
  7179. return
  7180.  
  7181. TraceVarSay:
  7182. call Line1 PpwRexxTraceColor|| "      | " ||arg(1)||Reset
  7183. call AddToBpSearch arg(1)
  7184. return
  7185.  
  7186. ExecuteUsersTraceCmd:
  7187. signal ON SYNTAX NAME _SyntaxErrorDuringExecuteUsersTraceCmd
  7188. signal ON NOVALUE NAME _UnknownVariableDuringExecuteUsersTraceCmd
  7189. interpret arg(1)
  7190. return(0)
  7191.  
  7192. _SyntaxErrorDuringExecuteUsersTraceCmd:
  7193. call Line1 ErrorColor|| 'SYNTAX ERROR: ' ||errortext(Rc)||Reset
  7194. call Line1 Beep
  7195. return(1)
  7196.  
  7197. _UnknownVariableDuringExecuteUsersTraceCmd:
  7198. call Line1 ErrorColor|| 'NOVALUE ERROR: VAR=' || condition('D')||Reset
  7199. call Line1 Beep
  7200. return(1)
  7201.  
  7202. LoadBpLists:
  7203. if TraceBpListsLoaded<> '' then
  7204. return
  7205. BpSaveTo=''
  7206. BpList=TraceBpList
  7207. BpAliasCnt=0
  7208. BpFileNumb=0
  7209. do while BpList<> ''
  7210. parse var BpList BpList1';'BpList
  7211. BpFileNumb=BpFileNumb+1
  7212. if BpFileNumb=1 then
  7213. BpSaveTo=BpList1
  7214. if BpList1='' then
  7215. iterate
  7216. BpList1=FindIncludeFile(BpList1)
  7217. if BpList1='' then
  7218. iterate
  7219. CloseRc=stream(BpList1, 'c', 'close')
  7220. BpListLine=0
  7221. BpLongestAlias=0
  7222. do while lines(BpList1)<>0
  7223. CurrentLine=strip(linein(BpList1))
  7224. BpListLine=BpListLine+1
  7225. if CurrentLine='' | left(CurrentLine, 1) = ';' then
  7226. iterate
  7227. AliasSource='line #' || BpListLine || ' of ' ||BpList1
  7228. call AddBpAlias CurrentLine,AliasSource,BpFileNumb
  7229. end
  7230. CloseRc=stream(BpList1, 'c', 'close')
  7231. end
  7232. TraceBpListsLoaded=TraceBpList
  7233. return
  7234.  
  7235. AddBpAlias:
  7236. parse arg AliasCmd,AliasSrc,FromFile
  7237. parse var AliasCmd '/'BpAliasName'='BpAliasValue
  7238. if BpAliasValue='' then
  7239. do
  7240. call DebugLine 'Alias Command from ' || AliasSrc || ' incorrectly formatted!'
  7241. return
  7242. end
  7243. BpAliasName=translate(BpAliasName)
  7244. if left(BpAliasName,1)=='#' then
  7245. do
  7246. call AddAutoAlias BpAliasValue
  7247. return
  7248. end
  7249. if length(BpAliasName)>BpLongestAlias then
  7250. BpLongestAlias=length(BpAliasName)
  7251. FoundIndex=0
  7252. do Index=1 to BpAliasCnt
  7253. if BpAliasName=BpAlias.Index.BpAName then
  7254. do
  7255. FoundIndex=Index
  7256. leave
  7257. end
  7258. end
  7259. if FoundIndex<>0 then
  7260. do
  7261. if FromFile<> '' then
  7262. return
  7263. end
  7264. else
  7265. do
  7266. BpAliasCnt=BpAliasCnt+1
  7267. FoundIndex=BpAliasCnt
  7268. end
  7269. BpAlias.FoundIndex.BpAName=BpAliasName
  7270. BpAlias.FoundIndex.BpAValue=BpAliasValue
  7271. BpAlias.FoundIndex.BpFNumb=FromFile
  7272. return
  7273.  
  7274. FindBpAlias:
  7275. BpAliasName=translate(strip(arg(1)))
  7276. do Index=1 to BpAliasCnt
  7277. if BpAliasName=BpAlias.Index.BpAName then
  7278. return(BpAlias.Index.BpAValue)
  7279. end
  7280. return('')
  7281.  
  7282. SaveBpAliasFile:
  7283. if BpSaveTo='' then
  7284. return('')
  7285. call MustDeleteFile BpSaveTo
  7286. call lineout BpSaveTo, ';***'
  7287. call lineout BpSaveTo, ';*** Automatically saved at: ' ||NiceDateTime()
  7288. call lineout BpSaveTo, ';***'
  7289. call lineout BpSaveTo, ''
  7290. FoundF='N'
  7291. do Index=1 to BpAliasCnt
  7292. if BpAlias.Index.BpFNumb=1 then
  7293. do
  7294. if FoundF='N' then
  7295. call lineout BpSaveTo, ';--- Loaded From File ---'
  7296. FoundF='Y'
  7297. call lineout BpSaveTo, '/' || BpAlias.Index.BpAName || '=' ||BpAlias.Index.BpAValue
  7298. end
  7299. end
  7300. CloseRc=stream(BpSaveTo, 'c', 'close')
  7301. FoundU='N'
  7302. do Index=1 to BpAliasCnt
  7303. if BpAlias.Index.BpFNumb=''then
  7304. do
  7305. if FoundU='N' then
  7306. do
  7307. if FoundF='Y' then
  7308. call lineout BpSaveTo, ''
  7309. call lineout BpSaveTo, ';--- User Modified This Session ---'
  7310. end
  7311. FoundU='Y'
  7312. call lineout BpSaveTo, '/' || BpAlias.Index.BpAName || '=' ||BpAlias.Index.BpAValue
  7313. end
  7314. end
  7315. CloseRc=stream(BpSaveTo, 'c', 'close')
  7316. if TraceAutoAliasCnt<>0 then
  7317. do
  7318. call lineout BpSaveTo, ''
  7319. call lineout BpSaveTo, ';--- Last Few Commands Used ---'
  7320. do Index=1 to TraceAutoAliasCnt
  7321. IndexN=(TraceAutoAliasCnt-Index)+1
  7322. call lineout BpSaveTo, '/#' || IndexN  || '=' ||Aalias.Index
  7323. end
  7324. end
  7325. CloseRc=stream(BpSaveTo, 'c', 'close')
  7326. return(BpSaveTo)
  7327.  
  7328. FindAutoAlias:
  7329. FindWhat=arg(1)
  7330. do FndIndex=1 to TraceAutoAliasCnt
  7331. if FindWhat=Aalias.FndIndex then
  7332. return(FndIndex)
  7333. end
  7334. return(0)
  7335.  
  7336. DeleteAutoAlias:
  7337. DelIndex=arg(1)
  7338. do DelIndexT=DelIndex to TraceAutoAliasCnt-1
  7339. DelIndexF=DelIndexT+1
  7340. Aalias.DelIndexT=Aalias.DelIndexF
  7341. end
  7342. TraceAutoAliasCnt=TraceAutoAliasCnt-1
  7343. return
  7344.  
  7345. AddAutoAlias:
  7346. SaveWhat=strip(arg(1))
  7347. if SaveWhat='' then
  7348. return(0)
  7349. FoundAt=FindAutoAlias(SaveWhat)
  7350. if FoundAt<>0 then
  7351. call DeleteAutoAlias FoundAt
  7352. if TraceAutoAliasCnt>=TraceAutoAliasMax then
  7353. call DeleteAutoAlias 1
  7354. TraceAutoAliasCnt=TraceAutoAliasCnt+1
  7355. Aalias.TraceAutoAliasCnt=SaveWhat
  7356. return(TraceAutoAliasCnt)
  7357.  
  7358. ExecCmd_33:
  7359. ExpandXEarly='N'
  7360. ExpandXLate='N'
  7361. ExpandXCmd='N'
  7362. signal EndExpandX
  7363.  
  7364. EXPANDX_DEBUG:
  7365. if OptionDebugOn='Y' then
  7366. do
  7367. if ExpandX='NONE' then
  7368. call OptionDebugShow 'EXPANDX', 'X codes are never expanded'
  7369. else
  7370. call OptionDebugShow 'EXPANDX', 'X codes are expanded "' || ExpandX || '"'
  7371. end
  7372. return
  7373.  
  7374. EXPANDX_GET:
  7375. call EXPANDX_DEBUG
  7376. return(ExpandX)
  7377.  
  7378. EXPANDX_SET:
  7379. ExpandX=translate(arg(1))
  7380. if ProcessedCmdLine='N' then
  7381. do
  7382. call OptionDebugShow 'EXPANDX', 'Setting default value of "X" var expansion to "' || EXPANDX || '"'
  7383. Default4_EXPANDX=ExpandX
  7384. return(0)
  7385. end
  7386. if ExpandX=='' then
  7387. ExpandX=Default4_EXPANDX
  7388. ExpandXEarly='N'
  7389. ExpandXLate='N'
  7390. ExpandXCmd='N'
  7391. if ExpandX<> 'NONE' then
  7392. do
  7393. TmpList=translate(ExpandX)
  7394. do while TmpList<> ''
  7395. parse var TmpList ThisItem','TmpList
  7396. select
  7397. when ThisItem='COMMAND' then
  7398. ExpandXCmd='Y'
  7399. when ThisItem='EARLY' then
  7400. ExpandXEarly='Y'
  7401. when ThisItem='LATE' then
  7402. ExpandXLate='Y'
  7403. otherwise
  7404. CryAndDie('Unknown EXPANDX option of "' || ThisItem || '"')
  7405. end
  7406. end
  7407. end
  7408. call EXPANDX_DEBUG
  7409. return
  7410.  
  7411. InitializeCharCodes:
  7412. call DebugLine_DEFINING 'Initializing <' || '?x00-FF> codes + <' || '?xRexxEos>'
  7413. do CharCode=0 to 255
  7414. call _valueS 'XVAR?.X?' ||c2x(translate(d2x(CharCode,2))),d2c(CharCode)
  7415. end
  7416. call _valueS 'XVAR?.X?'  || c2x(translate("RexxEos")),d2c(10)
  7417. return
  7418.  
  7419. ExpandXCodes:call TRACE "OFF"
  7420.  
  7421. ReplaceXCodesIfNotDisabled:
  7422. if pos(StartsStdSymbolReplacement_x,arg(1))=0 then
  7423. return(arg(1))
  7424.  
  7425. ReplaceTheXCodesWeKnowExist:
  7426. LeftBit=''
  7427. RightBit=arg(1)
  7428. StartPos=pos(StartsStdSymbolReplacement_x,RightBit)
  7429. do while StartPos<>0
  7430. ReplaceCount=ReplaceCount+1
  7431. EndPos=pos(EndsMacroReplacement,RightBit,StartPos+1)
  7432. XVarName='XVAR?.X?' ||c2x(translate(substr(RightBit,StartPos+3,(EndPos-StartPos)-3)))
  7433. if symbol(XVarName)='VAR' then
  7434. LeftBit=LeftBit||left(RightBit,StartPos-1)||_valueG(XVarName)
  7435. else
  7436. do
  7437. CryAndDie(StartsStdSymbolReplacement_x||substr(RightBit,StartPos+3,(EndPos-StartPos)-3)||EndsMacroReplacement|| ' is not defined (use "#RexxVar =x=" command)!')
  7438. end
  7439. RightBit=substr(RightBit,EndPos+1)
  7440. StartPos=pos(StartsStdSymbolReplacement_x,RightBit)
  7441. end
  7442. if OptionDebugOn='Y' then
  7443. call DebugOutputAfterReplacement LeftBit||RightBit, '?xXX'
  7444. return(LeftBit||RightBit)
  7445.  
  7446. EndExpandX:
  7447. signal OnExit_34
  7448.  
  7449. SetUpOnExitProcessingIfEndOfMainFile:
  7450. if IncludeLevel=1 then
  7451. do
  7452. if DoOnExit<> '' then
  7453. do
  7454. call DebugLine ''
  7455. call DebugLine '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
  7456. call DebugLine '!!! "#OnExit" processing follows !!!'
  7457. call DebugLine '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
  7458. call DebugLine ''
  7459. IncludeMemBufferNextLine=DoOnExit
  7460. DoOnExit=''
  7461. return('Y')
  7462. end
  7463. end
  7464. return('N')
  7465.  
  7466. ProcessOnExit:
  7467. Rest=strip(arg(1))
  7468. if Rest='' then
  7469. return
  7470. call DebugLine 'OnExit we will process ' ||DebugRightArrow||Rest||DebugLeftArrow
  7471. if DoOnExit='' then
  7472. DoOnExit=Rest
  7473. else
  7474. DoOnExit=DoOnExit||MarksNewLine||Rest
  7475. return(0)
  7476.  
  7477. OnExit_34:
  7478. IncludeIntoMemory=''
  7479. signal Include_35
  7480.  
  7481. RecursiveIncludeSave:
  7482. call LoopPush IncludeLevel
  7483. _DebugCurrentFileNumber.IncludeLevel=DebugCurrentFileNumber
  7484. _IncludeMemHandle.IncludeLevel=IncludeMemHandle
  7485. _IncludeEofLine.IncludeLevel=IncludeEofLine
  7486. _IncludeFragmentText.IncludeLevel=IncludeFragmentText
  7487. _IncludeLineNumber.IncludeLevel=IncludeLineNumber
  7488. _IncludeMemBufferNextLine.IncludeLevel=IncludeMemBufferNextLine
  7489. _EofForced.IncludeLevel=EofForced
  7490. EofForced=''
  7491. return
  7492.  
  7493. RecursiveIncludeRestore:
  7494. DebugCurrentFileNumber=_DebugCurrentFileNumber.IncludeLevel
  7495. IncludeMemHandle=_IncludeMemHandle.IncludeLevel
  7496. IncludeEofLine=_IncludeEofLine.IncludeLevel
  7497. IncludeFragmentText=_IncludeFragmentText.IncludeLevel
  7498. IncludeLineNumber=_IncludeLineNumber.IncludeLevel
  7499. IncludeMemBufferNextLine=_IncludeMemBufferNextLine.IncludeLevel
  7500. EofForced=_EofForced.IncludeLevel
  7501. IncludeFileName=IncludeFileName.IncludeLevel
  7502. call LoopPop IncludeLevel
  7503. return
  7504.  
  7505. FileInMemoryTimeStamp:
  7506. fimFullFileName=arg(1)
  7507. if RexSystemOpSys="UNIX" then
  7508. ifHandle='_IF_' || c2x(fimFullFileName) || '.'
  7509. else
  7510. ifHandle='_IF_' || c2x(translate(fimFullFileName)) || '.'
  7511. if symbol(ifHandle|| '!TS') <> 'VAR' then
  7512. return('')
  7513. else
  7514. do
  7515. Ts=_valueG(ifHandle|| '!TS')
  7516. if OptionDebugOn='Y' then
  7517. call DebugLine 'Cached Timestamp: "' || Ts || '"'
  7518. return(Ts)
  7519. end
  7520.  
  7521. IncludeFileOpen:
  7522. ifFullFileName=arg(1)
  7523. ifLoad2Mem=arg(2)
  7524. if RexSystemOpSys="UNIX" then
  7525. ifHandle='_IF_' || c2x(ifFullFileName) || '.'
  7526. else
  7527. ifHandle='_IF_' || c2x(translate(ifFullFileName)) || '.'
  7528. if symbol(ifHandle|| '0') = 'VAR' then
  7529. do
  7530. if OptionDebugOn='Y' then
  7531. call DebugLine '"' || ifFullFileName || '" will be read from memory cache'
  7532. return(_valueG(ifHandle|| '0') || ';' ||ifHandle)
  7533. end
  7534. CloseRc=stream(ifFullFileName, 'c', 'close')
  7535. OpenRc=stream(ifFullFileName, 'c', 'open read')
  7536. if ifLoad2Mem='' then
  7537. ifLoad2Mem=IncludeIntoMemory
  7538. if ifLoad2Mem='N' then
  7539. do
  7540. if OptionDebugOn='Y' then
  7541. call DebugLine 'Will read "' || ifFullFileName || '" directly from file'
  7542. return('')
  7543. end
  7544. if OptionDebugOn='Y' then
  7545. call DebugLine 'Will read "' || ifFullFileName || '" into memory cache'
  7546. Ts=GetFileTimeStamp(ifFullFileName)
  7547. call _valueS ifHandle|| '!TS',Ts
  7548. ifLineNum=0
  7549. do while lines(ifFullFileName)<>0
  7550. ifLineNum=ifLineNum+1
  7551. ifLineTxt=linein(ifFullFileName)
  7552. call _valueS ifHandle||ifLineNum,ifLineTxt
  7553. end
  7554. call _valueS ifHandle|| '0',ifLineNum
  7555. call DieIfIoErrorOccurred ifFullFileName, 'Y'
  7556. CloseRc=stream(ifFullFileName, 'c', 'close')
  7557. if OptionDebugOn='Y' then
  7558. do
  7559. call DebugIncrement 1
  7560. call DebugLine 'Read ' || AddCommasToDecimalNumber(ifLineNum) || ' lines'
  7561. call DebugIncrement-1
  7562. end
  7563. return(ifLineNum|| ';' ||ifHandle)
  7564.  
  7565. IncludeFileClose:
  7566. if IncludeMemHandle='' then
  7567. do
  7568. call DieIfIoErrorOccurred IncludeFileName, 'Y'
  7569. CloseRc=stream(IncludeFileName, 'c', 'close')
  7570. end
  7571. return
  7572.  
  7573. IncludeFileLines:
  7574. if IncludeMemHandle='' then
  7575. return(lines(IncludeFileName))
  7576. else
  7577. return(IncludeLineNumber<IncludeEofLine)
  7578.  
  7579. IncludeFileLineIn:
  7580. IncludeLineNumber=IncludeLineNumber+1
  7581. if IncludeMemHandle='' then
  7582. ifLineTxt=linein(IncludeFileName)
  7583. else
  7584. ifLineTxt=_valueG(IncludeMemHandle||IncludeLineNumber)
  7585. if ExtraWhiteSpace=='' then
  7586. return(ifLineTxt)
  7587. else
  7588. return(translate(ifLineTxt, '', ExtraWhiteSpace, ' '))
  7589.  
  7590. Include_35:
  7591. SummaryUserAllBldCount=0
  7592. SummaryUserOverallCount=0
  7593. SummaryUserThisBldCount=0
  7594. signal Summary_36
  7595.  
  7596. Summary:call TRACE "OFF"
  7597. parse arg SummaryLeft,SummaryRight,SummaryMode
  7598. SummaryLeft=strip(SummaryLeft)
  7599. SummaryMode1=translate(left(SummaryMode,1))
  7600. select
  7601. when SummaryMode1='D' then
  7602. do
  7603. call DebugLine "Don't" || ' want "' || SummaryLeft || '" in any summaries'
  7604. call _valueS '!SUMMDROP.!' ||c2x(SummaryLeft),CurrentSourceLocation()
  7605. end
  7606. when SummaryMode1='O' then
  7607. do
  7608. SummaryUserOverallCount=SummaryUserOverallCount+1
  7609. SummaryUserOverallL.SummaryUserOverallCount=SummaryLeft
  7610. SummaryUserOverallR.SummaryUserOverallCount=SummaryRight
  7611. end
  7612. when SummaryMode1='A' then
  7613. do
  7614. SummaryUserAllBldCount=SummaryUserAllBldCount+1
  7615. SummaryUserAllBldL.SummaryUserAllBldCount=SummaryLeft
  7616. SummaryUserAllBldR.SummaryUserAllBldCount=SummaryRight
  7617. end
  7618. otherwise
  7619. do
  7620. SummaryUserThisBldCount=SummaryUserThisBldCount+1
  7621. SummaryUserThisBldL.SummaryUserThisBldCount=SummaryLeft
  7622. SummaryUserThisBldR.SummaryUserThisBldCount=SummaryRight
  7623. end
  7624. end
  7625. return
  7626.  
  7627. GenerateUserSummaryThisBuild:
  7628. do SummLine=1 to SummaryUserThisBldCount
  7629. call AddSummaryLine SummaryUserThisBldL.SummLine,SummaryUserThisBldR.SummLine
  7630. end
  7631. SummaryUserThisBldCount=0
  7632. return
  7633.  
  7634. GenerateUserSummaryAllBuilds:
  7635. do SummLine=1 to SummaryUserAllBldCount
  7636. call AddSummaryLine SummaryUserAllBldL.SummLine,SummaryUserAllBldR.SummLine
  7637. end
  7638. return
  7639.  
  7640. GenerateUserSummaryOverall:
  7641. do SummLine=1 to SummaryUserOverallCount
  7642. call AddSummaryLine SummaryUserOverallL.SummLine,SummaryUserOverallR.SummLine
  7643. end
  7644. return
  7645.  
  7646. AboutToGenerateSummary:
  7647. MaxSummaryLeft=0
  7648. SummaryLines=0
  7649. call Line1 ''
  7650. if arg(1)<> 'N' then
  7651. do
  7652. TitleText='Summary'
  7653. call Line1 TitleColor
  7654. call Line1 TitleText
  7655. call Line1 copies('~',length(TitleText))||Reset
  7656. end
  7657. return
  7658.  
  7659. AddSummaryLine:
  7660. parse arg SummaryLeft,SummaryRight
  7661. SummaryLeft=strip(SummaryLeft)
  7662. DropSym='!SUMMDROP.!' ||c2x(SummaryLeft)
  7663. if symbol(DropSym)='VAR' then
  7664. do
  7665. call DebugLine 'Summary line for "' || SummaryLeft || '" unwanted (dropped at ' || _valueG(DropSym) || ')'
  7666. return
  7667. end
  7668. if length(SummaryLeft)>MaxSummaryLeft then
  7669. MaxSummaryLeft=length(SummaryLeft)
  7670. SummaryLines=SummaryLines+1
  7671. SummaryL.SummaryLines=SummaryLeft
  7672. SummaryR.SummaryLines=SummaryRight
  7673. return
  7674.  
  7675. GenerateSummaryLines:
  7676. do SummLine=1 to SummaryLines
  7677. call Line1 "   " || left(SummaryL.SummLine, MaxSummaryLeft) || ': ' ||SummaryR.SummLine
  7678. end
  7679. return
  7680.  
  7681. Summary_36:
  7682. numeric digits 14
  7683. trace off
  7684. CompileTime=NiceDateTime()
  7685. LineSourceBeingProcessed='?'
  7686. NullChar=d2c(0)
  7687. TabChar=d2c(9)
  7688. CrLf=d2c(13)||d2c(10)
  7689. MarksNewLine=d2c(10)
  7690. if RexSystemOpSys="UNIX" then
  7691. NewLineChars=MarksNewLine
  7692. else
  7693. NewLineChars=CrLf
  7694. if RexSystemOpSys="UNIX" then
  7695. MarksNewLineInHashDefine=d2c(2)|| 'nl' ||d2c(2)
  7696. else
  7697. MarksNewLineInHashDefine='nl'
  7698. MarksNewLineInHashDefine2=MarksNewLineInHashDefine||MarksNewLineInHashDefine
  7699. Ignore=0
  7700. LowerCase="abcdefghijklmnopqrstuvwxyz"
  7701. UpperCase="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  7702. DecimalDigits="0123456789"
  7703. DebugOnStuffOutputted='N'
  7704. WantedWarningRc=1
  7705. NotEqualInC='!' || '='
  7706. EofChar=d2c(26)
  7707. RexxCmtStart='/' || '*'
  7708. RexxCmtEnd='*' || '/'
  7709. TagSvNewLine='<' || '?NewLine>'
  7710. if RexSystemOpSys="OS/2" then
  7711. do
  7712. call SetColorCodes
  7713. call SetBeepCode
  7714. end
  7715. else
  7716. do
  7717. call RemoveColorCodes
  7718. call RemoveBeepCode
  7719. end
  7720. InputInterfaceVer="98.131"
  7721. OutputInterfaceVer="98.132"
  7722. call SetEnv "PPWIZARD_VER_II",InputInterfaceVer
  7723. call SetEnv "PPWIZARD_VER_OI",OutputInterfaceVer
  7724. ProtectPrefix='{PROTECT_' || time('Seconds') || '}'
  7725. ProtectFromPpwS="option PUSH LeaveBlankLines=YES KeepIndent=YES linecomment='NULL' LineContinuation='NULL' HashPrefix='" || ProtectPrefix || "'"
  7726. ProtectFromPpwE=ProtectPrefix|| 'option POP'
  7727. OptionWantInfoMsgs='Y'
  7728. OptionHashInclude=''
  7729. OptionTemplate=''
  7730. OptionDependsOn=''
  7731. OptionOutput=''
  7732. OptionSummary='Y'
  7733. OptionPack='N'
  7734. OptionTranslateFileNames='N'
  7735. OptionFilterIn=''
  7736. OptionFilterOut=''
  7737. OptionTabs='W'
  7738. OptionDefineCount=0
  7739. OptionKeepRexxCmts='N'
  7740. OptionCompleteAddToToDepFile='Y'
  7741. OptionHtmlGeneratorTags=PgmDefaultHtmlMetaTags
  7742. OptionsCmdLine=strip(arg(1))
  7743. OptionsEnvironment=GetEnv('PPWIZARD_OPTIONS')
  7744. TheCmdLine=OptionsEnvironment|| ' ' ||OptionsCmdLine
  7745. UpperTheCmdLine=translate(TheCmdLine)
  7746. LookFor=RexOptionChar|| 'DEBUG'
  7747. if(pos(LookFor|| ' ',UpperTheCmdLine)<>0)|(right(UpperTheCmdLine,length(LookFor))==LookFor)then
  7748. do
  7749. OptionDebugOn='Y'
  7750. OptionWantInfoMsgs='Y'
  7751. call DebugStateChanged
  7752. end
  7753. signal on NOVALUE name RexxTrapUninitializedVariable
  7754. signal on SYNTAX name RexxTrapSyntaxError
  7755. signal on HALT name RexxCtrlC
  7756. TrapHandler='FULL'
  7757. call SetUpPpwizardOptionDefaults
  7758. call InitializeCharCodes
  7759. call DebugLine 'Starting Processing of Parameters (from command line + Environment)'
  7760. call DebugIncrement 1
  7761. call DebugLine 'Switches start with "' || RexOptionChar || '"'
  7762. InputMaskCount=0
  7763. FullCommandLine=''
  7764. DebugSwitchUsed='N'
  7765. OptionWantCopyright='Y'
  7766. do while TheCmdLine<> ''
  7767. TheCmdLine=strip(TheCmdLine)
  7768. if left(TheCmdLine,1)='"' then
  7769. do
  7770. BeforeParse=TheCmdLine
  7771. parse value substr(TheCmdLine,2)with ThisParm'"'TheCmdLine
  7772. if TheCmdLine<> '' then
  7773. do
  7774. if left(TheCmdLine,1)\==' ' then
  7775. CryAndDie('Invalid quoted parameter at ==> ' ||BeforeParse)
  7776. end
  7777. end
  7778. else
  7779. do
  7780. parse var TheCmdLine ThisParm TheCmdLine
  7781. end
  7782. if left(ThisParm,1)=RexOptionChar then
  7783. ThisParmT='Switch'
  7784. else
  7785. ThisParmT='FileMask'
  7786. call DebugLine ThisParmT|| ': "' || ThisParm || '"'
  7787. call DebugIncrement 1
  7788. ThisParm=ReplaceCommandLineCodes(ThisParm)
  7789. FullCommandLine=space(FullCommandLine|| ' ' ThisParm)
  7790. if left(ThisParm,1)<>RexOptionChar then
  7791. do
  7792. InputMaskCount=InputMaskCount+1
  7793. InputMask.InputMaskCount=MakeAbsolute(ThisParm)
  7794. call DebugIncrement-1
  7795. iterate
  7796. end
  7797. parse var ThisParm ThisCmd':'ThisCmdOptions
  7798. ThisCmd=translate(substr(ThisCmd,2))
  7799. select
  7800. when ThisCmd='PACK' then
  7801. OptionPack=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7802. when ThisCmd='CRLF' then
  7803. do
  7804. if SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y') = 'Y' then
  7805. NewLineChars=CrLf
  7806. else
  7807. NewLineChars=MarksNewLine
  7808. end
  7809. when ThisCmd='OTHER' then
  7810. OptionCodeType='OTHER'
  7811. when ThisCmd='HTML' then
  7812. OptionCodeType='HTML'
  7813. when ThisCmd='REXX' then
  7814. do
  7815. call SwitchMustNotHaveOptions ThisCmd,ThisCmdOptions
  7816. OptionCodeType='REXX'
  7817. end
  7818. when ThisCmd='DEPENDSON' then
  7819. do
  7820. OptionDependsOn=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7821. if left(OptionDependsOn,1)<> '-' then
  7822. OptionSeeDependsProgress='Y'
  7823. else
  7824. do
  7825. OptionSeeDependsProgress='N'
  7826. OptionDependsOn=substr(OptionDependsOn,2)
  7827. end
  7828. end
  7829. when ThisCmd='DEPENDSONCOMPLETE' then
  7830. OptionCompleteAddToToDepFile=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7831. when ThisCmd='OUTPUT' then
  7832. OptionOutput=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7833. when ThisCmd='TEMPLATE' then
  7834. OptionTemplate=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7835. when ThisCmd='COLOR' | ThisCmd = 'COLOUR' then
  7836. do
  7837. call NotAvailableUnderNtYet ThisCmd
  7838. WantColor=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7839. if WantColor='N' then
  7840. call RemoveColorCodes
  7841. else
  7842. call SetColorCodes
  7843. end
  7844. when ThisCmd='BEEP' then
  7845. do
  7846. WantBeep=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7847. if WantBeep='N' then
  7848. call RemoveBeepCode
  7849. else
  7850. call SetBeepCode
  7851. end
  7852. when ThisCmd='WARNINGSIGNORE' then
  7853. WarningsToIgnore=translate(ThisCmdOptions)
  7854. when ThisCmd='WARNINGSRC' then
  7855. do
  7856. if ThisCmdOptions='' then
  7857. WantedWarningRc=1
  7858. else
  7859. do
  7860. WantedWarningRc=GetQuotedText(ThisCmdOptions)
  7861. if datatype(WantedWarningRc, 'W')=0 then
  7862. CryAndDie('Invalid warning return code of "' || WantedWarningRc || '" supplied!')
  7863. end
  7864. end
  7865. when ThisCmd='FILENAMES' then
  7866. do
  7867. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7868. OptionTranslateFileNames=translate(strip(ThisCmdOptions))
  7869. if OptionTranslateFileNames<> "LOWER" & OptionTranslateFileNames <> "UPPER" then
  7870. UserSyntaxError('Expected "UPPER" or "LOWER" on the "' || TheCmd || '" command, not "' || ThisCmdOptions || '"!')
  7871. end
  7872. when ThisCmd='DEFINE' then
  7873. do
  7874. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7875. parse var ThisCmdOptions DefineVar'='DefineContents
  7876. OptionDefineCount=OptionDefineCount+1
  7877. OptionDefine.OptionDefineCount.Var=DefineVar
  7878. OptionDefine.OptionDefineCount.Cont=strip(DefineContents)
  7879. end
  7880. when ThisCmd='OPTION' then
  7881. do
  7882. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7883. call ProcessOption ThisCmdOptions
  7884. end
  7885. when ThisCmd='FILTERINPUT' then
  7886. do
  7887. call NotAvailableUnderNtYet ThisCmd
  7888. OptionFilterIn=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7889. call DoMacroSpaceOperation "ADD", OptionFilterIn, "HtmlFilterIn"
  7890. end
  7891. when ThisCmd='FILTEROUTPUT' then
  7892. do
  7893. call NotAvailableUnderNtYet ThisCmd
  7894. OptionFilterOut=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7895. call DoMacroSpaceOperation "ADD", OptionFilterOut, "HtmlFilterOut"
  7896. end
  7897. when ThisCmd='TABS' then
  7898. do
  7899. OptionTabs=left(SwitchOptionsValidateAgainstList(ThisCmd,ThisCmdOptions, "ToSpaces,Ignore,Warnings"),1)
  7900. end
  7901. when ThisCmd='SPELLSHOWALL' then
  7902. SpellShowEachError=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7903. when ThisCmd='SPELLCHECK' then
  7904. do
  7905. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7906. call LoadSpellingDictionary ThisCmdOptions
  7907. end
  7908. when ThisCmd='SPELLADDWORD' then
  7909. do
  7910. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7911. SpellingAddFile=ThisCmdOptions
  7912. if left(SpellingAddFile,1)<> '-' then
  7913. SpellingPrompts='Y'
  7914. else
  7915. do
  7916. SpellingPrompts='OK'
  7917. SpellingAddFile=substr(SpellingAddFile,2)
  7918. end
  7919. end
  7920. when ThisCmd='**/' then
  7921. OptionKeepRexxCmts=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7922. when ThisCmd='INFO' then
  7923. OptionWantInfoMsgs=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7924. when ThisCmd='#INCLUDE' then
  7925. OptionHashInclude=ThisCmdOptions
  7926. when ThisCmd='CGI' then
  7927. call TurnCgiModeOn ThisCmdOptions
  7928. when ThisCmd='SLEEP' then
  7929. OnExitSleepFor=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7930. when ThisCmd='HTMLGENERATOR' then
  7931. OptionHtmlGeneratorTags=ThisCmdOptions
  7932. when ThisCmd='EXCLUDE' then
  7933. do
  7934. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7935. ExcludeList.0=0
  7936. TmpMask=ThisCmdOptions
  7937. call DebugLine 'Looking for files matching "' || TmpMask || '"'
  7938. if left(TmpMask,1)<> '+' then
  7939. FollowDirs='N'
  7940. else
  7941. do
  7942. FollowDirs='Y'
  7943. TmpMask=substr(TmpMask,2)
  7944. end
  7945. call GetListOfFiles TmpMask, 'ExcludeList',FollowDirs
  7946. call DebugIncrement 1
  7947. call DebugLine 'Found ' || ExcludeList.0 || ' files(s) to exclude'
  7948. call DebugIncrement 1
  7949. do InputIndex=1 to ExcludeList.0
  7950. TheFile=ExcludeList.InputIndex
  7951. call DebugLine TheFile
  7952. call _valueS "_EXCLUDE_._EXF_" || c2x(TheFile), 'you used "' || RexOptionChar || ThisCmd || ':' || ThisCmdOptions || '"'
  7953. end
  7954. call DebugIncrement-1
  7955. end
  7956. when ThisCmd='INC2CACHE' then
  7957. IncludeIntoMemory=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7958. when ThisCmd='$TRACE' then
  7959. call SetDollarTraceState SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7960. when ThisCmd='DEBUGTIME' then
  7961. OptionDebugTime=left(SwitchOptionsValidateAgainstList(ThisCmd,ThisCmdOptions, "N,NO,L,LONG,S,SHORT"),1)
  7962. when ThisCmd='HOOK' then
  7963. call RexxHookSet ThisCmd,ThisCmdOptions
  7964. when ThisCmd='REGSYNTAX' then
  7965. do
  7966. if RexWhich='REGINA' then
  7967. call DebugLine "/RegSyntax has no effect under Regina!"
  7968. NameOfOs2ReginaRexxInterpreter=ThisCmdOptions
  7969. end
  7970. when ThisCmd='REDIRMETHOD' then
  7971. RedirMethod=ThisCmdOptions
  7972. when ThisCmd='DEBUG' then
  7973. do
  7974. call RemoveBeepCode
  7975. call RemoveColorCodes
  7976. call SwitchMustNotHaveOptions ThisCmd,ThisCmdOptions
  7977. DebugSwitchUsed='Y'
  7978. OptionDebugOn='Y'
  7979. OptionWantInfoMsgs='Y'
  7980. call DebugStateChanged
  7981. end
  7982. when ThisCmd='COPYRIGHT' then
  7983. OptionWantCopyright=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7984. when ThisCmd='GETENV' then
  7985. do
  7986. FromEnv=DebugGetEnv(ThisCmdOptions)
  7987. if FromEnv='' then
  7988. CryAndDie('The environment variable "' || ThisCmdOptions || '" does not exist.')
  7989. call DebugLine 'Contained: ' ||FromEnv
  7990. TheCmdLine=FromEnv|| ' ' ||TheCmdLine
  7991. end
  7992. when ThisCmd='LIST' then
  7993. do
  7994. ListFile=SafeQueryExists(ThisCmdOptions)
  7995. if ListFile='' then
  7996. CryAndDie('The list file "' || ThisCmdOptions || '" does not exist')
  7997. call DebugLine 'Processing: "' || ListFile || '"'
  7998. call DebugIncrement 1
  7999. CloseRc=stream(ListFile, 'c', 'close')
  8000. LCmt=';' || ';'
  8001. LineNum=0
  8002. SpecList=''
  8003. do while lines(ListFile)<>0
  8004. OneSpec=strip(linein(ListFile))
  8005. CmtPos=lastpos(LCmt,OneSpec)
  8006. LineNum=LineNum+1
  8007. if CmtPos<>0 then
  8008. OneSpec=strip(left(OneSpec,CmtPos-1), 'T')
  8009. if OneSpec='' | left(OneSpec, 1) = ';' then
  8010. iterate
  8011. OneSpec=ReplaceString(OneSpec, ' ', '{' || 'x20}')
  8012. call DebugLine 'Line #' || LineNum || ': ' ||OneSpec
  8013. SpecList=SpecList|| ' ' ||OneSpec
  8014. end
  8015. call DebugIncrement-1
  8016. TheCmdLine=strip(SpecList)|| ' ' ||TheCmdLine
  8017. call DieIfIoErrorOccurred ListFile
  8018. CloseRc=stream(ListFile, 'c', 'close')
  8019. end
  8020. otherwise
  8021. UserSyntaxError('Unknown switch of "' || RexOptionChar || ThisCmd || '" specified')
  8022. end
  8023. call DebugIncrement-1
  8024. end
  8025. call DebugIncrement-1
  8026. call DebugLine 'Finished Processing : ' ||FullCommandLine
  8027. call CheckRexxInterpreter 'Y'
  8028. call DebugShowAsMuchEnvironmentDetailAsPossible
  8029. InpFileCount=0
  8030. InpFileCountActuallyMade=0
  8031. AllSameExtn=''
  8032. do SpecIndex=1 to InputMaskCount
  8033. InputList.0=0
  8034. TmpMask=InputMask.SpecIndex
  8035. call DebugLine 'Looking for files matching "' || TmpMask || '"'
  8036. if left(TmpMask,1)<> '+' then
  8037. FollowDirs='N'
  8038. else
  8039. do
  8040. FollowDirs='Y'
  8041. TmpMask=substr(TmpMask,2)
  8042. end
  8043. call GetListOfFiles TmpMask, 'InputList',FollowDirs
  8044. call DebugIncrement 1
  8045. call DebugLine 'Found ' || InputList.0 || ' files(s)'
  8046. call DebugIncrement 1
  8047. if InputList.0=0 then
  8048. do
  8049. call CheckForNotBeingAbleToExecAnything
  8050. WeWantToDie='Y'
  8051. if LookLikeASingleFile(TmpMask)='Y' then
  8052. do
  8053. if OptionDebugOn='N' then
  8054. do
  8055. call RemoveBeepCode
  8056. call RemoveColorCodes
  8057. OptionDebugOn='Y'
  8058. OptionWantInfoMsgs='Y'
  8059. call DebugStateChanged
  8060. call DebugLine 'Debug forced on as we seem top have a file find problem!'
  8061. call DebugIncrement 1
  8062. call GetListOfFiles TmpMask, 'InputList',FollowDirs
  8063. call DebugIncrement-1
  8064. call DebugLine 'Turning off debug again'
  8065. OptionDebugOn='N'
  8066. call DebugStateChanged
  8067. end
  8068. call DebugWarning 'We could not find "' || TmpMask || '", yet it seems to exist! We will solder on!, You could try ' || RexOptionChar || 'ListFiles!'
  8069. InputList.0=1
  8070. InputList.1=TmpMask
  8071. WeWantToDie='N'
  8072. end
  8073. if WeWantToDie='Y' then
  8074. do
  8075. Left1=left(InputMask.SpecIndex,1)
  8076. if Left1<> '-' & Left1 <> '/' then
  8077. Extra=''
  8078. else
  8079. Extra=' (all switches under ' || PpWizardOpSys || ' must start with "' || RexOptionChar || '")'
  8080. UserSyntaxError('No input files matched "' || InputMask.SpecIndex || '"' ||Extra)
  8081. end
  8082. end
  8083. do InputIndex=1 to InputList.0
  8084. TheFile=InputList.InputIndex
  8085. call DebugLine TheFile
  8086. InpFileCount=InpFileCount+1
  8087. InpFile.InpFileCount=TheFile
  8088. InpFileMaskIndex.InpFileCount=SpecIndex
  8089. DotPos=lastpos('.',TheFile)
  8090. if DotPos<>0 then
  8091. do
  8092. FileExtn=translate(substr(TheFile,DotPos+1))
  8093. if InpFileCount=1 then
  8094. AllSameExtn=FileExtn
  8095. if AllSameExtn<>FileExtn then
  8096. AllSameExtn=''
  8097. end
  8098. end
  8099. call DebugIncrement-2
  8100. end
  8101. if OptionCodeType='' then
  8102. do
  8103. select
  8104. when AllSameExtn='X' then
  8105. do
  8106. call DebugLine 'All input files end in ".' || AllSameExtn || '" so /REXX is default.'
  8107. OptionCodeType='REXX'
  8108. end
  8109. otherwise
  8110. OptionCodeType='HTML'
  8111. end
  8112. end
  8113. call DebugLine 'Processing input files in "' || OptionCodeType || '" mode'
  8114. if NewLineChars==CrLf then
  8115. LinesEndWith="CR followed by LF"
  8116. else
  8117. LinesEndWith="LF only"
  8118. call DebugLine 'Output lines are terminated with ' ||LinesEndWith
  8119. if OptionCodeType='HTML' then
  8120. OptionDefaultInputName="DEFAULT.IT"
  8121. else
  8122. OptionDefaultInputName=""
  8123. if OptionDependsOn<> '' & OptionCgiModeOn = 'Y' then
  8124. UserSyntaxError("Can't do dependancy checking in CGI mode!")
  8125. if OptionCodeType<> 'HTML' & OptionCgiModeOn = 'Y' then
  8126. UserSyntaxError("Must stay in HTML mode when /CGI switch used!")
  8127. if OptionCodeType='HTML' then
  8128. call DebugLine 'HTML Generator Tags are ' ||DebugRightArrow||OptionHtmlGeneratorTags||DebugLeftArrow
  8129. else
  8130. OptionHtmlGeneratorTags=''
  8131. if OptionOutput='' then
  8132. do
  8133. if OptionCodeType='REXX' then
  8134. OptionOutput='*.cmd'
  8135. else
  8136. OptionOutput='*.htm'
  8137. end
  8138. if OptionWantCopyright='Y' then
  8139. call DisplayCopyright
  8140. call DebugStateChanged
  8141. if InputMaskCount=0 then
  8142. do
  8143. call DebugLine 'No input masks were specified...'
  8144. if OptionDefaultInputName='' then
  8145. UserSyntaxError('No input files were specified!')
  8146. if stream(OptionDefaultInputName, 'c', 'query exists') = '' then
  8147. UserSyntaxError('No input files were specified and "' || OptionDefaultInputName || '" not found!')
  8148. InputMask.1=OptionDefaultInputName
  8149. InpFileCount=1
  8150. InpFile.InpFileCount=OptionDefaultInputName
  8151. InpFileMaskIndex.InpFileCount=1
  8152. end
  8153. if IncludeIntoMemory='' then
  8154. do
  8155. if InpFileCount=1 then
  8156. IncludeIntoMemory='N'
  8157. else
  8158. IncludeIntoMemory='Y'
  8159. end
  8160. call DebugLine 'Will read files into memory cache: ' ||IncludeIntoMemory
  8161. PpwExitRc=0
  8162. ActuallyProcessed=0
  8163. FailedProcessingWarning=0
  8164. do InputIndex=1 to InpFileCount
  8165. ThisFile=InpFile.InputIndex
  8166. if symbol("_EXCLUDE_._EXF_" || c2x(ThisFile)) = 'VAR' then
  8167. do
  8168. call DebugLine ThisFile|| ' excluded - ' || _valueG("_EXCLUDE_._EXF_" ||c2x(ThisFile))
  8169. iterate
  8170. end
  8171. ActuallyProcessed=ActuallyProcessed+1
  8172. call _valueS "_EXCLUDE_._EXF_" || c2x(ThisFile), "Already processed"
  8173. SpecIndex=InpFileMaskIndex.InputIndex
  8174. MaskUsedForCurrentInputFile=InputMask.SpecIndex
  8175. if OptionTemplate='' then
  8176. GenerateRc=GenerateOutput(ThisFile, '')
  8177. else
  8178. GenerateRc=GenerateOutput(OptionTemplate,ThisFile)
  8179. if GenerateRc>PpwExitRc then
  8180. PpwExitRc=GenerateRc
  8181. if OptionDebugOn='Y' then
  8182. call DebugLine 'The Exit Rc is currently "' || PpwExitRc || '"'
  8183. end
  8184. if ActuallyProcessed=0 then
  8185. UserSyntaxError('All input files were excluded by you!')
  8186. call OutputAnySpellingAdditions
  8187. if OptionSummary='Y' then
  8188. do
  8189. if InpFileCount>1 then
  8190. do
  8191. call AboutToGenerateSummary
  8192. call GenerateUserSummaryOverall
  8193. call AddSummaryLine 'Operating Syst' ,PpWizardOpSys
  8194. call AddSummaryLine 'Rexx Version' ,RexVersionInfo
  8195. if InpFileCount=InpFileCountActuallyMade then
  8196. call AddSummaryLine '# files' ,InpFileCount
  8197. else
  8198. call AddSummaryLine '# files made' ,InpFileCountActuallyMade || ' out of ' ||InpFileCount
  8199. call AddSummaryLine 'Exit Code' ,PpwExitRc
  8200. if FailedProcessingWarning<>0 then
  8201. call AddSummaryLine '# Warnings' ,FailedProcessingWarning
  8202. call AddSummaryLine 'Elapsed Time'     ,trunc(time('Elapsed'), 2) || ' seconds'
  8203. call GenerateSummaryLines
  8204. end
  8205. end
  8206. ThatsAllFolks(PpwExitRc)
  8207.  
  8208. SetColorCodes:
  8209. EscapeChar=d2c(27)
  8210. Reset=EscapeChar|| '[0m'
  8211. HighlightColor=EscapeChar|| '[1;35m'
  8212. TitleColor=EscapeChar|| '[0;32m'
  8213. PpwRexxTraceColor=EscapeChar|| '[0;32m'
  8214. ErrorColor=EscapeChar|| '[1;31m'
  8215. WarningColor=EscapeChar|| '[0;33m'
  8216. InfoColor=EscapeChar|| '[0;1m'
  8217. return
  8218.  
  8219. RemoveColorCodes:
  8220. Reset=''
  8221. HighlightColor=''
  8222. TitleColor=''
  8223. ErrorColor=''
  8224. WarningColor=''
  8225. InfoColor=''
  8226. PpwRexxTraceColor=''
  8227. return
  8228.  
  8229. SetBeepCode:
  8230. Beep=''
  8231. return
  8232.  
  8233. RemoveBeepCode:
  8234. Beep=''
  8235. return
  8236.  
  8237. ReplaceCommandLineCodes:
  8238. Before=arg(1)
  8239. RightBit=Before
  8240. LeftBit=''
  8241. StartPos=pos('{x',RightBit)
  8242. do while StartPos<>0
  8243. Codes2=substr(RightBit,StartPos+2,2)
  8244. if datatype(Codes2, 'X') <> 1 | substr(RightBit, StartPos+4, 1) <> '}' then
  8245. do
  8246. LeftBit=LeftBit||left(RightBit,StartPos+1)
  8247. RightBit=substr(RightBit,StartPos+2)
  8248. end
  8249. else
  8250. do
  8251. LeftBit=LeftBit||left(RightBit,StartPos-1)||x2c(Codes2)
  8252. RightBit=substr(RightBit,StartPos+5)
  8253. end
  8254. StartPos=pos('{x',RightBit)
  8255. end
  8256. LeftBit=LeftBit||RightBit
  8257. if OptionDebugOn='Y' then
  8258. do
  8259. if Before<>LeftBit then
  8260. call DebugOutputAfterReplacement LeftBit, '{xXX}'
  8261. end
  8262. return(LeftBit)
  8263.  
  8264. GetSourceFileDateTimeDieOnError:
  8265. DateTimeRc=GetFileDateTimeButDontWarnOnError(arg(1))
  8266. if DateTimeRc=-1 then
  8267. CryAndDie('Could not get date/time stamp of "' || arg(1) || '".')
  8268. return(DateTimeRc)
  8269.  
  8270. GenerateOutput:
  8271. InputFile=arg(1)
  8272. TemplateDataFile=arg(2)
  8273. if OptionTemplate='' then
  8274. do
  8275. call DebugLine 'Main file is not a template, no point loading into memory'
  8276. InFile=InputFile
  8277. ForceBaseFile2Mem='N'
  8278. end
  8279. else
  8280. do
  8281. call DebugLine 'Main file is a template'
  8282. InFile=TemplateDataFile
  8283. ForceBaseFile2Mem=''
  8284. end
  8285. CurrentOutFile=GenerateFileName(InFile,OptionOutput, 'Y')
  8286. call ClearDependancyTimeStampCache
  8287. if NeedToRemake(InFile)='N' then
  8288. return(0)
  8289. InpFileCountActuallyMade=InpFileCountActuallyMade+1
  8290. TitleText='Making - ' || _filespec('name',CurrentOutFile)
  8291. call Line1 TitleColor||TitleText
  8292. call Line1 copies('~',length(TitleText))||Reset
  8293. if OptionTemplate='' then
  8294. TmpTemplate=''
  8295. else
  8296. TmpTemplate=TemplateDataFile
  8297. call RexxHookSetBuildingParms InFile,CurrentOutFile,TmpTemplate
  8298. if RexxHookBefore<> '' then
  8299. call CallHook "BEFORE"
  8300. call SetUpOptionsForThisBuild
  8301. Dummy=time('Reset')
  8302. call DebugIncrementInit
  8303. call CompletelyInitializeAutoTagState
  8304. call InitTransformationCode
  8305. call InitOutputHold
  8306. call InitializeCharCodes
  8307. call InitializeDefineRexx
  8308. call InitializeOneLine
  8309. call InitCondNlCount
  8310. DebugIncludeNumber=0
  8311. Warnings=0
  8312. LineSourceBeingProcessed='?'
  8313. GeneratedLines=0
  8314. InputLines=0
  8315. PartialLine=''
  8316. IncludeLevel=0
  8317. EofForced=''
  8318. LineQueued=''
  8319. PPwizardUnique=0
  8320. StackCnt=0
  8321. OptionStackCnt=0
  8322. HtmlGeneratorTags=OptionHtmlGeneratorTags
  8323. AsIsModeOn='N'
  8324. if OptionCompleteAddToToDepFile='Y' then
  8325. call AddInputFileToDependancyList PpWizardPgmName
  8326. call PrepareSpellingForThisBuild
  8327. NewestSourcefile=GetSourceFileDateTimeDieOnError(PpWizardPgmName)
  8328. call InitializeHashDefinesForThisCompile
  8329. OutputLevel=0
  8330. call HaveNewOutputFile CurrentOutFile,,'N',OptionCodeType
  8331. IfNesting=0
  8332. IfState.WantLines.0='Y'
  8333. IfState.IfTrue.0='Y'
  8334. IfState.InTrue.0='Y'
  8335. WantLineCache='Y'
  8336. call OutputHeaderIfWantedOrRequired
  8337. GenerateRc=0
  8338. call CheckRexxInterpreter
  8339. IncludeList=OptionHashInclude
  8340. do while IncludeList<> ''
  8341. parse var IncludeList ThisInclude (PathDelimiterChar) IncludeList
  8342. call DebugLine '/#Include "' ||ThisInclude
  8343. GenerateRc=GenerateRc+ProcessInputFile(ThisInclude)
  8344. end
  8345. InputFileFull=SafeQueryExists(InputFile)
  8346. GenerateRc=GenerateRc+ProcessInputFile(InputFile,,,ForceBaseFile2Mem)
  8347. if GenerateRc=0 then
  8348. do
  8349. if OptionDebugOn='Y' then
  8350. call DebugLine 'Generation successful so far, look for nesting and other errors'
  8351. select
  8352. when IfNesting<>0 then
  8353. do
  8354. do Index=1 to IfNesting
  8355. NestingLevel=(IfNesting-Index)+1
  8356. call DebugLine 'Missing #endif at EOF - Nesting Level #' ||NestingLevel||MatchesIfDebugText(NestingLevel)
  8357. end
  8358. CryAndDie('Missing #endif at EOF' ||MatchesIfDebugText(IfNesting))
  8359. end
  8360. when StackCnt<>0 then
  8361. do
  8362. do Index=1 to StackCnt
  8363. NestingLevel=(StackCnt-Index)+1
  8364. call DebugLine 'Missing #RexxVar pop at EOF - Nesting Level #' ||NestingLevel||MatchesStackPushDebugText(NestingLevel)
  8365. end
  8366. CryAndDie('Incorrect #RexxVar push/pop nesting at EOF' ||MatchesStackPushDebugText(StackCnt))
  8367. end
  8368. when OptionStackCnt<>0 then
  8369. do
  8370. do Index=1 to OptionStackCnt
  8371. NestingLevel=(OptionStackCnt-Index)+1
  8372. call DebugLine 'Missing pop() at EOF - Nesting Level #' ||NestingLevel||MatchesOptionStackPushDebugText(NestingLevel)
  8373. end
  8374. CryAndDie('Missing #Option pop at EOF' ||MatchesOptionStackPushDebugText(OptionStackCnt))
  8375. end
  8376. when AutoTagStateCnt<>0 then
  8377. do
  8378. do Index=1 to AutoTagStateCnt
  8379. NestingLevel=(AutoTagStateCnt-Index)+1
  8380. call DebugLine 'Missing #AutoTagState- at EOF - Nesting Level #' ||NestingLevel||MatchesAutoTagStateIncDebugText(NestingLevel)
  8381. end
  8382. CryAndDie('Missing #AutoTagState- at EOF' ||MatchesAutoTagStateIncDebugText(AutoTagStateCnt))
  8383. end
  8384. when DefRexxVar<> '' then
  8385. CryAndDie('Missing #DefineRexx[+] at EOF', 'Block started at ' ||DefRexxStartLoc)
  8386. when TransformCode<> '' then
  8387. CryAndDie('Missing #transform (end) at EOF', 'Block started at ' ||TransformStartLoc)
  8388. when OneLineOn='Y' then
  8389. CryAndDie('#OneLine block did not end, started at ' ||OneLineStartLoc)
  8390. when OutputLevel>1 then
  8391. CryAndDie('Missing ' || OutputLevel - 1 || ' #output command(s) at EOF')
  8392. when OutputHoldLvl<>0 then
  8393. CryAndDie('Missing #OutputHold (end) at EOF', 'LAST Block started at ' ||OutHold_.OutputHoldLvl.!OutpHoldStartLoc)
  8394. otherwise
  8395. call DieIfHoldingOutput
  8396. end
  8397. if GeneratedLines=0 then
  8398. call OutputWarningToScreen 'GEN0', 'No output lines generated'
  8399. if OptionDebugOn='Y' then
  8400. call DebugLine 'No fatal errors detected so far'
  8401. end
  8402. call Stream CurrentOutFile, 'c', 'Close'
  8403. if RexxHookAfter<> '' then
  8404. call CallHook "AFTER"
  8405. if GenerateRc=0 then
  8406. do
  8407. if OptionDebugOn='Y' then
  8408. call DebugLine 'Looks OK so far, look for even more errors'
  8409. if PartialLine<> '' then
  8410. CryAndDie('A line continued to EOF')
  8411. if OptionCodeType='REXX' then
  8412. call CheckRexxModuleForSyntaxErrors
  8413. call CreateDependancyFileFromLists
  8414. if Warnings<>0 then
  8415. do
  8416. FailedProcessingWarning=FailedProcessingWarning+1
  8417. GenerateRc=WantedWarningRc
  8418. end
  8419. if OptionSummary='Y' then
  8420. do
  8421. if InpFileCount=1 then
  8422. call AboutToGenerateSummary
  8423. else
  8424. call AboutToGenerateSummary 'N'
  8425. call GenerateUserSummaryThisBuild
  8426. call GenerateUserSummaryAllBuilds
  8427. if InpFileCount=1 then
  8428. call GenerateUserSummaryOverall
  8429. if Warnings<>0 then
  8430. call AddSummaryLine 'Warnings'        ,'YES (' || AddCommasToDecimalNumber(Warnings) || ')'
  8431. if InpFileCount=1 then
  8432. do
  8433. call AddSummaryLine 'Operating Syst' ,PpWizardOpSys
  8434. call AddSummaryLine 'Rexx Version' ,RexVersionInfo
  8435. end
  8436. call AddSummaryLine 'Return Code' ,GenerateRc
  8437. call AddSummaryLine 'Elapsed Time'        ,trunc(time('Elapsed'), 2) || ' seconds'
  8438. call GenerateSummaryLines
  8439. end
  8440. end
  8441. call Line1 ''
  8442. call RexxHookSetBuildingParms
  8443. return(GenerateRc)
  8444.  
  8445. MyLineNumber:
  8446. return(SIGL)
  8447.  
  8448. OutputHeaderIfWantedOrRequired:
  8449. CommentStart=''
  8450. if OptionCodeType='REXX' then
  8451. do
  8452. CommentStart=RexxCmtStart
  8453. CommentEnd=RexxCmtEnd
  8454. end
  8455. else
  8456. do
  8457. end
  8458. if CommentStart<> '' then
  8459. do
  8460. call GenerateOneLine CommentStart
  8461. call GenerateOneLine ' * Generator   : PPWIZARD version ' ||PgmVersion
  8462. call GenerateOneLine ' *             : FREE tool for OS/2, Windows, DOS and UNIX by ' || PgmAuthor  || ' (' || PgmAuthorEmail || ')'
  8463. call GenerateOneLine ' *             : ' ||PgmHomePage
  8464. call GenerateOneLine " * Time        : " ||space(CompileTime)
  8465. call GenerateOneLine " * Input File  : " ||InputFile
  8466. do Index=1 to OutputLevel
  8467. call GenerateOneLine " * Output File : " ||Output.OutputLevel.File
  8468. end
  8469. call GenerateOneLine ' ' ||CommentEnd
  8470. call GenerateOneLine ''
  8471. if OptionCodeType='REXX' then
  8472. do
  8473. call GenerateOneLine 'if arg(1)="' || SyntaxOkText || '" then exit(' || SyntaxOkRc || ')'
  8474. call GenerateOneLine ''
  8475. end
  8476. end
  8477. return
  8478.  
  8479. FindIncludeFile:
  8480. LookForFile=arg(1)
  8481. FoundFile=SafeQueryExists(LookForFile)
  8482. if FoundFile="" then
  8483. do
  8484. FoundFile=DebugSysSearchPath('PPWIZARD_INCLUDE',LookForFile)
  8485. if FoundFile="" then
  8486. do
  8487. FoundFile=DebugSysSearchPath('INCLUDE',LookForFile)
  8488. if FoundFile="" then
  8489. do
  8490. parse source . . FoundFile
  8491. FoundFile=_filespec('drive', FoundFile) || _filespec('path',FoundFile)||LookForFile
  8492. if SafeQueryExists(FoundFile)='' then
  8493. FoundFile=''
  8494. end
  8495. end
  8496. end
  8497. return(FoundFile)
  8498.  
  8499. ProcessInputFile:
  8500. RequestedFile=arg(1)
  8501. IncludeFragmentText=arg(2)
  8502. AddToDepFile=arg(3)
  8503. ForceLoadingIntoMemory=arg(4)
  8504. IncludeLineNumber=0
  8505. IncludeMemBufferNextLine=''
  8506. DebugIncludeNumber=DebugIncludeNumber+1
  8507. DebugCurrentFileNumber=DebugIncludeNumber
  8508. IncludeFileName=FindIncludeFile(RequestedFile)
  8509. if IncludeFileName='' then
  8510. do
  8511. call RecursiveIncludeRestore
  8512. CryAndDie('File "' || RequestedFile || '" does not exist!')
  8513. end
  8514. IncludeLevel=IncludeLevel+1
  8515. IncludeFileName.IncludeLevel=IncludeFileName
  8516. if IncludeLevel>=InfiniteIncludeLoopWhen then
  8517. do
  8518. if InfiniteIncludeLoopWhen<>0 then
  8519. do
  8520. say 'Infinite #include loop detected, at level #' ||IncludeLevel
  8521. say 'Use "/define:INFINITE_INCLUDE_LOOP_WHEN=0"   to turn off detection'
  8522. say 'Use "/define:INFINITE_INCLUDE_LOOP_WHEN=100" to increase detection threshold etc'
  8523. IncludeLevel=IncludeLevel-1
  8524. call RecursiveIncludeRestore
  8525. CryAndDie("We seem to be in an infinite #include loop!")
  8526. end
  8527. end
  8528. MemUpdateIndex=0
  8529. do IncIndex=1 to IncludeLevel-1
  8530. if RexSystemOpSys="UNIX" then
  8531. IncSame=(IncludeFileName=IncludeFileName.IncIndex)
  8532. else
  8533. IncSame=(translate(IncludeFileName)=translate(IncludeFileName.IncIndex))
  8534. if IncSame=1 then
  8535. do
  8536. if _IncludeMemHandle.IncIndex<> '' then
  8537. call DebugLine 'File already being processed, already reading from memory cache!'
  8538. else
  8539. do
  8540. call DebugLine 'File already being processed, forcing use from memory cache'
  8541. CloseRc=stream(IncludeFileName, 'c', 'close')
  8542. MemUpdateIndex=IncIndex
  8543. ForceLoadingIntoMemory='Y'
  8544. end
  8545. leave
  8546. end
  8547. end
  8548. if AddToDepFile<> 'N' then
  8549. call AddInputFileToDependancyList(IncludeFileName)
  8550. call OutputProcessingFileStringToScreen '',IncludeFragmentText
  8551. ThisDateTime=GetSourceFileDateTimeDieOnError(IncludeFileName)
  8552. if ThisDateTime>NewestSourcefile then
  8553. NewestSourcefile=ThisDateTime
  8554. parse value IncludeFileOpen(IncludeFileName,ForceLoadingIntoMemory)with IncludeEofLine ';' IncludeMemHandle
  8555. if MemUpdateIndex<>0 then
  8556. do
  8557. _IncludeMemHandle.MemUpdateIndex=IncludeMemHandle
  8558. _IncludeEofLine.MemUpdateIndex=IncludeEofLine
  8559. end
  8560. if IncludeFragmentText<> '' then
  8561. do
  8562. call DebugLine 'Looking for the start of the fragment'
  8563. do while IncludeFileLines()<>0
  8564. InputLines=InputLines+1
  8565. FileLine=IncludeFileLineIn()
  8566. if pos(IncludeFragmentText,FileLine)<>0 then
  8567. leave
  8568. end
  8569. if IncludeFileLines()=0 then
  8570. do
  8571. FT=IncludeFragmentText
  8572. LP=IncludeLineNumber
  8573. IncludeLevel=IncludeLevel-1
  8574. call RecursiveIncludeRestore
  8575. CryAndDie('Did not find the START of the code fragment "' || FT || '" (processed ' || AddCommasToDecimalNumber(LP) || ' lines)')
  8576. end
  8577. end
  8578. do forever
  8579. LastLineAfterMacroRep=''
  8580. select
  8581. when IncludeMemBufferNextLine\=='' then
  8582. do
  8583. if InLoop='Y' &LoopLinesFromFile=0 then
  8584. FileLine=GetLoopLineIntoFileLine()
  8585. else
  8586. do
  8587. parse var IncludeMemBufferNextLine FileLine (MarksNewLine) IncludeMemBufferNextLine
  8588. end
  8589. LastLine=FileLine
  8590. LineSrc='M'
  8591. if OptionDebugOn='Y' then
  8592. call DebugShowCurrentLineWithLineNumber FileLine, '#'
  8593. end
  8594. when LineQueued\=='' then
  8595. do
  8596. call FlushQueuedOutput
  8597. iterate
  8598. end
  8599. when InLoop='Y' |IncludeFileLines()<>0 then
  8600. do
  8601. if EofForced<> '' then
  8602. do
  8603. if OptionDebugOn='Y' then
  8604. call DebugLine '#EOF (at ' || EofForced || ') told us to stop processing this file any further'
  8605. if SetUpOnExitProcessingIfEndOfMainFile()='Y' then
  8606. iterate
  8607. leave
  8608. end
  8609. if InLoop='Y' then
  8610. FileLine=GetLoopLineIntoFileLine()
  8611. else
  8612. do
  8613. InputLines=InputLines+1
  8614. FileLine=IncludeFileLineIn()
  8615. end
  8616. LastFileLine=FileLine
  8617. LastLine=FileLine
  8618. LineSrc='F'
  8619. if OptionDebugOn='Y' then
  8620. call DebugShowCurrentLineWithLineNumber FileLine
  8621. if IncludeFragmentText<> '' then
  8622. do
  8623. if pos(IncludeFragmentText,FileLine)<>0 then
  8624. do
  8625. call DebugLine 'Found the end of the fragment'
  8626. IncludeFragmentText=''
  8627. leave
  8628. end
  8629. end
  8630. if OptionFilterIn<> '' then
  8631. do
  8632. FileLine=HtmlFilterIn("I",FileLine,IncludeFileName,IncludeLineNumber,InputLines,MarksNewLine)
  8633. if pos(MarksNewLine,FileLine)<>0 then
  8634. do
  8635. IncludeMemBufferNextLine=FileLine
  8636. iterate
  8637. end
  8638. if left(FileLine,1)=NullChar then
  8639. do
  8640. if FileLine=NullChar then
  8641. iterate
  8642. else
  8643. CryAndDie(substr(FileLine,2))
  8644. end
  8645. end
  8646. if AsIsModeOn='Y' then
  8647. FileLine=ExpandAsIsTags(FileLine)
  8648. if AutoTagOn='Y' then
  8649. FileLine=AutoTag(FileLine)
  8650. end
  8651. otherwise
  8652. do
  8653. if SetUpOnExitProcessingIfEndOfMainFile()='Y' then
  8654. iterate
  8655. leave
  8656. end
  8657. end
  8658. if LineSrc<> 'F' then
  8659. do
  8660. LineContinued='N'
  8661. Word1=word(FileLine,1)
  8662. end
  8663. else
  8664. do
  8665. if pos(TabChar,FileLine)<>0 then
  8666. do
  8667. if OptionDebugOn='Y' then
  8668. call DebugLine 'Tab(s) found ("' || OptionTabs || '" handling in progress).'
  8669. select
  8670. when OptionTabs='W' then
  8671. do
  8672. call OutputWarningToScreen 'T000', 'There are TABS in the source (converted to spaces)!'
  8673. FileLine=translate(FileLine, ' ',TabChar)
  8674. end
  8675. when OptionTabs='T' then
  8676. do
  8677. FileLine=translate(FileLine, ' ',TabChar)
  8678. end
  8679. otherwise
  8680. do
  8681. end
  8682. end
  8683. end
  8684. FileLine=strip(FileLine, 'T')
  8685. CmtPos=lastpos(InLineComment,FileLine)
  8686. if CmtPos<>0 then
  8687. do
  8688. AddToEnd=''
  8689. if right(FileLine,1)=LineContChar then
  8690. do
  8691. Right2=right(FileLine,2)
  8692. if Right2=LineContAddNewLine|Right2=LineContAddNewLineObs|Right2=LineContWithoutSpace|Right2=LineContWithSpace|Right2=LineContDefault then
  8693. do
  8694. AddToEnd=' ' ||Right2
  8695. end
  8696. end
  8697. FileLine=strip(left(FileLine,CmtPos-1), 'T')||AddToEnd
  8698. end
  8699. if OptionCodeType='REXX' then
  8700. do
  8701. if OptionDebugOn='N' then
  8702. do
  8703. if OptionKeepRexxCmts='N' &right(FileLine,2)=RexxCmtEnd then
  8704. do
  8705. StartCmtPos=lastpos(RexxCmtStart,FileLine)
  8706. if StartCmtPos<>0 then
  8707. do
  8708. if StartCmtPos=0 then
  8709. FileLine=''
  8710. else
  8711. FileLine=strip(left(FileLine,StartCmtPos-1), 'T')
  8712. if FileLine='' then
  8713. iterate
  8714. end
  8715. end
  8716. end
  8717. end
  8718. if LineContChar=NullChar then
  8719. LineContinued='N'
  8720. else
  8721. do
  8722. if right(FileLine,1)<>LineContChar then
  8723. LineContinued='N'
  8724. else
  8725. do
  8726. Right2=right(FileLine,2)
  8727. MainBit=strip(left(FileLine,length(FileLine)-2), 'T')
  8728. select
  8729. when Right2=LineContWithoutSpace then
  8730. do
  8731. LineContinued='Y'
  8732. FileLine=MainBit
  8733. end
  8734. when Right2=LineContWithSpace|Right2=LineContDefault then
  8735. do
  8736. FileLine=MainBit
  8737. LineContinued='YS'
  8738. end
  8739. when Right2=LineContAddNewLine then
  8740. do
  8741. LineContinued='Y'
  8742. FileLine=MainBit||CodexNewLine
  8743. end
  8744. when Right2=LineContAddNewLineObs then
  8745. do
  8746. call WarnAboutDepreciatedFeature 'Line continuation using downarrow.  Replace with -> "%\"'
  8747. LineContinued='Y'
  8748. FileLine=MainBit||CodexNewLine
  8749. end
  8750. otherwise
  8751. LineContinued='N'
  8752. end
  8753. end
  8754. end
  8755. if FileLine='' then
  8756. do
  8757. if LeaveBlankLines='N' then
  8758. do
  8759. if OptionDebugOn='Y' then
  8760. call DebugShowLineDropped "Blank Line"
  8761. if LineContinued='N' & PartialLine \== '' then
  8762. do
  8763. if IncludeMemBufferNextLine=='' then
  8764. IncludeMemBufferNextLine=PartialLine
  8765. else
  8766. IncludeMemBufferNextLine=PartialLine||MarksNewLine||IncludeMemBufferNextLine
  8767. PartialLine=''
  8768. end
  8769. iterate
  8770. end
  8771. end
  8772. Word1=word(FileLine,1)
  8773. if left(Word1,1)=LineComment then
  8774. do
  8775. if LineContinued='N' & PartialLine \== '' then
  8776. do
  8777. if OptionDebugOn='Y' then
  8778. call DebugWarning 'Line continuation ends with a comment line'
  8779. if IncludeMemBufferNextLine=='' then
  8780. IncludeMemBufferNextLine=PartialLine
  8781. else
  8782. IncludeMemBufferNextLine=PartialLine||MarksNewLine||IncludeMemBufferNextLine
  8783. PartialLine=''
  8784. end
  8785. iterate
  8786. end
  8787. if LineSrc='F' then
  8788. do
  8789. if KeepIndent='N' then
  8790. FileLine=strip(FileLine, 'L')
  8791. else
  8792. FileLine=LeftIndent||FileLine
  8793. end
  8794. if PartialLine<> '' then
  8795. do
  8796. if left(Word1,HashPrefixLng)<>HashPrefix then
  8797. do
  8798. PartialLine=PartialLine||FileLine
  8799. end
  8800. else
  8801. do
  8802. parse var FileLine TheHashCmd TheRest
  8803. TheRest=strip(TheRest)
  8804. FileLine=TheHashCmd|| ' ' ||TheRest
  8805. PartialLine=PartialLine||PpwCmdDivider1||FileLine||PpwCmdDivider1
  8806. if LineContinued='YS' then
  8807. LineContinued='Y'
  8808. end
  8809. end
  8810. if LineContinued='N' then
  8811. do
  8812. if PartialLine\=='' then
  8813. do
  8814. if IncludeMemBufferNextLine=='' then
  8815. IncludeMemBufferNextLine=PartialLine
  8816. else
  8817. IncludeMemBufferNextLine=PartialLine||MarksNewLine||IncludeMemBufferNextLine
  8818. PartialLine=''
  8819. iterate
  8820. end
  8821. end
  8822. else
  8823. do
  8824. if PartialLine=='' then
  8825. do
  8826. PartialLine=FileLine
  8827. if translate(left(Word1,length(CmdHashDefine)))=CmdHashDefine then
  8828. PpwCmdDivider1=MarksNewLineInHashDefine
  8829. else
  8830. PpwCmdDivider1=MarksNewLine
  8831. end
  8832. if LineContinued='YS' then
  8833. PartialLine=PartialLine|| ' '
  8834. iterate
  8835. end
  8836. end
  8837. if OneLineOn='Y' then
  8838. do
  8839. FileLine=AddToOneLine(FileLine)
  8840. if FileLine=='' then
  8841. iterate
  8842. else
  8843. do
  8844. if IncludeMemBufferNextLine=='' then
  8845. IncludeMemBufferNextLine=FileLine
  8846. else
  8847. IncludeMemBufferNextLine=FileLine||MarksNewLine||IncludeMemBufferNextLine
  8848. iterate
  8849. end
  8850. end
  8851. if left(Word1,HashPrefixLng)=HashPrefix then
  8852. do
  8853. parse var FileLine HashCmd SecondWordEtc
  8854. HashCmd=translate(HashCmd)
  8855. HashRc='?'
  8856. select
  8857. when HashCmd=CmdHashIf then
  8858. do
  8859. HashRc=ProcessHashIfTest(FileLine)
  8860. end
  8861. when HashCmd=CmdHashIfDef then
  8862. do
  8863. HashRc=ProcessHashIfTest(FileLine)
  8864. end
  8865. when HashCmd=CmdHashIfnDef then
  8866. do
  8867. HashRc=ProcessHashIfTest(FileLine)
  8868. end
  8869. when HashCmd=CmdHashElseifL|HashCmd=CmdHashElseifS then
  8870. HashRc=ProcessHashElse(SecondWordEtc)
  8871. when HashCmd=CmdHashEndifL|HashCmd=CmdHashEndifS then
  8872. HashRc=ProcessHashEndif(SecondWordEtc)
  8873. otherwise
  8874. end
  8875. if HashRc<> '?' then
  8876. do
  8877. if HashRc<> 'OK' then
  8878. call CryAndDie 'Hash command failed, Rc = ' ||HashRc
  8879. else
  8880. do
  8881. WantLineCache=WantLine()
  8882. iterate
  8883. end
  8884. end
  8885. end
  8886. if WantLineCache='N' then
  8887. do
  8888. if OptionDebugOn='Y' then
  8889. call DebugShowLineDropped "False"
  8890. iterate
  8891. end
  8892. if left(Word1,HashPrefixLng)=HashPrefix then
  8893. do
  8894. call ProcessHashCommand FileLine
  8895. end
  8896. else
  8897. do
  8898. if DefRexxVar<> '' then
  8899. do
  8900. call AddDefineRexxLine FileLine
  8901. iterate
  8902. end
  8903. if ReplacementsAllowed='Y' then
  8904. do
  8905. NowCount=ReplaceCount
  8906. FileLine=ReplaceHashAndStandardDefines(FileLine,, 'Y')
  8907. if HtmlGeneratorTags<> '' then
  8908. do
  8909. FileLineU=translate(FileLine)
  8910. InsertTags=''
  8911. LookFor="<HEAD>"
  8912. TagPos=pos(LookFor,FileLineU)
  8913. if TagPos<>0 then
  8914. do
  8915. InsertTags=TagSvNewLine||HtmlGeneratorTags||TagSvNewLine
  8916. InsertAt=TagPos+length(LookFor)
  8917. end
  8918. else
  8919. do
  8920. LookFor="<BODY"
  8921. TagPos=pos(LookFor,FileLineU)
  8922. if TagPos<>0 then
  8923. do
  8924. InsertTags='<HEAD>' || TagSvNewLine || '  ' || HtmlGeneratorTags || TagSvNewLine || '</HEAD>' ||TagSvNewLine
  8925. InsertAt=TagPos
  8926. end
  8927. end
  8928. if InsertTags\=='' then
  8929. do
  8930. call DebugLine 'Found "' || LookFor || '" so inserted HTML generator tags'
  8931. FileLine=insert(InsertTags,FileLine,InsertAt-1)
  8932. FileLine=ReplaceHashAndStandardDefines(FileLine,, 'Y')
  8933. HtmlGeneratorTags=''
  8934. end
  8935. end
  8936. if ExpandXEarly='Y' then
  8937. do
  8938. if pos(StartsStdSymbolReplacement_x,FileLine)<>0 then
  8939. FileLine=ReplaceTheXCodesWeKnowExist(FileLine)
  8940. end
  8941. if NowCount<>ReplaceCount then
  8942. do
  8943. if pos(MarksNewLine,FileLine)<>0 then
  8944. do
  8945. if IncludeMemBufferNextLine=='' then
  8946. IncludeMemBufferNextLine=FileLine
  8947. else
  8948. IncludeMemBufferNextLine=FileLine||MarksNewLine||IncludeMemBufferNextLine
  8949. iterate
  8950. end
  8951. end
  8952. if ExpandXLate='Y' then
  8953. do
  8954. if pos(StartsStdSymbolReplacement_x,FileLine)<>0 then
  8955. FileLine=ReplaceTheXCodesWeKnowExist(FileLine)
  8956. end
  8957. end
  8958. if TransformCode<> '' then
  8959. do
  8960. BeforeLine=FileLine
  8961. call ExecRexxCmd TransformCode
  8962. if OptionDebugOn='Y' then
  8963. do
  8964. if BeforeLine==FileLine then
  8965. call DebugLine 'Line was not transformed'
  8966. else
  8967. call DebugLine 'Line transformed to ' ||DebugRightArrow||FileLine||DebugLeftArrow
  8968. end
  8969. end
  8970. if LineSrc='M' then
  8971. do
  8972. LineQueued=LineQueued||FileLine
  8973. iterate
  8974. end
  8975. do until FileLine == ''; parse var FileLine This1 (MarksNewLine) FileLine; if  OptionCodeType  = 'REXX' then call OutputRexxLine This1; else do; if  OptionCodeType <> 'HTML' then call GenerateOneLine This1; else do; call GenerateOneLine This1; end; end; end
  8976. end
  8977. end
  8978. EofForced=''
  8979. call IncludeFileClose
  8980. if IncludeFragmentText<> '' then
  8981. CryAndDie('Did not find the END of the code fragment "' || IncludeFragmentText || '"!')
  8982. IncludeLevel=IncludeLevel-1
  8983. if OptionDebugOn='Y' then
  8984. call DebugLine 'Finished processing the input file'
  8985. return(0)
  8986.  
  8987. OutputProcessingFileStringToScreen:
  8988. parse arg ProcessingWhat,ProcessingFrag
  8989. if ProcessingWhat='' then
  8990. ProcessingWhat=IncludeFileName
  8991. if ProcessingFrag<> '' then
  8992. ProcessingFrag='(' || ProcessingFrag || ')'
  8993. call Line1 copies("  ", IncludeLevel) || ' * Processing: ' ||ProcessingWhat||ProcessingFrag
  8994. return
  8995.  
  8996. FlushQueuedOutput:
  8997. if LineQueued=='' then
  8998. return
  8999. LineSrc='Q'
  9000. FileLine=LineQueued
  9001. LineQueued=''
  9002. if OptionDebugOn='Y' then
  9003. call DebugShowCurrentLineWithLineNumber FileLine, '+'
  9004. do until FileLine == ''; parse var FileLine This1 (MarksNewLine) FileLine; if  OptionCodeType  = 'REXX' then call OutputRexxLine This1; else do; if  OptionCodeType <> 'HTML' then call GenerateOneLine This1; else do; call GenerateOneLine This1; end; end; end
  9005. return
  9006.  
  9007. OutputInformationToScreen:
  9008. if OptionWantInfoMsgs='Y' then
  9009. do
  9010. InfoText=arg(1)
  9011. if IncludeLevel=0 then
  9012. LineText=''
  9013. else
  9014. LineText='(@' || AddCommasToDecimalNumber(IncludeLineNumber) || ')'
  9015. call Line1 copies("  ", IncludeLevel) || InfoColor || '   ' || LineText || 'INFO: ' ||InfoText||Reset
  9016. end
  9017. return
  9018.  
  9019. ProcessHashCommand:
  9020. HashCmd=translate(word(arg(1),1))
  9021. HashCmdParms=subword(arg(1),2)
  9022. select
  9023. when HashCmd=CmdHashDefine then
  9024. return(ProcessDefine(HashCmdParms))
  9025. when HashCmd=CmdHashDefinePlus then
  9026. return(ProcessDefine(HashCmdParms, 'Y'))
  9027. when HashCmd=CmdHashRexxVar then
  9028. return(ProcessRexxVar(HashCmdParms))
  9029. when HashCmd=CmdHashEvaluateL|HashCmd=CmdHashEvaluateS then
  9030. return(ProcessEvaluate(HashCmdParms))
  9031. when HashCmd=CmdHashEvaluatePlusL|HashCmd=CmdHashEvaluatePlusS then
  9032. return(ProcessEvaluate(HashCmdParms, 'Y'))
  9033. when HashCmd=CmdHashAutoTag then
  9034. do
  9035. ProcessRc=ProcessAutoTag(HashCmdParms)
  9036. return(ProcessRc)
  9037. end
  9038. when HashCmd=CmdHashUndefL|HashCmd=CmdHashUndefS then
  9039. return(HandleUndefCommand(HashCmdParms))
  9040. when HashCmd=CmdHashOption then
  9041. return(ProcessOption(HashCmdParms))
  9042. when HashCmd=CmdHashLoopS then
  9043. return(ProcessLoopStart(HashCmdParms))
  9044. when HashCmd=CmdHashLoopBreak then
  9045. return(ProcessLoopBreak(HashCmdParms))
  9046. when HashCmd=CmdHashLoopContinue then
  9047. return(ProcessLoopContinue(HashCmdParms))
  9048. when HashCmd=CmdHashInclude then
  9049. do
  9050. IncludeParms=strip(PerformReplacementsInCmdsParameters(HashCmdParms))
  9051. if IncludeParms="" then
  9052. return(CryAndDie("No filename specified on #include line!"))
  9053. QuoteChar=left(IncludeParms,1)
  9054. if QuoteChar<> '"' & QuoteChar <> "'" & QuoteChar <> "<" then
  9055. do
  9056. parse var IncludeParms IncludeName Fragment
  9057. end
  9058. else
  9059. do
  9060. if QuoteChar="<" then
  9061. QuoteChar='>'
  9062. IncludeParms=substr(IncludeParms,2)
  9063. QuotePos=pos(QuoteChar,IncludeParms)
  9064. if QuotePos=0 then
  9065. CryAndDie('Could not find the ending quote for the included filename')
  9066. IncludeName=left(IncludeParms,QuotePos-1)
  9067. Fragment=substr(IncludeParms,QuotePos+1)
  9068. end
  9069. if Fragment<> '' then
  9070. Fragment=GetQuotedText(Fragment)
  9071. call RecursiveIncludeSave
  9072. call ProcessInputFile IncludeName,Fragment
  9073. call RecursiveIncludeRestore
  9074. call OutputProcessingFileStringToScreen '',IncludeFragmentText
  9075. return(0)
  9076. end
  9077. when HashCmd=CmdHashImport then
  9078. return(ProcessImport(HashCmdParms))
  9079. when HashCmd=CmdHashOutput then
  9080. return(ProcessHashOutput(HashCmdParms))
  9081. when HashCmd=CmdHashOutputHold then
  9082. return(ProcessHashOutputHold(HashCmdParms))
  9083. when HashCmd=CmdHashOneLine then
  9084. return(ProcessOneLine(HashCmdParms))
  9085. when HashCmd=CmdHashDefineRexx then
  9086. return(ProcessDefineRexx(HashCmdParms))
  9087. when HashCmd=CmdHashDefineRexxPlus then
  9088. return(ProcessDefineRexx(HashCmdParms, 'Y'))
  9089. when HashCmd=CmdHashMacroSpace then
  9090. do
  9091. call NotAvailableUnderNtYet HashCmd
  9092. Rest=PerformReplacementsInCmdsParameters(HashCmdParms)
  9093. MsCommand=translate(GetQuotedText(Rest, "Rest"))
  9094. MsFile=GetQuotedText(Rest, "Rest")
  9095. if Rest='' then
  9096. MsFunction=''
  9097. else
  9098. MsFunction=GetQuotedText(Rest)
  9099. if MsCommand<> 'ADD' & MsCommand <> 'DROP' then
  9100. CryAndDie('The macro space command "' || MsCommand || '" is unknown!')
  9101. if SafeQueryExists(MsFile)='' then
  9102. CryAndDie('The rexx file "' || MsFile || '" does not exist!')
  9103. call DoMacroSpaceOperation MsCommand,MsFile,MsFunction
  9104. return(0)
  9105. end
  9106. when HashCmd=CmdHashAsIs then
  9107. return(ProcessAsIs(HashCmdParms))
  9108. when HashCmd=CmdHashWarningL|HashCmd=CmdHashWarningS then
  9109. return(ProcessHashWarning(HashCmdParms))
  9110. when HashCmd=CmdHashInfo then
  9111. do
  9112. InfoMsg=PerformReplacementsInCmdsParameters(HashCmdParms)
  9113. InfoMsg=GetQuotedRest(InfoMsg)
  9114. call OutputInformationToScreen InfoMsg
  9115. return(0)
  9116. end
  9117. when HashCmd=CmdHashAutoTagState then
  9118. return(ProcessAutoTagState(HashCmdParms))
  9119. when HashCmd=CmdHashAutoTagClear then
  9120. return(ProcessAutoTagClear(HashCmdParms))
  9121. when HashCmd=CmdHashDependsOn then
  9122. return(ProcessDependsOn(HashCmdParms))
  9123. when HashCmd=CmdHashOnExit then
  9124. return(ProcessOnExit(HashCmdParms))
  9125. when HashCmd=CmdHashEof then
  9126. do
  9127. if HashCmdParms<> '' then
  9128. do
  9129. EndifCounter=GetQuotedText(HashCmdParms)
  9130. EndifCounter=PerformReplacementsInCmdsParameters(EndifCounter)
  9131. if datatype(EndifCounter, 'W')=0 then
  9132. CryAndDie('Invalid #endif simulate count of "' || EndifCounter || '" supplied!')
  9133. do EndifIndex=1 to EndifCounter
  9134. call ProcessHashEndif
  9135. end
  9136. end
  9137. EofForced=CurrentSourceLocation()
  9138. return(0)
  9139. end
  9140. when HashCmd=CmdHashTransform then
  9141. return(ProcessTransform(HashCmdParms))
  9142. when HashCmd=CmdHashSystem then
  9143. return(ProcessSystem(HashCmdParms))
  9144. when HashCmd=CmdHashDebug then
  9145. return(ProcessHashDebug(HashCmdParms))
  9146. when HashCmd=CmdHashRequire then
  9147. return(ProcessRequire(HashCmdParms))
  9148. when HashCmd=CmdHashErrorL|HashCmd=CmdHashErrorS then
  9149. call ProcessHashError HashCmdParms
  9150. otherwise
  9151. do
  9152. if HashCmd=CmdHashLoopE then
  9153. CryAndDie('Missing "' || CmdHashLoopS || '" command')
  9154. else
  9155. CryAndDie("Invalid '#' command line of: " ||HashCmd)
  9156. end
  9157. end
  9158. return(0)
  9159.  
  9160. ProcessHashError:
  9161. ErrorMsg=GetQuotedRest(PerformReplacementsInCmdsParameters(arg(1)))
  9162. CryAndDie(ErrorMsg)
  9163.  
  9164. IsStringOnOrOffCmd:
  9165. OoCmd=translate(arg(1))
  9166. if OoCmd='+' | OoCmd = 'YES' |  OoCmd = 'ON' then
  9167. return('Y')
  9168. else
  9169. do
  9170. if OoCmd='-' | OoCmd = 'NO' |  OoCmd = 'OFF' then
  9171. return('N')
  9172. end
  9173. return('')
  9174.  
  9175. SetOnorOffVariable:
  9176. parse arg OnOffSrc,VarName
  9177. OnOrOffText=translate(GetQuotedText(OnOffSrc))
  9178. OnOrOff=IsStringOnOrOffCmd(OnOrOffText)
  9179. if OnOrOff='' then
  9180. CryAndDie(HashCmd|| ' command does not specify a correct value value (ON/OFF)!')
  9181. call _valueS VarName,OnOrOff
  9182. return(0)
  9183.  
  9184. DisplayCopyright:
  9185. if CopyrightDisplayed='N' then
  9186. do
  9187. call Char1 HighlightColor
  9188. call Line1 '[]--------------------------------------------------------------------------[]'
  9189. call Line1 '| PPWIZARD.CMD: Version ' || PgmVersion || ' (C)opyright ' || PgmAuthor || ' 1997-2000           |'
  9190. call Line1 '| ' || PgmAuthorHomePage || '  (' || PgmAuthorEmail || ') |'
  9191. call Line1 '[]--------------------------------------------------------------------------[]'
  9192. call Line1 Reset
  9193. CopyrightDisplayed='Y'
  9194. end
  9195. return
  9196.  
  9197. UserSyntaxError:
  9198. call CgiStartFatalError
  9199. call DisplayCopyright
  9200. call Line1 ErrorColor|| "SYNTAX ERROR"
  9201. call Line1 "~~~~~~~~~~~~"
  9202. call Line1 '    ' ||arg(1)
  9203. call CgiEndFatalError
  9204. call Line1 ''
  9205. call Line1 'CORRECT SYNTAX'
  9206. call Line1 '~~~~~~~~~~~~~~'
  9207. call Line1 '    PPWIZARD[.CMD] InputMask [Option1 ...]'
  9208. call Line1 ''
  9209. call Line1 'SOME COMMON OPTIONS'
  9210. call Line1 '~~~~~~~~~~~~~~~~~~~'
  9211. call Line1 RexOptionChar|| 'Output:Mask     = Call output what?  Place it where? (example "out\*.html")'
  9212. call Line1 RexOptionChar|| 'Rexx            = Using as a rexx preprocessor (not HTML!)'
  9213. call Line1 RexOptionChar|| 'DependsOn:Mask  = Generate/Check dependencies (makefile type functionality)'
  9214. call Line1 RexOptionChar|| 'Debug           = Generate debug comments in generated output'
  9215. call Line1 ''
  9216. call Line1 "Please see PPWIZARD's documentation for more details (and more options)." ||Beep||Beep||Reset
  9217. AbnormalExit(MyLineNumber(), "Invalid Command Line - " ||arg(1))
  9218.  
  9219. SwitchMustHaveOptions:
  9220. parse arg TheCmd,TheOptions
  9221. if TheOptions='' then
  9222. UserSyntaxError('You must supply parameters on the "' || RexOptionChar || TheCmd || '" switch!')
  9223. return(TheOptions)
  9224.  
  9225. SwitchMustNotHaveOptions:
  9226. parse arg TheCmd,TheOptions,Value2Set
  9227. if TheOptions<> '' then
  9228. UserSyntaxError('No parameters are expected for the "' || RexOptionChar || TheCmd || '" switch!')
  9229. return(Value2Set)
  9230.  
  9231. SwitchOptionsValidateAgainstList:
  9232. TheCmd=arg(1)
  9233. TheOption=translate(arg(2))
  9234. ValidList=',' || translate(arg(3)) || ','
  9235. if pos(',' || TheOption || ',',ValidList)<>0 then
  9236. return(TheOption)
  9237. UserSyntaxError('An invalid parameter of "' || TheOption || '" was specified on the "' || RexOptionChar || TheCmd || '" switch!')
  9238.  
  9239. SwitchWantsYesOrNo:
  9240. TheCmd=arg(1)
  9241. TheOption=translate(arg(2))
  9242. Default=arg(3)
  9243. if TheOption='' then
  9244. return(Default)
  9245. else
  9246. return(left(SwitchOptionsValidateAgainstList(TheCmd,TheOption, "Y,N,YES,NO"),1))
  9247.  
  9248. NotAvailableUnderNtYet:
  9249. TheCmd=arg(1)
  9250. if RexWhich='REGINA' then
  9251. UserSyntaxError('"' || RexOptionChar || TheCmd || '" can not be performed under NT (or regina).... Yet...')
  9252. return
  9253.  
  9254. CheckRexxInterpreter:
  9255. if RexWhich='REGINA' then
  9256. do
  9257. if pos(RexVerRegina,SupportedReginaVersions)<>0 then
  9258. return(0)
  9259. criText="The Regina " || RexVerRegina || " interpreter is unsupported, use " || SupportedReginaVersions || ' instead!'
  9260. if arg(1)='Y' then
  9261. call DebugLine criText
  9262. else
  9263. call OutputWarningToScreen 'URI0',criText
  9264. return(1)
  9265. end
  9266. return(0)
  9267.  
  9268. GetCurrentDirectory:
  9269. if RexWhich='STANDARD_OS/2' then
  9270. cwDir=directory()
  9271. else
  9272. do
  9273. cwDir=stream('.', 'c', 'query exists')
  9274. cwDirRegina=cwDir
  9275. cwLength=length(cwDir)
  9276. if lastpos(RexDirChar,cwDir)=cwLength then
  9277. do
  9278. if RexSystemOpSys="UNIX" then
  9279. do
  9280. if cwDir<>RexDirChar then
  9281. cwDir=left(cwDir,cwLength-1)
  9282. end
  9283. else
  9284. do
  9285. cwColonPos=pos(':',cwDir)
  9286. if cwColonPos+1<>cwLength then
  9287. cwDir=left(cwDir,cwLength-1)
  9288. end
  9289. end
  9290. if cwDirRegina<>cwDir then
  9291. call DebugLine 'Regina returned "' || cwDirRegina || '" for current directory'
  9292. end
  9293. if OptionDebugOn='Y' then
  9294. call DebugLine 'Current Directory = "' || cwDir || '"'
  9295. return(cwDir)
  9296.  
  9297. MakeAbsolute:
  9298. maFileOrig=arg(1)
  9299. if left(maFileOrig,1)<> '+' then
  9300. maFileOrigP=''
  9301. else
  9302. do
  9303. maFileOrig=substr(maFileOrig,2)
  9304. maFileOrigP='+'
  9305. end
  9306. maFile=maFileOrig
  9307. if left(maFile,1)='.' |pos(RexDirChar,maFile)=0 then
  9308. do
  9309. DotSlash='.' ||RexDirChar
  9310. DotDotSlash='.' ||DotSlash
  9311. maDir=GetCurrentDirectory()
  9312. if OptionDebugOn='Y' then
  9313. do
  9314. call DebugLine 'Converting relative "' || maFile || '"'
  9315. call DebugIncrement 1
  9316. end
  9317. if pos(RexDirChar,maFile)<>0 then
  9318. do
  9319. do forever
  9320. select
  9321. when left(maFile,2)==DotSlash then
  9322. do
  9323. maFile=substr(maFile,3)
  9324. end
  9325. when left(maFile,3)==DotDotSlash then
  9326. do
  9327. LastChar=right(maDir,1)
  9328. SlashPos=lastpos(RexDirChar,maDir)
  9329. if SlashPos=0|LastChar=RexDirChar|LastChar=':' then
  9330. CryAndDie('The spec "' || maFileOrig || '" can not be converted to absolute', 'from the current directory "' || GetCurrentDirectory() || '"')
  9331. maDir=left(maDir,SlashPos-1)
  9332. maFile=substr(maFile,4)
  9333. end
  9334. otherwise
  9335. leave
  9336. end
  9337. end
  9338. end
  9339. if right(maDir,1)=RexDirChar then
  9340. maFile=maDir||maFile
  9341. else
  9342. maFile=maDir||RexDirChar||maFile
  9343. if OptionDebugOn='Y' then
  9344. do
  9345. call DebugLine 'To Absolute "' || maFile || '"'
  9346. call DebugIncrement-1
  9347. end
  9348. end
  9349. return(maFileOrigP||maFile)
  9350.  
  9351. SafeQueryExists:
  9352. sfeFile=arg(1)
  9353. if sfeFile='' then
  9354. CryAndDie('The filename "" is invalid!')
  9355. else
  9356. return(RexQueryExists(sfeFile))
  9357.  
  9358. MustDeleteFile:
  9359. mdFile=arg(1)
  9360. CloseRc=stream(mdFile, 'c', 'close')
  9361. if SafeQueryExists(mdFile)<> '' then
  9362. do
  9363. DeleteRc=_SysFileDelete(mdFile)
  9364. if SafeQueryExists(mdFile)<> "" then
  9365. CryAndDie('Could not delete "' || mdFile || '", it must be in use (DosRc=' || DeleteRc || ')...')
  9366. end
  9367. return
  9368.  
  9369. GetListOfFiles:
  9370. parse arg glfMask,glfStem,glfFollowDirs
  9371. call DebugLine 'GetListOfFiles("' || glfMask || '"): Follow Directories = "' || glfFollowDirs || '"'
  9372. call DebugIncrement 1
  9373. call _valueS glfStem|| '.0',0
  9374. if RexxHookGetFileList='' then
  9375. do
  9376. if glfFollowDirs='N' then
  9377. glfFollowDirs=''
  9378. else
  9379. glfFollowDirs='S'
  9380. call DebugLine 'Using "_SysFileTree()" as ' || RexOptionChar || 'LISTFILES was not used'
  9381. call _SysFileTree glfMask,glfStem, 'FO' ||glfFollowDirs
  9382. end
  9383. else
  9384. do
  9385. call DebugLine 'Not using "_SysFileTree()" as user specified use of "' || RexxHookGetFileList || '"'
  9386. glfTmpFile=RexGetTmpFileName()
  9387. call MustDeleteFile glfTmpFile
  9388. glfLocn=_filespec('Location',glfMask)
  9389. glfName=_filespec('Name',glfMask)
  9390. call CallHook "GETFILELIST",,glfLocn,glfName,glfFollowDirs,glfTmpFile
  9391. if SafeQueryExists(glfTmpFile)='' then
  9392. CryAndDie('"' || RexxHookGetFileList || '" did not create the file list!')
  9393. glfLine=0
  9394. glfCount=0
  9395. do while lines(glfTmpFile)<>0
  9396. CurrentLine=linein(glfTmpFile)
  9397. glfLine=glfLine+1
  9398. if CurrentLine<> '' then
  9399. do
  9400. FullFile=SafeQueryExists(CurrentLine)
  9401. if FullFile='' then
  9402. CryAndDie('"' || RexxHookGetFileList || '" specified an invalid file of "' || CurrentLine || '" on line #' ||glfLine)
  9403. glfCount=glfCount+1
  9404. call _valueS glfStem|| '.' ||glfCount,CurrentLine
  9405. end
  9406. end
  9407. CloseRc=stream(glfTmpFile, 'c', 'close')
  9408. call _valueS glfStem|| '.0',glfCount
  9409. if OptionDebugOn='N' then
  9410. call MustDeleteFile glfTmpFile
  9411. end
  9412. call DebugIncrement-1
  9413. return
  9414.  
  9415. NiceDateTime:
  9416. return(date('Weekday') || ', ' || date() || ' ' ||GetAmPmTime())
  9417.  
  9418. GetInputFileNameAndLine:call TRACE "OFF"
  9419.  
  9420. CurrentSourceLocation:
  9421. if IncludeLevel<>0 then
  9422. return('line ' || AddCommasToDecimalNumber(IncludeLineNumber) || ' of "' || IncludeFileName || '"')
  9423. else
  9424. do
  9425. if arg(1, 'E')then
  9426. return(arg(1))
  9427. else
  9428. return("unknown")
  9429. end
  9430.  
  9431. GetLineBeingProcessed:call TRACE "OFF"
  9432. return(strip(LastLine))
  9433.  
  9434. GetFileLineBeingProcessed:call TRACE "OFF"
  9435. return(strip(LastFileLine))
  9436.  
  9437. DumpVarsIfCompoundVariable:
  9438. if pos('.',arg(1))<>0 then
  9439. ExpressionKilledUs=arg(1)
  9440. return
  9441.  
  9442. CheckForNotBeingAbleToExecAnything:
  9443. if RexWhich='REGINA' then
  9444. do
  9445. if RexSystemOpSys="UNIX" then
  9446. Exe=''
  9447. else
  9448. Exe='.exe'
  9449. RexxExe="rexx" ||Exe
  9450. ReginaExe="regina" ||Exe
  9451. DoWhat='Test for use of buggy regina "' || ReginaExe || '" rather than "' || RexxExe || '" executable'
  9452. call DebugLine DoWhat
  9453. TmpFile=RexGetTmpFileName()
  9454. call AddressCmd 'echo ' ||DoWhat||RedirectStdOutAndErr2(TmpFile),TmpFile
  9455. if stream(TmpFile, 'c', 'query exists') = '' then
  9456. do
  9457. CryAndDie( "Can't execute shell functions!", 'If you used regina''s "' || ReginaExe || '" executable then try the "' || RexxExe || '"', 'one instead!', '', 'If already using "' || RexxExe || '" then please report problem to', '"' || PgmAuthorEmail || '" (please attach zipped "' || RexOptionChar  || 'debug" output)!' )
  9458. end
  9459. call _SysFileDelete TmpFile
  9460. call DebugLine 'Looks OK to me!'
  9461. end
  9462. return
  9463.  
  9464. LookLikeASingleFile:
  9465. FileName=arg(1)
  9466. call DebugLine 'No files matched "' || FileName || '", does it look like a single file?'
  9467. if verify(FileName, '*?', 'M')<>0 then
  9468. NormalFile='N'
  9469. else
  9470. do
  9471. if stream(FileName, 'c', 'query exists') = '' then
  9472. NormalFile='N'
  9473. else
  9474. NormalFile='Y'
  9475. end
  9476. call DebugIncrement 1
  9477. call DebugLine 'Normal File: ' ||NormalFile
  9478. call DebugIncrement-1
  9479. return(NormalFile)
  9480.  
  9481. CryAndDie:
  9482. SynErrLine=SIGL
  9483. SynErrLineC=AddCommasToDecimalNumber(SynErrLine)
  9484. call DebugIncrementInit
  9485. call DebugLine 'Fatal Error Detected (at line ' || SynErrLineC || ' of ppwizard)'
  9486. call DebugIncrement 1
  9487. PpwSize=stream(PpWizardPgmName, 'c', 'query size')
  9488. if PpwSize<> '' then
  9489. PpwSize=AddCommasToDecimalNumber(PpwSize)
  9490. PpwDateTime=GetFileTimeStamp(PpWizardPgmName)
  9491. call Char1 ErrorColor
  9492. call Line1 ''
  9493. call Line1 copies('!!',38)
  9494. call Line1 copies('!!', 15) || '[ Fatal  Error ]' || copies('!!',15)
  9495. call Line1 copies('!!',38)
  9496. call CgiStartFatalError
  9497. if IncludeLevel<>0 then
  9498. do
  9499. LastFileLine=strip(LastFileLine)
  9500. LastLine=strip(LastLine)
  9501. call Line1 'Location  : ' ||CurrentSourceLocation()
  9502. call Line1 'File Line : ' ||LastFileLine
  9503. if LastLine<>LastFileLine then
  9504. call Line1 'Fail Line : ' ||LastLine
  9505. if LastLineAfterMacroRep<> '' &LastLine<>LastLineAfterMacroRep&LastFileLine<>LastLineAfterMacroRep then
  9506. call Line1 'After Repl: ' ||LastLineAfterMacroRep
  9507. if MacroBeingExpanded<> '' then
  9508. call Line1 'Expanding : ' || StartsMacroReplacement || MacroBeingExpanded || ' ...' ||EndsMacroReplacement
  9509. end
  9510. call Line1 'Detected @: Line ' || SynErrLineC || ' of ' || _filespec('name', PpWizardPgmName) || ' (v' || PgmVersion || ' in ' || PpWizardOpSys || ')'
  9511. call Line1 'PPWIZARD  : Length ' || PpwSize || ' bytes.  TimeStamped ' ||PpwDateTime
  9512. call Line1 'Running In: ' || PpWizardOpSys || ', ' ||RexVersionInfo
  9513. call Line1 'Reason'
  9514. call Line1 '~~~~~~'
  9515. LastArg=1
  9516. do LineIndex=1 to arg()
  9517. if arg(LineIndex)<> '' then
  9518. LastArg=LineIndex
  9519. end
  9520. do LineIndex=1 to LastArg
  9521. call Line1 arg(LineIndex)
  9522. end
  9523. if ExpressionKilledUs<> '' then
  9524. call DumpVarsInExpression ExpressionKilledUs,, "KNOWN VARIABLES"
  9525. call CgiEndFatalError
  9526. call Line1 copies('!!',38)
  9527. call Line1 ''
  9528. call Line1 ''
  9529. call Char1 Beep||Reset
  9530. if RexxHookError<> '' then
  9531. do
  9532. do LineIndex=1 to LastArg
  9533. call SetEnv "PPWH_ERROR" ||LineIndex,arg(LineIndex)
  9534. end
  9535. call CallHook "ERROR",,LastArg
  9536. do LineIndex=1 to LastArg
  9537. call SetEnv "PPWH_ERROR" || LineIndex, ''
  9538. end
  9539. end
  9540. AbnormalExit(SynErrLine)
  9541.  
  9542. RexSystemFailure:
  9543. FailedAt=SIGL
  9544. if TrapHandler='FULL' then
  9545. call DebugLine 'RexSystemFailure(REXSYSTM.XH routine failed)'
  9546. call DisplayCopyright
  9547. call RexDumpSystemInfo
  9548. say ''
  9549. if TrapHandler='FULL' then
  9550. CryAndDie(arg(1))
  9551. say 'ERROR'
  9552. say '~~~~~'
  9553. say arg(1)
  9554. call CallErrorHookForSimpleOneLiner arg(1)
  9555. exit(FailedAt)
  9556.  
  9557. CallErrorHookForSimpleOneLiner:
  9558. if RexxHookError<> '' then
  9559. do
  9560. call SetEnv "PPWH_ERROR1",arg(1)
  9561. call CallHook "ERROR",,1
  9562. call SetEnv "PPWH_ERROR1", ''
  9563. end
  9564. return
  9565.  
  9566. AbnormalExit:
  9567. call DebugLine 'AbnormalExit(' || arg(1) || ') called.'
  9568. if arg(2)<> '' then
  9569. call CallErrorHookForSimpleOneLiner arg(2)
  9570. OnExitSleepFor=1
  9571. ThatsAllFolks(arg(1))
  9572.  
  9573. ThatsAllFolks:
  9574. call DebugLine 'ThatsAllFolks() called to exit program.'
  9575. if CurrentOutFile<> '' then
  9576. CloseRc=stream(CurrentOutFile, 'c', 'close')
  9577. if IncludeLevel<>0 then
  9578. do
  9579. do FileIndex=1 to IncludeLevel
  9580. CloseRc=stream(IncludeFileName.FileIndex, 'c', 'close')
  9581. end
  9582. end
  9583. call CloseCgiFileIfOpen
  9584. if OptionFilterIn<> '' then
  9585. call DoMacroSpaceOperation "DROP", OptionFilterIn,  "HtmlFilterIn",  "QUIET"
  9586. if OptionFilterOut<> '' then
  9587. call DoMacroSpaceOperation "DROP", OptionFilterOut, "HtmlFilterOut", "QUIET"
  9588. call DebugLine 'Exiting with a return code of ' ||arg(1)
  9589. if OnExitSleepFor<>0&OptionCgiModeOn='N' then
  9590. do
  9591. call DebugLine 'Sleeping for ' || OnExitSleepFor || ' second(s)'
  9592. call _SysSleep OnExitSleepFor
  9593. end
  9594. exit(arg(1))
  9595. signal INDENT_37
  9596.  
  9597. EXTRAINDENT_DEBUG:
  9598. if OptionDebugOn='Y' then
  9599. call OptionDebugShow 'EXTRAINDENT', 'Extra left indent is now "' || LeftIndent || '"'
  9600. return
  9601.  
  9602. EXTRAINDENT_GET:
  9603. call EXTRAINDENT_DEBUG
  9604. return(LeftIndentSet2)
  9605.  
  9606. EXTRAINDENT_SET:
  9607. LeftIndentSet2=arg(1)
  9608. if ProcessedCmdLine='N' then
  9609. do
  9610. call OptionDebugShow 'EXTRAINDENT', 'Setting default value of extra left indent to "' || LeftIndentSet2 || '"'
  9611. Default4_LeftIndent=LeftIndentSet2
  9612. return(0)
  9613. end
  9614. if LeftIndentSet2=='' then
  9615. LeftIndentCmd=Default4_LeftIndent
  9616. else
  9617. LeftIndentCmd=LeftIndentSet2
  9618. if translate(LeftIndentCmd)='NULL' then
  9619. LeftIndent=''
  9620. else
  9621. call ExecRexxCmd "LeftIndent = " ||LeftIndentCmd
  9622. call EXTRAINDENT_DEBUG
  9623. return
  9624.  
  9625. INDENT_37:
  9626.  
  9627. _DieAsNoTextConditionSupplied:
  9628. CryAndDie('No test condition supplied on "#if" command')
  9629.  
  9630. _PerformSimpleHashIfTest:
  9631. SimpleTest=arg(1)
  9632. if left(SimpleTest,1)<> '[' | right(SimpleTest, 1) <> ']' then
  9633. CryAndDie('Incorrectly bracketed simple #if command.')
  9634. SimpleTest=substr(SimpleTest,2,length(SimpleTest)-2)
  9635. if SimpleTest='' then
  9636. call _DieAsNoTextConditionSupplied
  9637. Parm1=GetSimpleRexxValue(SimpleTest, "SimpleTest")
  9638. parse var SimpleTest FastOperator SimpleTest
  9639. if SimpleTest='' then
  9640. CryAndDie('#if [] has too few parameters (you must put spaces around operator!)')
  9641. Parm3=GetSimpleRexxValue(SimpleTest, "SimpleTest")
  9642. if SimpleTest<> '' then
  9643. CryAndDie('#if [] has too many parameters, expected 3!')
  9644. select
  9645. when FastOperator='==' then
  9646. return(Parm1==Parm3)
  9647. when FastOperator='<>' then
  9648. return(Parm1<>Parm3)
  9649. when FastOperator='=' then
  9650. return(Parm1=Parm3)
  9651. when FastOperator='<' then
  9652. return(Parm1<Parm3)
  9653. when FastOperator='>' then
  9654. return(Parm1>Parm3)
  9655. when FastOperator='<=' then
  9656. return(Parm1<=Parm3)
  9657. when FastOperator='>=' then
  9658. return(Parm1>=Parm3)
  9659. otherwise
  9660. CryAndDie("Unsupported operator of '" || FastOperator || "' used on simple " || HashCmd, '', 'ONLY "==, <>, =, <, >, <=, >=" are supported!')
  9661. end
  9662. CryAndDie('BUG: Did not expect to get here!')
  9663.  
  9664. MatchesIfDebugText:
  9665. MatchIndex=arg(1)
  9666. if MatchIndex<=0 then
  9667. return('')
  9668. else
  9669. return(' (matches #if at ' || IfState.IfAtLine.MatchIndex || ')')
  9670.  
  9671. WantLine:
  9672. if IfState.WantLines.IfNesting='N' then
  9673. return('N')
  9674. else
  9675. do
  9676. if IfState.IfTrue.IfNesting=IfState.InTrue.IfNesting then
  9677. return('Y')
  9678. else
  9679. return('N')
  9680. end
  9681.  
  9682. ProcessHashIfTest:
  9683. if OptionDebugOn='Y' then
  9684. do
  9685. call DebugLine_CONDITIONAL '#If? at nesting level ' ||IfNesting+1
  9686. call DebugIncrement 1
  9687. end
  9688. WantTheLines=WantLine()
  9689. if WantTheLines='N' then
  9690. IfResult='N'
  9691. else
  9692. do
  9693. if OptionDebugOn='Y' then
  9694. call DebugIncrement 1
  9695. parse value PerformReplacementsInCmdsParameters(arg(1))with HashCmd TestCondition
  9696. TestCondition=strip(TestCondition)
  9697. if translate(HashCmd)=CmdHashIf then
  9698. do
  9699. if left(TestCondition,1)<> '[' then
  9700. do
  9701. if TestCondition='' then
  9702. call _DieAsNoTextConditionSupplied
  9703. call ExecRexxCmd 'IfResult = (' || TestCondition || ')'
  9704. end
  9705. else
  9706. do
  9707. IfResult=_PerformSimpleHashIfTest(TestCondition)
  9708. end
  9709. if IfResult then
  9710. IfResult='Y'
  9711. else
  9712. IfResult='N'
  9713. end
  9714. else
  9715. do
  9716. if TestCondition='' then
  9717. CryAndDie(HashCmd|| ' command does not specify the variable name!')
  9718. IfResult=VariableExists(TestCondition)
  9719. if translate(HashCmd)=CmdHashIfndef then
  9720. IfResult=translate(IfResult, 'YN', 'NY')
  9721. end
  9722. if OptionDebugOn='Y' then
  9723. do
  9724. call DebugIncrement-1
  9725. if IfResult='N' then
  9726. Tf='FALSE'
  9727. else
  9728. Tf='TRUE'
  9729. if OptionDebugOn='Y' then
  9730. call DebugLine_CONDITIONAL 'Answer is ' ||Tf
  9731. end
  9732. end
  9733. IfNesting=IfNesting+1
  9734. IfState.WantLines.IfNesting=WantTheLines
  9735. IfState.InTrue.IfNesting='Y'
  9736. IfState.IfTrue.IfNesting=IfResult
  9737. IfState.IfAtLine.IfNesting=CurrentSourceLocation()
  9738. if OptionDebugOn='Y' then
  9739. call DebugIncrement-1
  9740. return('OK')
  9741.  
  9742. ProcessHashElse:
  9743. if OptionDebugOn='Y' then
  9744. call DebugLine_CONDITIONAL '#elseif at level #' ||IfNesting||MatchesIfDebugText(IfNesting)
  9745. if IfNesting=0 then
  9746. CryAndDie("Found #elseif without matching #if")
  9747. if IfState.InTrue.IfNesting='N' then
  9748. CryAndDie("Found unexpected #elseif - duplicated #elseif?" ||MatchesIfDebugText(IfNesting))
  9749. if arg(1)<> '' then
  9750. CryAndDie('The #elseif command does not take parameters')
  9751. IfState.InTrue.IfNesting='N'
  9752. return('OK')
  9753.  
  9754. ProcessHashEndif:
  9755. if OptionDebugOn='Y' then
  9756. call DebugLine_CONDITIONAL 'Endif at level #' ||IfNesting||MatchesIfDebugText(IfNesting)
  9757. if IfNesting=0 then
  9758. CryAndDie("Found #endif without matching #if")
  9759. IfNesting=IfNesting-1
  9760. return('OK')
  9761.  
  9762. _ReportCurrentOutputFile:
  9763. call DebugLine 'Current Output file = "' || CurrentOutFile || '" (level ' || OutputLevel || ')'
  9764. return
  9765.  
  9766. HaveNewOutputFile:
  9767. hnofAppend=arg(3)
  9768. hnofNOCTYPE=arg(4)
  9769. if OutputLevel<>0 then
  9770. CloseRc=stream(CurrentOutFile, 'c', 'close')
  9771. if OptionCgiModeOn='Y' then
  9772. do
  9773. CurrentOutFile=RexStdoutStream
  9774. call DebugLine 'In CGI mode, will output to "' || CurrentOutFile || '" (standard output)'
  9775. end
  9776. else
  9777. do
  9778. if arg(2)<> '' then
  9779. CurrentOutFile=GenerateFileName(arg(1),arg(2), 'Y')
  9780. else
  9781. do
  9782. CurrentOutFile=arg(1)
  9783. call MakeDirectoryTree _filespec('drive', CurrentOutFile) || _filespec('path',CurrentOutFile)
  9784. end
  9785. end
  9786. CurrentOutLine=0
  9787. do ChkIndex=1 to OutputLevel
  9788. if Output.ChkIndex.File=CurrentOutFile then
  9789. do
  9790. if hnofAppend='Y' then
  9791. call OutputWarningToScreen 'OFO0', 'Appending to currently opened file ("' || CurrentOutFile || '")!'
  9792. else
  9793. do
  9794. WhereOpened=Output.ChkIndex.!Locn
  9795. if WhereOpened='' then
  9796. Extra='Check "/Output" mask for correctness'
  9797. else
  9798. Extra='File opened at ' ||WhereOpened
  9799. CryAndDie('Already have "' || CurrentOutFile || '" open for output!',Extra)
  9800. end
  9801. end
  9802. end
  9803. OutputLevel=OutputLevel+1
  9804. Output.OutputLevel.File=CurrentOutFile
  9805. Output.OutputLevel.Line=CurrentOutLine
  9806. Output.OutputLevel.!Locn=CurrentSourceLocation('')
  9807. Output.OutputLevel.OCTYPE=OptionCodeType
  9808. if OptionCodeType<>hnofNOCTYPE then
  9809. do
  9810. call DebugLine 'Processing mode for "' || CurrentOutFile || '" is "' || hnofNOCTYPE || '" (changed from "' || OptionCodeType || '")'
  9811. OptionCodeType=hnofNOCTYPE
  9812. end
  9813. if OptionCgiModeOn='N' then
  9814. do
  9815. if SafeQueryExists(CurrentOutFile)<> "" then
  9816. do
  9817. if hnofAppend='Y' then
  9818. call DebugLine 'Appending to "' || CurrentOutFile || '"'
  9819. else
  9820. do
  9821. call DebugLine 'Deleting "' || CurrentOutFile || '"'
  9822. call MustDeleteFile CurrentOutFile
  9823. end
  9824. end
  9825. end
  9826. call AddOutputFileToDependancyList CurrentOutFile
  9827. call charout CurrentOutFile, ""
  9828. CloseRc=stream(CurrentOutFile, 'c', 'close')
  9829. call _ReportCurrentOutputFile
  9830. return
  9831.  
  9832. _BackToPreviousOutput:
  9833. CloseRc=stream(CurrentOutFile, 'c', 'close')
  9834. call DebugLine 'Closed the Output file = "' || CurrentOutFile || '" (wrote ' || CurrentOutLine || ' line(s))'
  9835. if OutputLevel<=1 then
  9836. CryAndDie('No output files on stack!')
  9837. else
  9838. do
  9839. OutputLevel=OutputLevel-1
  9840. CurrentOutFile=Output.OutputLevel.File
  9841. CurrentOutLine=Output.OutputLevel.Line
  9842. if OptionCodeType<>Output.OutputLevel.OCTYPE then
  9843. do
  9844. OptionCodeType=Output.OutputLevel.OCTYPE
  9845. call DebugLine 'Restoring mode for "' || CurrentOutFile || '" to "' || OptionCodeType || '"'
  9846. end
  9847. call DieIfHoldingOutput
  9848. call OutputHoldPop
  9849. end
  9850. call _ReportCurrentOutputFile
  9851. return
  9852.  
  9853. ProcessHashOutput:
  9854. call DieIfCgiModeOn
  9855. if LineQueued\=='' then
  9856. do
  9857. if OptionDebugOn='Y' then
  9858. do
  9859. call DebugLine 'Need to flush queued data'
  9860. call DebugIncrement 3
  9861. end
  9862. call FlushQueuedOutput
  9863. if OptionDebugOn='Y' then
  9864. call DebugIncrement-3
  9865. end
  9866. OutputParms=PerformReplacementsInCmdsParameters(arg(1))
  9867. if OutputParms='' then
  9868. call _BackToPreviousOutput
  9869. else
  9870. do
  9871. NewOutFile=GetQuotedText(OutputParms, "OutputParms")
  9872. OutputParms=translate(OutputParms)
  9873. NewOutAsIs='N'
  9874. NewOutAppend='N'
  9875. NewOCTYPE=OptionCodeType
  9876. do while OutputParms<> ''
  9877. ThisParm=GetQuotedText(OutputParms, "OutputParms")
  9878. select
  9879. when ThisParm="ASIS" then
  9880. NewOutAsIs='Y'
  9881. when ThisParm="APPEND" then
  9882. NewOutAppend='Y'
  9883. when ThisParm="HTML" | ThisParm = "REXX" | ThisParm = "OTHER" then
  9884. NewOCTYPE=ThisParm
  9885. otherwise
  9886. CryAndDie('The parameter "' || ThisParm || '" is unknown!')
  9887. end
  9888. end
  9889. call OutputHoldPushAndClear
  9890. if NewOutAsIs='N' then
  9891. call HaveNewOutputFile NewOutFile,OptionOutput,NewOutAppend,NewOCTYPE
  9892. else
  9893. call HaveNewOutputFile NewOutFile,,NewOutAppend,NewOCTYPE
  9894. end
  9895. return(0)
  9896.  
  9897. GetQuotedText:
  9898. parse arg TheString,RestVarName,QuoteDel
  9899. TheString=strip(TheString, 'L')
  9900. QuoteDel=' ' ||QuoteDel
  9901. if OptionDebugOn='Y' then
  9902. do
  9903. call DebugLine_QUOTING 'GetQuotedText(): ' ||DebugRightArrow||TheString||DebugLeftArrow
  9904. call DebugIncrement 1
  9905. end
  9906. if TheString='' then
  9907. call _ErrorNoQuotedParm
  9908. QuoteChar=left(TheString,1)
  9909. if datatype(QuoteChar, 'Alphanumeric')then
  9910. do
  9911. if OptionDebugOn='Y' then
  9912. call DebugLine_QUOTING 'Text is unquoted'
  9913. DelPos=verify(TheString,QuoteDel, 'M')
  9914. if DelPos=0 then
  9915. do
  9916. QuotedString=TheString
  9917. TheRest=''
  9918. end
  9919. else
  9920. do
  9921. QuotedString=substr(TheString,1,DelPos-1)
  9922. TheRest=substr(TheString,DelPos)
  9923. end
  9924. end
  9925. else
  9926. do
  9927. if OptionDebugOn='Y' then
  9928. call DebugLine_QUOTING 'Text is quoted with ' ||DebugRightArrow||QuoteChar||DebugLeftArrow
  9929. SecondQuotePosn=pos(QuoteChar,TheString,2)
  9930. if SecondQuotePosn=0 then
  9931. call _ErrorNoEndQuote
  9932. QuotedString=substr(TheString,2,SecondQuotePosn-2)
  9933. TheRest=substr(TheString,SecondQuotePosn+1)
  9934. end
  9935. if TheRest<> '' then
  9936. do
  9937. if QuoteDel<> 'Y' then
  9938. do
  9939. if pos(left(TheRest,1),QuoteDel)=0 then
  9940. do
  9941. Line1='There is no whitespace after the 2nd quote char of "' || QuoteChar || '" (did not expect to find "' || left(TheRest, 1) || '")'
  9942. Line2='The rest of the line:'
  9943. Line3=copies(' ',8)||DebugRightArrow||TheRest||DebugLeftArrow
  9944. CryAndDie(Line1,Line2,Line3)
  9945. end
  9946. end
  9947. end
  9948. TheRest=strip(TheRest, 'L')
  9949. if RestVarName<> '' then
  9950. call _valueS RestVarName,TheRest
  9951. else
  9952. do
  9953. if TheRest<> '' then
  9954. call DieIfExtraUnexpectedParms TheRest
  9955. end
  9956. if OptionDebugOn='Y' then
  9957. do
  9958. call DebugLine_QUOTING 'Text is  ' ||DebugRightArrow||QuotedString||DebugLeftArrow
  9959. call DebugIncrement-1
  9960. end
  9961. return(QuotedString)
  9962.  
  9963. GetQuotedRest:
  9964. TheString=strip(arg(1))
  9965. if OptionDebugOn='Y' then
  9966. do
  9967. call DebugIncrement 1
  9968. call DebugLine_QUOTING 'GetQuotedRest(): ' ||DebugRightArrow||TheString||DebugLeftArrow
  9969. end
  9970. if TheString='' then
  9971. call _ErrorNoQuotedParm
  9972. QuoteChar=left(TheString,1)
  9973. if datatype(QuoteChar, 'Alphanumeric')then
  9974. do
  9975. QuotedString=TheString
  9976. if OptionDebugOn='Y' then
  9977. call DebugLine_QUOTING 'Text is unquoted'
  9978. end
  9979. else
  9980. do
  9981. if OptionDebugOn='Y' then
  9982. call DebugLine_QUOTING 'Text is quoted with '||DebugRightArrow||QuoteChar||DebugLeftArrow
  9983. SecondQuotePosn=length(TheString)
  9984. if SecondQuotePosn<2|substr(TheString,SecondQuotePosn,1)<>QuoteChar then
  9985. call _ErrorNoEndQuote
  9986. QuotedString=substr(TheString,2,SecondQuotePosn-2)
  9987. end
  9988. if OptionDebugOn='Y' then
  9989. do
  9990. call DebugLine_QUOTING 'Text is  ' ||DebugRightArrow||QuotedString||DebugLeftArrow
  9991. call DebugIncrement-1
  9992. end
  9993. return(QuotedString)
  9994.  
  9995. DieIfExtraUnexpectedParms:
  9996. if arg(1)='' then
  9997. return
  9998. CryAndDie('Unexpected parameter(s) of "' || strip(arg(1)) || '" found!')
  9999.  
  10000. _ErrorNoQuotedParm:
  10001. CryAndDie('Expect a quoted string, not enough parameters available!')
  10002.  
  10003. _ErrorNoEndQuote:
  10004. Line1='Could not find a matching end quote character of "' || QuoteChar || '"!'
  10005. Line2='Processing:'
  10006. Line3=copies(' ',8)||DebugRightArrow||TheString||DebugLeftArrow
  10007. CryAndDie(Line1,Line2,Line3)
  10008.  
  10009. GetRexxVarValueOrDie:
  10010. grvVar=arg(1)
  10011. if symbol(grvVar)='VAR' then
  10012. return(_valueG(grvVar))
  10013. else
  10014. do
  10015. if symbol(grvVar)='BAD' then
  10016. Reason="contains invalid character(s)"
  10017. else
  10018. Reason="is unknown"
  10019. call DumpVarsIfCompoundVariable grvVar
  10020. CryAndDie('The rexx variable "' || grvVar || '" ' || Reason || '!')
  10021. end
  10022.  
  10023. ProcessRexxVar:
  10024. ResultVar=GetQuotedText(PerformReplacementsInCmdsParameters(arg(1)), "Rest")
  10025. XVarName=''
  10026. ResultVarU=translate(ResultVar)
  10027. if ResultVarU="PUSH" then
  10028. do
  10029. do while Rest<> ''
  10030. ResultVar=GetQuotedText(Rest, "Rest")
  10031. call _StackPush GetRexxVarValueOrDie(ResultVar)
  10032. end
  10033. return(0)
  10034. end
  10035. if ResultVarU="POP" then
  10036. do
  10037. TmpVarCnt=0
  10038. do while Rest<> ''
  10039. ResultVar=GetQuotedText(Rest, "Rest")
  10040. TmpVarCnt=TmpVarCnt+1
  10041. TmpVar.TmpVarCnt=ResultVar
  10042. end
  10043. do while TmpVarCnt<>0
  10044. call _valueS TmpVar.TmpVarCnt,_StackPop()
  10045. TmpVarCnt=TmpVarCnt-1
  10046. end
  10047. return(0)
  10048. end
  10049. parse var Rest FastOperator Rest
  10050. if FastOperator<> '=' then
  10051. do
  10052. FastOperator=translate(FastOperator)
  10053. if left(FastOperator,1)='=' then
  10054. do
  10055. if FastOperator='=X=' then
  10056. do
  10057. XVarName=ResultVar
  10058. ResultVar='XVAR?.X?' ||c2x(translate(XVarName))
  10059. end
  10060. else
  10061. do
  10062. Rest=strip(Rest)
  10063. if symbol(Rest)='VAR' then
  10064. ResultValue=GetRexxVarValueOrDie(Rest)
  10065. else
  10066. ResultValue=GetQuotedRest(Rest)
  10067. select
  10068. when FastOperator='=ASIS=' then
  10069. do
  10070. RestVar=AsIs(ResultValue)
  10071. end
  10072. otherwise
  10073. CryAndDie('Unsupported "=?=" operator of "' || FastOperator || '" used on ' ||HashCmd)
  10074. end
  10075. Rest='RestVar'
  10076. end
  10077. FastOperator='='
  10078. end
  10079. end
  10080. select
  10081. when FastOperator='=' then
  10082. do
  10083. Rest=strip(Rest)
  10084. if symbol(Rest)='VAR' then
  10085. ResultValue=GetRexxVarValueOrDie(Rest)
  10086. else
  10087. ResultValue=GetQuotedRest(Rest)
  10088. end
  10089. when FastOperator='PUSH' then
  10090. do
  10091. call DieIfExtraUnexpectedParms Rest
  10092. call _StackPush GetRexxVarValueOrDie(ResultVar)
  10093. return(0)
  10094. end
  10095. when FastOperator='POP' then
  10096. do
  10097. call DieIfExtraUnexpectedParms Rest
  10098. ResultValue=_StackPop()
  10099. end
  10100. otherwise
  10101. do
  10102. AfterOperator=GetSimpleRexxValue(Rest, "Rest")
  10103. if Rest<> '' then
  10104. SourceValue=GetSimpleRexxValue(Rest)
  10105. else
  10106. SourceValue=GetRexxVarValueOrDie(ResultVar)
  10107. if OptionDebugOn='Y' then
  10108. call DebugLine_REXXVAR 'Evaluating: ' || SourceValue || ' ' || FastOperator || ' ' ||AfterOperator
  10109. select
  10110. when FastOperator='+' then
  10111. ResultValue=SourceValue+AfterOperator
  10112. when FastOperator='-' then
  10113. ResultValue=SourceValue-AfterOperator
  10114. when FastOperator='||' then
  10115. ResultValue=SourceValue||AfterOperator
  10116. when FastOperator='*' then
  10117. ResultValue=SourceValue*AfterOperator
  10118. when FastOperator='/' then
  10119. ResultValue=SourceValue/AfterOperator
  10120. when FastOperator='//' then
  10121. ResultValue=SourceValue//AfterOperator
  10122. when FastOperator='%' then
  10123. ResultValue=SourceValue%AfterOperator
  10124. otherwise
  10125. CryAndDie("Unsupported operator of '" || FastOperator || "' used on " ||HashCmd)
  10126. end
  10127. end
  10128. end
  10129. call _valueS ResultVar,ResultValue
  10130. if OptionDebugOn='Y' then
  10131. do
  10132. call DebugIncrement 1
  10133. if XVarName='' then
  10134. DbgPrefix=ResultVar
  10135. else
  10136. DbgPrefix='"X" Variable ' ||XVarName
  10137. call DebugLine_REXXVAR DbgPrefix|| ' = ' ||DebugRightArrow||ResultValue||DebugLeftArrow
  10138. call DebugIncrement-1
  10139. end
  10140. return(0)
  10141.  
  10142. GetSimpleRexxValue:
  10143. sParm=strip(arg(1), 'L')
  10144. sRestVar=arg(2)
  10145. sQuote=left(sParm,1)
  10146. if sQuote="'" | sQuote = '"' then
  10147. do
  10148. sEndPos=pos(sQuote,sParm,2)
  10149. if sEndPos=0 then
  10150. CryAndDie('Incorrectly quoted rexx literal (could not find ending quote)')
  10151. sValue=substr(sParm,2,sEndPos-2)
  10152. sRest=substr(sParm,sEndPos+1)
  10153. end
  10154. else
  10155. do
  10156. parse var sParm sValue sRest
  10157. if datatype(sValue, 'Number')=0 then
  10158. sValue=GetRexxVarValueOrDie(sValue)
  10159. end
  10160. if sRestVar<> '' then
  10161. call _valueS sRestVar,sRest
  10162. else
  10163. do
  10164. if sRestVar<> '' then
  10165. CryAndDie('Extra unexpected parameters of "' || sRestVar || '" found')
  10166. end
  10167. return(sValue)
  10168.  
  10169. _StackPush:
  10170. StackCnt=StackCnt+1
  10171. Stack.StackCnt.StackData=arg(1)
  10172. Stack.StackCnt.StackPosn=CurrentSourceLocation()
  10173. if OptionDebugOn='Y' then
  10174. call DebugLine_REXXVAR 'Stack Push(#' || StackCnt || ') = ' ||DebugRightArrow||arg(1)||DebugLeftArrow
  10175. return
  10176.  
  10177. _StackPop:
  10178. if StackCnt<=0 then
  10179. CryAndDie('There is nothing on the stack!')
  10180. spData=Stack.StackCnt.StackData
  10181. if OptionDebugOn='Y' then
  10182. do
  10183. call DebugLine_REXXVAR 'Stack pop(#' || StackCnt || ') = ' ||DebugRightArrow||spData||DebugLeftArrow
  10184. call DebugLine_REXXVAR 'matched push() at ' ||Stack.StackCnt.StackPosn
  10185. end
  10186. StackCnt=StackCnt-1
  10187. return(spData)
  10188.  
  10189. MatchesStackPushDebugText:
  10190. MatchIndex=arg(1)
  10191. if MatchIndex<=0 then
  10192. return('')
  10193. else
  10194. return(' (matches "#RexxVar PUSH" at ' || Stack.MatchIndex.StackPosn || ')')
  10195.  
  10196. _EnsureVersionY2KSafe:
  10197. TheVer=ReplaceString(arg(1), '2K', '00')
  10198. if datatype(TheVer, 'Number')=0|(length(TheVer)<>6&length(TheVer)<>8)then
  10199. CryAndDie('The version number "' || TheVer || '" is not valid')
  10200. if TheVer<100 then
  10201. do
  10202. if TheVer>98 then
  10203. TheVer='19' ||TheVer
  10204. else
  10205. TheVer='20' ||TheVer
  10206. end
  10207. return(TheVer)
  10208.  
  10209. ProcessRequire:
  10210. MinimumVersion=GetQuotedText(PerformReplacementsInCmdsParameters(arg(1)))
  10211. MinimumVersionY2k=_EnsureVersionY2KSafe(MinimumVersion)
  10212. ThisVersionY2k=_EnsureVersionY2KSafe(PgmVersion)
  10213. if OptionDebugOn='Y' then
  10214. do
  10215. call DebugLine 'You require "' || MinimumVersionY2k || '"'
  10216. call DebugLine 'You have    "' || ThisVersionY2k || '"'
  10217. end
  10218. if ThisVersionY2k<MinimumVersionY2k then
  10219. CryAndDie('You required at least PPWIZARD version "' || MinimumVersion || '", you are using version "' || PgmVersion || '"')
  10220. return(0)
  10221.  
  10222. RexxCtrlC:
  10223. LineCtrlC=SIGL
  10224. TRACE OFF
  10225. call Line1 ''
  10226. call Line1 HighlightColor||copies('=+',39)||ErrorColor
  10227. call CgiStartFatalError
  10228. call Line1 "Come on, you pressed Ctrl+C or Break didn't you!"
  10229. call CgiEndFatalError
  10230. call Line1 HighlightColor||copies('=+',39)||Reset
  10231. AbnormalExit(LineCtrlC, "CTRL+C Pressed")
  10232.  
  10233. QuickSourceLine:
  10234. LineNum=arg(1)
  10235. slKey='PPWSL!.' ||LineNum
  10236. if symbol(slKey)='VAR' then
  10237. return(_valueG(slKey))
  10238. SrcLine=sourceline(LineNum)
  10239. call _valueS slKey,SrcLine
  10240. return(SrcLine)
  10241.  
  10242. _FindLastLabel:
  10243. FailedOnLine=arg(1)
  10244. TryLine=FailedOnLine
  10245. do while TryLine>1
  10246. TryLine=TryLine-1
  10247. TheLine=QuickSourceLine(TryLine)
  10248. ColonPos=pos(':',TheLine)
  10249. if ColonPos<>0 then
  10250. do
  10251. MaybeLabel=strip(left(TheLine,ColonPos-1))
  10252. if symbol(MaybeLabel)<> 'BAD' then
  10253. do
  10254. FoundLabelOnLine=TryLine
  10255. return(MaybeLabel|| ':  (line #' || AddCommasToDecimalNumber(TryLine) || ')')
  10256. end
  10257. end
  10258. end
  10259. FoundLabelOnLine=0
  10260. return('')
  10261.  
  10262. CommonTrapHandler:
  10263. signal on NOVALUE name SimpleRexxTrapUninitializedVariable
  10264. signal on SYNTAX name SimpleRexxTrapSyntaxError
  10265. FailingLine=arg(1)
  10266. TrapHeading=arg(2)
  10267. TextDescription=arg(3)
  10268. Text=arg(4)
  10269. CmdBeingEvaluated=arg(5)
  10270. UserBreakPoint=arg(6)
  10271. HaveCapturedTrapDetails='Y'
  10272. call Line1 ''
  10273. call Line1 HighlightColor||copies('=+',39)||ErrorColor
  10274. call CgiStartFatalError
  10275. call Line1 TrapHeading
  10276. call Line1 copies('~',length(TrapHeading))
  10277. call Line1 substr(TextDescription,1,16)|| ': ' ||Text
  10278. BetterErrorText=Condition('D')
  10279. if BetterErrorText<> '' &BetterErrorText<>Text then
  10280. call Line1 copies(' ',18)||BetterErrorText
  10281. if IncludeLevel<>0 then
  10282. do
  10283. call Line1 'Processing locn : ' ||CurrentSourceLocation()
  10284. LastFileLine=strip(LastFileLine)
  10285. LastLine=strip(LastLine)
  10286. call Line1 'Line from file  : ' ||LastFileLine
  10287. if LastLine<>LastFileLine then
  10288. call Line1 'Failing line    : ' ||LastLine
  10289. if LastLineAfterMacroRep<> '' &LastLine<>LastLineAfterMacroRep&LastFileLine<>LastLineAfterMacroRep then
  10290. call Line1 'After Replace   : ' ||LastLineAfterMacroRep
  10291. if MacroBeingExpanded<> '' then
  10292. call Line1 'Expanding Macro : ' || StartsMacroReplacement || MacroBeingExpanded || ' ...' ||EndsMacroReplacement
  10293. end
  10294. if CmdBeingEvaluated<> '' then
  10295. call Line1 'Evaluating This : ' ||CmdBeingEvaluated
  10296. if RexWhich='REGINA' then
  10297. ReginaUname=' (' || uname() || ')'
  10298. else
  10299. ReginaUname=''
  10300. FailingLineText=AddCommasToDecimalNumber(FailingLine)
  10301. call Line1 'Operating System: ' ||RexSystemOpSys||ReginaUname
  10302. call Line1 'Rexx Version    : ' ||RexVersionInfo
  10303. if CmdBeingEvaluated='' then
  10304. DumpSource='Y'
  10305. else
  10306. do
  10307. DumpSource='N'
  10308. call DumpVarsInExpression CmdBeingEvaluated,, 'KNOWN VARIABLES', 'Line1'
  10309. end
  10310. if DumpSource='Y' then
  10311. do
  10312. call Line1 'Failing Module  : ' || PpWizardPgmName || ' (' || PgmVersion || ')'
  10313. call Line1 'Failing Line #  : ' ||FailingLineText
  10314. InRoutine=_FindLastLabel(FailingLine)
  10315. StartAt=FailingLine-7
  10316. if FoundLabelOnLine<>0 then
  10317. do
  10318. if FoundLabelOnLine>StartAt then
  10319. StartAt=FoundLabelOnLine
  10320. else
  10321. do
  10322. if FoundLabelOnLine<>0 then
  10323. do
  10324. if(FailingLine-FoundLabelOnLine)<10 then
  10325. StartAt=FoundLabelOnLine
  10326. else
  10327. call Line1 'After label     : ' ||InRoutine
  10328. end
  10329. end
  10330. end
  10331. call Line1 'SOURCE'
  10332. call Line1 '~~~~~~'
  10333. vlist.0=0
  10334. do ShowLine=StartAt to FailingLine
  10335. FailingSrcLineTxt=strip(QuickSourceLine(ShowLine))
  10336. call Line1 left(AddCommasToDecimalNumber(ShowLine),length(FailingLineText))|| ' : ' ||FailingSrcLineTxt
  10337. call DumpVarsInExpression FailingSrcLineTxt, 'vlist'
  10338. end
  10339. call DumpVarsInExpressionNow 'vlist', 'KNOWN VARIABLES', 'Line1'
  10340. end
  10341. HookText=TrapHeading|| ' at line ' || FailingLineText || '. ' || TextDescription || ': ' ||Text
  10342. call CgiEndFatalError
  10343. call Line1 HighlightColor||copies('=+',39)||Reset
  10344. call Line1 ''
  10345. if UserBreakPoint<> '' then
  10346. do
  10347. call RexxTrace HookText,,,'Y'
  10348. end
  10349. AbnormalExit(FailingLine,HookText)
  10350.  
  10351. RexxTrapUninitializedVariable:
  10352. TrappingLine=SIGL
  10353. call CommonTrapHandler TrappingLine, 'NoValue Abort!', 'Unknown Variable', condition('D')
  10354.  
  10355. RexxTrapSyntaxError:
  10356. TrappingLine=SIGL
  10357. call CommonTrapHandler TrappingLine, 'Syntax Error!', 'Reason',errortext(Rc)
  10358.  
  10359. SimpleCommonTrapHandler:
  10360. if HaveCapturedTrapDetails='N' then
  10361. do
  10362. FailingLine=arg(1)
  10363. TrapHeading=arg(2)
  10364. TextDescription=arg(3)
  10365. Text=arg(4)
  10366. end
  10367. FailingLineText=AddCommasToDecimalNumber(FailingLine)
  10368. say ''
  10369. say copies('*-',39)
  10370. say TrapHeading
  10371. say copies('~',length(TrapHeading))
  10372. if HaveCapturedTrapDetails='Y' then
  10373. say 'Trap within Trap: Original trap details saved and displayed below!'
  10374. say substr(TextDescription,1,16)|| ': ' ||Text
  10375. BetterErrorText=Condition('D')
  10376. if BetterErrorText<> '' &BetterErrorText<>Text then
  10377. call Line1 copies(' ',18)||BetterErrorText
  10378. parse source . . PpWizardPgmName
  10379. parse version VersionOfRexx
  10380. FailingSrcLineTxt=strip(QuickSourceLine(FailingLine))
  10381. say 'Failed at       : ' || PpWizardPgmName || ' (line ' || FailingLineText || ', version ' || PgmVersion || ')'
  10382. say 'Source Code     : ' ||FailingSrcLineTxt
  10383. say 'Rexx Version    : ' ||VersionOfRexx
  10384. call DumpVarsInExpression FailingSrcLineTxt, '', 'KNOWN VARIABLES'
  10385. HookText=TrapHeading|| ' at line ' || FailingLineText || '. ' || TextDescription || ': ' ||Text
  10386. if HaveCapturedTrapDetails='Y' then
  10387. do
  10388. FailingLine=arg(1)
  10389. TrapHeading=arg(2)
  10390. TextDescription=arg(3)
  10391. Text=arg(4)
  10392. say ''
  10393. say 'Reason for secondary trap'
  10394. say '~~~~~~~~~~~~~~~~~~~~~~~~~'
  10395. say substr(TextDescription,1,16)|| ': ' ||Text
  10396. say 'Failed at       : ' || PpWizardPgmName || ' (line ' || FailingLineText || ', version ' || PgmVersion || ')'
  10397. say 'Source Code     : ' ||strip(QuickSourceLine(FailingLine))
  10398. end
  10399. say copies('*-',39)
  10400. call CallErrorHookForSimpleOneLiner HookText
  10401. exit(FailingLine)
  10402.  
  10403. SimpleRexxTrapUninitializedVariable:
  10404. TrappingLine=SIGL
  10405. call SimpleCommonTrapHandler TrappingLine, 'NoValue Abort!', 'Unknown Variable', condition('D')
  10406.  
  10407. SimpleRexxTrapSyntaxError:
  10408. TrappingLine=SIGL
  10409. call SimpleCommonTrapHandler TrappingLine, 'Syntax Error!', 'Reason',errortext(Rc)
  10410.