home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ppwi2284.zip / ppwizard.cmd < prev    next >
OS/2 REXX Batch file  |  2002-10-10  |  416KB  |  16,393 lines

  1. /**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+
  2. * Generator   : PPWIZARD version 02.268
  3. *             : FREE tool for Windows, OS/2, DOS and UNIX by Dennis Bareis (dbareis@labyrinth.net.au)
  4. *             : http://www.labyrinth.net.au/~dbareis/ppwizard.htm
  5. * Time        : Friday, 11 Oct 2002 11:06:34am
  6. * Input File  : C:\DBAREIS\Projects\MultiOs\PPWIZARD\ppwizard.x
  7. * Output File : C:\DBAREIS\Projects\MultiOs\PPWIZARD\out\ppwizard.rex
  8. *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*/
  9.  
  10. if arg(1)="!CheckSyntax!" then exit(21924)
  11.  
  12. PgmVersion="02.284"
  13. SupportedReginaVersions='2.0, 2.2, 3.0, 3.0.1 or 3.0BETA2'
  14. RecommendedReginaVersions='3.0.1'
  15. TrapHandler=''
  16. RedirMethod=''
  17. call ConsoleWriteAllowed 'Y'
  18. call InitScreenHandling2Off
  19. call InitCommandLineOptions arg(1)
  20. call InitConsoleOutputVarsPass1
  21. PpwDoing='Initializing'
  22. Dummy=time('Reset')
  23. b2rNewSingleQuote="' || " || '"' || "'" || '" || ' || "'"
  24. b2rAllHexCodes=''
  25. b2rAllAsciiCodes=''
  26. do b2rCharCode=0 to 31
  27. b2rAllHexCodes=b2rAllHexCodes||d2c(b2rCharCode)
  28. end
  29. do b2rCharCode=32 to 126
  30. b2rAllAsciiCodes=b2rAllAsciiCodes||d2c(b2rCharCode)
  31. end
  32. do b2rCharCode=127 to 255
  33. b2rAllHexCodes=b2rAllHexCodes||d2c(b2rCharCode)
  34. end
  35. signal EndBIN2REXPXh
  36.  
  37. _QuoteAscii:
  38. b2rAscii2Quote=arg(1)
  39. if pos("'",b2rAscii2Quote)=0 then
  40. return("'" || b2rAscii2Quote || "'")
  41. else
  42. do
  43. if pos('"',b2rAscii2Quote)=0 then
  44. return('"' || b2rAscii2Quote || '"')
  45. else
  46. do
  47. return("'" || ReplaceString(b2rAscii2Quote, "'", b2rNewSingleQuote) || "'")
  48. end
  49. end
  50.  
  51. _FormatHex:
  52. b2rHexString=arg(1)
  53. b2rLengthHex=length(b2rHexString)
  54. b2rFormattedHex="'"
  55. if b2rLengthHex>7 then
  56. do
  57. b2rLeft1=left(b2rHexString,1)
  58. b2rLeft1Pos=verify(b2rHexString,b2rLeft1)
  59. if b2rLeft1Pos=0 then
  60. return( "copies('" || c2x(b2rLeft1) || "'x, " || b2rLengthHex || ")" )
  61. else
  62. do
  63. if b2rLeft1Pos>7 then
  64. do
  65. b2rFormattedHex="copies('" || c2x(b2rLeft1) || "'x, " || b2rLeft1Pos-1 || ") || '"
  66. b2rHexString=substr(b2rHexString,b2rLeft1Pos)
  67. b2rLengthHex=b2rLengthHex-(b2rLeft1Pos-1)
  68. end
  69. end
  70. end
  71. do b2rCharPosn=1 to b2rLengthHex
  72. if(b2rCharPosn//8)=1 then
  73. do
  74. if b2rCharPosn<>1 then
  75. b2rFormattedHex=b2rFormattedHex|| ' '
  76. end
  77. b2rFormattedHex=b2rFormattedHex||c2x(substr(b2rHexString,b2rCharPosn,1))
  78. end
  79. b2rFormattedHex=b2rFormattedHex|| "'x"
  80. return(b2rFormattedHex)
  81.  
  82. _QuoteAsciiBreakIfRequired:
  83. qabAscii=arg(1)
  84. qabLength=length(qabAscii)
  85. qabReturn=''
  86. do while qabLength>256
  87. qabLeft=left(qabAscii,256)
  88. qabAscii=substr(qabAscii,256+1)
  89. qabLength=qabLength-256
  90. if qabReturn='' then
  91. qabReturn=_QuoteAscii(qabLeft)
  92. else
  93. qabReturn=qabReturn|| " || " ||_QuoteAscii(qabLeft)
  94. end
  95. if qabLength=0 then
  96. return(qabReturn)
  97. else
  98. do
  99. if qabReturn='' then
  100. return(_QuoteAscii(qabAscii))
  101. else
  102. return(qabReturn|| " || " ||_QuoteAscii(qabAscii))
  103. end
  104.  
  105. _FormatHexBreakIfRequired:
  106. fhbHex=arg(1)
  107. fhbLength=length(fhbHex)
  108. fhbReturn=''
  109. do while fhbLength>80
  110. fhbLeft=left(fhbHex,80)
  111. fhbHex=substr(fhbHex,80+1)
  112. fhbLength=fhbLength-80
  113. if fhbReturn='' then
  114. fhbReturn=_FormatHex(fhbLeft)
  115. else
  116. fhbReturn=fhbReturn|| " || " ||_FormatHex(fhbLeft)
  117. end
  118. if fhbLength=0 then
  119. return(fhbReturn)
  120. else
  121. do
  122. if fhbReturn='' then
  123. return(_FormatHex(fhbHex))
  124. else
  125. return(fhbReturn|| " || " ||_FormatHex(fhbHex))
  126. end
  127.  
  128. BIN2REXP:
  129. call BIN2REXP_START
  130. b2rValue=arg(1)
  131. b2rValueLength=length(b2rValue)
  132. if b2rValueLength=0 then
  133. call BIN2REXP_ONEBIT '""'
  134. else
  135. do
  136. do while b2rValue\==''
  137. b2rEndAsciiPos=verify(b2rValue,b2rAllAsciiCodes)
  138. if b2rEndAsciiPos=0 then
  139. do
  140. call BIN2REXP_ONEBIT _QuoteAsciiBreakIfRequired(b2rValue)
  141. b2rValue=''
  142. end
  143. else
  144. do
  145. if b2rEndAsciiPos<>1 then
  146. do
  147. call BIN2REXP_ONEBIT _QuoteAsciiBreakIfRequired(left(b2rValue,b2rEndAsciiPos-1))
  148. b2rValue=substr(b2rValue,b2rEndAsciiPos)
  149. end
  150. else
  151. do
  152. b2rEndBinaryPos=verify(b2rValue,b2rAllHexCodes)
  153. if b2rEndBinaryPos=0 then
  154. do
  155. call BIN2REXP_ONEBIT _FormatHexBreakIfRequired(b2rValue)
  156. b2rValue=''
  157. end
  158. else
  159. do
  160. call BIN2REXP_ONEBIT _FormatHexBreakIfRequired(left(b2rValue,b2rEndBinaryPos-1))
  161. b2rValue=substr(b2rValue,b2rEndBinaryPos)
  162. end
  163. end
  164. end
  165. end
  166. end
  167. call BIN2REXP_END
  168. return
  169.  
  170. EndBIN2REXPXh:
  171. signal EndDUMPVARXh
  172.  
  173. DumpVarsInExpression:
  174. dv_RexxExp=arg(1)
  175. dv_Stem=translate(arg(2))
  176. dv_VarHeading=arg(3)
  177. dv_LineRoutine=arg(4)
  178. if dv_Stem<> '' then
  179. do
  180. dv_AutoDump='N'
  181. dv_StemDot=dv_Stem|| '.'
  182. if symbol(dv_StemDot|| '0') = 'VAR' then
  183. dv_VarCount=value(dv_StemDot|| '0')
  184. else
  185. do
  186. call _DumpVarsLineOutput 'DumpVar: Could not find "' || dv_StemDot || '0' || '"'
  187. return(0)
  188. end
  189. end
  190. else
  191. do
  192. dv_AutoDump='Y'
  193. dv_Stem='DV_VARLIST'
  194. dv_StemDot=dv_Stem|| '.'
  195. dv_VarCount=0
  196. end
  197. if dv_VarCount=0 then
  198. dv_MaxVarLng=0
  199. do while dv_RexxExp<> ''
  200. parse value strip(dv_RexxExp, 'L')with dv_1stChar+1 dv_RexxExp
  201. select
  202. when datatype(dv_1stChar, 'S')then
  203. do
  204. dv_OneVar=dv_1stChar
  205. do while dv_RexxExp<> ''
  206. parse var dv_RexxExp dv_1stChar+1 dv_RexxExp
  207. if datatype(dv_1stChar, 'S')then
  208. dv_OneVar=dv_OneVar||dv_1stChar
  209. else
  210. do
  211. dv_RexxExp=dv_1stChar||dv_RexxExp
  212. leave
  213. end
  214. end
  215. call _RememberDumpedVar dv_OneVar
  216. if pos('.',dv_OneVar)<>0 then
  217. do
  218. do while dv_OneVar<> ''
  219. parse var dv_OneVar dv_ThisBit '.' dv_OneVar
  220. call _RememberDumpedVar dv_ThisBit
  221. end
  222. end
  223. end
  224. when dv_1stChar='"' | dv_1stChar = "'" then
  225. do
  226. dv_EndQuotePos=pos(dv_1stChar,dv_RexxExp)
  227. if dv_EndQuotePos=0 then
  228. dv_RexxExp=''
  229. else
  230. dv_RexxExp=substr(dv_RexxExp,dv_EndQuotePos+1)
  231. end
  232. otherwise
  233. nop
  234. end
  235. end
  236. call value dv_StemDot|| '0',dv_VarCount
  237. if dv_AutoDump='Y' then
  238. call DumpVarsInExpressionNow dv_Stem,dv_VarHeading,dv_LineRoutine
  239. return(dv_VarCount)
  240.  
  241. DumpVarsInExpressionNow:
  242. dv_StemDot=arg(1)|| '.'
  243. dv_VarHeading=arg(2)
  244. dv_LineRoutine=arg(3)
  245. if symbol(dv_StemDot|| '0') = 'VAR' then
  246. dv_VarCount=value(dv_StemDot|| '0')
  247. else
  248. do
  249. call _DumpVarsLineOutput 'DumpVar: could not find "' || dv_StemDot || '0' || '"'
  250. return(0)
  251. end
  252. if dv_VarCount<>0&dv_VarHeading<> '' then
  253. do
  254. call _DumpVarsLineOutput ''
  255. call _DumpVarsLineOutput dv_VarHeading
  256. call _DumpVarsLineOutput copies('~',length(dv_VarHeading))
  257. end
  258. dv_ShowVarLng=dv_MaxVarLng
  259. if dv_MaxVarLng>30 then
  260. dv_ShowVarLng=30
  261. do dv_Index=1 to dv_VarCount
  262. dv_OneVar=value(dv_StemDot||dv_Index)
  263. if length(dv_OneVar)>=dv_ShowVarLng then
  264. ShowVar=dv_OneVar
  265. else
  266. ShowVar=right(dv_OneVar,dv_ShowVarLng)
  267. dv_OneVarValue=value(translate(dv_OneVar))
  268. if datatype(dv_OneVarValue, 'N')=0 then
  269. do
  270. call BIN2REXP dv_OneVarValue
  271. dv_OneVarValue=dv_Value
  272. end
  273. call _DumpVarsLineOutput ShowVar|| ' = ' ||dv_OneVarValue
  274. end
  275. return
  276.  
  277. _RememberDumpedVar:
  278. dv_ThisVar=arg(1)
  279. if symbol(dv_ThisVar)='VAR' then
  280. do
  281. dv_AlreadyHave='N'
  282. dv_ThisVarUpper=translate(dv_ThisVar)
  283. do dv_Index=1 to dv_VarCount
  284. if dv_ThisVarUpper=translate(value(dv_StemDot||dv_Index))then
  285. do
  286. dv_AlreadyHave='Y'
  287. leave
  288. end
  289. end
  290. if dv_AlreadyHave='N' then
  291. do
  292. dv_VarCount=dv_VarCount+1
  293. call value dv_StemDot||dv_VarCount,dv_ThisVar
  294. if length(dv_ThisVar)>dv_MaxVarLng then
  295. dv_MaxVarLng=length(dv_ThisVar)
  296. end
  297. end
  298. return
  299.  
  300. _DumpVarsLineOutput:
  301. if dv_LineRoutine='' then
  302. call say arg(1)
  303. else
  304. interpret 'call ' || dv_LineRoutine || ' arg(1)'
  305. return
  306.  
  307. BIN2REXP_START:
  308. dv_Value=''
  309. return
  310.  
  311. BIN2REXP_ONEBIT:
  312. if dv_Value<> '' then
  313. dv_Value=dv_Value|| ' || '
  314. dv_Value=dv_Value||arg(1)
  315. return
  316.  
  317. BIN2REXP_END:
  318. return
  319.  
  320. EndDUMPVARXh:
  321. HaveCapturedTrapDetails='N'
  322. MacroBeingExpanded=''
  323. LastLineAfterMacroRep=''
  324. LastFileLine=''
  325. LastLine=''
  326. ErrorHookCount=0
  327. call RexxHookInit
  328. signal on NOVALUE name SimpleRexxTrapUninitializedVariable
  329. signal on SYNTAX name SimpleRexxTrapSyntaxError
  330. TrapHandler='SIMPLE'
  331. MyBaseHomeDir="http://www.labyrinth.net.au/~dbareis/"
  332. PgmHomePage=MyBaseHomeDir|| "ppwizard.htm"
  333. PgmAuthorHomePage=MyBaseHomeDir|| "index.htm"
  334. PgmAuthor="Dennis Bareis"
  335. PgmAuthorEmail="dbareis@labyrinth.net.au"
  336. ExpressionKilledUs=''
  337. SyntaxOkRc=21924
  338. SyntaxOkText='!CheckSyntax!'
  339. CopyrightDisplayed='N'
  340. CurrentOutFile=''
  341. CurrentOutLine=0
  342. OutSyntaxMsg=''
  343. OutSyntaxCmd=''
  344. OutSyntaxRc=''
  345. OutSyntaxCode=''
  346. OutSyntaxErrLineMask=''
  347. IncludeLevel=0
  348. Warnings=0
  349. LineSourceBeingProcessed='?'
  350. OnExitSleepForOk=0
  351. OnExitSleepForError=2
  352. SleepSwitch='N'
  353. if translate(strip(arg(1)))='DEBUG' then
  354. call DisplayCopyright
  355. /*
  356. *REXSYSTM.XH Version 02.249 By Dennis Bareis
  357. *http://www.labyrinth.net.au/~dbareis/index.htm(db0@anz.com)
  358. */
  359. trace off
  360. RexSystmRexxPgmName='?'
  361. if '1' == 'F1'x then
  362. RexIsAscii='N'
  363. else
  364. RexIsAscii='Y'
  365. parse version RexVersionInfo
  366. if pos('REGINA',translate(RexVersionInfo))<>0 then
  367. do
  368. RexWhich='REGINA'
  369. parse value translate(RexVersionInfo)with . 'REGINA_' RexVerRegina ' '
  370. RexVerRegina=translate(RexVerRegina, '.', '_')
  371. end
  372. else
  373. do
  374. RexVerRegina=''
  375. if pos('REXX370',translate(RexVersionInfo))<>0 then
  376. do
  377. RexWhich='REXX370'
  378. end
  379. else
  380. do
  381. RexWhich='STANDARD_OS/2'
  382. end
  383. end
  384. parse source RexSystemOpSys .
  385. RexSystemOpSysREAL=RexSystemOpSys
  386. if RexWhich='REGINA' then
  387. do
  388. if RexSystemOpSys="WIN32" then
  389. parse value uname()with RexSystemOpSysREAL .
  390. if RexSystemOpSys="UNIX" then
  391. parse value uname()with RexSystemOpSysREAL .
  392. end
  393. if RexSystemOpSys="BEOS" then
  394. RexSystemOpSys="UNIX"
  395. if RexSystemOpSys="TSO" then
  396. do
  397. call syscalls 'ON'
  398. RexSystemOpSys="UNIX"
  399. end
  400. RexSystmRexxPgmName=RexGetFullSourceName()
  401. if RexIsAscii='N' then
  402. do
  403. RexEOL='15'x
  404. end
  405. else
  406. do
  407. if RexSystemOpSys="UNIX" then
  408. RexEOL='0A'x
  409. else
  410. RexEOL='0D0A'x
  411. end
  412. if arg(2)<> '' then
  413. call RexSystemFailure 'ARG(2) contains unexpected data of ' || arg(2) || '.'
  414. if translate(strip(arg(1)))='DEBUG' then
  415. do
  416. call RexDumpSystemInfo
  417. exit(0)
  418. end
  419. if RexWhich='STANDARD_OS/2' then
  420. do
  421. call RxFuncAdd 'SysSleep',        'RexxUtil', 'SysSleep'
  422. call RxFuncAdd 'SysFileDelete',   'RexxUtil', 'SysFileDelete'
  423. call RxFuncAdd 'SysSearchPath',   'RexxUtil', 'SysSearchPath'
  424. call RxFuncAdd 'SysFileTree',     'RexxUtil', 'SysFileTree'
  425. call RxFuncAdd 'SysTempFileName', 'RexxUtil', 'SysTempFileName'
  426. call SetLocal
  427. RexEnvVarPool='OS2ENVIRONMENT'
  428. RexStdoutStream='STDOUT'
  429. RexStderrStream='STDERR'
  430. RexTmpFileCntr=random(90000)
  431. end
  432. else
  433. do
  434. OPTIONS 'NOEXT_COMMANDS_AS_FUNCS'
  435. numeric digits 11
  436. RexEnvVarPool='SYSTEM'
  437. RexStdoutStream='<stdout>'
  438. RexStderrStream='<stderr>'
  439. end
  440. if RexSystemOpSys<> "UNIX" then
  441. do
  442. RexDirChar='\'
  443. RexOptionChar='/'
  444. end
  445. else
  446. do
  447. RexDirChar='/'
  448. RexOptionChar='-'
  449. end
  450. signal REXSYSTM_1
  451.  
  452. RexDumpSystemInfo:
  453. say 'Program Name  : ' ||RexSystmRexxPgmName
  454. say 'Op System     : ' ||RexSystemOpSys
  455. say 'Rexx Ver      : ' ||RexVersionInfo
  456. say 'Which System  : ' ||RexWhich
  457. if RexWhich='REGINA' then
  458. say 'regina uname(): ' ||uname()
  459. return
  460.  
  461. RexNeedReginaWorkAround:
  462. if RexWhich='STANDARD_OS/2' then
  463. return('N')
  464. else
  465. return('Y')
  466.  
  467. RexGetFullSourceName:
  468. parse source . . TmpRexxSrc
  469. if RexWhich='REGINA' then
  470. TmpRexxSrc=_FileQueryExists(strip(TmpRexxSrc))
  471. if RexSystemOpSysREAL="TSO" then
  472. do
  473. TmpRexxSrc=word(TmpRexxSrc,1)
  474. TmpRexxSrc=_FileQueryExists(TmpRexxSrc)
  475. end
  476. if TmpRexxSrc='' then
  477. call RexSystemFailure 'Could not determine the name of the rexx program!'
  478. return(TmpRexxSrc)
  479.  
  480. RexGetNameOfTmpDir:call TRACE "OFF"
  481. TmpDir=strip(GetEnv('TMP'))
  482. if TmpDir='' then
  483. TmpDir=strip(GetEnv('TEMP'))
  484. if TmpDir='' then
  485. do
  486. if RexSystemOpSys="UNIX" then
  487. TmpDir='/tmp'
  488. end
  489. if right(TmpDir,1)==RexDirChar then
  490. TmpDir=left(TmpDir,length(TmpDir)-1)
  491. if RexWhich='REXX370' then
  492. do
  493. if TmpDir="SYSTEM" then
  494. TmpDir="TMP"
  495. end
  496. return(TmpDir)
  497.  
  498. RedirectStdOutAndErr2:
  499. if RedirMethod<> '' then
  500. do
  501. select
  502. when RedirMethod="@bash" then
  503. return(' > "' || arg(1) || '" 2>&1')
  504. when RedirMethod="@csh" then
  505. return(' >& "' || arg(1) || '"')
  506. otherwise
  507. do
  508. r12Meth=RedirMethod
  509. r12Pos=pos('{?}',r12Meth)
  510. do while r12Pos<>0
  511. r12Meth=left(r12Meth,r12Pos-1)||arg(1)||substr(r12Meth,r12Pos+3)
  512. r12Pos=pos('{?}',r12Meth)
  513. end
  514. end
  515. end
  516. return(' ' ||r12Meth)
  517. end
  518. if RexSystemOpSys="DOS" | RexSystemOpSysREAL = "WIN95" | RexSystemOpSysREAL = "WIN98" | RexSystemOpSysREAL = "WINME" then
  519. do
  520. return(' >' ||arg(1))
  521. end
  522. else
  523. do
  524. return(' > "' || arg(1) || '" 2>&1')
  525. end
  526.  
  527. NameOfNulDevice:
  528. if RexSystemOpSys="UNIX" then
  529. return('/dev/null')
  530. else
  531. return('nul')
  532.  
  533. AllCmdOutput2Nul:
  534. return(RedirectStdOutAndErr2(NameOfNulDevice()))
  535.  
  536. AddressCmd:call TRACE "OFF"
  537. SysCmd2Exec=arg(1)
  538. if RexWhich='STANDARD_OS/2' then
  539. SysCmd2Exec='@' ||SysCmd2Exec
  540. call DebugAddressCmdBefore SysCmd2Exec
  541. SysCmd2Exec
  542. SysCmdRc=Rc
  543. FileIndex=2
  544. SysCmdFile=arg(FileIndex)
  545. do while SysCmdFile<> ''
  546. call DebugAddressCmdOutput SysCmdFile, 'H1'
  547. call DebugAddressCmdOutput copies('~', length(SysCmdFile)), 'H2'
  548. if _FileQueryExists(SysCmdFile)='' then
  549. call DebugAddressCmdOutput '*File does not exist*',     '!'
  550. else
  551. do
  552. SysCmdLine=0
  553. call _FileClose SysCmdFile
  554. do while lines(SysCmdFile)<>0
  555. SysCmdLine=SysCmdLine+1
  556. call DebugAddressCmdOutput linein(SysCmdFile),SysCmdLine
  557. end
  558. call _FileClose SysCmdFile
  559. end
  560. FileIndex=FileIndex+1
  561. SysCmdFile=arg(FileIndex)
  562. end
  563. call DebugAddressCmdAfter SysCmdRc
  564. Rc=SysCmdRc
  565. return(SysCmdRc)
  566.  
  567. _filespec:call TRACE "OFF"
  568. fsCmd=translate(arg(1))
  569. select
  570. when fsCmd='D' | fsCmd = 'DRIVE' then
  571. do
  572. if RexSystemOpSys="UNIX" then
  573. return('')
  574. fsPos=pos(':',arg(2))
  575. if fsPos=0 then
  576. return('')
  577. else
  578. return(left(arg(2),fsPos))
  579. end
  580. when fsCmd='P' | fsCmd = 'PATH' then
  581. do
  582. fsStartWith=substr(arg(2),length(_filespec('D',arg(2)))+1)
  583. fsPos=lastpos(RexDirChar,fsStartWith)
  584. if fsPos=0 then
  585. return('')
  586. else
  587. return(left(fsStartWith,fsPos))
  588. end
  589. when fsCmd='N' | fsCmd = 'NAME' then
  590. do
  591. return(substr(arg(2),length(_filespec('L',arg(2)))+1))
  592. end
  593. when fsCmd='L' | fsCmd = 'LOCATION' then
  594. do
  595. return(_filespec('D', arg(2)) || _filespec('P',arg(2)))
  596. end
  597. when fsCmd='S' | fsCmd = 'SLASHLESS' then
  598. do
  599. fsPos=_filespec('L',arg(2))
  600. if right(fsPos,1)=RexDirChar then
  601. fsPos=left(fsPos,length(fsPos)-1)
  602. return(fsPos)
  603. end
  604. when fsCmd='E' | fsCmd = 'EXTN' then
  605. do
  606. fsDotPos=lastpos('.',arg(2))
  607. if fsDotPos=0 then
  608. return('')
  609. else
  610. return(substr(arg(2),fsDotPos+1))
  611. end
  612. when fsCmd='W' | fsCmd = 'WITHOUTEXTN' then
  613. do
  614. fsDotPos=lastpos('.',arg(2))
  615. if fsDotPos=0 then
  616. return(arg(2))
  617. else
  618. return(left(arg(2),fsDotPos-1))
  619. end
  620. when fsCmd='B' | fsCmd = 'BASENAME' then
  621. do
  622. return(_filespec('W', _filespec('N',arg(2))))
  623. end
  624. otherwise
  625. call RexSystemFailure 'Unknown _filespec() command of "' || arg(1) || '"'
  626. end
  627. return
  628.  
  629. _SysSleep:call TRACE "OFF"
  630. if RexWhich='STANDARD_OS/2' then
  631. do
  632. call SysSleep arg(1)
  633. return
  634. end
  635. call sleep arg(1)
  636. return
  637.  
  638. _SysFileTree:call TRACE "OFF"
  639. a!Mask=arg(1)
  640. a!Stem=arg(2)
  641. if pos('D',arg(3))<>0 then
  642. a!Type='D'
  643. else
  644. a!Type='F'
  645. if RexWhich='STANDARD_OS/2' then
  646. do
  647. a!P3=a!Type|| 'O'
  648. if pos('S',arg(3))<>0 then
  649. a!P3=a!P3|| 'S'
  650. return(SysFileTree(a!Mask,a!Stem,a!P3))
  651. end
  652. a!TmpFile=RexGetTmpFileName()
  653. if RexSystemOpSys<> "UNIX" then
  654. do
  655. a!Cmd='dir /B '
  656. if pos('S',arg(3))<>0 then
  657. a!Cmd=a!Cmd|| "/S "
  658. if a!Type='F' then
  659. a!Cmd=a!Cmd|| "/A-D "
  660. else
  661. a!Cmd=a!Cmd|| "/AD "
  662. if RexSystemOpSys="DOS" then
  663. a!CmdMask=a!Mask
  664. else
  665. a!CmdMask='"' || a!Mask || '"'
  666. a!Cmd=a!Cmd||a!CmdMask||RedirectStdOutAndErr2(a!TmpFile)
  667. end
  668. else
  669. do
  670. a!Cmd='find ' || _filespec('L', a!Mask) || ' '
  671. if RexSystemOpSysREAL<> "FREEBSD" & RexSystemOpSysREAL <> "Darwin" & RexSystemOpSysREAL <> "TSO" then
  672. a!Cmd=a!Cmd|| '-noleaf '
  673. if pos('S',arg(3))=0 then
  674. do
  675. if RexSystemOpSysREAL<> "FREEBSD" & RexSystemOpSysREAL <> "Darwin" & RexSystemOpSysREAL <> "TSO" then
  676. a!Cmd=a!Cmd|| '-maxdepth 1 '
  677. else
  678. a!Cmd=a!Cmd|| '-prune '
  679. end
  680. if a!Type='F' then
  681. a!Cmd=a!Cmd|| "-type f "
  682. else
  683. a!Cmd=a!Cmd|| "-type d "
  684. stfSName=_filespec('N',a!Mask)
  685. if stfSName<> '' then
  686. a!Cmd=a!Cmd|| '-name "' || stfSName || '"'
  687. a!Cmd=a!Cmd||RedirectStdOutAndErr2(a!TmpFile)
  688. end
  689. Rc=AddressCmd(a!Cmd,a!TmpFile)
  690. LastSlash=lastpos(RexDirChar,a!Mask)
  691. call _FileClose a!TmpFile
  692. a!FileCnt=0
  693. do while lines(a!TmpFile)<>0
  694. a!AFile=linein(a!TmpFile)
  695. if a!AFile='' | a!AFile = '.' | a!AFile = '..' then
  696. iterate
  697. if RexSystemOpSys="UNIX" & a!Type = 'D' then
  698. do
  699. if a!AFile=_filespec('L',a!Mask)then
  700. iterate
  701. end
  702. if LastSlash<>0 then
  703. do
  704. if pos(RexDirChar,a!AFile)==0 then
  705. a!AFile=left(a!Mask,LastSlash)||a!AFile
  706. end
  707. if a!Type='F' then
  708. do
  709. a!AFile=_FileQueryExists(a!AFile)
  710. if a!AFile='' then
  711. iterate
  712. end
  713. else
  714. do
  715. if RexWhich='REGINA' then
  716. do
  717. if DirQueryExists(a!AFile)='' then
  718. iterate
  719. end
  720. else
  721. do
  722. if pos(' ',a!AFile)<>0 then
  723. iterate
  724. end
  725. end
  726. a!FileCnt=a!FileCnt+1
  727. call _valueS a!Stem|| '.' ||a!FileCnt,strip(a!AFile)
  728. end
  729. call _FileClose a!TmpFile
  730. DeleteRc=_SysFileDelete(a!TmpFile)
  731. call _valueS a!Stem|| '.0',a!FileCnt
  732. return(0)
  733.  
  734. _SysFileDelete:call TRACE "OFF"
  735. if RexWhich='STANDARD_OS/2' then
  736. return(SysFileDelete(arg(1)))
  737. b!F=arg(1)
  738. if RexSystemOpSys<> "DOS" then
  739. b!F='"' || b!F || '"'
  740. if RexSystemOpSys="DOS" | RexSystemOpSysREAL = "WIN95" | RexSystemOpSysREAL = "WIN98" | RexSystemOpSysREAL = "WINME" then
  741. return(AddressCmd('if exist ' || b!F || ' del ' ||b!F||AllCmdOutput2Nul()))
  742. else
  743. do
  744. if RexSystemOpSys="UNIX" then
  745. return(AddressCmd('rm -f ' ||b!F||AllCmdOutput2Nul()))
  746. else
  747. return(AddressCmd('del ' ||b!F||AllCmdOutput2Nul()))
  748. end
  749.  
  750. RexGetTmpFileName:call TRACE "OFF"
  751. if arg(1)<> '' then
  752. TmpFileM=arg(1)
  753. else
  754. do
  755. if RexSystemOpSys<> "UNIX" then
  756. TmpFileM='RSTM????.TMP'
  757. else
  758. do
  759. TmpFileM=GetEnv('USER')
  760. if TmpFileM='' then
  761. TmpFileM=GetEnv('user')
  762. if TmpFileM='' then
  763. TmpFileM='?????.rstm'
  764. else
  765. TmpFileM=TmpFileM|| '_?????.rstm'
  766. end
  767. end
  768. TmpFileM=RexGetNameOfTmpDir()||RexDirChar||TmpFileM
  769. if RexWhich='STANDARD_OS/2' then
  770. do
  771. TmpFileF=SysTempFileName(TmpFileM)
  772. if TmpFileF='' then
  773. do
  774. RexTmpFileCntr=RexTmpFileCntr+1
  775. TmpFileF='C_' || right(RexTmpFileCntr, 6, '0') || '.TMP'
  776. end
  777. return(TmpFileF)
  778. end
  779. TmpRandom=right(time('S'),3)||random(99999)
  780. TmpRandomAdd=0
  781. do until _FileQueryExists(TmpFileA)=''
  782. TmpRandomS=reverse(d2x(TmpRandom+TmpRandomAdd))
  783. TmpRandomAdd=TmpRandomAdd+1
  784. TmpFileA=TmpFileM
  785. TmpWhich=1
  786. QmPos=pos('?',TmpFileA)
  787. do while QmPos<>0
  788. TmpReplace=substr(TmpRandomS,TmpWhich,1)
  789. TmpWhich=TmpWhich+1
  790. if TmpReplace='' then
  791. TmpWhich=1
  792. else
  793. do
  794. TmpFileA=overlay(TmpReplace,TmpFileA,QmPos)
  795. QmPos=pos('?',TmpFileA)
  796. end
  797. end
  798. end
  799. return(TmpFileA)
  800.  
  801. GetEnv:call TRACE "OFF"
  802. if RexWhich<> 'REXX370' then
  803. rsGetEnv=value(arg(1),,RexEnvVarPool)
  804. else
  805. do
  806. rsGetEnv=''
  807. end
  808. if rsGetEnv=='' & arg(2) = 'Y' then
  809. call RexSystemFailure 'Could not find the environment variable "' || arg(1) || '"'
  810. call DebugGetEnv arg(1),rsGetEnv
  811. return(rsGetEnv)
  812.  
  813. SetEnv:call TRACE "OFF"
  814. if RexWhich<> 'REXX370' then
  815. return(value(arg(1),arg(2),RexEnvVarPool))
  816. else
  817. do
  818. return('')
  819. end
  820.  
  821. _valueS:call TRACE "OFF"
  822. if RexWhich='STANDARD_OS/2' then
  823. return(value(arg(1),arg(2)))
  824. return(value(translate(arg(1)),arg(2)))
  825.  
  826. _valueG:call TRACE "OFF"
  827. if RexWhich='STANDARD_OS/2' then
  828. return(value(arg(1)))
  829. return(value(arg(1)))
  830. /*
  831.  * DB$STUBS - Keep indent (not so easy for comments)
  832.  *            for this bit until finished!
  833.  */
  834.  
  835. DirGetCurrent:
  836.    return( directory() )
  837.  
  838. DirQueryExists:
  839.    if  arg(1) = '' then
  840.        return('')
  841.    select
  842.        when RexWhich = 'REGINA' then
  843.        do
  844.            return( stream(arg(1) || RexDirChar || '.', 'c', 'query exists') )
  845.        end
  846.        when RexWhich = 'STANDARD_OS/2' then
  847.        do
  848.            c!CDir = directory()
  849.            c!NewDir = directory(arg(1))
  850.            call directory c!CDir
  851.            return(c!NewDir)
  852.        end
  853.        when RexWhich = 'REXX370' then
  854.        do
  855.            /* DB$390 - return passed name (BAD! - ppwizard might fail in parts)
  856.             */
  857.            return(arg(1))
  858.        end
  859.        otherwise
  860.        do
  861.            return(arg(1))
  862.        end
  863.    end
  864.  
  865. _FileQueryExists:
  866.    if  arg(1) = '' then
  867.        return('')
  868.    if  RexWhich <> 'REXX370' then
  869.        return( stream(arg(1), 'c', 'query exists') )
  870.    else
  871.    do
  872.        /* DB$390 - return passed name (BAD! - ppwizard might fail in parts)
  873.        */
  874.        return(arg(1))
  875.    end
  876.  
  877. _FileQueryDateTime:
  878.    if  RexWhich <> 'REXX370' then
  879.        return( stream(arg(1), 'c', 'query datetime') )
  880.    else
  881.    do
  882.        /* DB$390 - Return valid but fixed value
  883.        */
  884.        return('01-01-01 12:00:00')
  885.    end
  886.  
  887. FileQuerySize:
  888.    if  RexWhich <> 'REXX370' then
  889.        return( stream(arg(1), 'c', 'query size') )
  890.    else
  891.    do
  892.        /* DB$390 - Return valid but fixed value
  893.        */
  894.        return('219')
  895.    end
  896.  
  897. FileOpenReadOnly:
  898.    if  RexWhich <> 'REXX370' then
  899.        return( stream(arg(1), 'c', 'open read') )
  900.    else
  901.    do
  902.        /* DB$390 - For now do nothing (so file opens read/write - so what)
  903.        */
  904.        return('')
  905.    end
  906.  
  907. FileLineIn:
  908.    parse arg d!F, d!Ln
  909.    if  d!Ln = '' then
  910.        return( LineIn(d!F) )
  911.    else
  912.    do
  913.        if  RexWhich = 'REGINA' | d!LN = 1 then
  914.            return( LineIn(d!F, d!Ln) )
  915.        else
  916.        do
  917.            d!Cont = linein(d!F, 1);
  918.            do d!l = 2 to d!LN
  919.               d!Cont = linein(d!F);
  920.            end
  921.            return(d!Cont)
  922.        end
  923.    end
  924.  
  925. _FileClose:
  926.    if  RexWhich <> 'REXX370' then
  927.        return( stream(arg(1), 'c', 'close') )
  928.    else
  929.    do
  930.        /* DB$390 - Worth a try
  931.        */
  932.        call lineout arg(1)
  933.        return('')
  934.    end
  935.  
  936. FileState:
  937.    if  RexWhich <> 'REXX370' then
  938.        return( stream(arg(1), 'State') )
  939.    else
  940.    do
  941.        /* DB$390 - Stream Description
  942.        */
  943.        return('')
  944.    end
  945.  
  946. FileDescription:
  947.    if  RexWhich <> 'REXX370' then
  948.        return( stream(arg(1), 'Description') )
  949.    else
  950.    do
  951.        /* DB$390 - Stream Description
  952.        */
  953.        return('')
  954.    end
  955. /*
  956.    REXSYSTM.XH - a few stream there (need to move stubs there)
  957.    DirMake
  958.    FileCharin    ?
  959.    FileCharout   ?
  960.    FileLineOut   ?
  961. */
  962.  
  963. REXSYSTM_1:
  964. PpWizardPgmName=RexSystmRexxPgmName
  965. PpWizardOpSysREAL=RexSystemOpSysREAL
  966. PpWizardOpSys=RexSystemOpSys
  967. WizName=translate(_filespec('name',PpWizardPgmName))
  968. call InitScreenHandling
  969. TryQuoteListSd="'" || '"'
  970. TryQuoteListDs='"' || "'"
  971. TryQuoteListAny=TryQuoteListDs|| '^~!@#$%&*-+=?/\|`:;._'
  972. NullChar='00'x
  973. TabChar='09'x
  974. CrLf=RexEOL
  975. if RexIsAscii='N' then
  976. do
  977. MarksNewLine='15'x
  978. end
  979. else
  980. do
  981. MarksNewLine='0A'x
  982. TryQuoteListAny=TryQuoteListAny||xrange('DB'x, 'FE'x) || xrange('80'x, 'DA'x)
  983. end
  984. call InitConsoleOutputVarsPass2
  985. if RexSystemOpSys<> "UNIX" then
  986. call SetDebugChars '96,96,25',  'Y'
  987. else
  988. call SetDebugChars '34,-1,165', 'Y'
  989. numeric digits 14
  990. trace off
  991. if RexSystemOpSys="UNIX" then
  992. NewLineChars=MarksNewLine
  993. else
  994. NewLineChars=CrLf
  995. MarksNewLineInHashDefine='<{nl}>'
  996. MarksNewLineInHashDefine2=MarksNewLineInHashDefine||MarksNewLineInHashDefine
  997. Ignore=0
  998. LowerCase="abcdefghijklmnopqrstuvwxyz"
  999. UpperCase="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  1000. DecimalDigits="0123456789"
  1001. CharsLUN=LowerCase||UpperCase||DecimalDigits
  1002. DebugOnStuffOutputted='N'
  1003. WantedWarningRc=1
  1004. NotEqualInC='!' || '='
  1005. EofChar=d2c(26)
  1006. RexxCmtStart='/' || '*'
  1007. RexxCmtEnd='*' || '/'
  1008. TagSvNewLine='<' || '?NewLine>' ||MarksNewLine
  1009. signal Screen_2
  1010.  
  1011. InitScreenHandling2Off:
  1012. e!G_CtextAvail=''
  1013. e!BeepsAllow='N'
  1014. e!ColorAllow='N'
  1015. e!How2ChangeColors='A'
  1016. return
  1017.  
  1018. CfgColor:
  1019. parse arg e!Var,e!DefC,e!DefA
  1020. if e!How2ChangeColors='C' then
  1021. e!D=e!DefC
  1022. else
  1023. e!D=e!DefA
  1024. e!Val=CfgEnv('PPWIZARD_COLOR_' ||e!Var,e!D)
  1025. e!Val=ReplaceCurlyHexCodes(e!Val)
  1026. call value 'e!COL_' ||e!Var,e!Val
  1027. return
  1028.  
  1029. InitScreenHandling:
  1030. if RexSystemOpSys="WIN32" then
  1031. do
  1032. e!Comspec=GetEnv("COMSPEC", "Y")
  1033. if pos('.COM',e!Comspec)<>0 then
  1034. do
  1035. e!How2ChangeColors='A'
  1036. call DBG 'This windows version does not support use of CTEXT.EXE'
  1037. call DBG 'It can use ANSI.SYS if this is installed in "config.sys".'
  1038. end
  1039. else
  1040. do
  1041. e!G_CtextAvail=FileQueryExists(_filespec('L', PpWizardPgmName) || 'ctext.exe')
  1042. if e!G_CtextAvail='' then
  1043. do
  1044. e!How2ChangeColors=''
  1045. e!Cmt='not'
  1046. end
  1047. else
  1048. do
  1049. e!How2ChangeColors='C'
  1050. e!Cmt='found'
  1051. end
  1052. call DBG 'This windows version supports use of CTEXT.EXE (CTEXT.EXE ' || e!Cmt || ' in the PPWIZARD directory)'
  1053. end
  1054. end
  1055. call CfgColor 'RESET',      '{white}',    '{x1B}[0m'
  1056. call CfgColor 'DEFAULT',    '{brown}',    '{x1B}[0;33m'
  1057. call CfgColor 'Error',      '{bred}',     '{x1B}[0;1;31m'
  1058. call CfgColor 'Warning',    '{yellow}',   '{x1B}[0;1;33m'
  1059. call CfgColor 'Info',       '{bwhite}',   '{x1B}[0;1m'
  1060. call CfgColor 'HighLight',  '{bmagenta}', '{x1B}[0;1;35m'
  1061. call CfgColor 'Title',      '{green}',    '{x1B}[0;32m'
  1062. call CfgColor 'PromptText', '{bwhite}',   '{x1B}[0;1m'
  1063. call CfgColor 'RexxTrace',  '{bmagenta}', '{x1B}[0;1;35m'
  1064. call CfgColor 'RexxOther',  '{cyan}'      '{x1B}[0;36m'
  1065. call CfgColor 'Summary',    '{white}'     '{x1B}[0m'
  1066. e!HowToBeep=d2c(7)
  1067. e!BeepsAllow='Y'
  1068. e!ColorAllow='N'
  1069. if RexSystemOpSys="OS/2" then
  1070. e!ColorAllow='Y'
  1071. else
  1072. do
  1073. if e!How2ChangeColors='C' then
  1074. e!ColorAllow='Y'
  1075. end
  1076. return
  1077.  
  1078. GetColorCode:
  1079. e!Cc='e!COL_' ||arg(1)
  1080. if symbol(e!Cc)<> 'VAR' then
  1081. CryAndDie('Invalid color category of "' || arg(1) || '" specified!')
  1082. return(e!CC)
  1083.  
  1084. Beeps:call TRACE "OFF"
  1085. if e!BeepsAllow='Y' then
  1086. do
  1087. e!C=arg(1)
  1088. if e!C='' then
  1089. e!C=1
  1090. do e!i=1 to e!C
  1091. call charout,e!HowToBeep
  1092. end
  1093. end
  1094. return("")
  1095.  
  1096. ColorCfg:call TRACE "OFF"
  1097. parse arg e!Var,e!Val
  1098. call DBG 'ColorCfg(' || e!Var || ') = ' ||e!Val
  1099. e!Val=ReplaceCurlyHexCodes(e!Val)
  1100. e!S=GetColorCode(e!Var)
  1101. e!P=value(e!S)
  1102. call value e!S,e!Val
  1103. return(e!P)
  1104.  
  1105. ColorSet:call TRACE "OFF"
  1106. if e!ColorAllow='Y' then
  1107. do
  1108. e!C=arg(1)
  1109. if e!C='' then
  1110. e!C='DEFAULT'
  1111. e!S=GetColorCode(e!C)
  1112. if e!How2ChangeColors='C' then
  1113. do
  1114. e!Cmd='"' || e!G_CtextAvail || '" ' || value(e!S) || ' ' ||AllCmdOutput2Nul()
  1115. e!Comspec|| ' /c ' ||e!Cmd
  1116. end
  1117. else
  1118. do
  1119. if e!How2ChangeColors='A' then
  1120. call charout,value(e!S)
  1121. end
  1122. end
  1123. return
  1124.  
  1125. ColorAllow:call TRACE "OFF"
  1126. e!Rc=e!ColorAllow
  1127. e!ColorAllow=translate(arg(1))
  1128. if e!How2ChangeColors='' then
  1129. do
  1130. if e!ColorAllow='Y' then
  1131. do
  1132. e!ColorAllow='N'
  1133. call DBG 'User tried to turn on color changing but it is not possible to change colors...'
  1134. end
  1135. end
  1136. return(e!Rc)
  1137.  
  1138. BeepsAllow:call TRACE "OFF"
  1139. e!Rc=e!BeepsAllow
  1140. e!BeepsAllow=translate(arg(1))
  1141. return(e!Rc)
  1142.  
  1143. Screen_2:
  1144. signal Progress_3
  1145.  
  1146. RepCommonProgCodes:
  1147. parse arg f!T,f!F
  1148. f!CDU=UFile(DirGetCurrent())||RexDirChar
  1149. f!CDUL=length(f!CDU)
  1150. if pos('{.}',f!T)<>0 then
  1151. f!T=ReplaceString(f!T, '{.}',FileNameRelative(f!F))
  1152. f!T=ReplaceString(f!T, '{S}',  _filespec('N',f!F))
  1153. f!T=ReplaceString(f!T, '{L}',f!F)
  1154. f!T=ReplaceString(f!T, '{PM}',ProcessingMode)
  1155. return(f!T)
  1156.  
  1157. Making:call TRACE "OFF"
  1158. parse arg g!FN,MsgMode
  1159. if g!FN='' then
  1160. g!FN=CurrentOutFile
  1161. g!FFN=FileQueryExists(g!FN)
  1162. if g!FFN<> '' then
  1163. g!FN=g!FFN
  1164. call DBG 'Making(' || g!FN || ')'
  1165. call DBGIND 1
  1166. g!I=copies("  ", IncludeLevel+1) || ' '
  1167. g!T=OptionMsgMaking
  1168. g!Rexx=CfgMacro('HOOK_MSG_MAKING', '')
  1169. g!Rexx=PerformReplacementsInCmdsParameters(g!Rexx)
  1170. if g!Rexx<> '' then
  1171. do
  1172. MsgFile=g!FN
  1173. MsgInd=g!I
  1174. MsgText=g!T
  1175. call ExecRexxCmd g!Rexx
  1176. call DBGIND-1
  1177. return
  1178. end
  1179. call DBG 'Spec: ' ||g!T
  1180. if g!T='' then
  1181. do
  1182. call DBGIND-1
  1183. return
  1184. end
  1185. if pos('{R?}',g!T)<>0 then
  1186. do
  1187. if MsgMode<> 'R' then
  1188. g!T=ReplaceString(g!T, '{R?}', '')
  1189. else
  1190. do
  1191. call DBGIND-1
  1192. return
  1193. end
  1194. end
  1195. g!T=RepCommonProgCodes(g!T,g!FN)
  1196. call Line1 g!I||g!T
  1197. call DBGIND-1
  1198. return
  1199.  
  1200. Reading:call TRACE "OFF"
  1201. if arg(1)='' then
  1202. h!Ex=0
  1203. else
  1204. h!Ex=1
  1205. call ReadingI arg(1),,h!Ex
  1206. return
  1207.  
  1208. ReadingI:
  1209. parse arg i!FFN,i!Frag,i!Ex
  1210. call DBG 'Reading(' || i!FFN || ')'
  1211. call DBGIND 1
  1212. if i!FFN='' then
  1213. i!FFN=IncludeFileName
  1214. if i!Frag='N' then
  1215. do
  1216. MsgFragSp=''
  1217. MsgFragS=''
  1218. MsgFragE=''
  1219. end
  1220. else
  1221. do
  1222. MsgFragSp=IncludeFragmentSpec
  1223. MsgFragS=IncludeFragmentS
  1224. MsgFragE=IncludeFragmentE
  1225. end
  1226. i!I=ReadingIndent(i!Ex)
  1227. i!T=OptionMsgReading
  1228. i!Rexx=CfgMacro('HOOK_MSG_READING', '')
  1229. i!Rexx=PerformReplacementsInCmdsParameters(i!Rexx)
  1230. if i!Rexx<> '' then
  1231. do
  1232. MsgFile=i!FFN
  1233. MsgInd=i!I
  1234. MsgText=i!T
  1235. call ExecRexxCmd i!Rexx
  1236. call DBGIND-1
  1237. return
  1238. end
  1239. call DBG 'Spec: ' ||i!T
  1240. if i!T='' then
  1241. do
  1242. call DBGIND-1
  1243. return
  1244. end
  1245. i!P=pos('{F?}',i!T)
  1246. if i!P<>0 then
  1247. do
  1248. if MsgFragSp='' then
  1249. i!T=left(i!T,i!P-1)
  1250. else
  1251. i!T=ReplaceString(i!T, '{F?}', '')
  1252. end
  1253. i!T=RepCommonProgCodes(i!T,i!FFN)
  1254. i!T=ReplaceString(i!T, '{F}',MsgFragSp)
  1255. i!T=ReplaceString(i!T, '{FS}',MsgFragS)
  1256. i!T=ReplaceString(i!T, '{FE}',MsgFragE)
  1257. call Line1 i!I||i!T
  1258. call DBGIND-1
  1259. return
  1260.  
  1261. ReadingIndent:
  1262. j!Ex=arg(1)
  1263. if j!Ex='' then j!Ex=0
  1264. return(copies("  ", IncludeLevel+j!Ex) || ' ')
  1265.  
  1266. UFile:
  1267. if RexSystemOpSys="UNIX" then
  1268. return(arg(1))
  1269. else
  1270. return(translate(arg(1)))
  1271.  
  1272. Progress_3:
  1273. LastSystemCmd="none"
  1274. LastSystemCmdFull="none"
  1275. LastSystemRc=999
  1276. signal System_4
  1277.  
  1278. ProcessSystem:
  1279. Rest=PerformReplacementsInCmdsParameters(arg(1))
  1280. Log2File=GetQuotedText(Rest, "Rest")
  1281. LastSystemCmd=GetQuotedRest(Rest)
  1282. select
  1283. when RexSystemOpSys="OS/2" then
  1284. CmdProc='CMD.EXE /c '
  1285. otherwise
  1286. CmdProc=''
  1287. end
  1288. LastSystemCmdFull=CmdProc||LastSystemCmd
  1289. DeleteFileAfter='N'
  1290. select
  1291. when translate(Log2File)='ASIS' then
  1292. Log2File=''
  1293. when Log2File='-' then
  1294. Log2File=NameOfNulDevice()
  1295. when Log2File='?' then
  1296. do
  1297. Log2File=RexGetTmpFileName()
  1298. DeleteFileAfter='Y'
  1299. end
  1300. otherwise
  1301. nop
  1302. end
  1303. if Log2File<> '' then
  1304. LastSystemCmdFull=LastSystemCmdFull||RedirectStdOutAndErr2(Log2File)
  1305. LastSystemRc=AddressCmd(LastSystemCmdFull,Log2File)
  1306. if DeleteFileAfter='Y' then
  1307. call _SysFileDelete(Log2File)
  1308. return(0)
  1309.  
  1310. System_4:
  1311. signal stack_5
  1312.  
  1313. StackInitForBuild:
  1314. STK_CNT=0
  1315. return
  1316.  
  1317. _StkErrLine:
  1318. if StackErrorText='' then
  1319. StackErrorText=arg(1)
  1320. else
  1321. StackErrorText=StackErrorText||MarksNewLine||arg(1)
  1322. return
  1323.  
  1324. StackValidation:
  1325. call DBG "Validating the " || STK_CNT || " stack(s)"
  1326. call DBGIND+1
  1327. StackErrorText=''
  1328. k!Invalid=0
  1329. do k!S=1 to STK_CNT
  1330. k!ID=STK.k!S
  1331. k!Desc=value(k!ID|| '_DESC')
  1332. call DBG 'Validating: ' ||k!Desc
  1333. k!Lvl=value(k!ID|| '.0')
  1334. call DBGIND+1
  1335. if k!Lvl=0 then
  1336. call DBG 'OK'
  1337. else
  1338. do
  1339. k!Invalid=k!Invalid+1
  1340. call DBG 'There are ' || k!Lvl || ' items still on the stack!'
  1341. k!T='STACK "' || k!Desc || '" has ' || k!Lvl || ' errors'
  1342. call _StkErrLine ''
  1343. call _StkErrLine k!T
  1344. call _StkErrLine copies('~',length(k!T))
  1345. do k!Inv=1 to k!Lvl
  1346. call _StkErrLine 'Push # : ' ||k!Inv
  1347. call _StkErrLine 'Where  : ' || value(k!ID || '_LOCN.' ||k!Inv)
  1348. call _StkErrLine 'Doing  : ' || value(k!ID || '_DOING.' ||k!Inv)
  1349. call _StkErrLine ''
  1350. end
  1351. end
  1352. call DBGIND-1
  1353. end
  1354. if k!Invalid<>0 then
  1355. CryAndDie(StackErrorText||MarksNewLine|| 'There are ' || k!Invalid || ' stacks with incorrect nesting (details above).')
  1356. call DBGIND-1
  1357. return
  1358.  
  1359. StackPush:call TRACE "OFF"
  1360. parse arg l!Desc,l!What,l!Doing
  1361. l!ID='STK_' ||c2x(l!Desc)
  1362. if symbol(l!ID|| '.0') = 'VAR' then
  1363. l!L=value(l!ID|| '.0')+1
  1364. else
  1365. do
  1366. l!L=1
  1367. STK_CNT=STK_CNT+1
  1368. STK.STK_CNT=l!ID
  1369. call value l!ID|| '_DESC',l!Desc
  1370. end
  1371. call value l!ID|| '.0',l!L
  1372. call value l!ID|| '.' ||l!L,l!What
  1373. call value l!ID|| '_LOCN.' ||l!L,GetInputFileNameAndLine()
  1374. if l!Doing='' then
  1375. l!Doing=GetFileLineBeingProcessed()
  1376. call value l!ID|| '_DOING.' ||l!L,l!Doing
  1377. return
  1378.  
  1379. StackPop:call TRACE "OFF"
  1380. m!ID='STK_' ||c2x(arg(1))
  1381. if symbol(m!ID|| '.0') <> 'VAR' then
  1382. CryAndDie('Can''t pop the non-existant stack "' || arg(1) || '"')
  1383. m!L=value(m!ID|| '.0')
  1384. if m!L<=0 then
  1385. CryAndDie('Nothing on the stack "' || arg(1) || '"')
  1386. call value m!ID|| '.0',m!L-1
  1387. return(value(m!ID|| '.' ||m!L))
  1388.  
  1389. ProcessPush:
  1390. n!R=PerformReplacementsInCmdsParameters(arg(1))
  1391. n!Typ=translate(GetQuotedText(n!R, "n!R"))
  1392. do until n!R=''
  1393. n!I=GetQuotedText(n!R, "n!R")
  1394. select
  1395. when n!Typ='MACRO' then
  1396. do
  1397. call StackPush '#Push MACRO',MacroGet(n!I)
  1398. end
  1399. when n!Typ='REXXVAR' then
  1400. do
  1401. call StackPush '#Push REXXVAR',_valueG(n!I)
  1402. end
  1403. otherwise
  1404. CryAndDie('Unsupported #PUSH type of ' ||n!Typ)
  1405. end
  1406. end
  1407. return(0)
  1408.  
  1409. ProcessPop:
  1410. o!R=PerformReplacementsInCmdsParameters(arg(1))
  1411. o!Typ=translate(GetQuotedText(o!R, "o!R"))
  1412. o!C=0
  1413. do until o!R=''
  1414. o!C=o!C+1
  1415. o!S.o!C=GetQuotedText(o!R, "o!R")
  1416. end
  1417. do o!I=o!C to 1 by-1
  1418. select
  1419. when o!Typ='MACRO' then
  1420. do
  1421. call MacroSet o!S.o!I,StackPop('#Push MACRO'), 'Y'
  1422. end
  1423. when o!Typ='REXXVAR' then
  1424. do
  1425. call _valueS o!S.o!I,StackPop('#Push REXXVAR')
  1426. end
  1427. otherwise
  1428. CryAndDie('Unsupported #POP type of ' ||o!Typ)
  1429. end
  1430. end
  1431. return(0)
  1432.  
  1433. stack_5:
  1434. call InitTransformationCode
  1435. signal Transfrm_6
  1436.  
  1437. InitTransformationCode:
  1438. TransformCodeLvl=0
  1439. return
  1440.  
  1441. ProcessTransform:
  1442. p!Do=arg(1)
  1443. if p!Do<> '' then
  1444. do
  1445. p!Do=PerformReplacementsInCmdsParameters(p!Do)
  1446. p!Do=GetQuotedText(p!Do)
  1447. end
  1448. if p!Do<> '' then
  1449. do
  1450. TransformCodeLvl=TransformCodeLvl+1
  1451. if OptionDebugOn='Y' then
  1452. call DBG 'Start of transformation block #' || TransformCodeLvl || ' - "' || p!Do || '"'
  1453. p!C=MacroGet(p!Do)
  1454. p!C=PerformReplacementsInCmdsParameters(p!C)
  1455. call StackPush "#transform Nesting",,"PPWIZARD's #transform command"
  1456. TransformCode.TransformCodeLvl=p!C
  1457. end
  1458. else
  1459. do
  1460. if OptionDebugOn='Y' then
  1461. call DBG "End of transformation block #" ||TransformCodeLvl
  1462. call StackPop "#transform Nesting"
  1463. TransformCodeLvl=TransformCodeLvl-1
  1464. end
  1465. return(0)
  1466.  
  1467. Transfrm_6:
  1468. signal NextId_7
  1469.  
  1470. InitNextId:
  1471. NextIdUnique=0
  1472. NextIdReplOn='N'
  1473. NextIdMarker='@' || '@'
  1474. NextIdMask='*_'
  1475. NextIdNewCounter=NextIdUnique
  1476. NextIdChars1st=LowerCase
  1477. NextIdCharsRst=LowerCase|| '!?_' ||DecimalDigits
  1478. NextIdNew=_GetNextIdPrefix()
  1479. NextIdUsed='N'
  1480. NextIdLocked=''
  1481. NextIdLockedAt=''
  1482. return
  1483.  
  1484. ProcessNextId:
  1485. q!P=arg(1)
  1486. if q!P='' then
  1487. call _NextIdInc
  1488. else
  1489. do
  1490. q!P=PerformReplacementsInCmdsParameters(q!P)
  1491. q!Cmd=GetQuotedText(q!P, 'q!P')
  1492. q!CmdU=translate(q!Cmd)
  1493. select
  1494. when q!CmdU='OFF' then
  1495. NextIdReplOn='N'
  1496. when q!CmdU='ON' then
  1497. NextIdReplOn='Y'
  1498. when q!CmdU='CHARS' then
  1499. do
  1500. call _DieIfLocked q!Cmd
  1501. NextIdChars1st=GetQuotedText(q!P, 'q!P')
  1502. NextIdCharsRst=GetQuotedRest(q!P)
  1503. NextIdNew=_GetNextIdPrefix()
  1504. end
  1505. when q!CmdU='LOCK' then
  1506. do
  1507. call _DieIfLocked q!Cmd
  1508. if q!P='' then
  1509. q!P='"?"'
  1510. NextIdLocked=GetQuotedRest(q!P)
  1511. NextIdLockedAt=CurrentSourceLocation()
  1512. if NextIdLocked='' then
  1513. CryAndDie('You must specify a KEY to lock Next ID incrementing.')
  1514. end
  1515. when q!CmdU='UNLOCK' then
  1516. do
  1517. if NextIdLocked='' then
  1518. CryAndDie('Not locked!')
  1519. if q!P='' then
  1520. q!P='"?"'
  1521. q!Key=GetQuotedRest(q!P)
  1522. if q!Key<>NextIdLocked then
  1523. CryAndDie('Incorrect key used, required "' || NextIdLocked || '"', 'Locking was done at ' ||NextIdLockedAt)
  1524. NextIdLocked=''
  1525. end
  1526. when q!CmdU='REPLACE' then
  1527. do
  1528. call _DieIfLocked q!Cmd
  1529. NextIdMarker=GetQuotedRest(q!P)
  1530. if NextIdMarker='' then
  1531. NextIdMarker='@' || '@'
  1532. end
  1533. when q!CmdU='MASK' then
  1534. do
  1535. call _DieIfLocked q!Cmd
  1536. NextIdMask=GetQuotedRest(q!P)
  1537. if NextIdMask='' then
  1538. NextIdMask='*_'
  1539. NextIdNew=_GetNextIdPrefix()
  1540. end
  1541. when q!CmdU='PUSH' then
  1542. do
  1543. q!Info=NextIdReplOn|| '00'x || NextIdMarker || '00'x || NextIdMask || '00'x || NextIdNew || '00'x || NextIdNewCounter || '00'x || NextIdUsed || '00'x || NextIdLocked || '00'x || NextIdLockedAt || '00'x || NextIdChars1st || '00'x||NextIdCharsRst
  1544. call StackPush "#NextId PUSH",q!Info
  1545. NextIdLocked=''
  1546. NextIdUsed='Y'
  1547. call _NextIdInc
  1548. NextIdReplOn='N'
  1549. end
  1550. when q!CmdU='POP' then
  1551. do
  1552. q!Info=StackPop("#NextId PUSH")
  1553. parse var q!Info NextIdReplOn '00'x NextIdMarker '00'x NextIdMask '00'x NextIdNew '00'x NextIdNewCounter '00'x NextIdUsed '00'x NextIdLocked '00'x NextIdLockedAt '00'x NextIdChars1st '00'x NextIdCharsRst
  1554. end
  1555. otherwise
  1556. CryAndDie('Unknown #NextID command of "' || q!Cmd || '"')
  1557. end
  1558. end
  1559. if OptionDebugOn='Y' then
  1560. do
  1561. if NextIdReplOn='N' then
  1562. q!T='off'
  1563. else
  1564. q!T='on'
  1565. q!I=NextIdLocked
  1566. if q!I='' then
  1567. q!I='unlocked'
  1568. else
  1569. q!I='locked (KEY = "' || NextIdLocked || '", locked at ' || NextIdLockedAt || ')'
  1570. call DBG '#NextID processing is turned ' ||q!T
  1571. call DBG '#NextID incrementing is ' ||q!I
  1572. call DBG 'If ON, any "' || NextIdMarker || '" strings will be replaced with "' || NextIdNew || '"'
  1573. end
  1574. return(0)
  1575.  
  1576. _NextIdInc:
  1577. call _DieIfLocked 'increment'
  1578. NextIdReplOn='Y'
  1579. if NextIdUsed='Y' then
  1580. do
  1581. NextIdUnique=NextIdUnique+1
  1582. NextIdNewCounter=NextIdUnique
  1583. NextIdNew=_GetNextIdPrefix()
  1584. end
  1585. return
  1586.  
  1587. _DieIfLocked:
  1588. if NextIdLocked<> '' then
  1589. CryAndDie('Operation (' || arg(1) || ') not allowed as #NextId ID is locked, KEY = "' || NextIdLocked || '"', 'Locking was done at ' ||NextIdLockedAt)
  1590. return
  1591.  
  1592. _GetNextIdPrefix:
  1593. r!Dec=NextIdNewCounter
  1594. r!LenLeading=length(NextIdChars1st)
  1595. r!LenTrailing=length(NextIdCharsRst)
  1596. r!1=''
  1597. r!P=''
  1598. do until r!Dec=0
  1599. if r!1=='' then
  1600. do
  1601. r!1=substr(NextIdChars1st,(r!Dec//r!LenLeading)+1,1)
  1602. r!Dec=r!Dec%r!LenLeading
  1603. end
  1604. else
  1605. do
  1606. r!P=substr(NextIdCharsRst,(r!Dec//r!LenTrailing)+1,1)||r!P
  1607. r!Dec=r!Dec%r!LenTrailing
  1608. end
  1609. end
  1610. r!P=ReplaceString(NextIdMask, '*',r!1||r!P)
  1611. NextIdUsed='N'
  1612. return(r!P)
  1613.  
  1614. NextId_7:
  1615. call InitINTERCEPTCode
  1616. signal Intercpt_8
  1617.  
  1618. InitINTERCEPTCode:
  1619. InterceptCode=''
  1620. InterceptStartLoc=''
  1621. InterceptOffMarker=''
  1622. return
  1623.  
  1624. ProcessIntercept:
  1625. RexxCode=arg(1)
  1626. if RexxCode<> '' then
  1627. do
  1628. RexxCode=PerformReplacementsInCmdsParameters(RexxCode)
  1629. RexxCode=GetQuotedText(RexxCode)
  1630. end
  1631. if RexxCode<> '' then
  1632. do
  1633. if OptionDebugOn='Y' then
  1634. call DBG 'Start of INTERCPT block "' || RexxCode || '"'
  1635. if InterceptCode<> '' then
  1636. CryAndDie("Already in tranformation block started at " ||InterceptStartLoc)
  1637. InterceptStartLoc=CurrentSourceLocation()
  1638. InterceptOffMarker=arg(2)
  1639. InterceptCode=MacroGet(RexxCode)
  1640. InterceptCode=PerformReplacementsInCmdsParameters(InterceptCode)
  1641. end
  1642. else
  1643. do
  1644. if OptionDebugOn='Y' then
  1645. call DBG "End of INTERCPT block"
  1646. if InterceptCode='' then
  1647. CryAndDie('We were not in a INTERCPT block!')
  1648. InterceptCode=''
  1649. end
  1650. return(0)
  1651.  
  1652. Intercpt_8:
  1653. OutputHoldLvl=0
  1654. call InitOutputHold
  1655. signal OutpHold_9
  1656.  
  1657. InitOutputHold:
  1658. HoldingOutput='N'
  1659. HeldOutput=''
  1660. OutpHoldStartLoc=''
  1661. return
  1662.  
  1663. OutputHoldPushAndClear:
  1664. OutputHoldLvl=OutputHoldLvl+1
  1665. OutHold_.OutputHoldLvl.!HoldingOutput=HoldingOutput
  1666. OutHold_.OutputHoldLvl.!HeldOutput=HeldOutput
  1667. OutHold_.OutputHoldLvl.!OutpHoldStartLoc=OutpHoldStartLoc
  1668. call InitOutputHold
  1669. return
  1670.  
  1671. OutputHoldPop:
  1672. HoldingOutput=OutHold_.OutputHoldLvl.!HoldingOutput
  1673. HeldOutput=OutHold_.OutputHoldLvl.!HeldOutput
  1674. OutpHoldStartLoc=OutHold_.OutputHoldLvl.!OutpHoldStartLoc
  1675. OutputHoldLvl=OutputHoldLvl-1
  1676. return
  1677.  
  1678. DieIfHoldingOutput:
  1679. if HoldingOutput='Y' then
  1680. CryAndDie('Missing #OutputHold (end)', 'Block started at ' ||OutpHoldStartLoc)
  1681. return
  1682.  
  1683. ProcessHashOutputHold:
  1684. OrexxRexx=arg(1)
  1685. if OrexxRexx='' then
  1686. do
  1687. if OptionDebugOn='Y' then
  1688. call DBG 'Start of hold output block'
  1689. if HoldingOutput='Y' then
  1690. CryAndDie("Already in hold output block started at " ||OutpHoldStartLoc)
  1691. call FlushQueuedOutput
  1692. HoldingOutput='Y'
  1693. OutpHoldStartLoc=CurrentSourceLocation()
  1694. end
  1695. else
  1696. do
  1697. if OptionDebugOn='Y' then
  1698. call DBG "End of hold output block - Held " || length(HeldOutput) || ' byte(s)'
  1699. if HoldingOutput='N' then
  1700. CryAndDie('We were not in a hold output block!')
  1701. call FlushQueuedOutput
  1702. OrexxRexx=PerformReplacementsInCmdsParameters(OrexxRexx)
  1703. OrexxRexx=GetQuotedText(OrexxRexx)
  1704. if translate(OrexxRexx)='DROP' then
  1705. HeldOutput=''
  1706. else
  1707. do
  1708. OutputModCode=MacroGet(OrexxRexx)
  1709. OutputModCode=PerformReplacementsInCmdsParameters(OutputModCode)
  1710. call ExecRexxCmd OutputModCode
  1711. end
  1712. if HeldOutput\=='' then
  1713. do
  1714. if OptionDebugOn='Y' then
  1715. call DBG 'Writing ' || length(HeldOutput) || ' byte(s) to output'
  1716. call FileCharOut HeldOutput
  1717. end
  1718. call InitOutputHold
  1719. end
  1720. return(0)
  1721.  
  1722. OutpHold_9:
  1723. signal RexxHook_10
  1724.  
  1725. RexxHookSetBuildingParms:
  1726. parse arg HookBuildParmInput,HookBuildParmOutput,HookBuildParmTemplate
  1727. return
  1728.  
  1729. RexxHookInit:
  1730. RexxHookBefore=''
  1731. RexxHookAfter=''
  1732. RexxHookWarning=''
  1733. RexxHookError=''
  1734. RexxHookGetFileList=''
  1735. call RexxHookSetBuildingParms
  1736. return
  1737.  
  1738. RexxHookSet:
  1739. parse arg ThisCmd,s!Spec
  1740. parse var s!Spec s!W';'s!Rx
  1741. s!W=translate(s!W)
  1742. do until s!W=''
  1743. parse var s!W s!W1','s!W
  1744. rhDone='N'
  1745. if s!W1='' | abbrev("BEFORE",s!W1)then
  1746. do
  1747. rhDone='Y'
  1748. RexxHookBefore=s!Rx
  1749. end
  1750. if s!W1='' | abbrev("AFTER",s!W1)then
  1751. do
  1752. rhDone='Y'
  1753. RexxHookAfter=s!Rx
  1754. end
  1755. if s!W1='' | abbrev("WARNING",s!W1)then
  1756. do
  1757. rhDone='Y'
  1758. RexxHookWarning=s!Rx
  1759. end
  1760. if s!W1='' | abbrev("ERROR",s!W1)then
  1761. do
  1762. rhDone='Y'
  1763. RexxHookError=s!Rx
  1764. end
  1765. if s!W1='' | abbrev("GETFILELIST",s!W1)then
  1766. do
  1767. rhDone='Y'
  1768. RexxHookGetFileList=s!Rx
  1769. end
  1770. if rhDone='N' then
  1771. CryAndDie('The hook type of "' || s!W1 || '" is unknown')
  1772. end
  1773. return
  1774.  
  1775. CallHook:
  1776. parse arg CallHook,CallHookOkParmsOk,Parm1,Parm2,Parm3,Parm4
  1777. BuildDetailParms=', HookBuildParmInput, HookBuildParmOutput, HookBuildParmTemplate'
  1778. HookSpecificParms=', Parm1, Parm2, Parm3, Parm4'
  1779. select
  1780. when CallHook="WARNING" then
  1781. HookRexxCmd=RexxHookWarning
  1782. when CallHook="BEFORE" then
  1783. HookRexxCmd=RexxHookBefore
  1784. when CallHook="AFTER" then
  1785. HookRexxCmd=RexxHookAfter
  1786. when CallHook="ERROR" then
  1787. do
  1788. ErrorHookCount=ErrorHookCount+1
  1789. if ErrorHookCount>1 then
  1790. return
  1791. HookRexxCmd=RexxHookError
  1792. end
  1793. when CallHook="GETFILELIST" then
  1794. do
  1795. HookRexxCmd=RexxHookGetFileList
  1796. BuildDetailParms=''
  1797. end
  1798. end
  1799. SrcLineLoc=CurrentSourceLocation('')
  1800. if OptionDebugOn='Y' then
  1801. do
  1802. call DBG 'Calling hook: ' || CallHook || ' - ' ||HookRexxCmd
  1803. call DBGIND 1
  1804. end
  1805. HookCmd='HookRc =  "' || HookRexxCmd || '"("00.050", SrcLineLoc, "' || CallHook || '"' || BuildDetailParms || HookSpecificParms || ')'
  1806. HookRc='?'
  1807. signal ON SYNTAX NAME SyntaxErrorInHook
  1808. Interpret HookCmd
  1809. if OptionDebugOn='Y' then
  1810. call DBG 'Rc = ' ||HookRc
  1811. if abbrev(HookRc, 'OK:')=0 then
  1812. do
  1813. call DumpVarsInExpression HookCmd,, 'HOOK VARIABLES', 'Line1'
  1814. CryAndDie('Hook Command Failed: ' || HookCmd, "Hook's Return Code : " ||HookRc)
  1815. end
  1816. OkParms=substr(HookRc,4)
  1817. if OkParms<> '' & CallHookOkParmsOk <> 'Y' then
  1818. CryAndDie('OK parameters not allowed on "' || CallHook || '" hooks.')
  1819. if OptionDebugOn='Y' then
  1820. call DBGIND-1
  1821. return(OkParms)
  1822.  
  1823. SyntaxErrorInHook:
  1824. CryAndDie('Hook Cmd Failed: ' ||HookCmd)
  1825.  
  1826. RexxHook_10:
  1827. WarningSpecs=''
  1828. signal Warning_11
  1829.  
  1830. OutputWarningToScreen:
  1831. t!Code=strip( 'WARNING ' ||strip(arg(1)))
  1832. t!Txt=arg(2)
  1833. if IncludeLevel=0 then
  1834. LineText=''
  1835. else
  1836. LineText='(@' || AddCommasToDecimalNumber(IncludeLineNumber) || ')'
  1837. t!CodeTxt=t!Code|| ': ' ||t!Txt
  1838. t!Msg=LineText||t!CodeTxt
  1839. t!LookIn=translate(t!Msg)
  1840. t!Lst=WarningSpecs
  1841. do while t!Lst<> ''
  1842. parse var t!Lst t!Spec (PathDelimiterChar) t!Lst
  1843. t!Spec1=left(t!Spec,1)
  1844. t!SpecR=substr(t!Spec,2)
  1845. if t!Spec1<> '-' & t!Spec1 <> '+' & t!Spec1 <> '!' then
  1846. do
  1847. t!Spec1='-'
  1848. t!SpecR=t!Spec
  1849. t!Spec=t!Spec1||t!SpecR
  1850. end
  1851. if t!SpecR='' then
  1852. iterate
  1853. if t!SpecR='*' |pos(translate(t!SpecR),t!LookIn)<>0 then
  1854. do
  1855. if OptionDebugOn='Y' then
  1856. call DBG 'Warning matched the spec => ' ||t!Spec
  1857. select
  1858. when t!Spec1='!' then
  1859. do
  1860. if OptionDebugOn='Y' then
  1861. call DBG 'Normal Warning => ' ||t!Msg
  1862. leave
  1863. end
  1864. when t!Spec1='+' then
  1865. do
  1866. CryAndDie(t!CodeTxt,, 'This warning was promoted to a fatal error by "' || t!Spec || '"')
  1867. end
  1868. when t!Spec1='-' then
  1869. do
  1870. if OptionDebugOn='Y' then
  1871. call DBG 'Ignoring Warning => ' ||t!Msg
  1872. return
  1873. end
  1874. end
  1875. end
  1876. end
  1877. if RexxHookWarning<> '' then
  1878. do
  1879. t!Rc=translate(CallHook("WARNING", 'Y',t!Txt))
  1880. if t!Rc='IGNORE+' then
  1881. Warnings=Warnings+1
  1882. if t!Rc='IGNORE' | t!Rc = 'IGNORE+' then
  1883. do
  1884. if OptionDebugOn='Y' then
  1885. call DBG "HOOK said to drop warning: " ||t!Txt
  1886. return
  1887. end
  1888. if t!Rc<> '' then
  1889. CryAndDie('Unknown warning hook return code of: ' ||t!Rc)
  1890. end
  1891. call ColorSet 'WARNING'
  1892. call Line1 ReadingIndent()|| '  ' ||t!Msg
  1893. call ColorSet
  1894. Warnings=Warnings+1
  1895. return
  1896.  
  1897. WarnAboutDepreciatedFeature:
  1898. call OutputWarningToScreen 'DEP0', 'Replace OBSOLETE Feature ASAP -> ' ||arg(1)
  1899. return
  1900.  
  1901. ProcessHashWarning:
  1902. u!R=PerformReplacementsInCmdsParameters(arg(1))
  1903. u!Code=GetQuotedText(u!R, "u!R")
  1904. u!Txt=GetQuotedRest(u!R)
  1905. call OutputWarningToScreen u!Code,u!Txt
  1906. return(0)
  1907.  
  1908. WARNINGS_DEBUG:
  1909. if OptionDebugOn='Y' then
  1910. call OptionDebugShow 'WARNINGS', 'Ignoring any warnings containing "' || WarningSpecs || '"'
  1911. return
  1912.  
  1913. WARNINGS_SET:
  1914. Tags=arg(1)
  1915. if ProcessedCmdLine='N' then
  1916. do
  1917. call OptionDebugShow 'WARNINGS', 'Setting default ignore warnings to "' || Tags || '"'
  1918. Default4_WarningSpecs=Tags
  1919. return(0)
  1920. end
  1921. if Tags=='' then
  1922. Tags=Default4_WarningSpecs
  1923. if translate(Tags)=='NULL' then
  1924. Tags=''
  1925. WarningSpecs=Tags
  1926. call WARNINGS_DEBUG
  1927. return
  1928.  
  1929. WARNINGS_GET:
  1930. call WARNINGS_DEBUG
  1931. return(WarningSpecs)
  1932.  
  1933. Warning_11:
  1934. signal Tabs_12
  1935.  
  1936. TABS_DEBUG:
  1937. if OptionDebugOn='Y' then
  1938. call OptionDebugShow 'TABS', 'TABS is set to "' || OptionTabsString || '" (' || TabsMode || ')'
  1939. return
  1940.  
  1941. TABS_SET:
  1942. OptionTabsString=translate(arg(1))
  1943. if ProcessedCmdLine='N' then
  1944. do
  1945. call OptionDebugShow 'TABS', 'Setting default TABS to "' || OptionTabsString || '"'
  1946. DefaultTabsString=OptionTabsString
  1947. return(0)
  1948. end
  1949. if OptionTabsString=='' then
  1950. OptionTabsString=DefaultTabsString
  1951. WidthOfTab=0
  1952. OptionTabs=left(OptionTabsString,1)
  1953. select
  1954. when datatype(OptionTabsString, 'W')then
  1955. do
  1956. OptionTabs='E'
  1957. WidthOfTab=OptionTabsString
  1958. TabsMode='expanding tabs, fixed tab stop every ' || WidthOfTab || ' characters'
  1959. end
  1960. when OptionTabsString='WARNINGS' then
  1961. TabsMode='display warnings'
  1962. when OptionTabsString='IGNORE' then
  1963. TabsMode='ignore tabs, leave in place'
  1964. when OptionTabsString='TOSPACES' then
  1965. TabsMode='converting each tab to one space'
  1966. otherwise
  1967. CryAndDie('Invalid TABS option of "' || OptionTabsString || '"')
  1968. end
  1969. call TABS_DEBUG
  1970. return
  1971.  
  1972. TABS_GET:
  1973. call TABS_DEBUG
  1974. return(OptionTabsString)
  1975.  
  1976. Tabs_12:
  1977. SrTypePre=d2c(254)||d2c(174)
  1978. SrTypeSuf=d2c(175)
  1979. call SrInit
  1980. signal SR_TYPE_13
  1981.  
  1982. SrInit:
  1983. SrCaseIns=SrTypePre|| 'CI' ||SrTypeSuf
  1984. SrCaseIns_P=length(SrCaseIns)+1
  1985. SrFixed=SrTypePre|| 'FiX' ||SrTypeSuf
  1986. SrFixed_P=length(SrFixed)+1
  1987. return
  1988.  
  1989. CompareReplaceFixed:call TRACE "OFF"
  1990.  
  1991. CompareReplaceFixed2:
  1992. sr_FromOrig=arg(1)
  1993. sr_SSpec=arg(2)
  1994. sr_CaseInSens='N'
  1995. sr_From=sr_FromOrig
  1996. sr_From_L=length(sr_From)
  1997. if arg(3, 'E')=1 then
  1998. sr_NoMatch=sr_From
  1999. else
  2000. sr_NoMatch=0
  2001. do while sr_SSpec<> ''
  2002. parse var sr_SSpec sr_CmdChar +1 sr_SSpec
  2003. select
  2004. when sr_CmdChar='@' then
  2005. do
  2006. parse var sr_SSpec sr_Operator ',' sr_Posn '=' +1 sr_Delim +1 sr_CompWith (sr_Delim) sr_SSpec
  2007. sr_Length=length(sr_CompWith)
  2008. if datatype(sr_Posn, 'W')=0 then
  2009. CryAndDie("CompareReplaceFixed()", "The position must be a whole number, '" || sr_Posn || "' is invalid")
  2010. if sr_Posn<0 then
  2011. do
  2012. sr_Posn=sr_From_L+sr_Posn+1
  2013. if sr_Posn<1 then
  2014. return(sr_NoMatch)
  2015. end
  2016. if sr_CaseInSens='N' then
  2017. sr_bit=substr(sr_From,sr_Posn,sr_Length)
  2018. else
  2019. sr_bit=translate(substr(sr_From,sr_Posn,sr_Length))
  2020. select
  2021. when sr_Operator='=' then
  2022. srCompRc=sr_bit=sr_CompWith
  2023. when sr_Operator='<>' then
  2024. srCompRc=sr_bit<>sr_CompWith
  2025. when sr_Operator='==' then
  2026. srCompRc=sr_bit==sr_CompWith
  2027. when sr_Operator='\==' then
  2028. srCompRc=sr_bit\==sr_CompWith
  2029. when sr_Operator='<' then
  2030. srCompRc=sr_bit<sr_CompWith
  2031. when sr_Operator='>' then
  2032. srCompRc=sr_bit>sr_CompWith
  2033. when sr_Operator='<=' then
  2034. srCompRc=sr_bit<=sr_CompWith
  2035. when sr_Operator='>=' then
  2036. srCompRc=sr_bit>=sr_CompWith
  2037. otherwise
  2038. CryAndDie("CompareReplaceFixed()", "Unsupported operator of '" || sr_Operator || "' used", '', 'ONLY "=, <>, ==, \==, <, >, <=, >=" are supported!')
  2039. end
  2040. if srCompRc=0 then
  2041. return(sr_NoMatch)
  2042. end
  2043. when sr_CmdChar='!' then
  2044. do
  2045. parse var sr_SSpec sr_CmdChar2 +1 sr_SSpec
  2046. select
  2047. when sr_CmdChar2='B' | sr_CmdChar2 = 'L' | sr_CmdChar2 = 'T' then
  2048. do
  2049. sr_From=strip(sr_From,sr_CmdChar2)
  2050. sr_From_L=length(sr_From)
  2051. end
  2052. when sr_CmdChar2='I' then
  2053. do
  2054. sr_From=space(sr_From)
  2055. sr_From_L=length(sr_From)
  2056. end
  2057. when sr_CmdChar2='S' then
  2058. sr_CaseInSens='N'
  2059. when sr_CmdChar2='i' then
  2060. sr_CaseInSens='Y'
  2061. otherwise
  2062. CryAndDie("CompareReplaceFixed()", 'Invalid "!" command of "' || sr_CmdChar2 || '"')
  2063. end
  2064. end
  2065. when sr_CmdChar='?' then
  2066. do
  2067. parse var sr_SSpec sr_Operator +1 sr_Delim +1 sr_LookFor (sr_Delim) sr_SSpec
  2068. if sr_CaseInSens='N' then
  2069. sr_Pos=pos(sr_LookFor,sr_From)
  2070. else
  2071. sr_Pos=pos(sr_LookFor,translate(sr_From))
  2072. if sr_Operator='=' then
  2073. do
  2074. if sr_Pos=0 then
  2075. return(sr_NoMatch)
  2076. end
  2077. else
  2078. do
  2079. if sr_Pos<>0 then
  2080. return(sr_NoMatch)
  2081. end
  2082. end
  2083. otherwise
  2084. CryAndDie("CompareReplaceFixed()", 'Invalid compare command of "' || sr_CmdChar || '"')
  2085. end
  2086. end
  2087. if arg(3, 'O')=1 then
  2088. return(1)
  2089. sr_RSpec=arg(3)
  2090. ReplaceCount=ReplaceCount+1
  2091. sr_From=sr_FromOrig
  2092. sr_From_L=length(sr_From)
  2093. sr_output=''
  2094. do forever
  2095. parse var sr_RSpec sr_Before '@' sr_RSpec
  2096. sr_Output = sr_Output || sr_Before
  2097. if sr_RSpec=='' then
  2098. return(sr_Output)
  2099. parse var sr_RSpec sr_CmdChar +1 sr_RSpec
  2100. select
  2101. when sr_CmdChar='$' then
  2102. do
  2103. parse var sr_RSpec sr_Posn ',' sr_Length ';' sr_RSpec
  2104. if sr_Posn<0 then
  2105. do
  2106. sr_Posn=sr_From_L+sr_Posn+1
  2107. if sr_Posn<1 then
  2108. return(sr_From)
  2109. end
  2110. if sr_Length='*' then
  2111. sr_Output=sr_Output||substr(sr_From,sr_Posn)
  2112. else
  2113. sr_Output=sr_Output||substr(sr_From,sr_Posn,sr_Length)
  2114. end
  2115. when sr_CmdChar='=' then
  2116. do
  2117. parse var sr_RSpec sr_Delim +1 sr_Exec (sr_Delim) sr_RSpec
  2118. CompareString=sr_From
  2119. call ExecRexxCmd('sr_Output = sr_Output || ' ||sr_Exec)
  2120. end
  2121. when sr_CmdChar='@' then
  2122. sr_Output=sr_Output|| '@'
  2123. otherwise
  2124. CryAndDie("CompareReplaceFixed()", 'Invalid replace command of "' || sr_CmdChar || '"')
  2125. end
  2126. end
  2127.  
  2128. SR_TYPE_13:
  2129. SpellDelChars=d2c(9)|| ',.=:;<>&-%()!/~' || '?#${}[]"'
  2130. SpellDictFileCount=0
  2131. SpellDelChangeCount=0
  2132. SpellingPrompts='N'
  2133. SpellShowEachError='N'
  2134. SpellingAddFile=''
  2135. SpellWordCount=0
  2136. SpellMistakeCount=0
  2137. SpellingAddCount=0
  2138. BadlySpellWordCount=0
  2139. CheckSpelling='N';
  2140. signal SPELLING_14
  2141.  
  2142. PrepareSpellingForThisBuild:
  2143. if OptionCompleteAddToToDepFile='Y' then
  2144. do
  2145. do DictIndex=1 to SpellDictFileCount
  2146. call AddInputFileToDependancyList SpellDictFile.DictIndex,SpellDictTime.DictIndex
  2147. end
  2148. end
  2149. Drop ?BADWORDEB.
  2150. return
  2151.  
  2152. LoadSpellingDictionary:
  2153. DictFileS=arg(1)
  2154. call DBG_SPELLING 'User wants the dictionary "' || DictFileS || '"'
  2155. DictFile=FindFile(DictFileS, 'dictionary')
  2156. call DBG_SPELLING 'Loading "' || DictFile || '"'
  2157. SpellDictFileCount=SpellDictFileCount+1
  2158. SpellDictFile.SpellDictFileCount=DictFile
  2159. SpellDictTime.SpellDictFileCount=GetFileDateTimeButDontWarnOnError(DictFile)
  2160. call FileClose DictFile, 'N'
  2161. do while lines(DictFile)<>0
  2162. ThisWord=translate(strip(linein(DictFile)))
  2163. if ThisWord='' then
  2164. iterate
  2165. if left(ThisWord,1)=';' then
  2166. iterate
  2167. if left(ThisWord,1)<> '$' then
  2168. do
  2169. SpellWordCount=SpellWordCount+1
  2170. call _valueS '?SPELLDICT.?' || c2x(ThisWord), ''
  2171. end
  2172. else
  2173. do
  2174. parse var ThisWord DictCmd Rest
  2175. select
  2176. when DictCmd='$MISTAKE' then
  2177. do
  2178. parse var Rest SpeltWrong SpeltCorrectly .
  2179. SpellMistakeCount=SpellMistakeCount+1
  2180. call _valueS '?SPELLERR.?' ||c2x(SpeltWrong),SpeltCorrectly
  2181. end
  2182. when DictCmd='$DELIMITERS' then
  2183. do
  2184. call DBG_SPELLING 'Dictionary is changing spelling delimiters'
  2185. SpellDelChangeCount=SpellDelChangeCount+1
  2186. if SpellDelChangeCount>1 then
  2187. call OutputWarningToScreen 'SPL9', 'Spell check delimiters already modified!'
  2188. call ExecRexxCmd "SpellDelChars = " ||strip(Rest)
  2189. end
  2190. otherwise
  2191. do
  2192. SpellWordCount=SpellWordCount+1
  2193. call _valueS '?SPELLDICT.?' || c2x(ThisWord), ''
  2194. end
  2195. end
  2196. end
  2197. end
  2198. call FileClose DictFile
  2199. call DBG_SPELLING 'Now have ' || AddCommasToDecimalNumber(SpellWordCount) || ' word(s) in dictionary and ' || AddCommasToDecimalNumber(SpellMistakeCount) || ' common mistakes noted!'
  2200. CheckSpelling='Y';
  2201. return
  2202.  
  2203. SpellCheckOneLine:
  2204. SpellLine=space(arg(1))
  2205. if 1=1 then
  2206. do
  2207. RightBit=SpellLine
  2208. SpellLine=''
  2209. StartPos=pos('<',RightBit)
  2210. do while StartPos<>0
  2211. EndPos=pos('>',RightBit,StartPos+1)
  2212. if EndPos=0 then
  2213. EndPos=StartPos
  2214. SpellLine=SpellLine||left(RightBit,StartPos-1)|| ' '
  2215. RightBit=substr(RightBit,EndPos+1)
  2216. StartPos=pos('<',RightBit)
  2217. end
  2218. SpellLine=SpellLine||RightBit
  2219. if SpellLine='' then
  2220. return
  2221. end
  2222. SpellLine=translate(translate(SpellLine), '', SpellDelChars, ' ')
  2223. do WordIndex=1 to words(SpellLine)
  2224. ThisWord=Word(SpellLine,WordIndex)
  2225. if left(ThisWord,1)="'" then
  2226. ThisWord=substr(ThisWord,2)
  2227. if right(ThisWord,1)="'" then
  2228. ThisWord=left(ThisWord,length(ThisWord)-1)
  2229. if length(ThisWord)>100 then
  2230. do
  2231. if OptionDebugOn='Y' then
  2232. call DBG_SPELLING 'Word too big to safely handle "' || ThisWord || '"'
  2233. iterate
  2234. end
  2235. ThisWordC2X=c2x(ThisWord)
  2236. if SpellMistakeCount<>0 then
  2237. do
  2238. MistakeId='?SPELLERR.?' ||ThisWordC2X
  2239. if symbol(MistakeId)='VAR' then
  2240. do
  2241. if SpellShowEachError='Y' then
  2242. ShowThisError='Y'
  2243. else
  2244. do
  2245. DuplicatedId='?BADWORDEB.?' ||ThisWordC2X
  2246. if symbol(DuplicatedId)='VAR' then
  2247. ShowThisError='N'
  2248. else
  2249. do
  2250. ShowThisError='Y'
  2251. call _valueS DuplicatedId, ''
  2252. end
  2253. end
  2254. if ShowThisError='Y' then
  2255. do
  2256. CorrectWord=_valueG(MistakeId)
  2257. if CorrectWord='' then
  2258. call OutputWarningToScreen 'SPL0', 'Common Mistake: ' ||ThisWord
  2259. else
  2260. call OutputWarningToScreen 'SPL0', 'Common Mistake: ' || ThisWord || ' (use "' || CorrectWord || '" instead)'
  2261. end
  2262. iterate
  2263. end
  2264. end
  2265. if SpellWordCount=0&SpellingPrompts='N' then
  2266. iterate
  2267. ValidId='?SPELLDICT.?' ||ThisWordC2X
  2268. if symbol(ValidId)<> 'VAR' then
  2269. do
  2270. if datatype(ThisWord)<> 'NUM' then
  2271. do
  2272. WordWarningId=''
  2273. WordWarningMsg=''
  2274. if SpellingPrompts<> 'N' then
  2275. do
  2276. DuplicatedId='?BADWORDPI.?' ||ThisWordC2X
  2277. if symbol(DuplicatedId)='VAR' then
  2278. do
  2279. BadIndex=_valueG(DuplicatedId)
  2280. if BadIndex<> '' then
  2281. do
  2282. WordWarningId='SPL1'
  2283. WordWarningMsg='Added "' || ThisWord || '" to "' || SpellingAddFile || '"'
  2284. SpellingAddOccurs.BadIndex=SpellingAddOccurs.BadIndex+1
  2285. end
  2286. end
  2287. else
  2288. do
  2289. DuplicatedIdValue=''
  2290. if SpellingAddFile<> '' & SpellingPrompts <> 'N' then
  2291. do
  2292. if SpellingPrompts='OK' then
  2293. UserResp='Y'
  2294. else
  2295. do
  2296. do until UserResp='Y' | UserResp = 'N' | UserResp = 'Q' | UserResp = 'A'
  2297. call ColorSet 'PromptText'
  2298. call charout,ThisWord|| ' <- OK (Yes/yes All/No/Quit asking)?'
  2299. call ColorSet
  2300. UserResp=translate(left(linein(),1))
  2301. end
  2302. end
  2303. if UserResp='A' then
  2304. do
  2305. SpellingPrompts='OK'
  2306. UserResp='Y'
  2307. end
  2308. if UserResp='Y' then
  2309. do
  2310. SpellingAddCount=SpellingAddCount+1
  2311. DuplicatedIdValue=SpellingAddCount
  2312. SpellingAddWord.SpellingAddCount=ThisWord
  2313. SpellingAddOccurs.SpellingAddCount=1
  2314. if SpellingPrompts='OK' then
  2315. do
  2316. WordWarningId='SPL1'
  2317. WordWarningMsg='Added "' || ThisWord || '" to "' || SpellingAddFile || '"'
  2318. end
  2319. end
  2320. else
  2321. do
  2322. if UserResp='Q' then
  2323. SpellingPrompts='N'
  2324. end
  2325. end
  2326. BadlySpellWordCount=BadlySpellWordCount+1
  2327. call _valueS DuplicatedId,DuplicatedIdValue
  2328. end
  2329. end
  2330. if SpellShowEachError='Y' then
  2331. ShowThisError='Y'
  2332. else
  2333. do
  2334. DuplicatedId='?BADWORDEB.?' ||ThisWordC2X
  2335. if symbol(DuplicatedId)='VAR' then
  2336. ShowThisError='N'
  2337. else
  2338. do
  2339. ShowThisError='Y'
  2340. call _valueS DuplicatedId, ''
  2341. end
  2342. end
  2343. if ShowThisError='Y' then
  2344. do
  2345. if WordWarningId='' then
  2346. do
  2347. WordWarningId='SPL1'
  2348. WordWarningMsg='Spelling? : ' ||ThisWord
  2349. end
  2350. call OutputWarningToScreen WordWarningId,WordWarningMsg
  2351. end
  2352. end
  2353. end
  2354. end
  2355. return
  2356.  
  2357. OutputAnySpellingAdditions:
  2358. if SpellingAddCount=0 then
  2359. return
  2360. call DBG_SPELLING 'Adding spelling words to file "' || SpellingAddFile || '"'
  2361. call DBGIND 1
  2362. if MacroExists("PPWIZARD_DONT_SORT_ADD_WORDS") = 'N' then
  2363. do
  2364. call DBG_SPELLING 'Sorting ' || SpellingAddCount || ' "bad" word(s) by number of occurences!'
  2365. SpellingAddWord.0=SpellingAddCount
  2366. SpellingAddOccurs.0=SpellingAddCount
  2367. SrtM=1
  2368. SrtCount=SpellingAddOccurs.0
  2369. do while(9*SrtM+4)<SrtCount
  2370. SrtM=SrtM*3+1
  2371. end
  2372. do while SrtM>0
  2373. SrtK=SrtCount-SrtM
  2374. do SrtJ=1 to SrtK
  2375. SrtIndex1=SrtJ
  2376. do while SrtIndex1>0
  2377. SrtIndex2=SrtIndex1+SrtM
  2378. SrtGreater=SpellingAddOccurs.SrtIndex1>SpellingAddOccurs.SrtIndex2
  2379. if SrtGreater then
  2380. do
  2381. SrtTemp=SpellingAddOccurs.SrtIndex1;SpellingAddOccurs.SrtIndex1=SpellingAddOccurs.SrtIndex2;SpellingAddOccurs.SrtIndex2=SrtTemp;SrtTemp=SpellingAddWord.SrtIndex1;SpellingAddWord.SrtIndex1=SpellingAddWord.SrtIndex2;SpellingAddWord.SrtIndex2=SrtTemp
  2382. end
  2383. else
  2384. leave
  2385. SrtIndex1=SrtIndex1-SrtM
  2386. end
  2387. end
  2388. SrtM=SrtM%3
  2389. end
  2390. call ArrayReverse "SpellingAddWord"
  2391. call ArrayReverse "SpellingAddOccurs"
  2392. end
  2393. call FileClose SpellingAddFile, 'N'
  2394. if FileQueryExists(SpellingAddFile)<> "" then
  2395. do
  2396. call DBG_SPELLING 'Deleting existing "' || SpellingAddFile || '"'
  2397. call MustDeleteFile SpellingAddFile
  2398. end
  2399. call DBG_SPELLING 'Writing words to file'
  2400. call DBGIND 1
  2401. do WordIndex=1 to SpellingAddCount
  2402. call lineout SpellingAddFile,SpellingAddWord.WordIndex
  2403. if OptionDebugOn='Y' then
  2404. call DBG_SPELLING 'The word "' || SpellingAddWord.WordIndex || '" occured ' || SpellingAddOccurs.WordIndex || ' time(s).'
  2405. end
  2406. call DBGIND-1
  2407. call FileClose SpellingAddFile
  2408. call OutputInformationToScreen AddCommasToDecimalNumber(SpellingAddCount)|| ' word(s) added to "' || SpellingAddFile || '"'
  2409. call DBGIND-1
  2410. return
  2411.  
  2412. SPELLING_14:
  2413. OptionDebugOn='N'
  2414. OptionMaxCol=500
  2415. OptionDebugTime='*'
  2416. call DBGINDInit
  2417. signal Debug_15
  2418.  
  2419. DebugInc:call TRACE "OFF"
  2420. call DBGIND 1
  2421. return
  2422.  
  2423. DebugDec:call TRACE "OFF"
  2424. call DBGIND-1
  2425. return
  2426.  
  2427. DebugOn:call TRACE "OFF"
  2428. call _DebugOnOff 'Y'
  2429. return
  2430.  
  2431. DebugOff:call TRACE "OFF"
  2432. call _DebugOnOff 'N'
  2433. return
  2434.  
  2435. _DebugOnOff:
  2436. if DebugSwitchUsed='Y' then
  2437. call DBG 'Command ignored as "/debug" used'
  2438. else
  2439. do
  2440. OptionDebugOn=arg(1)
  2441. call DebugStateChanged
  2442. end
  2443. return
  2444.  
  2445. DebugIndent:call TRACE "OFF"
  2446.  
  2447. DBGIND:
  2448. DebugIndent=DebugIndent+(arg(1)*2)
  2449. if DebugIndent<0 then
  2450. DebugIndent=0
  2451. return
  2452.  
  2453. Debug:call TRACE "OFF"
  2454.  
  2455. DBG:
  2456. if OptionDebugOn='N' then
  2457. return
  2458.  
  2459. DBG2:
  2460. if arg(1)='' then
  2461. call _DBG1 ''
  2462. else
  2463. call _DBG1 _DebugPrefix()|| '         >' ||translate(arg(1),DebugNewline,MarksNewLine)
  2464. return
  2465.  
  2466. _DebugPrefix:
  2467. if OptionDebugTime='' then
  2468. v!T=''
  2469. else
  2470. do
  2471. if OptionDebugTime="*" then
  2472. v!T=trunc(time('E'),3)
  2473. else
  2474. v!T=time(OptionDebugTime)
  2475. v!T='[' || v!T || ']'
  2476. end
  2477. return(v!T||copies("  ",IncludeLevel+DebugIndent))
  2478.  
  2479. YorN2OnorOff:
  2480. if arg(1)='Y' then
  2481. return('ON')
  2482. else
  2483. return('OFF')
  2484.  
  2485. DebugShowCurrentLineWithLineNumber:
  2486. if OptionDebugOn='Y' then
  2487. do
  2488. FmtLineNum=IncludeLineNumber
  2489. if length(FmtLineNum)<4 then
  2490. FmtLineNum=right(FmtLineNum,4, '0')
  2491. if arg(2)<> '' then
  2492. FmtLineNum=left(arg(2),length(FmtLineNum))
  2493. if IncludeMemHandle='' then
  2494. FmtLineNum='{' || DebugCurrentFileNumber || '}' ||FmtLineNum
  2495. else
  2496. FmtLineNum='[' || DebugCurrentFileNumber || ']' ||FmtLineNum
  2497. select
  2498. when AsIsModeOn='Y' & AutoTagOn = 'Y' then
  2499. DebugSym='> '
  2500. when AsIsModeOn='Y' then
  2501. DebugSym='} '
  2502. when AutoTagOn='Y' then
  2503. DebugSym=') '
  2504. otherwise
  2505. DebugSym=': '
  2506. end
  2507. if arg(1)=='' then
  2508. call _DBG1 _DebugPrefix()||FmtLineNum||DebugSym
  2509. else
  2510. call _DBG1 _DebugPrefix()||FmtLineNum||DebugSym||DebugRightArrow||translate(arg(1),DebugNewline,MarksNewLine)||DebugLeftArrow
  2511. end
  2512. return
  2513.  
  2514. DebugShowLineDropped:
  2515. if OptionDebugOn='Y' then
  2516. do
  2517. call _DBG1 _DebugPrefix()||left(arg(1),length(FmtLineNum), ' ') || '-'
  2518. end
  2519. return
  2520.  
  2521. DebugGetEnv:
  2522. if OptionDebugOn='Y' then
  2523. call DBG 'GetEnv(): "' || arg(1) || '" = ' ||DebugRightArrow||arg(2)||DebugLeftArrow
  2524. return
  2525.  
  2526. DebugWarning:
  2527. if OptionDebugOn='N' then
  2528. return
  2529. DbgWarning='!!! ' || arg(1) || ' !!!'
  2530. DbgLine=copies('!',length(DbgWarning))
  2531. call DBG2 ''
  2532. call DBG2 left('!!!![ DEBUG WARNING ]', length(DbgWarning), '!')
  2533. call DBG2 DbgWarning
  2534. call DBG2 left('', length(DbgWarning), '!')
  2535. call DBG2 ''
  2536. return
  2537.  
  2538. DebugOutputVariableInfo:
  2539. if OptionDebugOn='Y' then
  2540. call DBG2 '? ' ||translate(arg(1),DebugNewline,MarksNewLine)
  2541. return
  2542.  
  2543. DBGINDInit:
  2544. DebugIndent=0
  2545. return
  2546.  
  2547. DebugGetOpSysText:
  2548. if PpWizardOpSys=PpWizardOpSysREAL then
  2549. return(PpWizardOpSys)
  2550. else
  2551. return(PpWizardOpSys|| ' ("' || PpWizardOpSysREAL || '")')
  2552.  
  2553. DebugStateChanged:
  2554. if OptionDebugOn='Y' then
  2555. do
  2556. call DisplayCopyright
  2557. if DebugOnStuffOutputted='N' then
  2558. do
  2559. call _DBG1 ''
  2560. call _DBG1 ''
  2561. call _DBG1 'BRIEF INTRO TO DEBUG OUTPUT'
  2562. call _DBG1 '~~~~~~~~~~~~~~~~~~~~~~~~~~~'
  2563. call _DBG1 'Indenting of debug text represents logic "nesting", the format'
  2564. call _DBG1 'of a line read from file is explained below:'
  2565. call _DBG1 ''
  2566. call _DBG1 '[0.050]  {1}0006: #define Fred Value'
  2567. call _DBG1 '-------  ~~~----  ------------------'
  2568. call _DBG1 '   ^      ^  ^            ^'
  2569. call _DBG1 '   |      |  |            + The line(s)'
  2570. call _DBG1 '   |      |  |'
  2571. call _DBG1 '   |      |  +-- <<#{   = Line came from memory buffer only used for "<<ML" lines'
  2572. call _DBG1 '   |      |  +-- <<ML   = Line came from #{ defined within a macro'
  2573. call _DBG1 '   |      |  +-- <<<<   = Line came from memory buffer (macro, line continuation etc - Imbedded newlines IGNORED)'
  2574. call _DBG1 '   |      |  +-- >>>>   = Writing buffered line to output'
  2575. call _DBG1 '   |      |  +-- <<FL   = Line came from #{ defined in a file'
  2576. call _DBG1 '   |      |  +-- Number = Number of line just read from file'
  2577. call _DBG1 '   |      |'
  2578. call _DBG1 '   |      +-- The number is a unique number to represent a file inclusion'
  2579. call _DBG1 '   |          {file#} means file is being read from disk'
  2580. call _DBG1 '   |          [file#] means file is being read from cached memory'
  2581. call _DBG1 '   |          Indenting represents #include level'
  2582. call _DBG1 '   |'
  2583. call _DBG1 '   +- Time in your preferred format (defaults to elapsed - See /DebugTime)'
  2584. call _DBG1 ''
  2585. call _DBG1 'Note that the #OPTION "DebugLevel" command can be used to reduce the'
  2586. call _DBG1 'information generated!'
  2587. call _DBG1 ''
  2588. call _DBG1 'Never use the rexx say command to display output! Use the PPWIZARD'
  2589. call _DBG1 '"say()" function instead to ensure that the output is included in any'
  2590. call _DBG1 'PPWIZARD output.'
  2591. call _DBG1 'There are MANY rexx debugging options, including tracing, interactive debugging'
  2592. call _DBG1 'and break points. The #DefineRexx command will so cause rexx code variables to be dumped.'
  2593. call _DBG1 ''
  2594. call _DBG1 ''
  2595. call _DBG1 ''
  2596. SourceTime=_FileQueryDateTime(PpWizardPgmName)
  2597. call DBG 'Debug Header'
  2598. call DBG '~~~~~~~~~~~~'
  2599. call DBGIND 1
  2600. call DBG 'Started@: "' || PpwCompTime        || '"'
  2601. call DBG 'Program : "' || PpWizardPgmName    || '" (' || SourceTime || ')'
  2602. call DBG 'OptionE : "' || OptionsEnvironment || '"'
  2603. call DBG 'OptionC : "' || OptionsCmdLine     || '"'
  2604. call DBG 'Src Type: "' || ProcessingMode     || '"'
  2605. call DBG 'OpSystem: "' ||DebugGetOpSysText()
  2606. call DBG 'Rexx Ver: "' || RexVersionInfo     || '"'
  2607. call DBG 'Mode    : "' || RexWhich           || '"'
  2608. if RexWhich='REGINA' then
  2609. call DBG 'uname() : "' || uname()        || '"'
  2610. if OptionFilterIn<> '' then
  2611. call DBG 'Filter I: ' || FunctionFilterIn || '(' || InputInterfaceVer || ')'
  2612. if OptionFilterOut<> '' then
  2613. call DBG 'Filter O: "' || OptionFilterOut   || '" (interface version ' || OutputInterfaceVer || ')'
  2614. DebugOnStuffOutputted='Y'
  2615. call DBGIND-1
  2616. end
  2617. end
  2618. call SetEnv "PPWIZARD_DEBUG",OptionDebugOn
  2619. return
  2620.  
  2621. ProcessHashDebug:
  2622. if DebugSwitchUsed='Y' then
  2623. call DBG 'Command ignored as "/debug" used'
  2624. else
  2625. do
  2626. ReturnRc=SetOnorOffVariable(arg(1), 'OptionDebugOn')
  2627. call DebugStateChanged
  2628. end
  2629. return(0)
  2630.  
  2631. DebugShowAsMuchEnvironmentDetailAsPossible:
  2632. if OptionDebugOn='N' then
  2633. return
  2634. call DBG 'Dumping Environmental Info'
  2635. TmpSetFile=RexGetTmpFileName()
  2636. RedirBit=RedirectStdOutAndErr2(TmpSetFile)
  2637. call _EnvAddCmd 'set'
  2638. if RexSystemOpSys<> "UNIX" then
  2639. do
  2640. select
  2641. when RexSystemOpSys="OS/2"  then VerCmd = 'VER /R'
  2642. otherwise VerCmd='VER'
  2643. end
  2644. call _EnvAddCmd VerCmd
  2645. end
  2646. if RexSystemOpSys<> "UNIX" then
  2647. call _SysFileDelete TmpSetFile
  2648. return
  2649.  
  2650. _EnvAddCmd:
  2651. call AddressCmd arg(1)||RedirBit,TmpSetFile
  2652. if RexSystemOpSys="UNIX" then
  2653. call _SysFileDelete TmpSetFile
  2654. return
  2655.  
  2656. _DBG1:
  2657. w!Line=arg(1)
  2658. if OptionMaxCol=0 then
  2659. call Line1 w!Line
  2660. else
  2661. do
  2662. if length(w!Line)<=OptionMaxCol then
  2663. call Line1 w!Line
  2664. else
  2665. call Line1 left(w!Line,OptionMaxCol)|| ' <-[' || OptionMaxCol || ']'
  2666. end
  2667. return
  2668.  
  2669. _SetDebugChar:
  2670. x!Var=arg(1)
  2671. x!CurValVar=arg(2)
  2672. parse value strip(value(x!Var)) with x!Val ',' x!Rest
  2673. call value x!Var,x!Rest
  2674. if x!Val=-1 then
  2675. x!NewVal=''
  2676. else
  2677. do
  2678. x!Val=strip(x!Val)
  2679. if x!Val='' then
  2680. x!NewVal=value(x!CurValVar)
  2681. else
  2682. do
  2683. if datatype(x!Val, 'W')then
  2684. x!NewVal=d2c(x!Val)
  2685. else
  2686. x!NewVal=x!Val
  2687. end
  2688. end
  2689. return(x!NewVal)
  2690.  
  2691. SetDebugChars:
  2692. y!Chars=arg(1)
  2693. y!MakDef=arg(2)
  2694. if y!Chars='' then
  2695. do
  2696. DebugLeftArrow=_DebugLeftArrow
  2697. DebugRightArrow=_DebugRightArrow
  2698. DebugNewline=_DebugNewline
  2699. end
  2700. else
  2701. do
  2702. DebugRightArrow=_SetDebugChar('y!Chars', 'DebugRightArrow')
  2703. DebugLeftArrow=_SetDebugChar('y!Chars', 'DebugLeftArrow' )
  2704. DebugNewline=_SetDebugChar('y!Chars', 'DebugNewline' )
  2705. end
  2706. if y!MakDef='Y' then
  2707. do
  2708. _DebugLeftArrow=DebugLeftArrow
  2709. _DebugRightArrow=DebugRightArrow
  2710. _DebugNewline=DebugNewline
  2711. end
  2712. call DBG 'New debug characters are "LEFT=' || DebugRightArrow || ', RIGHT=' || DebugLeftArrow || ', NL=' || DebugNewline || '"'
  2713. return
  2714.  
  2715. Debug_15:
  2716. DebugLevelCnt=0
  2717. SeeLevelAll=_SaveDebugLevel("ALL",           "FFFFFF")
  2718. SeeNone=_SaveDebugLevel("NONE",          "000000")
  2719. DummyUser1=_SaveDebugLevel("USER1",         "000001")
  2720. DummyUser2=_SaveDebugLevel("USER2",         "000002")
  2721. SeeLevelConditional=_SaveDebugLevel("CONDITIONAL",   "000004")
  2722. SeeFoundVar=_SaveDebugLevel("FOUNDVAR",      "000008")
  2723. SeeFoundVarParms=_SaveDebugLevel("FOUNDVARPARMS", "000010")
  2724. SeeFoundStdVar=_SaveDebugLevel("FOUNDSTDVAR",   "000020")
  2725. SeeAfterReplace=_SaveDebugLevel("AFTERREPLACE",  "000040")
  2726. SeeOptions=_SaveDebugLevel("OPTIONS",       "000080")
  2727. SeeOpSys=_SaveDebugLevel("OPSYS",         "000100")
  2728. SeeDefining=_SaveDebugLevel("DEFINING",      "000200")
  2729. SeeDefaultOrMacroValue=_SaveDebugLevel("MACROVALORDEF", "000400")
  2730. SeeAsIs=_SaveDebugLevel("ASIS",          "000800")
  2731. SeeAutoTag=_SaveDebugLevel("AUTOTAG",       "001000")
  2732. SeeRexxVar=_SaveDebugLevel("REXXVAR",       "002000")
  2733. SeeRexxTrace=_SaveDebugLevel("REXXTRACE",     "004000")
  2734. SeeInterpret=_SaveDebugLevel("INTERPRET",     "008000")
  2735. SeeEvaluate=_SaveDebugLevel("EVALUATE",      "010000")
  2736. SeeImport=_SaveDebugLevel("IMPORT",        "020000")
  2737. SeeSpelling=_SaveDebugLevel("SPELLING",      "040000")
  2738. SeeQuoting=_SaveDebugLevel("QUOTING",       "080000")
  2739. SeeImport=bitand(SeeImport,SeeDefaultOrMacroValue)
  2740. UserBitsOn=bitor(DummyUser1,DummyUser2)
  2741. DebugLevel=bitxor(SeeLevelAll,UserBitsOn)
  2742. DebugLevel=bitxor(DebugLevel,SeeQuoting)
  2743. SeeLevelDEFAULT=_SaveDebugLevel("DEFAULT",c2x(DebugLevel))
  2744. signal DebugOpt_16
  2745.  
  2746. IsDebugOn:call TRACE "OFF"
  2747. ido1=arg(1)
  2748. if ido1='' then
  2749. return(OptionDebugOn)
  2750. else
  2751. do
  2752. if OptionDebugOn='N' then
  2753. return(0)
  2754. else
  2755. do
  2756. idoUBits=bitand(DebugLevel,UserBitsOn)
  2757. idoUBits=bitand(idoUBits,x2c(right(ido1,6, '0')))
  2758. return(c2d(idoUBits))
  2759. end
  2760. end
  2761.  
  2762. DebugAddressCmdBefore:
  2763. if OptionDebugOn='Y' then
  2764. do
  2765. if bitand(DebugLevel,SeeOpSys)==SeeOpSys then
  2766. do
  2767. call DBGIND 1
  2768. call DBG 'Executing: ' ||arg(1)
  2769. call DBGIND-1
  2770. end
  2771. end
  2772. return
  2773.  
  2774. DebugAddressCmdOutput:
  2775. if OptionDebugOn='Y' then
  2776. do
  2777. if bitand(DebugLevel,SeeOpSys)==SeeOpSys then
  2778. do
  2779. call DBGIND 2
  2780. DbgLineNumber=arg(2)
  2781. if datatype(DbgLineNumber, 'W')=0 then
  2782. call DBG '> ' ||arg(1)
  2783. else
  2784. do
  2785. if DbgLineNumber<999 then
  2786. DbgLineNumber=right(DbgLineNumber,3, '0')
  2787. call DBG '> ' || DbgLineNumber || ': ' ||arg(1)
  2788. end
  2789. call DBGIND-2
  2790. end
  2791. end
  2792. return
  2793.  
  2794. DebugAddressCmdAfter:
  2795. if OptionDebugOn='Y' then
  2796. do
  2797. if bitand(DebugLevel,SeeOpSys)==SeeOpSys then
  2798. do
  2799. call DBGIND 2
  2800. call DBG '  Rc = ' ||arg(1)
  2801. call DBGIND-2
  2802. end
  2803. end
  2804. return
  2805.  
  2806. DebugOutputAfterReplacement:
  2807. if OptionDebugOn='N' then
  2808. return
  2809. if bitand(DebugLevel,SeeAfterReplace)==SeeAfterReplace then
  2810. call DBG2 arg(2)||DebugRightArrow||translate(arg(1),DebugNewline,MarksNewLine)||DebugLeftArrow
  2811. return
  2812.  
  2813. DBG_DEFINING:
  2814. if bitand(DebugLevel,SeeDefining)==SeeDefining then
  2815. call DBG arg(1)
  2816. return
  2817.  
  2818. DBG_ASIS:
  2819. if bitand(DebugLevel,SeeAsIs)==SeeAsIs then
  2820. call DBG arg(1)
  2821. return
  2822.  
  2823. DBG_REXXVAR:
  2824. if bitand(DebugLevel,SeeRexxVar)==SeeRexxVar then
  2825. call DBG arg(1)
  2826. return
  2827.  
  2828. DBG_INTERPRET:
  2829. if bitand(DebugLevel,SeeInterpret)==SeeInterpret then
  2830. call DBG arg(1)
  2831. return
  2832.  
  2833. DBG_EVALUATE:
  2834. if bitand(DebugLevel,SeeEvaluate)==SeeEvaluate then
  2835. call DBG arg(1)
  2836. return
  2837.  
  2838. DBG_SPELLING:
  2839. if bitand(DebugLevel,SeeSpelling)==SeeSpelling then
  2840. call DBG arg(1)
  2841. return
  2842.  
  2843. DBG_QUOTING:
  2844. if bitand(DebugLevel,SeeQuoting)==SeeQuoting then
  2845. call DBG arg(1)
  2846. return
  2847.  
  2848. DBG_IMPORT:
  2849. if bitand(DebugLevel,SeeImport)==SeeImport then
  2850. call DBG arg(1)
  2851. return
  2852.  
  2853. DBG_AUTOTAG:
  2854. if bitand(DebugLevel,SeeAutoTag)==SeeAutoTag then
  2855. call DBG arg(1)
  2856. return
  2857.  
  2858. DBG_MACROVALORDEF:
  2859. if bitand(DebugLevel,SeeDefaultOrMacroValue)==SeeDefaultOrMacroValue then
  2860. call DBG arg(1)
  2861. return
  2862.  
  2863. DBG_OPTIONS:
  2864. if bitand(DebugLevel,SeeOptions)==SeeOptions then
  2865. call DBG arg(1)
  2866. return
  2867.  
  2868. DBG_CONDITIONAL:
  2869. if bitand(DebugLevel,SeeLevelConditional)==SeeLevelConditional then
  2870. call DBG arg(1)
  2871. return
  2872.  
  2873. DebugOutputVariableInfo_FOUNDSTDVAR:
  2874. if bitand(DebugLevel,SeeFoundStdVar)==SeeFoundStdVar then
  2875. call DebugOutputVariableInfo arg(1)
  2876. return
  2877.  
  2878. DebugOutputVariableInfo_FOUNDVAR:
  2879. if bitand(DebugLevel,SeeFoundVar)==SeeFoundVar then
  2880. call DebugOutputVariableInfo arg(1)
  2881. return
  2882.  
  2883. DebugOutputVariableInfo_FOUNDVARPARMS:
  2884. if bitand(DebugLevel,SeeFoundVarParms)==SeeFoundVarParms then
  2885. call DebugOutputVariableInfo arg(1)
  2886. return
  2887.  
  2888. DebugOutputVariableInfo_FOUNDSTDVAR:
  2889. if bitand(DebugLevel,SeeFoundVar)==SeeFoundVar then
  2890. call DebugOutputVariableInfo arg(1)
  2891. return
  2892.  
  2893. _SaveDebugLevel:
  2894. DebugLevelCnt=DebugLevelCnt+1
  2895. DebugLevelNme.DebugLevelCnt=translate(arg(1))
  2896. DebugLevelVal.DebugLevelCnt=arg(2)
  2897. return(x2c(arg(2)))
  2898.  
  2899. GetDebugLevel:
  2900. WantedName=translate(arg(1))
  2901. do DbgIndex=1 to DebugLevelCnt
  2902. if WantedName=DebugLevelNme.DbgIndex then
  2903. return(DebugLevelVal.DbgIndex)
  2904. end
  2905. return('')
  2906.  
  2907. _WorkOutDebugLevelText:
  2908. DbgLvlTxt="ALL"
  2909. do DbgIndex=1 to DebugLevelCnt
  2910. if bitand(DebugLevel,x2c(DebugLevelVal.DbgIndex))=SeeNone then
  2911. DbgLvlTxt=DbgLvlTxt|| ',-' ||DebugLevelNme.DbgIndex
  2912. end
  2913. return(DbgLvlTxt)
  2914.  
  2915. DEBUGLEVEL_DEBUG:
  2916. if OptionDebugOn='Y' then
  2917. call OptionDebugShow 'DEBUGLEVEL', 'Debug level (when on) is ' ||_WorkOutDebugLevelText()
  2918. return
  2919.  
  2920. DEBUGLEVEL_GET:
  2921. call DEBUGLEVEL_DEBUG
  2922. return(_WorkOutDebugLevelText())
  2923.  
  2924. DEBUGLEVEL_SET:
  2925. DebugCmdsIn=arg(1)
  2926. DebugCmds=DebugCmdsIn
  2927. do while DebugCmds<> ''
  2928. parse var DebugCmds OneDebugOpt','DebugCmds
  2929. OptionAction=left(OneDebugOpt,1)
  2930. if OptionAction='+' then
  2931. OneDebugOpt=substr(OneDebugOpt,2)
  2932. else
  2933. do
  2934. if OptionAction='-' then
  2935. OneDebugOpt=substr(OneDebugOpt,2)
  2936. else
  2937. OptionAction='='
  2938. end
  2939. OptionBinary=x2c(GetDebugLevel(OneDebugOpt))
  2940. if OptionBinary='' then
  2941. CryAndDie('Invalid debug option of "' || OneDebugOpt || '"')
  2942. if OptionAction='=' then
  2943. DebugLevel=OptionBinary
  2944. else
  2945. do
  2946. if OptionAction='+' then
  2947. DebugLevel=bitor(DebugLevel,OptionBinary)
  2948. else
  2949. DebugLevel=bitxor(DebugLevel,OptionBinary)
  2950. end
  2951. end
  2952. if ProcessedCmdLine='N' then
  2953. do
  2954. call OptionDebugShow 'DEBUGLEVEL', 'Setting default value of debug level to "' || _WorkOutDebugLevelText() || '"'
  2955. Default4_DebugLevel=DebugLevel
  2956. return(0)
  2957. end
  2958. if DebugCmdsIn='' then
  2959. DebugLevel=Default4_DebugLevel
  2960. call DEBUGLEVEL_DEBUG
  2961. return
  2962.  
  2963. DebugOpt_16:
  2964. OptionCgiModeOn='N'
  2965. CgiOutputFile=''
  2966. CgiFatalError='N'
  2967. signal CGI_17
  2968.  
  2969. InitConsoleOutputVarsPass1:
  2970. ConsoleFile=''
  2971. OutputToConsoleLog='N'
  2972. OutputToErrorLog='N'
  2973. ConsoleErrorFile='PPWIZARD.ERR'
  2974. TruncateDefaultErrorFile='Y'
  2975. return
  2976.  
  2977. InitConsoleOutputVarsPass2:
  2978. call UserIsSpecifyingConsoleFileName GetEnv("PPWIZARD_CONSOLEFILE")
  2979. call UserIsSpecifyingErrorFileName GetEnv("PPWIZARD_ERRORFILE")
  2980. if ConsoleErrorFile='' then
  2981. ConsoleErrorFile='PPWIZARD.ERR'
  2982. return
  2983.  
  2984. ConsoleWriteAllowed:
  2985. _ConsoleWriteAllowed=translate(arg(1))
  2986. return
  2987.  
  2988. UserIsSpecifyingErrorFileName:
  2989. ConsoleErrorFile=arg(1)
  2990. if ConsoleErrorFile<> '' then
  2991. do
  2992. if left(ConsoleErrorFile,1)='+' then
  2993. do
  2994. ConsoleErrorFile=substr(ConsoleErrorFile,2)
  2995. TruncateDefaultErrorFile='N'
  2996. end
  2997. else
  2998. do
  2999. TruncateDefaultErrorFile='Y'
  3000. end
  3001. end
  3002. return
  3003.  
  3004. UserIsSpecifyingConsoleFileName:
  3005. z!ConFile=arg(1)
  3006. z!CopyFrom=''
  3007. if OutputToConsoleLog='Y' then
  3008. do
  3009. if left(z!ConFile,1)='+' then
  3010. z!New=substr(z!ConFile,2)
  3011. else
  3012. z!New=z!ConFile
  3013. if translate(ConsoleFile)<>translate(z!New)then
  3014. z!CopyFrom=ConsoleFile
  3015. else
  3016. z!ConFile='+' ||z!New
  3017. end
  3018. if ConsoleFile<> '' then
  3019. do
  3020. call _FileClose ConsoleFile
  3021. ConsoleFile=''
  3022. end
  3023. if z!ConFile<> '' then
  3024. do
  3025. if left(z!ConFile,1)='+' then
  3026. do
  3027. z!ConFile=substr(z!ConFile,2)
  3028. end
  3029. else
  3030. do
  3031. call MustDeleteFile z!ConFile
  3032. end
  3033. end
  3034. if z!ConFile='' then
  3035. OutputToConsoleLog='N'
  3036. else
  3037. do
  3038. call MakeDirectoryTree _filespec('Location',z!ConFile)
  3039. OutputToConsoleLog='y'
  3040. ConsoleFile=z!ConFile
  3041. if z!CopyFrom<> '' then
  3042. do
  3043. do while lines(z!CopyFrom)<>0
  3044. call _Lne2CFle linein(z!CopyFrom)
  3045. end
  3046. call lineout z!CopyFrom, ''
  3047. call lineout z!CopyFrom, 'See "' || ConsoleFile || '" for more console output...'
  3048. call _FileClose z!CopyFrom
  3049. call _Lne2CFle ''
  3050. call _Lne2CFle ''
  3051. call _Lne2CFle copies('*+',38)
  3052. call _Lne2CFle strip(PadString('above copied from "' || z!CopyFrom || '"', 78, 'C'), 'T')
  3053. call _Lne2CFle strip(PadString(TheTime,78, 'C'), 'T')
  3054. call _Lne2CFle copies('*+',38)
  3055. call _Lne2CFle ''
  3056. OutputToConsoleLog='Y'
  3057. end
  3058. end
  3059. return
  3060.  
  3061. AllFollowingOutputGoesToErrorFile:
  3062. call ConsoleWriteAllowed 'Y'
  3063. if ConsoleErrorFile='' then
  3064. return
  3065. if TruncateDefaultErrorFile='Y' then
  3066. do
  3067. TruncateDefaultErrorFile='N'
  3068. call MustDeleteFile ConsoleErrorFile
  3069. end
  3070. call MakeDirectoryTree _filespec('Location',ConsoleErrorFile)
  3071. TheTime=NiceDateTime()
  3072. if symbol('InputFileFull') <> 'VAR' then
  3073. TheFile=''
  3074. else
  3075. TheFile=InputFileFull
  3076. OutputToErrorLog='Y'
  3077. call Say2ErrorFile ''
  3078. call Say2ErrorFile ''
  3079. call Say2ErrorFile copies('*+',38)
  3080. call Say2ErrorFile strip(PadString(TheFile,78, 'C'), 'T')
  3081. call Say2ErrorFile strip(PadString(TheTime,78, 'C'), 'T')
  3082. call Say2ErrorFile copies('*+',38)
  3083. call Say2ErrorFile ''
  3084. return
  3085.  
  3086. Say2ErrorFile:
  3087. if OutputToErrorLog='Y' then
  3088. do
  3089. ab!L=arg(1)
  3090. do until ab!L==''
  3091. parse var ab!L ab!Nxt (MarksNewLine) ab!L
  3092. call lineout ConsoleErrorFile,ab!Nxt
  3093. end
  3094. end
  3095. return
  3096.  
  3097. Char1ToErrorFile:
  3098. if OutputToErrorLog='Y' then
  3099. call charout ConsoleErrorFile,arg(1)
  3100. return
  3101.  
  3102. AddConsoleHdr:
  3103. OutputToConsoleLog='N' 
  3104. TheTime=NiceDateTime()
  3105. OutputToConsoleLog='Y' 
  3106. call _Lne2CFle ''
  3107. call _Lne2CFle ''
  3108. call _Lne2CFle copies('*+',38)
  3109. call _Lne2CFle strip(PadString(TheTime,78, 'C'), 'T')
  3110. call _Lne2CFle copies('*+',38)
  3111. call _Lne2CFle ''
  3112. return
  3113.  
  3114. _Lne2CFle:
  3115. if OutputToConsoleLog<> 'N' then
  3116. do
  3117. bb!L=arg(1)
  3118. do until bb!L==''
  3119. parse var bb!L bb!Nxt (MarksNewLine) bb!L
  3120. call lineout ConsoleFile,bb!Nxt
  3121. end
  3122. end
  3123. return
  3124.  
  3125. _Chr2CFle:
  3126. if OutputToConsoleLog<> 'N' then
  3127. call charout ConsoleFile,arg(1)
  3128. return
  3129.  
  3130. Say:call TRACE "OFF"
  3131.  
  3132. Line1:
  3133. parse arg cb!Short,cb!Long
  3134. if cb!Long='' then
  3135. cb!Long=cb!Short
  3136. if OptionCgiModeOn='N' then
  3137. do
  3138. if _ConsoleWriteAllowed='Y' then
  3139. say cb!Short
  3140. if OutputToErrorLog='Y' then
  3141. call Say2ErrorFile cb!Long
  3142. if OutputToConsoleLog<> 'N' then
  3143. do
  3144. if OutputToConsoleLog='y' then
  3145. call AddConsoleHdr
  3146. call _Lne2CFle cb!Long
  3147. end
  3148. end
  3149. else
  3150. do
  3151. if CgiOutputFile<> '' then
  3152. call lineout CgiOutputFile,cb!Short
  3153. if CgiFatalError='Y' then
  3154. say _MustSeeAsIsInHtmlViewer(cb!Short)
  3155. end
  3156. return
  3157.  
  3158. Chars:call TRACE "OFF"
  3159.  
  3160. Char1:
  3161. TheChar1=arg(1)
  3162. if OptionCgiModeOn='N' then
  3163. do
  3164. call charout,TheChar1
  3165. if OutputToErrorLog='Y' then
  3166. call Char1ToErrorFile TheChar1
  3167. if OutputToConsoleLog<> 'N' then
  3168. do
  3169. if OutputToConsoleLog='y' then
  3170. call AddConsoleHdr
  3171. call _Chr2CFle TheChar1
  3172. end
  3173. end
  3174. else
  3175. do
  3176. if CgiOutputFile<> '' then
  3177. call charout CgiOutputFile,TheChar1
  3178. if CgiFatalError='Y' then
  3179. call charout,_MustSeeAsIsInHtmlViewer(TheChar1)
  3180. end
  3181. return
  3182.  
  3183. DieIfCgiModeOn:
  3184. if OptionCgiModeOn='Y' then
  3185. call CryAndDie "This feature is not allowed in CGI mode"
  3186. return
  3187.  
  3188. TurnCgiModeOn:
  3189. OptionCgiModeOn='Y'
  3190. CgiOutputFile=ThisCmdOptions
  3191. if pos('?',CgiOutputFile)<>0 then
  3192. do
  3193. PartSecond=time('Long')
  3194. parse var PartSecond .'.'PartSecond
  3195. RandomBit=right(time('Seconds'), 5, '0')
  3196. RandomBit=RandomBit||left(strip(PartSecond),3)
  3197. RandomBit=RandomBit|| '.' || right( date('Days'), 3, '0')
  3198. CgiOutputFile=ReplaceString(CgiOutputFile, '?',RandomBit)
  3199. end
  3200. if CgiOutputFile<> '' then
  3201. do
  3202. if FileQueryExists(CgiOutputFile)<> '' then
  3203. do
  3204. call _FileClose CgiOutputFile
  3205. DeleteRc=_SysFileDelete(CgiOutputFile)
  3206. if DeleteRc<>0 then
  3207. call DBG 'Could not delete "' || CgiOutputFile || '" (Rc = ' || DeleteRc || ')'
  3208. end
  3209. end
  3210. call ColorAllow 'N'
  3211. call BeepsAllow 'N'
  3212. return
  3213.  
  3214. CloseCgiFileIfOpen:
  3215. if OutputToConsoleLog<> 'N' then
  3216. do
  3217. call _FileClose ConsoleFile
  3218. OutputToConsoleLog='N'
  3219. end
  3220. if OutputToErrorLog='Y' then
  3221. do
  3222. call _FileClose ConsoleErrorFile
  3223. OutputToErrorLog='N'
  3224. end
  3225. if CgiOutputFile<> '' then
  3226. call _FileClose CgiOutputFile
  3227. return
  3228.  
  3229. CgiStartFatalError:
  3230. if OptionCgiModeOn='N' then
  3231. return
  3232. CgiDoVar='CGI_FATAL_MY_MESSAGE_ONLY'
  3233. if MacroExists(CgiDoVar)='Y' then
  3234. do
  3235. CgiErrorCodes=CfgMacro(CgiDoVar, '')
  3236. if CgiErrorCodes='' then
  3237. call DBG 'We do not want any error indication in user output'
  3238. else
  3239. call DBG 'Displaying user message only (no error details)'
  3240. say CgiErrorCodes
  3241. return
  3242. end
  3243. call DBG 'Will show user error output as "' || CgiDoVar || '" was not defined'
  3244. CgiErrDefault='<P><HR><FONT SIZE=+1 COLOR=RED><CENTER><H1>FATAL ERROR</H1></CENTER><P><PRE>'
  3245. CgiErrorCodes=CfgMacro("CGI_FATAL_HEADER",CgiErrDefault)
  3246. say CgiErrorCodes
  3247. CgiErrDefault='</PRE><HR></FONT>'
  3248. CgiErrorCodes=CfgMacro("CGI_FATAL_TRAILER",CgiErrDefault)
  3249. CgiFatalError='Y'
  3250. return
  3251.  
  3252. CgiEndFatalError:
  3253. if OptionCgiModeOn='N' then
  3254. return
  3255. if CgiFatalError='N' then
  3256. return
  3257. say CgiErrorCodes
  3258. CgiFatalError='N'
  3259. return
  3260.  
  3261. _MustSeeAsIsInHtmlViewer:
  3262. BrowserOk=ReplaceString(arg(1), "<",          "<")
  3263. BrowserOk=ReplaceString(BrowserOk, ">",          ">")
  3264. return(BrowserOk)
  3265.  
  3266. CGI_17:
  3267. ReplaceCount=0
  3268. CiSelfRef="{*}"
  3269. signal EndREPLSTR
  3270.  
  3271. ReplaceString:call TRACE "OFF"
  3272. parse arg rs?TheString,rs?ChangeFrom
  3273. rs?FoundPosn=pos(rs?ChangeFrom,rs?TheString)
  3274. if rs?FoundPosn=0 then
  3275. return(rs?TheString)
  3276. rs?ChangeTo=arg(3)
  3277. rs?ChangeFromLength=length(rs?ChangeFrom)
  3278. rs?LeftPart=''
  3279. do until rs?FoundPosn=0
  3280. rs?LeftPart=rs?LeftPart||left(rs?TheString,rs?FoundPosn-1)||rs?ChangeTo
  3281. rs?TheString=substr(rs?TheString,rs?FoundPosn+rs?ChangeFromLength)
  3282. ReplaceCount=ReplaceCount+1
  3283. rs?FoundPosn=pos(rs?ChangeFrom,rs?TheString)
  3284. end
  3285. return(rs?LeftPart||rs?TheString)
  3286.  
  3287. ReplaceStringCi:call TRACE "OFF"
  3288. rsi?TheString=arg(1)
  3289. rsi?TheStringU=translate(rsi?TheString)
  3290. rsi?ChangeFrom=translate(arg(2))
  3291. rsi?FoundPosn=pos(rsi?ChangeFrom,rsi?TheStringU)
  3292. if rsi?FoundPosn=0 then
  3293. return(rsi?TheString)
  3294. rsi?ChangeTo=arg(3)
  3295. if pos(CiSelfRef,rsi?ChangeTo)=0 then
  3296. rsi?Ref='N'
  3297. else
  3298. rsi?Ref='Y'
  3299. rsi?ChangeFromLength=length(rsi?ChangeFrom)
  3300. rsi?LeftPart=''
  3301. do until rsi?FoundPosn=0
  3302. if rsi?Ref='N' then
  3303. rsi?SubWith=rsi?ChangeTo
  3304. else
  3305. do
  3306. rsi?SaveCount=ReplaceCount
  3307. rsi?SubWith=ReplaceString(rsi?ChangeTo,CiSelfRef,substr(rsi?TheString,rsi?FoundPosn,rsi?ChangeFromLength))
  3308. ReplaceCount=rsi?SaveCount
  3309. end
  3310. rsi?LeftPart=rsi?LeftPart||left(rsi?TheString,rsi?FoundPosn-1)||rsi?SubWith
  3311. rsi?TheString=substr(rsi?TheString,rsi?FoundPosn+rsi?ChangeFromLength)
  3312. rsi?TheStringU=substr(rsi?TheStringU,rsi?FoundPosn+rsi?ChangeFromLength)
  3313. ReplaceCount=ReplaceCount+1
  3314. rsi?FoundPosn=pos(rsi?ChangeFrom,rsi?TheStringU)
  3315. end
  3316. return(rsi?LeftPart||rsi?TheString)
  3317.  
  3318. EndREPLSTR:
  3319. ReplaceCount=0
  3320. signal EndBULK_C2S
  3321.  
  3322. BulkChar2String:call TRACE "OFF"
  3323. parse arg brRightBit,brArray
  3324. brModifyThese=value(brArray)
  3325. brPos=verify(brRightBit,brModifyThese, 'M')
  3326. if brPos=0 then
  3327. return(brRightBit)
  3328. brLeftBit=''
  3329. brArray=brArray|| '.'
  3330. do until brPos=0
  3331. brLeftBit=brLeftBit||left(brRightBit,brPos-1)||value(brArray||pos(substr(brRightBit,brPos,1),brModifyThese))
  3332. brRightBit=substr(brRightBit,brPos+1)
  3333. ReplaceCount=ReplaceCount+1
  3334. brPos=verify(brRightBit,brModifyThese, 'M')
  3335. end
  3336. return(brLeftBit||brRightBit)
  3337.  
  3338. BulkChangePrepare:call TRACE "OFF"
  3339. parse arg brArray,brChar,brString
  3340. if brChar=='' then
  3341. call value brArray, ''
  3342. else
  3343. do
  3344. brValue=value(brArray)||BrChar
  3345. call value brArray,brValue
  3346. call value brArray|| '.' ||length(brValue),brString
  3347. end
  3348. return
  3349.  
  3350. EndBULK_C2S:
  3351. _CCnt=0
  3352. call _32 '00000000'x
  3353. call _32 '77073096'x
  3354. call _32 'EE0E612C'x
  3355. call _32 '990951BA'x
  3356. call _32 '076DC419'x
  3357. call _32 '706AF48F'x
  3358. call _32 'E963A535'x
  3359. call _32 '9E6495A3'x
  3360. call _32 '0EDB8832'x
  3361. call _32 '79DCB8A4'x
  3362. call _32 'E0D5E91E'x
  3363. call _32 '97D2D988'x
  3364. call _32 '09B64C2B'x
  3365. call _32 '7EB17CBD'x
  3366. call _32 'E7B82D07'x
  3367. call _32 '90BF1D91'x
  3368. call _32 '1DB71064'x
  3369. call _32 '6AB020F2'x
  3370. call _32 'F3B97148'x
  3371. call _32 '84BE41DE'x
  3372. call _32 '1ADAD47D'x
  3373. call _32 '6DDDE4EB'x
  3374. call _32 'F4D4B551'x
  3375. call _32 '83D385C7'x
  3376. call _32 '136C9856'x
  3377. call _32 '646BA8C0'x
  3378. call _32 'FD62F97A'x
  3379. call _32 '8A65C9EC'x
  3380. call _32 '14015C4F'x
  3381. call _32 '63066CD9'x
  3382. call _32 'FA0F3D63'x
  3383. call _32 '8D080DF5'x
  3384. call _32 '3B6E20C8'x
  3385. call _32 '4C69105E'x
  3386. call _32 'D56041E4'x
  3387. call _32 'A2677172'x
  3388. call _32 '3C03E4D1'x
  3389. call _32 '4B04D447'x
  3390. call _32 'D20D85FD'x
  3391. call _32 'A50AB56B'x
  3392. call _32 '35B5A8FA'x
  3393. call _32 '42B2986C'x
  3394. call _32 'DBBBC9D6'x
  3395. call _32 'ACBCF940'x
  3396. call _32 '32D86CE3'x
  3397. call _32 '45DF5C75'x
  3398. call _32 'DCD60DCF'x
  3399. call _32 'ABD13D59'x
  3400. call _32 '26D930AC'x
  3401. call _32 '51DE003A'x
  3402. call _32 'C8D75180'x
  3403. call _32 'BFD06116'x
  3404. call _32 '21B4F4B5'x
  3405. call _32 '56B3C423'x
  3406. call _32 'CFBA9599'x
  3407. call _32 'B8BDA50F'x
  3408. call _32 '2802B89E'x
  3409. call _32 '5F058808'x
  3410. call _32 'C60CD9B2'x
  3411. call _32 'B10BE924'x
  3412. call _32 '2F6F7C87'x
  3413. call _32 '58684C11'x
  3414. call _32 'C1611DAB'x
  3415. call _32 'B6662D3D'x
  3416. call _32 '76DC4190'x
  3417. call _32 '01DB7106'x
  3418. call _32 '98D220BC'x
  3419. call _32 'EFD5102A'x
  3420. call _32 '71B18589'x
  3421. call _32 '06B6B51F'x
  3422. call _32 '9FBFE4A5'x
  3423. call _32 'E8B8D433'x
  3424. call _32 '7807C9A2'x
  3425. call _32 '0F00F934'x
  3426. call _32 '9609A88E'x
  3427. call _32 'E10E9818'x
  3428. call _32 '7F6A0DBB'x
  3429. call _32 '086D3D2D'x
  3430. call _32 '91646C97'x
  3431. call _32 'E6635C01'x
  3432. call _32 '6B6B51F4'x
  3433. call _32 '1C6C6162'x
  3434. call _32 '856530D8'x
  3435. call _32 'F262004E'x
  3436. call _32 '6C0695ED'x
  3437. call _32 '1B01A57B'x
  3438. call _32 '8208F4C1'x
  3439. call _32 'F50FC457'x
  3440. call _32 '65B0D9C6'x
  3441. call _32 '12B7E950'x
  3442. call _32 '8BBEB8EA'x
  3443. call _32 'FCB9887C'x
  3444. call _32 '62DD1DDF'x
  3445. call _32 '15DA2D49'x
  3446. call _32 '8CD37CF3'x
  3447. call _32 'FBD44C65'x
  3448. call _32 '4DB26158'x
  3449. call _32 '3AB551CE'x
  3450. call _32 'A3BC0074'x
  3451. call _32 'D4BB30E2'x
  3452. call _32 '4ADFA541'x
  3453. call _32 '3DD895D7'x
  3454. call _32 'A4D1C46D'x
  3455. call _32 'D3D6F4FB'x
  3456. call _32 '4369E96A'x
  3457. call _32 '346ED9FC'x
  3458. call _32 'AD678846'x
  3459. call _32 'DA60B8D0'x
  3460. call _32 '44042D73'x
  3461. call _32 '33031DE5'x
  3462. call _32 'AA0A4C5F'x
  3463. call _32 'DD0D7CC9'x
  3464. call _32 '5005713C'x
  3465. call _32 '270241AA'x
  3466. call _32 'BE0B1010'x
  3467. call _32 'C90C2086'x
  3468. call _32 '5768B525'x
  3469. call _32 '206F85B3'x
  3470. call _32 'B966D409'x
  3471. call _32 'CE61E49F'x
  3472. call _32 '5EDEF90E'x
  3473. call _32 '29D9C998'x
  3474. call _32 'B0D09822'x
  3475. call _32 'C7D7A8B4'x
  3476. call _32 '59B33D17'x
  3477. call _32 '2EB40D81'x
  3478. call _32 'B7BD5C3B'x
  3479. call _32 'C0BA6CAD'x
  3480. call _32 'EDB88320'x
  3481. call _32 '9ABFB3B6'x
  3482. call _32 '03B6E20C'x
  3483. call _32 '74B1D29A'x
  3484. call _32 'EAD54739'x
  3485. call _32 '9DD277AF'x
  3486. call _32 '04DB2615'x
  3487. call _32 '73DC1683'x
  3488. call _32 'E3630B12'x
  3489. call _32 '94643B84'x
  3490. call _32 '0D6D6A3E'x
  3491. call _32 '7A6A5AA8'x
  3492. call _32 'E40ECF0B'x
  3493. call _32 '9309FF9D'x
  3494. call _32 '0A00AE27'x
  3495. call _32 '7D079EB1'x
  3496. call _32 'F00F9344'x
  3497. call _32 '8708A3D2'x
  3498. call _32 '1E01F268'x
  3499. call _32 '6906C2FE'x
  3500. call _32 'F762575D'x
  3501. call _32 '806567CB'x
  3502. call _32 '196C3671'x
  3503. call _32 '6E6B06E7'x
  3504. call _32 'FED41B76'x
  3505. call _32 '89D32BE0'x
  3506. call _32 '10DA7A5A'x
  3507. call _32 '67DD4ACC'x
  3508. call _32 'F9B9DF6F'x
  3509. call _32 '8EBEEFF9'x
  3510. call _32 '17B7BE43'x
  3511. call _32 '60B08ED5'x
  3512. call _32 'D6D6A3E8'x
  3513. call _32 'A1D1937E'x
  3514. call _32 '38D8C2C4'x
  3515. call _32 '4FDFF252'x
  3516. call _32 'D1BB67F1'x
  3517. call _32 'A6BC5767'x
  3518. call _32 '3FB506DD'x
  3519. call _32 '48B2364B'x
  3520. call _32 'D80D2BDA'x
  3521. call _32 'AF0A1B4C'x
  3522. call _32 '36034AF6'x
  3523. call _32 '41047A60'x
  3524. call _32 'DF60EFC3'x
  3525. call _32 'A867DF55'x
  3526. call _32 '316E8EEF'x
  3527. call _32 '4669BE79'x
  3528. call _32 'CB61B38C'x
  3529. call _32 'BC66831A'x
  3530. call _32 '256FD2A0'x
  3531. call _32 '5268E236'x
  3532. call _32 'CC0C7795'x
  3533. call _32 'BB0B4703'x
  3534. call _32 '220216B9'x
  3535. call _32 '5505262F'x
  3536. call _32 'C5BA3BBE'x
  3537. call _32 'B2BD0B28'x
  3538. call _32 '2BB45A92'x
  3539. call _32 '5CB36A04'x
  3540. call _32 'C2D7FFA7'x
  3541. call _32 'B5D0CF31'x
  3542. call _32 '2CD99E8B'x
  3543. call _32 '5BDEAE1D'x
  3544. call _32 '9B64C2B0'x
  3545. call _32 'EC63F226'x
  3546. call _32 '756AA39C'x
  3547. call _32 '026D930A'x
  3548. call _32 '9C0906A9'x
  3549. call _32 'EB0E363F'x
  3550. call _32 '72076785'x
  3551. call _32 '05005713'x
  3552. call _32 '95BF4A82'x
  3553. call _32 'E2B87A14'x
  3554. call _32 '7BB12BAE'x
  3555. call _32 '0CB61B38'x
  3556. call _32 '92D28E9B'x
  3557. call _32 'E5D5BE0D'x
  3558. call _32 '7CDCEFB7'x
  3559. call _32 '0BDBDF21'x
  3560. call _32 '86D3D2D4'x
  3561. call _32 'F1D4E242'x
  3562. call _32 '68DDB3F8'x
  3563. call _32 '1FDA836E'x
  3564. call _32 '81BE16CD'x
  3565. call _32 'F6B9265B'x
  3566. call _32 '6FB077E1'x
  3567. call _32 '18B74777'x
  3568. call _32 '88085AE6'x
  3569. call _32 'FF0F6A70'x
  3570. call _32 '66063BCA'x
  3571. call _32 '11010B5C'x
  3572. call _32 '8F659EFF'x
  3573. call _32 'F862AE69'x
  3574. call _32 '616BFFD3'x
  3575. call _32 '166CCF45'x
  3576. call _32 'A00AE278'x
  3577. call _32 'D70DD2EE'x
  3578. call _32 '4E048354'x
  3579. call _32 '3903B3C2'x
  3580. call _32 'A7672661'x
  3581. call _32 'D06016F7'x
  3582. call _32 '4969474D'x
  3583. call _32 '3E6E77DB'x
  3584. call _32 'AED16A4A'x
  3585. call _32 'D9D65ADC'x
  3586. call _32 '40DF0B66'x
  3587. call _32 '37D83BF0'x
  3588. call _32 'A9BCAE53'x
  3589. call _32 'DEBB9EC5'x
  3590. call _32 '47B2CF7F'x
  3591. call _32 '30B5FFE9'x
  3592. call _32 'BDBDF21C'x
  3593. call _32 'CABAC28A'x
  3594. call _32 '53B39330'x
  3595. call _32 '24B4A3A6'x
  3596. call _32 'BAD03605'x
  3597. call _32 'CDD70693'x
  3598. call _32 '54DE5729'x
  3599. call _32 '23D967BF'x
  3600. call _32 'B3667A2E'x
  3601. call _32 'C4614AB8'x
  3602. call _32 '5D681B02'x
  3603. call _32 '2A6F2B94'x
  3604. call _32 'B40BBE37'x
  3605. call _32 'C30C8EA1'x
  3606. call _32 '5A05DF1B'x
  3607. call _32 '2D02EF8D'x
  3608. signal CRC32REX_18
  3609.  
  3610. _32:
  3611. db!c=d2c(_CCnt)
  3612. _C.db!c=arg(1)
  3613. _CCnt=_CCnt+1
  3614. return
  3615.  
  3616. Crc32PrePostConditioning:call TRACE "OFF"
  3617. if arg(1)='' then
  3618. return('FFFFFFFF'x)
  3619. else
  3620. return(bitxor(arg(1), 'FFFFFFFF'x))
  3621.  
  3622. UpdateCrc32:call TRACE "OFF"
  3623. parse arg eb!Crc,eb!Buffer
  3624. do while eb!Buffer\==''
  3625. parse var eb!Buffer eb!PerfBuffer 2001 eb!Buffer
  3626. do eb!ThisByte=1 to length(eb!PerfBuffer)
  3627. parse var eb!Crc eb!L3 4 eb!R1
  3628. eb!ArrayEl=bitxor(eb!R1,substr(eb!PerfBuffer,eb!ThisByte,1))
  3629. eb!Crc=Bitxor('00'x||eb!L3,_C.eb!ArrayEl)
  3630. end
  3631. end
  3632. return(eb!Crc)
  3633.  
  3634. Crc32InDisplayableForm:call TRACE "OFF"
  3635. return(c2x(arg(1)))
  3636.  
  3637. CRC32REX_18:
  3638. signal EndBASEDATEXh
  3639.  
  3640. BaseDate:procedure;call TRACE "OFF"
  3641. TheDate=translate(arg(1), ' ', '/-')
  3642. if TheDate='' then
  3643. TheDate=date('Sorted')
  3644. parse var TheDate Year MM DD
  3645. if length(Year)>=8 then
  3646. do
  3647. DD=substr(Year,7,2)
  3648. MM=substr(Year,5,2)
  3649. Year=left(Year,4)
  3650. end
  3651. DaysInMonth='31  28  31  30  31  30  31  31  30  31  30  31'
  3652. if datatype(Year, 'WholeNumber')<>1 then
  3653. return(-10)
  3654. if datatype(MM, 'WholeNumber')<>1 then
  3655. return(-20)
  3656. if datatype(DD, 'WholeNumber')<>1 then
  3657. return(-30)
  3658. if MM<0|MM>12 then
  3659. return(-21)
  3660. DaysThisMonth=word(DaysInMonth,MM)
  3661. if MM=2 then
  3662. DaysThisMonth=DaysThisMonth+1
  3663. if DD<0|DD>DaysThisMonth then
  3664. return(-31)
  3665. if length(strip(Year))=2 then
  3666. do
  3667. if Year>=80 then
  3668. Year='19' ||Year
  3669. else
  3670. Year='20' ||Year
  3671. end
  3672. y=Year;m=MM;d=DD
  3673. z=y+(m-14)%12
  3674. f=word('306 337 0 31 61 92 122 153 184 214 245 275',m)
  3675. b=d+f+365*z+z%4-z%100+z%400-307
  3676. return(b)
  3677.  
  3678. _Bd2Date:procedure;call TRACE "OFF"
  3679. parse arg rd,Format,Delimiter
  3680. z=rd+307
  3681. h=100*z-25
  3682. a=h%3652425
  3683. b=a-a%4
  3684. year=(100*b+h)%36525
  3685. c=b+z-365*year-year%4
  3686. month=(5*c+456)%153
  3687. day=c-word('0 31 61 92 122 153 184 214 245 275 306 337',month-2)
  3688. if month>12 then
  3689. do
  3690. year=year+1
  3691. month=month-12
  3692. end
  3693. yyyy=right(year,4, '0')
  3694. mm=right(month,2, '0')
  3695. dd=right(day,2, '0')
  3696. return(yyyy||Delimiter||mm||Delimiter||dd)
  3697.  
  3698. EndBASEDATEXh:
  3699. signal PREFIX_19
  3700.  
  3701. HASHPREFIX_DEBUG:
  3702. if OptionDebugOn='Y' then
  3703. call OptionDebugShow 'HASHPREFIX', 'Hash prefix is now "' || HashPrefix || '" (' || HashPrefix || 'define etc)'
  3704. return
  3705.  
  3706. HASHPREFIX_GET:
  3707. call HASHPREFIX_DEBUG
  3708. return(HashPrefix)
  3709.  
  3710. HASHPREFIX_SET:
  3711. HashPrefix=arg(1)
  3712. if ProcessedCmdLine='N' then
  3713. do
  3714. call OptionDebugShow 'HASHPREFIX', 'Setting default value of hash Prefix to "' || HashPrefix || '"'
  3715. Default4_HashPrefix=HashPrefix
  3716. return(0)
  3717. end
  3718. if HashPrefix=='' then
  3719. HashPrefix=Default4_HashPrefix
  3720. AfterPrefix=translate(HashPrefix, '',LowerCase)
  3721. if AfterPrefix<>HashPrefix then
  3722. CryAndDie('A hash prefix should not include lower case characters!')
  3723. HashPrefixLng=length(HashPrefix)
  3724. call HASHPREFIX_DEBUG
  3725. CmdHashAsIs=HashPrefix|| 'ASIS'
  3726. CmdHashAutoTag=HashPrefix|| 'AUTOTAG'
  3727. CmdHashAutoTagClear=HashPrefix|| 'AUTOTAGCLEAR'
  3728. CmdHashAutoTagState=HashPrefix|| 'AUTOTAGSTATE'
  3729. CmdHashLoopBreak=HashPrefix|| 'BREAK'
  3730. CmdHashLoopContinue=HashPrefix|| 'CONTINUE'
  3731. CmdHashDebug=HashPrefix|| 'DEBUG'
  3732. CmdHashDefine=HashPrefix|| 'DEFINE'
  3733. CmdHashDefinePlus=HashPrefix|| 'DEFINE+'
  3734. CmdHashDefineIfReq=HashPrefix|| 'DEFINE?'
  3735. CmdHashDefineRexx=HashPrefix|| 'DEFINEREXX'
  3736. CmdHashDefineRexxPlus=HashPrefix|| 'DEFINEREXX+'
  3737. CmdHashDependsOn=HashPrefix|| 'DEPENDSON'
  3738. CmdHashElseifL=HashPrefix|| 'ELSEIF'
  3739. CmdHashEndifL=HashPrefix|| 'ENDIF'
  3740. CmdHashEof=HashPrefix|| 'EOF'
  3741. CmdHashErrorL=HashPrefix|| 'ERROR'
  3742. CmdHashEvaluateL=HashPrefix|| 'EVALUATE'
  3743. CmdHashEvaluatePlusL=HashPrefix|| 'EVALUATE+'
  3744. CmdHashIf=HashPrefix|| 'IF'
  3745. CmdHashIfdef=HashPrefix|| 'IFDEF'
  3746. CmdHashIfndef=HashPrefix|| 'IFNDEF'
  3747. CmdHashImport=HashPrefix|| 'IMPORT'
  3748. CmdHashInclude=HashPrefix|| 'INCLUDE'
  3749. CmdHashInfo=HashPrefix|| 'INFO'
  3750. CmdHashIntercept=HashPrefix|| 'INTERCEPT'
  3751. CmdHashMacroSpace=HashPrefix|| 'MACROSPACE'
  3752. CmdHashNextId=HashPrefix|| 'NEXTID'
  3753. CmdHashOnExit=HashPrefix|| 'ONEXIT'
  3754. CmdHashOption=HashPrefix|| 'OPTION'
  3755. CmdHashOutput=HashPrefix|| 'OUTPUT'
  3756. CmdHashOutputHold=HashPrefix|| 'OUTPUTHOLD'
  3757. CmdHashPush=HashPrefix|| 'PUSH'
  3758. CmdHashPop=HashPrefix|| 'POP'
  3759. CmdHashRequire=HashPrefix|| 'REQUIRE'
  3760. CmdHashSystem=HashPrefix|| 'SYSTEM'
  3761. CmdHashTransform=HashPrefix|| 'TRANSFORM'
  3762. CmdHashRexxVar=HashPrefix|| 'REXXVAR'
  3763. CmdHashUndefL=HashPrefix|| 'UNDEF'
  3764. CmdHashWarningL=HashPrefix|| 'WARNING'
  3765. CmdHashLoopS=HashPrefix|| '{'
  3766. CmdHashLoopE=HashPrefix|| '}'
  3767. CmdHash1Line=HashPrefix|| '('
  3768. CmdHash1LineEnd=HashPrefix|| ')'
  3769. CmdHashOneLine=HashPrefix|| 'ONELINE'
  3770. CmdHashEvaluateS=HashPrefix|| 'E'
  3771. CmdHashEvaluatePlusS=HashPrefix|| 'E+'
  3772. CmdHashUndefS=HashPrefix|| 'U'
  3773. CmdHashElseifS=HashPrefix|| 'ELSE'
  3774. CmdHashEndifS=HashPrefix|| 'END'
  3775. CmdHashErrorS=HashPrefix|| '!'
  3776. CmdHashWarningS=HashPrefix|| 'W'
  3777. return
  3778.  
  3779. PREFIX_19:
  3780. signal LineCmt_20
  3781.  
  3782. LINECOMMENT_DEBUG:
  3783. if OptionDebugOn='Y' then
  3784. do
  3785. if LineComment<>NullChar then
  3786. call OptionDebugShow 'LINECOMMENT', 'Lines starting with "' || LineComment || '" are comments ("' || InLineComment || '" for inline comments)'
  3787. else
  3788. call OptionDebugShow 'LINECOMMENT', 'Comment removal has been turned off'
  3789. end
  3790. return
  3791.  
  3792. LINECOMMENT_GET:
  3793. call LINECOMMENT_DEBUG
  3794. return(LineCommentSet2)
  3795.  
  3796. LINECOMMENT_SET:
  3797. LineComment=arg(1)
  3798. LineCommentSet2=LineComment
  3799. if ProcessedCmdLine='N' then
  3800. do
  3801. call OptionDebugShow 'LINECOMMENT', 'Setting default value of line comment to "' || LineComment || '"'
  3802. Default4_LineComment=LineComment
  3803. return(0)
  3804. end
  3805. if LineComment=='' then
  3806. LineComment=Default4_LineComment
  3807. if translate(LineComment)='NULL' then
  3808. LineComment=NullChar
  3809. else
  3810. do
  3811. if length(LineComment)<>1 then
  3812. CryAndDie('A comment char should be one character long')
  3813. end
  3814. InLineComment=LineComment||LineComment
  3815. call LINECOMMENT_DEBUG
  3816. return
  3817.  
  3818. LineCmt_20:
  3819. signal WhiteSpc_21
  3820.  
  3821. _WsFmt:
  3822. dbgExtra=''
  3823. do CharIndex=1 to length(ExtraWhiteSpace)
  3824. if CharIndex<>1 then
  3825. dbgExtra=dbgExtra|| ', '
  3826. dbgExtra=dbgExtra||c2x(substr(ExtraWhiteSpace,CharIndex,1))
  3827. end
  3828. return(dbgExtra)
  3829.  
  3830. WHITESPACE_DEBUG:
  3831. if OptionDebugOn='Y' then
  3832. do
  3833. if ExtraWhiteSpace=='' then
  3834. call OptionDebugShow 'WHITESPACE', 'No extra whitespace characters defined'
  3835. else
  3836. call OptionDebugShow 'WHITESPACE', 'Extra whitespace characters are hexadecimal ' ||_WsFmt()
  3837. end
  3838. return
  3839.  
  3840. WHITESPACE_GET:
  3841. call WHITESPACE_DEBUG
  3842. return(ExtraWhiteSpace)
  3843.  
  3844. WHITESPACE_SET:
  3845. ExtraWhiteSpace=arg(1)
  3846. if ProcessedCmdLine='N' then
  3847. do
  3848. Default4_ExtraWhiteSpace=ExtraWhiteSpace
  3849. if ExtraWhiteSpace=='' then
  3850. call OptionDebugShow 'WHITESPACE', 'Setting default to no extra whitespace'
  3851. else
  3852. call OptionDebugShow 'WHITESPACE', 'Setting default to extra whitespace characters are hexadecimal ' ||_WsFmt()
  3853. return(0)
  3854. end
  3855. if ExtraWhiteSpace=='NULL' then
  3856. ExtraWhiteSpace=Default4_ExtraWhiteSpace
  3857. call WHITESPACE_DEBUG
  3858. return
  3859.  
  3860. WhiteSpc_21:
  3861. signal LineCont_22
  3862.  
  3863. LINECONTINUATION_DEBUG:
  3864. if OptionDebugOn='Y' then
  3865. do
  3866. if LineContChar=NullChar then
  3867. call OptionDebugShow 'LINECONTINUATION', 'Line continuation handling has been turned off'
  3868. else
  3869. do
  3870. call OptionDebugShow 'LINECONTINUATION', 'The line continuation marker is now "' || LineContChar || '"'
  3871. if symbol('CodexNewLine') = 'VAR' then
  3872. DbgText='"' || CodexNewLine || '"'
  3873. else
  3874. DbgText="'X' code for newline"
  3875. call DBGIND 1
  3876. call DBG '"' || LineContAddNewLine   || '" = Join with    ' ||DbgText
  3877. call DBG '"' || LineContWithoutSpace || '" = Join without space'
  3878. call DBG '"' || LineContWithSpace    || '" = Join with    space'
  3879. call DBG '"' || LineContDefault      || '" = Join with    space'
  3880. call DBGIND-1
  3881. end
  3882. end
  3883. return
  3884.  
  3885. LINECONTINUATION_GET:
  3886. call LINECONTINUATION_DEBUG
  3887. return(LineContCharList)
  3888.  
  3889. LINECONTINUATION_SET:
  3890. LineContParm=arg(1)
  3891. LineContParmSet2=LineContParm
  3892. if ProcessedCmdLine='N' then
  3893. do
  3894. call OptionDebugShow 'LINECONTINUATION', 'Setting default value of line continuation chars to "' || LineContParm || '"'
  3895. Default4_LineContParm=LineContParm
  3896. LineContCharList=LineContParm
  3897. return(0)
  3898. end
  3899. if LineContParm=='' then
  3900. LineContParm=Default4_LineContParm
  3901. if translate(LineContParm)='NULL' then
  3902. LineContParm=NullChar
  3903. else
  3904. do
  3905. if length(LineContParm)<>1&length(LineContParm)<>5 then
  3906. CryAndDie('Invalid line continuation spec of "' || LineContParm || '"')
  3907. end
  3908. LineContCharList=overlay(LineContParm,LineContCharList)
  3909. LineContChar=substr(LineContCharList,1,1)
  3910. LineContAddNewLine=substr(LineContCharList,2,1)||LineContChar
  3911. LineContAddNewLineObs=d2c(25)||LineContChar
  3912. LineContWithoutSpace=substr(LineContCharList,3,1)||LineContChar
  3913. LineContWithSpace=substr(LineContCharList,4,1)||LineContChar
  3914. LineContDefault=substr(LineContCharList,5,1)||LineContChar
  3915. call LINECONTINUATION_DEBUG
  3916. return
  3917.  
  3918. LineCont_22:
  3919. AsIsCount=0
  3920. AsIsUsing=''
  3921. signal AsIs_23
  3922.  
  3923. AsIsPrepare:call TRACE "OFF"
  3924. AsIsParms=space(arg(1))
  3925. AsIsUsing=AsIsParms
  3926. AsIsCount=0
  3927. AsIsIndex=0
  3928. AsIsCollecting=''
  3929. call DBG_ASIS 'AsIsPrepare(): Cleared memory. Processing "' || AsIsUsing || '"'
  3930. call DBGIND 1
  3931. aiOptCnt=0
  3932. do while AsIsParms<> ''
  3933. call _SetUpAsIsTagging translate(GetQuotedText(AsIsParms, "AsIsParms"))
  3934. end
  3935. if AsIsCount<>0 then
  3936. do
  3937. if aiOptCnt=0 then
  3938. aiMsg='none'
  3939. else
  3940. do
  3941. if aiOptCnt=AsIsCount then
  3942. aiMsg='all'
  3943. else
  3944. aiMsg=aiOptCnt
  3945. end
  3946. call DBG_ASIS 'Have ' || AsIsCount || ' "as is" tags (' || aiMsg || ' optimised)'
  3947. end
  3948. call DBGIND-1
  3949. return(AsIsCount)
  3950.  
  3951. ExpandAsIsTags:
  3952. if AsIsModeOn='N' then
  3953. return(arg(1))
  3954.  
  3955. AsIs:call TRACE "OFF"
  3956. if AsIsCount=0 then
  3957. return(arg(1))
  3958. EaiString=arg(1)
  3959. AsIsCnt=ReplaceCount
  3960. do Tag=1 to AsIsIndex
  3961. if AsIsBef.Tag=='' then
  3962. EaiString=BulkChar2String(EaiString,AsIsAft.Tag)
  3963. else
  3964. do
  3965. if left(AsIsBef.Tag,2)<>SrTypePre then
  3966. EaiString=ReplaceString(EaiString,AsIsBef.Tag,AsIsAft.Tag)
  3967. else
  3968. do
  3969. select
  3970. when abbrev(AsIsBef.Tag,SrCaseIns)then
  3971. EaiString=ReplaceStringCI(EaiString,substr(AsIsBef.Tag,SrCaseIns_P),AsIsAft.Tag)
  3972. when abbrev(AsIsBef.Tag,SrFixed)then
  3973. EaiString=CompareReplaceFixed2(EaiString,substr(AsIsBef.Tag,SrFixed_P),AsIsAft.Tag)
  3974. otherwise
  3975. EaiString=ReplaceString(EaiString,AsIsBef.Tag,AsIsAft.Tag)
  3976. end
  3977. end
  3978. end
  3979. end
  3980. if OptionDebugOn='Y' then
  3981. do
  3982. if AsIsCnt<>ReplaceCount then
  3983. call DebugOutputAfterReplacement EaiString, 'ASIS'
  3984. end
  3985. return(EaiString)
  3986.  
  3987. ProcessAsIs:
  3988. HashCmdParms=PerformReplacementsInCmdsParameters(arg(1))
  3989. AsIsCmd=translate(GetQuotedText(HashCmdParms, "AsIsParms"))
  3990. if AsIsCmd='SETUP' then
  3991. do
  3992. AsIsPrepCache='?'
  3993. call SetupNamedAsIsStorage GetQuotedText(AsIsParms)
  3994. return(0)
  3995. end
  3996. call SetOnorOffVariable AsIsCmd, 'AsIsModeOn'
  3997. if AsIsModeOn='N' then
  3998. do
  3999. AsIsCount=0
  4000. if AsIsParms<> '' then
  4001. CryAndDie('Did not expect more than the "OFF" parameter')
  4002. call OptionsPop
  4003. end
  4004. else
  4005. do
  4006. call OptionsPush
  4007. call OptionOnOrOff_SET "KEEPINDENT",      "KeepIndent",      "ON"
  4008. call OptionOnOrOff_SET "LEAVEBLANKLINES", "LeaveBlankLines", "ON"
  4009. call LINECOMMENT_SET "NULL"
  4010. call LINECONTINUATION_SET "NULL"
  4011. call AsIsPrepare AsIsParms
  4012. end
  4013. if OptionDebugOn='Y' then
  4014. do
  4015. if AsIsCount=0 then
  4016. call DBG_ASIS 'AsIs mode is ' || YorN2OnorOff(AsIsModeOn) || '.  No tags prepared.'
  4017. else
  4018. call DBG_ASIS 'AsIs mode is ' || YorN2OnorOff(AsIsModeOn) || '.  Have ' || AsIsCount || ' tags from "' || AsIsUsing || '"'
  4019. end
  4020. return(0)
  4021.  
  4022. SetupNamedAsIsStorage:
  4023. AsIsNameU=translate(arg(1))
  4024. AsIsName='AI_' ||c2x(AsIsNameU)
  4025. AsIsAltCnt=arg(2)
  4026. AsIsCounter=0
  4027. if AsIsAltCnt='' then
  4028. do
  4029. TagFrom=AutoTagFirst
  4030. TagTo=AutoTagLast
  4031. end
  4032. else
  4033. do
  4034. TagFrom=1
  4035. TagTo=AsIsAltCnt
  4036. end
  4037. do Tag=TagFrom to TagTo
  4038. AsIsCounter=AsIsCounter+1
  4039. if AsIsAltCnt='' then
  4040. do
  4041. AsIsBef.AsIsCounter.AsIsName=AutoTagOnB.Tag
  4042. AsIsAft.AsIsCounter.AsIsName=AutoTagOnA.Tag
  4043. end
  4044. else
  4045. do
  4046. AsIsBef.AsIsCounter.AsIsName=ImportB.Tag
  4047. AsIsAft.AsIsCounter.AsIsName=ImportA.Tag
  4048. end
  4049. end
  4050. call _valueS AsIsName,AsIsCounter
  4051. if AsIsAltCnt='' then
  4052. call ClearAutoTags 'N'
  4053. call DBG_ASIS 'Captured ' || AsIsCounter || ' tags as "' || AsIsNameU || '"'
  4054. return
  4055.  
  4056. _SetUpAsIsTagging:
  4057. AsIsNameU=translate(arg(1))
  4058. AsIsName='AI_' ||c2x(AsIsNameU)
  4059. call DBG_ASIS 'Getting tags from storage named "' || AsIsNameU || '"'
  4060. call DBGIND 1
  4061. if symbol(AsIsName)<> 'VAR' then
  4062. CryAndDie('#AsIs "SETUP" has not been run for "' || AsIsNameU || '"')
  4063. AsIsCopyCount=_valueG(AsIsName)
  4064. do Index=1 to AsIsCopyCount
  4065. ThisBefore=AsIsBef.Index.AsIsName
  4066. ThisAfter=AsIsAft.Index.AsIsName
  4067. AsIsCount=AsIsCount+1
  4068. call DBG_ASIS 'AsIs #' || AsIsCount || ': From=' || DebugRightArrow || ThisBefore || DebugLeftArrow || ',  To=' ||DebugRightArrow||ThisAfter||DebugLeftArrow
  4069. if length(ThisBefore)<>1 then
  4070. do
  4071. AsIsCollecting=''
  4072. AsIsIndex=AsIsIndex+1
  4073. AsIsBef.AsIsIndex=ThisBefore
  4074. AsIsAft.AsIsIndex=ThisAfter
  4075. end
  4076. else
  4077. do
  4078. if AsIsCollecting=='' then
  4079. do
  4080. AsIsCollecting='OptAsIs' ||AsIsIndex
  4081. call _valueS AsIsCollecting, ''
  4082. AsIsIndex=AsIsIndex+1
  4083. AsIsBef.AsIsIndex=''
  4084. AsIsAft.AsIsIndex=AsIsCollecting
  4085. end
  4086. aiOptCnt=aiOptCnt+1
  4087. aiOptList=_valueG(AsIsCollecting)||ThisBefore
  4088. aiIndex=length(aiOptList)
  4089. call _valueS AsIsCollecting,aiOptList
  4090. call _valueS AsIsCollecting|| '.' ||aiIndex,ThisAfter
  4091. end
  4092. end
  4093. call DBG_ASIS 'Copied ' || AsIsCopyCount || ' tags'
  4094. call DBGIND-1
  4095. return
  4096.  
  4097. AsIs_23:
  4098. AtChangeType=''
  4099. AtChangeTypeDesc="CASESENSITIVE"
  4100. signal AutoTag_24
  4101.  
  4102. ShowAutoTagStateWhenDebugOn:
  4103. if OptionDebugOn='Y' then
  4104. do
  4105. if AutoTagName='' then
  4106. DbgText1=''
  4107. else
  4108. DbgText1=' (named "' || AutoTagName || '")'
  4109. call DBG_AUTOTAG 'AutoTagging is ' || YorN2OnorOff(AutoTagOn) || '.  Have ' || ((AutoTagLast - AutoTagFirst) + 1) || ' tags available in state #' ||AutoTagStateCnt||DbgText1
  4110. if arg(1)='Y' then
  4111. do
  4112. call DBGIND 1
  4113. do Tag=AutoTagFirst to AutoTagLast
  4114. call DBG_AUTOTAG 'AutoTag #' || Tag || ': From=' || DebugRightArrow || AutoTagOnB.Tag || DebugLeftArrow || ',  To=' ||DebugRightArrow||AutoTagOnA.Tag||DebugLeftArrow
  4115. end
  4116. call DBGIND-1
  4117. end
  4118. end
  4119. return
  4120.  
  4121. CompletelyInitializeAutoTagState:
  4122. AutoTagOn='N'
  4123. call ClearAutoTags 'Y'
  4124. return
  4125.  
  4126. ClearAutoTags:
  4127. if arg(1)='N' then
  4128. do
  4129. if AutoTagStateCnt=0 then
  4130. AutoTagLast=0
  4131. else
  4132. AutoTagLast=AutoTagState.AutoTagStateCnt.Last
  4133. end
  4134. else
  4135. do
  4136. AutoTagLast=0
  4137. AutoTagStateCnt=0
  4138. AutoTagFirst=1
  4139. AutoTagName=''
  4140. end
  4141. if OptionDebugOn='Y' then
  4142. do
  4143. if AutoTagStateCnt=0 then
  4144. call DBG_AUTOTAG 'Cleared ALL autotags (no state information saved - State #0).'
  4145. else
  4146. call ShowAutoTagStateWhenDebugOn
  4147. end
  4148. return
  4149.  
  4150. AutoTagAdd:call TRACE "OFF"
  4151. parse arg fb!B,fb!A,fb!T,fb!S
  4152. if fb!T=='' then
  4153. fb!T=Default4_ATCHANGETYPEDESC
  4154. if OptionDebugOn='Y' then
  4155. call DBG_AUTOTAG 'AutoTagAdd(): Assigning ' || DebugRightArrow || fb!B || DebugLeftArrow || ' = ' || DebugRightArrow || fb!A || DebugLeftArrow || ' (TYPE=' || fb!T || ')'
  4156. call _AddAutoTag GetCtCode(fb!T)||fb!B,fb!A,fb!S
  4157. return
  4158.  
  4159. AutoTag:call TRACE "OFF"
  4160. EatString=arg(1)
  4161. if AutoTagFirst>AutoTagLast then
  4162. return(EatString)
  4163. AtCnt=ReplaceCount
  4164. do Tag=AutoTagFirst to AutoTagLast
  4165. if left(AutoTagOnB.Tag,2)<>SrTypePre then
  4166. EatString=ReplaceString(EatString,AutoTagOnB.Tag,AutoTagOnA.Tag)
  4167. else
  4168. do
  4169. select
  4170. when abbrev(AutoTagOnB.Tag,SrCaseIns)then
  4171. EatString=ReplaceStringCI(EatString,substr(AutoTagOnB.Tag,SrCaseIns_P),AutoTagOnA.Tag)
  4172. when abbrev(AutoTagOnB.Tag,SrFixed)then
  4173. EatString=CompareReplaceFixed2(EatString,substr(AutoTagOnB.Tag,SrFixed_P),AutoTagOnA.Tag)
  4174. otherwise
  4175. EatString=ReplaceString(EatString,AutoTagOnB.Tag,AutoTagOnA.Tag)
  4176. end
  4177. end
  4178. end
  4179. if OptionDebugOn='Y' then
  4180. do
  4181. if AtCnt<>ReplaceCount then
  4182. call DebugOutputAfterReplacement EatString, 'ATAG'
  4183. end
  4184. return(EatString)
  4185.  
  4186. ProcessAutoTagClear:
  4187. if arg(1)='' then
  4188. AtClearAll='N'
  4189. else
  4190. do
  4191. AtParm=GetQuotedText(arg(1))
  4192. if translate(AtParm)<> 'ALL' then
  4193. CryAndDie('Invalid parameter of "' || AtParm || '" specified!')
  4194. AtClearAll='Y'
  4195. end
  4196. call ClearAutoTags AtClearAll
  4197. return(0)
  4198.  
  4199. _GetStateIndexForNameOrDie:
  4200. gsiName=arg(1)
  4201. do NameIndex=1 to AutoTagStateCnt
  4202. if gsiName=AutoTagState.NameIndex.Name then
  4203. return(NameIndex)
  4204. end
  4205. CryAndDie('There is no state known as "' || gsiName(1) || '"')
  4206.  
  4207. MatchesAutoTagStateIncDebugText:
  4208. MatchIndex=arg(1)
  4209. if MatchIndex<=0 then
  4210. return('')
  4211. else
  4212. return(' (matches "#AutoTagState +" at ' || AutoTagState.MatchIndex.AtLine || ')')
  4213.  
  4214. ProcessAutoTagState:
  4215. Rest=strip(arg(1))
  4216. Ats1stParm=left(Rest,1)
  4217. if Ats1stParm='+' | Ats1stParm = '-' then
  4218. Rest=substr(Rest,2)
  4219. else
  4220. Ats1stParm=GetQuotedText(arg(1), "Rest")
  4221. select
  4222. when Ats1stParm='+' then
  4223. do
  4224. AutoTagStateCnt=AutoTagStateCnt+1
  4225. AutoTagState.AutoTagStateCnt.First=AutoTagFirst
  4226. AutoTagState.AutoTagStateCnt.Last=AutoTagLast
  4227. AutoTagState.AutoTagStateCnt.Name=AutoTagName
  4228. AutoTagState.AutoTagStateCnt.AtOnOff=AutoTagOn
  4229. AutoTagState.AutoTagStateCnt.AtLine=CurrentSourceLocation()
  4230. BeforeFirst=AutoTagFirst
  4231. BeforeLast=AutoTagLast
  4232. AutoTagFirst=AutoTagLast+1
  4233. AutoTagName=''
  4234. do while Rest<> ''
  4235. StateAlias=translate(GetQuotedText(Rest, "Rest"))
  4236. if StateAlias="REMEMBER" then
  4237. do
  4238. CopyFrom=BeforeFirst
  4239. Copyto=BeforeLast
  4240. end
  4241. else
  4242. do
  4243. NameIndex=_GetStateIndexForNameOrDie(StateAlias)
  4244. CopyFrom=AutoTagState.NameIndex.First
  4245. Copyto=AutoTagState.NameIndex.Last
  4246. end
  4247. do AddTagIndex=CopyFrom to CopyTo
  4248. call _AddAutoTag AutoTagOnB.AddTagIndex,AutoTagOnA.AddTagIndex
  4249. end
  4250. end
  4251. if OptionDebugOn='Y' then
  4252. call DBG_AUTOTAG 'Remembering current #AutoTag state, now in state #' ||AutoTagStateCnt
  4253. end
  4254. when Ats1stParm='-' then
  4255. do
  4256. if AutoTagStateCnt<=0 then
  4257. CryAndDie('No #autotag states memorised!')
  4258. if OptionDebugOn='Y' then
  4259. call DBG_AUTOTAG 'This restore matches the setup at ' ||AutoTagState.AutoTagStateCnt.AtLine
  4260. BeforeFirst=AutoTagFirst
  4261. BeforeLast=AutoTagLast
  4262. AutoTagFirst=AutoTagState.AutoTagStateCnt.First
  4263. AutoTagLast=AutoTagState.AutoTagStateCnt.Last
  4264. AutoTagOn=AutoTagState.AutoTagStateCnt.AtOnOff
  4265. AutoTagName=AutoTagState.AutoTagStateCnt.Name
  4266. AutoTagStateCnt=AutoTagStateCnt-1
  4267. if Rest='' then
  4268. Remember='N'
  4269. else
  4270. do
  4271. Rest=translate(GetQuotedText(Rest, "Rest"))
  4272. if Rest="REMEMBER" then
  4273. Remember='Y'
  4274. else
  4275. CryAndDie('Invalid parameter of "' || Rest || '" specified (expected "REMEMBER")')
  4276. end
  4277. if Rest='' then
  4278. DbgWord='dropping'
  4279. else
  4280. do
  4281. Rest=translate(GetQuotedText(Rest))
  4282. if Rest<> "REMEMBER" then
  4283. CryAndDie('Invalid parameter of "' || Rest || '" specified (expected "REMEMBER")')
  4284. DbgWord='remembering'
  4285. AutoTagLast=AutoTagFirst-1
  4286. do AddTagIndex=BeforeFirst to BeforeLast
  4287. call _AddAutoTag AutoTagOnB.AddTagIndex,AutoTagOnA.AddTagIndex
  4288. end
  4289. end
  4290. if OptionDebugOn='Y' then
  4291. call DBG_AUTOTAG 'Restoring #AutoTag state #' || AutoTagStateCnt || ', we are ' || DbgWord || ' any new tags you may have defined'
  4292. end
  4293. otherwise
  4294. AutoTagName=translate(Ats1stParm)
  4295. if Rest<> '' then
  4296. call DieIfExtraUnexpectedParms Rest
  4297. if OptionDebugOn='Y' then
  4298. call DBG_AUTOTAG 'This state is now named "' || AutoTagName || '"'
  4299. end
  4300. call ShowAutoTagStateWhenDebugOn AutoTagOn
  4301. return(0)
  4302.  
  4303. _AddAutoTag:
  4304. TheTagB=arg(1)
  4305. TheTagA=arg(2)
  4306. ThePosn=arg(3)
  4307. if ThePosn='' then
  4308. ThePosn='999999'
  4309. ThePosn=(ThePosn+AutoTagFirst)-1
  4310. if ThePosn>AutoTagLast then
  4311. do
  4312. AutoTagLast=AutoTagLast+1
  4313. SlotIndex=AutoTagLast
  4314. end
  4315. else
  4316. do
  4317. ToIndex=AutoTagLast+2
  4318. do MoveIndex=ThePosn to AutoTagLast
  4319. ToIndex=ToIndex-1
  4320. FromIndex=ToIndex-1
  4321. AutoTagOnB.ToIndex=AutoTagOnB.FromIndex
  4322. AutoTagOnA.ToIndex=AutoTagOnA.FromIndex
  4323. end
  4324. SlotIndex=ThePosn
  4325. AutoTagLast=AutoTagLast+1
  4326. end
  4327. AutoTagOnB.SlotIndex=TheTagB
  4328. AutoTagOnA.SlotIndex=TheTagA
  4329. return
  4330.  
  4331. _DeleteAutoTag:
  4332. TheTagB=arg(1)
  4333. do Tag=AutoTagFirst to AutoTagLast
  4334. if TheTagB=AutoTagOnB.Tag then
  4335. do
  4336. AutoTagLast=AutoTagLast-1
  4337. do ToIndex=Tag to AutoTagLast
  4338. FromIndex=ToIndex+1
  4339. AutoTagOnB.ToIndex=AutoTagOnB.FromIndex
  4340. AutoTagOnA.ToIndex=AutoTagOnA.FromIndex
  4341. end
  4342. return('Y')
  4343. end
  4344. end
  4345. if OptionDebugOn='Y' then
  4346. call DBG_AUTOTAG 'No need to delete the tag (it does not exist)'
  4347. return('N')
  4348.  
  4349. ProcessAutoTag:
  4350. AtBefore=GetQuotedText(arg(1), "Rest")
  4351. if AtBefore='' then
  4352. CryAndDie("You did not supply text to be replaced (can't replace empty string)!")
  4353. AtDumpList='N'
  4354. OnOrOff=IsStringOnOrOffCmd(AtBefore)
  4355. if OnOrOff<> '' & Rest = '' then
  4356. do
  4357. AutoTagOn=OnOrOff
  4358. if AutoTagOn='Y' then
  4359. AtDumpList='Y'
  4360. end
  4361. else
  4362. do
  4363. AtBefore_NoCT=AtBefore
  4364. AtBefore=AtChangeType||AtBefore
  4365. if Rest='' then
  4366. call _DeleteAutoTag AtBefore
  4367. else
  4368. do
  4369. AtAfter=ReplaceString(GetQuotedText(Rest, "Rest"),AutoTagSelf,AtBefore_NoCT)
  4370. if ReplacementsAllowed='Y' then
  4371. do
  4372. do while pos(StartsMacroReplacement,AtAfter)<>0
  4373. BeforeCount=ReplaceCount
  4374. AtAfterR=_ReplaceAllHashDefinedVariables(AtAfter)
  4375. if pos(MarksNewLine,AtAfterR)<>0 then
  4376. leave
  4377. AtAfter=AtAfterR
  4378. if OptionDebugOn='Y' then
  4379. do
  4380. if BeforeCount<>ReplaceCount then
  4381. call DebugOutputAfterReplacement AtAfter, 'VP2O'
  4382. end
  4383. end
  4384. if pos(StartsStdSymbolReplacement,AtAfter)<>0 then
  4385. do
  4386. if pos(MarksNewLine,AtAfter)=0 then
  4387. do
  4388. BeforeCount=ReplaceCount
  4389. AtAfterR=ReplaceStandardDefinitions(AtAfter)
  4390. if BeforeCount<>ReplaceCount then
  4391. do
  4392. if pos(MarksNewLine,AtAfterR)=0 then
  4393. do
  4394. AtAfter=AtAfterR
  4395. if OptionDebugOn='Y' then
  4396. call DebugOutputAfterReplacement AtAfter, 'SP2O'
  4397. end
  4398. end
  4399. end
  4400. end
  4401. end
  4402. AtSlot=''
  4403. if Rest<> '' then
  4404. do
  4405. SlotSpec=word(rest,1)
  4406. Rest=subword(rest,2)
  4407. if left(SlotSpec,1)<> '#' then
  4408. CryAndDie('Invalid slot specification of "' || SlotSpec || '" supplied, must begin with a "#"!')
  4409. AtSlot=substr(SlotSpec,2)
  4410. end
  4411. if OptionDebugOn='Y' then
  4412. call DBG_AUTOTAG 'Assigning ' || DebugRightArrow || AtBefore_NoCT || DebugLeftArrow || ' = ' || DebugRightArrow || AtAfter || DebugLeftArrow || ' (TYPE=' || AtChangeTypeDesc || ')'
  4413. call _AddAutoTag AtBefore,AtAfter,AtSlot
  4414. end
  4415. end
  4416. call ShowAutoTagStateWhenDebugOn AtDumpList
  4417. if Rest<> '' then
  4418. CryAndDie('Too many parameters!')
  4419. return(0)
  4420.  
  4421. ATCHANGETYPE_DEBUG:
  4422. if OptionDebugOn='Y' then
  4423. call OptionDebugShow 'ATCHANGETYPE', 'AutoTag change type is "' || AtChangeTypeDesc || '"'
  4424. return
  4425.  
  4426. ATCHANGETYPE_GET:
  4427. call ATCHANGETYPE_DEBUG
  4428. return(AtChangeTypeDesc)
  4429.  
  4430. ATCHANGETYPE_SET:
  4431. AtChangeTypeDesc=translate(arg(1))
  4432. if ProcessedCmdLine='N' then
  4433. do
  4434. call OptionDebugShow 'ATCHANGETYPE', 'Setting default change type to "' || AtChangeTypeDesc || '"'
  4435. Default4_ATCHANGETYPEDESC=AtChangeTypeDesc
  4436. return(0)
  4437. end
  4438. if AtChangeTypeDesc=='' then
  4439. AtChangeTypeDesc=Default4_ATCHANGETYPEDESC
  4440. AtChangeType=GetCtCode(AtChangeTypeDesc)
  4441. call ATCHANGETYPE_DEBUG
  4442. return
  4443.  
  4444. GetCtCode:
  4445. gb!D=arg(1)
  4446. gb!U=translate(gb!D)
  4447. select
  4448. when gb!U="CASESENSITIVE" then
  4449. gb!C=''
  4450. when gb!U="CASEINSENSITIVE" then
  4451. gb!C=SrCaseIns
  4452. when gb!U="FIXED" then
  4453. gb!C=SrFixed
  4454. otherwise
  4455. CryAndDie('Unknown AutoTag Change Type of "' || gb!D || '"')
  4456. end
  4457. return(gb!C)
  4458.  
  4459. AutoTag_24:
  4460. DefRexxSpecialSepTag='<' || '?xRexxEos>'
  4461. call InitializeDefineRexx
  4462. ValidPpwTrace='OFF ON AUTO'
  4463. signal Def_Rexx_25
  4464.  
  4465. MakeSafeInSQuotes:
  4466. hb!Str=arg(1)
  4467. hb!Str=ReplaceString(hb!Str, "'", "''")
  4468. hb!L1M=left(StartsMacroReplacement,1)
  4469. hb!Str=ReplaceString(hb!Str,hb!L1M, "' || '" || hb!L1M || "' || '")
  4470. hb!L1P=left(StartsMacroParm,1)
  4471. hb!Str=ReplaceString(hb!Str,hb!L1P, "' || '" || hb!L1P || "' || '")
  4472. return(hb!Str)
  4473.  
  4474. InitializeDefineRexx:
  4475. DefRexxVar=''
  4476. DefRexxAddType=''
  4477. DefRexxCode=''
  4478. DefRexxStartLoc=''
  4479. DefRexxPack='Y'
  4480. DefRexxTraceNext='N'
  4481. DefRexxLineCnt=0
  4482. if symbol('OptionPpwTrace') = 'VAR' then
  4483. DefRexxTrace=OptionPpwTrace
  4484. else
  4485. DefRexxTrace='OFF'
  4486. DefRexxNumTrace=0
  4487. DefRexxTraceAllowed='Y'
  4488. return
  4489.  
  4490. ProcessDefineRexx:
  4491. if arg(1)='' then
  4492. do
  4493. if DefRexxVar='' then
  4494. CryAndDie("Not currently defining rexx code!", 'To execute you need to specify a parameter of ""')
  4495. if DefRexxNumTrace<>0 then
  4496. do
  4497. if DefRexxVar<> '?JustExec?';then
  4498. EndCmt='@Finished@ (Executing rexx from macro "' || DefRexxVar || '")'
  4499. else
  4500. EndCmt="@Finished@"
  4501. call DefRexxAddLine "call RexxTrace '" || EndCmt || "','?'"
  4502. DefRexxNumTrace=DefRexxNumTrace+1
  4503. call DBG_DEFINING DefRexxNumTrace|| ' $trace statements inserted'
  4504. end
  4505. if DefineMacroReplace='Y' then
  4506. DefRexxCode=PerformReplacementsInCmdsParameters(DefRexxCode)
  4507. if DefRexxVar<> '?JustExec?';then
  4508. do
  4509. call AddHashDefine DefRexxVar,DefRexxCode,DefRexxAddType
  4510. end
  4511. else
  4512. do
  4513. if OptionDebugOn='Y' then
  4514. call DBG_DEFINING 'Rexx code will be immediately executed but not saved'
  4515. call ExecRexxCmd DefRexxCode, 'Y'
  4516. end
  4517. call InitializeDefineRexx
  4518. end
  4519. else
  4520. do
  4521. if DefRexxVar<> '' then
  4522. CryAndDie("Already in rexx code block started at " ||DefRexxStartLoc)
  4523. call InitializeDefineRexx
  4524. DefRexxStartLoc=CurrentSourceLocation()
  4525. DefRexxAddType=arg(2)
  4526. DefRexxVar=GetQuotedText(PerformReplacementsInCmdsParameters(arg(1)), "Rest")
  4527. if DefRexxVar='' then
  4528. do
  4529. DefRexxVar='?JustExec?';
  4530. DefRexxPack='N'
  4531. end
  4532. if Rest<> '' then
  4533. do
  4534. Rest=translate(Rest)
  4535. do until Rest=''
  4536. DefSpec=GetQuotedText(Rest, "Rest")
  4537. select
  4538. when DefSpec='NOPACK' then
  4539. DefRexxPack='N'
  4540. when DefSpec='TRACE:AUTO' then
  4541. DefRexxTrace='AUTO'
  4542. when DefSpec='TRACE:ON' | DefSpec = '$TRACE' then
  4543. DefRexxTrace='ON'
  4544. when DefSpec='TRACE:OFF' then
  4545. DefRexxTrace='OFF'
  4546. otherwise
  4547. CryAndDie('Invalid option of "' || DefSpec || '" used')
  4548. end
  4549. end
  4550. end
  4551. if OptionPpwTraceAllowed='N' then
  4552. do
  4553. if DefRexxTrace<> 'OFF' then
  4554. do
  4555. call DBG_DEFINING 'Tracing turned off with /PPWTRACE, otherwise would trace using "' || DefRexxTrace || '"!'
  4556. DefRexxTrace='OFF'
  4557. end
  4558. end
  4559. if OptionDebugOn='Y' then
  4560. do
  4561. if DefRexxPack='Y' then
  4562. call DBG_DEFINING "AllowPack option is currently " ||YorN2OnorOff(AllowPack)
  4563. if DefRexxTrace='OFF' then
  4564. call DBG_DEFINING '$Trace and $Breakpoint commands will be ignored!'
  4565. else
  4566. do
  4567. if DefRexxTrace='AUTO' then
  4568. call DBG_DEFINING '$Trace statements for each line are being automatically inserted!'
  4569. else
  4570. call DBG_DEFINING '$Trace statements for each line are NOT being automatically inserted!'
  4571. end
  4572. end
  4573. if DefRexxTrace<> 'OFF' then
  4574. do
  4575. if DefRexxVar<> '?JustExec?';then
  4576. StrCmt='@Starting@ (Executing rexx from macro "' || DefRexxVar || '")'
  4577. else
  4578. StrCmt="@Starting@ (direct: " || CurrentSourceLocation() || ")"
  4579. call DefRexxAddLine "call RexxTrace '" || StrCmt || "','?'"
  4580. DefRexxNumTrace=DefRexxNumTrace+1
  4581. end
  4582. end
  4583. return(0)
  4584.  
  4585. AddDefineRexxLine:
  4586. NewRexxLine=strip(arg(1))
  4587. DefRexxLineCnt=DefRexxLineCnt+1
  4588. if right(NewRexxLine,2)=RexxCmtEnd then
  4589. do
  4590. StartCmtPos=lastpos(RexxCmtStart,NewRexxLine)
  4591. if StartCmtPos<>0 then
  4592. do
  4593. if StartCmtPos=0 then
  4594. NewRexxLine=''
  4595. else
  4596. NewRexxLine=strip(left(NewRexxLine,StartCmtPos-1), 'T')
  4597. end
  4598. end
  4599. do while right(NewRexxLine,1)=';'
  4600. NewRexxLine=strip(left(NewRexxLine,length(NewRexxLine)-1), 'T')
  4601. end
  4602. if NewRexxLine='' then
  4603. return
  4604. UnpackedLine=space(NewRexxLine)
  4605. if DefRexxPack='Y' then
  4606. do
  4607. if AllowPack='Y' then
  4608. NewRexxLine=CompressRexxLine(NewRexxLine)
  4609. end
  4610. DropLine='N'
  4611. ib!W1=translate(word(NewRexxLine,1))
  4612. select
  4613. when ib!W1="$BREAKPOINT" then
  4614. do
  4615. UserTraceCmt=subword(NewRexxLine,2)
  4616. if DefRexxTrace='OFF' then
  4617. ib!I='Ignoring - '
  4618. else
  4619. do
  4620. ib!I=''
  4621. UserTraceCmt=MakeSafeInSQuotes(UserTraceCmt)
  4622. NewRexxLine="call UserBreakPoint '$BreakPoint: " || UserTraceCmt || "','?'"
  4623. call DefRexxAddLine NewRexxLine
  4624. DefRexxNumTrace=DefRexxNumTrace+1
  4625. end
  4626. call DBG_DEFINING ib!I|| '$BreakPoint: ' ||UserTraceCmt
  4627. DropLine='Y'
  4628. end
  4629. when ib!W1="$TRACE" then
  4630. do
  4631. DropLine='Y'
  4632. if DefRexxTrace='OFF' then
  4633. call DBG_DEFINING 'Ignoring - $Trace command'
  4634. else
  4635. do
  4636. Rest=translate(subword(NewRexxLine,2))
  4637. select
  4638. when Rest="ON" then
  4639. DefRexxTraceAllowed='Y'
  4640. when Rest="OFF" then
  4641. DefRexxTraceAllowed='N'
  4642. otherwise
  4643. do
  4644. UserTraceCmt=subword(NewRexxLine,2)
  4645. if UserTraceCmt='' then
  4646. DefRexxTraceNext="Y"
  4647. else
  4648. do
  4649. call DBG_DEFINING '$tracing comment: ' ||UserTraceCmt
  4650. DefRexxTraceNext="N"
  4651. UserTraceCmt=MakeSafeInSQuotes(UserTraceCmt)
  4652. NewRexxLine="call RexxTrace '" || UserTraceCmt || "','?'"
  4653. call DefRexxAddLine NewRexxLine
  4654. DefRexxNumTrace=DefRexxNumTrace+1
  4655. end
  4656. end
  4657. end
  4658. end
  4659. end
  4660. otherwise
  4661. end
  4662. if DropLine='Y' then
  4663. DropLine='N'
  4664. else
  4665. do
  4666. if DefRexxTraceNext="Y" then
  4667. TraceThis='Y'
  4668. else
  4669. do
  4670. if DefRexxTrace<> 'AUTO' then
  4671. TraceThis='N'
  4672. else
  4673. do
  4674. if pos('/' || translate(NewRexxLine) || '/', "/THEN/DO/ELSE/")=0 then
  4675. TraceThis='Y'
  4676. else
  4677. TraceThis='N'
  4678. end
  4679. end
  4680. if TraceThis='Y' then
  4681. do
  4682. DefRexxTraceNext="N"
  4683. if DefRexxTraceAllowed='Y' then
  4684. do
  4685. call DBG_DEFINING '$tracing: ' ||UnpackedLine
  4686. TraceThis=MakeSafeInSQuotes(UnpackedLine)
  4687. NewRexxLine="call RexxTrace '@" || DefRexxLineCnt || " -> " || TraceThis || "',,'Y'" ||DefRexxSpecialSepTag||NewRexxLine
  4688. DefRexxNumTrace=DefRexxNumTrace+1
  4689. end
  4690. end
  4691. call DefRexxAddLine NewRexxLine
  4692. end
  4693. return
  4694.  
  4695. DefRexxAddLine:
  4696. if DefRexxCode='' then
  4697. DefRexxCode=arg(1)
  4698. else
  4699. DefRexxCode=DefRexxCode||DefRexxSpecialSepTag||arg(1)
  4700. return
  4701.  
  4702. PPWTRACE_DEBUG:
  4703. if OptionDebugOn='Y' then
  4704. call OptionDebugShow 'PPWTRACE', 'PPWTRACE is set to "' || OptionPpwTrace || '"'
  4705. return
  4706.  
  4707. PPWTRACE_SET:
  4708. OptionPpwTrace=translate(arg(1))
  4709. if ProcessedCmdLine='N' then
  4710. do
  4711. call OptionDebugShow 'PPWTRACE', 'Setting default PPWTRACE to "' || OptionPpwTrace || '"'
  4712. DefaultPpwTrace=OptionPpwTrace
  4713. return(0)
  4714. end
  4715. if OptionPpwTrace=='' then
  4716. OptionPpwTrace=DefaultPpwTrace
  4717. if pos(OptionPpwTrace,ValidPpwTrace)=0 then
  4718. CryAndDie('Invalid PPWTRACE value of "' || OptionPpwTrace || '", should be one of "' || ValidPpwTrace || '"!')
  4719. call PPWTRACE_DEBUG
  4720. return
  4721.  
  4722. PPWTRACE_GET:
  4723. call PPWTRACE_DEBUG
  4724. return(OptionPpwTrace)
  4725.  
  4726. Def_Rexx_25:
  4727. OptionCount=0
  4728. LongestPpwOptionLng=0
  4729. call _OptionsAdd "ALLOWPACK"
  4730. call _OptionsAdd "ALLOWSPELL"
  4731. call _OptionsAdd "CSREPLACEMENT"
  4732. call _OptionsAdd "DEFINEMACROREPLACE"
  4733. call _OptionsAdd "KEEPINDENT"
  4734. call _OptionsAdd "LEAVEBLANKLINES"
  4735. call _OptionsAdd "REPLACE"
  4736. call _OptionsAdd "ATCHANGETYPE"
  4737. call _OptionsAdd "DEBUGLEVEL"
  4738. call _OptionsAdd "EXTRAINDENT"
  4739. call _OptionsAdd "EXPANDX"
  4740. call _OptionsAdd "HASHPREFIX"
  4741. call _OptionsAdd "LINECOMMENT"
  4742. call _OptionsAdd "LINECONTINUATION"
  4743. call _OptionsAdd "MACROPARMTAGS"
  4744. call _OptionsAdd "PARMVAL"
  4745. call _OptionsAdd "PPWTRACE"
  4746. call _OptionsAdd "REPLACEMENTTAGS"
  4747. call _OptionsAdd "TABS"
  4748. call _OptionsAdd "WARNINGS"
  4749. call _OptionsAdd "WHITESPACE"
  4750. signal OPTION_26
  4751.  
  4752. _OptionsAdd:
  4753. OptionCount=OptionCount+1
  4754. OptionList.OptionCount=arg(1)
  4755. ThisLng=length(arg(1))
  4756. if ThisLng>LongestPpwOptionLng then
  4757. LongestPpwOptionLng=ThisLng
  4758. return
  4759.  
  4760. SetUpPpwizardOptionDefaults:
  4761. if RexIsAscii='N' then
  4762. DefWhite=''
  4763. else
  4764. do
  4765. if RexSystemOpSys<> "UNIX" then
  4766. DefWhite=d2c(26)||d2c(27)
  4767. else
  4768. DefWhite=d2c(13)||d2c(26)||d2c(27)
  4769. end
  4770. ProcessedCmdLine='N'
  4771. call DBG_OPTIONS 'Setting PPWIZARD defaults (may be overriden with ' || OptChar || 'option switch)'
  4772. call DBGIND 1
  4773. call OptionOnOrOff_SET "ALLOWPACK",          "AllowPack",           "ON"
  4774. call OptionOnOrOff_SET "ALLOWSPELL",         "AllowSpell",          "ON"
  4775. call ATCHANGETYPE_SET "CASESENSITIVE"
  4776. call OptionOnOrOff_SET "CSREPLACEMENT",      "CsReplacement",       "OFF"
  4777. call DEBUGLEVEL_SET 'DEFAULT'
  4778. call OptionOnOrOff_SET "DEFINEMACROREPLACE", "DefineMacroReplace",  "OFF"
  4779. call EXPANDX_SET 'LATE'
  4780. call EXTRAINDENT_SET 'NULL'
  4781. call HASHPREFIX_SET '#'
  4782. call OptionOnOrOff_SET "KEEPINDENT",         "KeepIndent",          "OFF"
  4783. call OptionOnOrOff_SET "LEAVEBLANKLINES",    "LeaveBlankLines",     "OFF"
  4784. call LINECOMMENT_SET ';'
  4785. call LINECONTINUATION_SET '\%-+ '
  4786. call MACROPARMTAGS_SET '{}$'
  4787. call OptionOnOrOff_SET "REPLACE",            "ReplacementsAllowed", "ON"
  4788. call PARMVAL_SET "SOME"
  4789. if OptionDebugOn='Y' then
  4790. jb!D='ON'
  4791. else
  4792. jb!D='OFF'
  4793. call PPWTRACE_SET jb!D
  4794. call REPLACEMENTTAGS_SET '<>$?[]'
  4795. call TABS_SET 'Warnings'
  4796. call WARNINGS_SET ''
  4797. call WHITESPACE_SET DefWhite
  4798. call DBGIND-1
  4799. return
  4800.  
  4801. SetUpOptionsForThisBuild:
  4802. ProcessedCmdLine='Y'
  4803. call DBG_OPTIONS 'Initializing #options for this build of ' ||CurrentOutFile
  4804. call DBGIND 1
  4805. call OptionOnOrOff_SET "ALLOWPACK",          "AllowPack",           ""
  4806. call OptionOnOrOff_SET "ALLOWSPELL",         "AllowSpell",          ""
  4807. call ATCHANGETYPE_SET ''
  4808. call OptionOnOrOff_SET "CSREPLACEMENT",      "CsReplacement",       ""
  4809. call DEBUGLEVEL_SET ''
  4810. call OptionOnOrOff_SET "DEFINEMACROREPLACE", "DefineMacroReplace",  ""
  4811. call EXPANDX_SET ''
  4812. call EXTRAINDENT_SET ''
  4813. call HASHPREFIX_SET ''
  4814. call OptionOnOrOff_SET "KEEPINDENT",         "KeepIndent",          ""
  4815. call OptionOnOrOff_SET "LEAVEBLANKLINES",    "LeaveBlankLines",     ""
  4816. call LINECOMMENT_SET ''
  4817. call LINECONTINUATION_SET ''
  4818. call MACROPARMTAGS_SET ''
  4819. call OptionOnOrOff_SET "REPLACE",            "ReplacementsAllowed", ""
  4820. call PARMVAL_SET ''
  4821. call PPWTRACE_SET ''
  4822. call REPLACEMENTTAGS_SET ''
  4823. call TABS_SET ''
  4824. call WARNINGS_SET ''
  4825. call WHITESPACE_SET 'NULL'
  4826. call DBGIND-1
  4827. return
  4828.  
  4829. MatchesOptionStackPushDebugText:
  4830. MatchIndex=arg(1)
  4831. if MatchIndex<=0 then
  4832. return('')
  4833. else
  4834. return(' (matches "#option PUSH" at ' || OptPush.MatchIndex || ')')
  4835.  
  4836. OptionsPush:
  4837. OptionStackCnt=OptionStackCnt+1
  4838. OptPush.OptionStackCnt=CurrentSourceLocation()
  4839. PushName='OptPush' ||OptionStackCnt
  4840. if OptionDebugOn='Y' then
  4841. call DBG_OPTIONS 'Saving current options on stack as #' ||OptionStackCnt
  4842. call DBGIND 1
  4843. do OptionIndex=1 to OptionCount
  4844. call _valueS PushName|| '.' ||OptionIndex,OptionGetValue(OptionList.OptionIndex)
  4845. end
  4846. call DBGIND-1
  4847. return
  4848.  
  4849. OptionsPop:
  4850. if OptionStackCnt<=0 then
  4851. CryAndDie('There are no options on the stack to pop!')
  4852. if OptionDebugOn='Y' then
  4853. call DBG_OPTIONS 'Restoring current options from #' || OptionStackCnt || ' (pushed at ' || OptPush.OptionStackCnt || ')'
  4854. call DBGIND 1
  4855. PushName='OptPush' ||OptionStackCnt
  4856. do OptionIndex=1 to OptionCount
  4857. call OptionSetValue OptionList.OptionIndex,_valueG(PushName|| '.' ||OptionIndex)
  4858. end
  4859. call DBGIND-1
  4860. OptionStackCnt=OptionStackCnt-1
  4861. return
  4862.  
  4863. ProcessOption:
  4864. Options=arg(1)
  4865. if ProcessedCmdLine='Y' then
  4866. Options=PerformReplacementsInCmdsParameters(Options)
  4867. if Options='' then
  4868. CryAndDie('No options specified!')
  4869. do while Options<> ''
  4870. parse var Options Word1' 'RestOptions
  4871. Word1=translate(word1)
  4872. select
  4873. when Word1="PUSH" | Word1 = "+" then
  4874. do
  4875. Options=RestOptions
  4876. call OptionsPush
  4877. end
  4878. when Word1="POP" | Word1 = "-" then
  4879. do
  4880. Options=RestOptions
  4881. call OptionsPop
  4882. end
  4883. otherwise
  4884. do
  4885. if pos('=',Options)=0 then
  4886. CryAndDie('Could not find an "=" sign in "' || Options || '"')
  4887. parse var Options ThisOption'='Options
  4888. ThisOption=translate(strip(ThisOption))
  4889. ThisValue=GetQuotedText(Options, "Options")
  4890. call OptionSetValue ThisOption,ThisValue
  4891. end
  4892. end
  4893. end
  4894. return(0)
  4895.  
  4896. OptionDebugShow:
  4897. if OptionDebugOn='Y' then
  4898. do
  4899. jb!M=left(arg(1),LongestPpwOptionLng)|| ': ' ||arg(2)
  4900. if arg(1)='DEBUGLEVEL' then
  4901. call DBG jb!M
  4902. else
  4903. call DBG_OPTIONS jb!M
  4904. end
  4905. return
  4906.  
  4907. OptionOnOrOff_DEBUG:
  4908. if OptionDebugOn='Y' then
  4909. call OptionDebugShow arg(1), 'Currently set to ' ||YorN2OnorOff(_valueG(arg(2)))
  4910. return
  4911.  
  4912. OptionOnOrOff_SET:
  4913. parse arg OptionName,OnOffVar2Set,OnOffValue
  4914. if ProcessedCmdLine='N' then
  4915. do
  4916. call OptionDebugShow OptionName, 'Setting default to "' || OnOffValue || '"'
  4917. call _valueS "Default4_" ||OnOffVar2Set,OnOffValue
  4918. return(0)
  4919. end
  4920. if OnOffValue=='' then
  4921. OnOffValue=_valueG("Default4_" ||OnOffVar2Set)
  4922. OnOrOff=IsStringOnOrOffCmd(OnOffValue)
  4923. if OnOrOff='' then
  4924. CryAndDie('Tried to set "' || OnOffVar2Set || '" to an invalid value of "' || OnOffValue || '"')
  4925. call _valueS OnOffVar2Set,OnOrOff
  4926. call OptionOnOrOff_DEBUG OptionName,OnOffVar2Set
  4927. return(0)
  4928.  
  4929. OptionOnOrOff_GET:
  4930. parse arg OptionName,OnOffVar2Get
  4931. VarState=YorN2OnorOff(_valueG(OnOffVar2Get))
  4932. call OptionOnOrOff_DEBUG OptionName,OnOffVar2Get
  4933. return(VarState)
  4934.  
  4935. OptionSetValue:
  4936. parse arg sOption,sValue
  4937. select
  4938. when sOption="ALLOWPACK" then
  4939. call OptionOnOrOff_SET "ALLOWPACK", "AllowPack",sValue
  4940. when sOption="ALLOWSPELL" then
  4941. call OptionOnOrOff_SET "ALLOWSPELL", "AllowSpell",sValue
  4942. when sOption="ATCHANGETYPE" then
  4943. call ATCHANGETYPE_SET sValue,sOption
  4944. when sOption="CSREPLACEMENT" then
  4945. call OptionOnOrOff_SET "CSREPLACEMENT", "CsReplacement",sValue
  4946. when sOption="DEBUGLEVEL" then
  4947. call DEBUGLEVEL_SET sValue,sOption
  4948. when sOption="DEFINEMACROREPLACE" then
  4949. call OptionOnOrOff_SET "DEFINEMACROREPLACE", "DefineMacroReplace",sValue
  4950. when sOption="EXPANDX" then
  4951. call EXPANDX_SET sValue,sOption
  4952. when sOption="EXTRAINDENT" then
  4953. call EXTRAINDENT_SET sValue,sOption
  4954. when sOption="HASHPREFIX" then
  4955. call HASHPREFIX_SET sValue,sOption
  4956. when sOption="KEEPINDENT" then
  4957. call OptionOnOrOff_SET "KEEPINDENT", "KeepIndent",sValue
  4958. when sOption="LEAVEBLANKLINES" then
  4959. call OptionOnOrOff_SET "LEAVEBLANKLINES", "LeaveBlankLines",sValue
  4960. when sOption="LINECOMMENT" then
  4961. call LINECOMMENT_SET sValue,sOption
  4962. when sOption="LINECONTINUATION" then
  4963. call LINECONTINUATION_SET sValue,sOption
  4964. when sOption="MACROPARMTAGS" then
  4965. call MACROPARMTAGS_SET sValue,sOption
  4966. when sOption="PARMVAL" then
  4967. call PARMVAL_SET sValue,sOption
  4968. when sOption="PPWTRACE" then
  4969. call PPWTRACE_SET sValue,sOption
  4970. when sOption="REPLACE" then
  4971. call OptionOnOrOff_SET "REPLACE", "ReplacementsAllowed",sValue
  4972. when sOption="REPLACEMENTTAGS" then
  4973. call REPLACEMENTTAGS_SET sValue,sOption
  4974. when sOption="TABS" then
  4975. call TABS_SET sValue,sOption
  4976. when sOption="WARNINGS" then
  4977. call WARNINGS_SET sValue,sOption
  4978. when sOption="WHITESPACE" then
  4979. call WHITESPACE_SET sValue,sOption
  4980. otherwise
  4981. CryAndDie("Can't set '" || sOption || "' as this option is unknown")
  4982. end
  4983. return
  4984.  
  4985. OptionGetValue:
  4986. parse arg gOption
  4987. select
  4988. when gOption="ALLOWPACK" then
  4989. return(OptionOnOrOff_GET("ALLOWPACK", "AllowPack"))
  4990. when gOption="ALLOWSPELL" then
  4991. return(OptionOnOrOff_GET("ALLOWSPELL", "AllowSpell"))
  4992. when gOption="ATCHANGETYPE" then
  4993. return(ATCHANGETYPE_GET(gOption))
  4994. when gOption="CSREPLACEMENT" then
  4995. return(OptionOnOrOff_GET("CSREPLACEMENT", "CsReplacement"))
  4996. when gOption="DEBUGLEVEL" then
  4997. return(DEBUGLEVEL_GET(gOption))
  4998. when gOption="DEFINEMACROREPLACE" then
  4999. return(OptionOnOrOff_GET("DEFINEMACROREPLACE", "DefineMacroReplace"))
  5000. when gOption="EXPANDX" then
  5001. return(EXPANDX_GET(gOption))
  5002. when gOption="EXTRAINDENT" then
  5003. return(EXTRAINDENT_GET(gOption))
  5004. when gOption="HASHPREFIX" then
  5005. return(HASHPREFIX_GET(gOption))
  5006. when gOption="KEEPINDENT" then
  5007. return(OptionOnOrOff_GET("KEEPINDENT", "KeepIndent"))
  5008. when gOption="LEAVEBLANKLINES" then
  5009. return(OptionOnOrOff_GET("LEAVEBLANKLINES", "LeaveBlankLines"))
  5010. when gOption="LINECOMMENT" then
  5011. return(LINECOMMENT_GET(gOption))
  5012. when gOption="LINECONTINUATION" then
  5013. return(LINECONTINUATION_GET(gOption))
  5014. when gOption="MACROPARMTAGS" then
  5015. return(MACROPARMTAGS_GET(gOption))
  5016. when gOption="PARMVAL" then
  5017. return(PARMVAL_GET(gOption))
  5018. when gOption="PPWTRACE" then
  5019. return(PPWTRACE_GET(gOption))
  5020. when gOption="REPLACE" then
  5021. return(OptionOnOrOff_GET("REPLACE", "ReplacementsAllowed"))
  5022. when gOption="REPLACEMENTTAGS" then
  5023. return(REPLACEMENTTAGS_GET(gOption))
  5024. when gOption="TABS" then
  5025. return(TABS_GET(gOption))
  5026. when gOption="WARNINGS" then
  5027. return(WARNINGS_GET(gOption))
  5028. when gOption="WHITESPACE" then
  5029. return(WHITESPACE_GET(gOption))
  5030. otherwise
  5031. CryAndDie("Can't get '" || gOption || "' as this option is unknown")
  5032. end
  5033. return
  5034.  
  5035. OPTION_26:
  5036. NameOfOs2ReginaRexxInterpreter=""
  5037. signal Rexx_27
  5038.  
  5039. _GetNameOfMacroSpaceExe:
  5040. if Symbol('MacroSpaceExe') <> 'VAR' then
  5041. do
  5042. MacroSpaceExeBase='MacroSpc.EXE'
  5043. MacroSpaceExe=_filespec('drive', PpWizardPgmName) || _filespec('Path',PpWizardPgmName)||MacroSpaceExeBase
  5044. if FileQueryExists(MacroSpaceExe)='' then
  5045. do
  5046. MacroSpaceExe=FindFileInPath(MacroSpaceExeBase, '*PATH')
  5047. if MacroSpaceExe="" then
  5048. MacroSpaceExe=FindFileInPath(MacroSpaceExeBase, '*DPATH')
  5049. end
  5050. call DBG 'Macro Space Pgm: ' ||MacroSpaceExe
  5051. end
  5052. return(MacroSpaceExe)
  5053.  
  5054. _GetNameOfOs2ReginaExe:
  5055. if Symbol('Os2ReginaExe') <> 'VAR' then
  5056. do
  5057. Os2ReginaExeBase='ROS2REXX.EXE'
  5058. Os2ReginaExe=_filespec('drive', PpWizardPgmName) || _filespec('Path',PpWizardPgmName)||Os2ReginaExeBase
  5059. if FileQueryExists(Os2ReginaExe)='' then
  5060. do
  5061. Os2ReginaExe=FindFileInPath(Os2ReginaExeBase, '*PATH')
  5062. end
  5063. end
  5064. return(Os2ReginaExe)
  5065.  
  5066. DoMacroSpaceOperation:
  5067. parse arg MsCommand,MsFile,MsFunction,MsQuiet
  5068. CallersLine=SIGL
  5069. call DBG 'Trying to macrospace "' || MsCommand || '" "' || MsFile || '" alias (' || MsFunction || ')'
  5070. TmpFile=RexGetTmpFileName()
  5071. CheckPgm=_GetNameOfMacroSpaceExe()
  5072. if CheckPgm='' then
  5073. do
  5074. if MsQuiet="QUIET" then
  5075. return
  5076. else
  5077. CryAndDie("Can't perform macro space command as " || MacroSpaceExeBase || ' is unavailable.')
  5078. end
  5079. FailMsg='MACRO SPACE COMMAND FAILED'
  5080. call AddressCmd CheckPgm|| ' ' || MsCommand || ' ' || MsFile || ' ' || MsFunction || ' >' || TmpFile || ' 2>&1'
  5081. if MsQuiet="QUIET" then
  5082. return
  5083. else
  5084. signal CheckMacroSpaceRc
  5085.  
  5086. CheckRexxModuleForSyntaxErrors:
  5087. call DBG 'CheckRexxModuleForSyntaxErrors()'
  5088. if RexWhich='REGINA' then
  5089. do
  5090. call CallStubInGeneratedCodeToCheckSyntax
  5091. return
  5092. end
  5093. CallersLine=SIGL
  5094. TmpFile=RexGetTmpFileName()
  5095. CheckPgm=_GetNameOfMacroSpaceExe()
  5096. if CheckPgm='' then
  5097. do
  5098. call DBG "Can't use normal validation method on the rexx syntax - " || MacroSpaceExeBase || ' file not found!'
  5099. call CallStubInGeneratedCodeToCheckSyntax
  5100. return
  5101. end
  5102. FailMsg='INVALID SYNTAX'
  5103. call AddressCmd CheckPgm|| ' CheckSyntax ' || Output.1.File || ' >' || NameOfNulDevice() || ' 2>' ||TmpFile
  5104.  
  5105. CheckMacroSpaceRc:
  5106. CheckRc=Rc
  5107. if CheckRc=0 then
  5108. do
  5109. DosDelRc=_SysFileDelete(TmpFile)
  5110. call UseOs2ReginaToDoubleCheckSyntax
  5111. return
  5112. end
  5113. call Line1 ''
  5114. call ColorSet 'ERROR'
  5115. call Line1 FailMsg
  5116. call Line1 copies('~',length(FailMsg))
  5117. do while lines(TmpFile)<>0
  5118. call Line1 linein(TmpFile)
  5119. end
  5120. call ColorSet
  5121. call _FileClose TmpFile
  5122. DosDelRc=_SysFileDelete(TmpFile)
  5123. AbnormalExit(CallersLine, "Syntax Error in generated rexx code")
  5124.  
  5125. CallStubInGeneratedCodeToCheckSyntax:
  5126. CheckingFile=Output.1.File
  5127. call DBGIND 1
  5128. call DBG 'Calling stub in generated code'
  5129. signal ON SYNTAX NAME SyntaxErrorInGeneratedCode
  5130. CheckRc='*?*'
  5131. interpret 'CheckRc =  "' || CheckingFile || '"("' || SyntaxOkText || '")'
  5132. if CheckRc<>SyntaxOkRc then
  5133. CryAndDie('Probably Syntax Error, got unexpected RC of "' || CheckRc || '"')
  5134. call DBGIND-1
  5135. return
  5136.  
  5137. SyntaxErrorInGeneratedCode:
  5138. CryAndDie('Faulty syntax in generated "' || CheckingFile || '"!')
  5139.  
  5140. UseOs2ReginaToDoubleCheckSyntax:
  5141. if RexWhich='REGINA' then
  5142. return
  5143. if NameOfOs2ReginaRexxInterpreter='-' then
  5144. return
  5145. call DBG 'OS/2 rexx already passed code, can we double check using OS/2 regina?'
  5146. UseExe=NameOfOs2ReginaRexxInterpreter
  5147. if UseExe='' then
  5148. UseExe=_GetNameOfOs2ReginaExe()
  5149. if UseExe='' then
  5150. return
  5151. CheckingFile=Output.1.File
  5152. call DBGIND 1
  5153. call DBG 'Checking using "' || UseExe || '"'
  5154. call AddressCmd UseExe|| ' ' || CheckingFile || ' ' ||SyntaxOkText
  5155. if Rc<>SyntaxOkRc&Rc<>255 then
  5156. CryAndDie('Probably syntax error in "' || Output.1.File || '"', 'Got unexpected RC of "' || Rc || '" from ' ||UseExe)
  5157. call DBGIND-1
  5158. return
  5159.  
  5160. Rexx_27:
  5161. InfiniteLoopDetected='N'
  5162. InfiniteLoopWhen=0
  5163. InfiniteIncludeLoopWhen=0
  5164. RexxSkipCounter=0
  5165. ArePositionalChars='"' || "'="
  5166. MarksPhpXml='<' || '?'
  5167. signal Define_28
  5168.  
  5169. _RXQuote:
  5170. parse arg lb!Right,lb!Quote,lb!OpQuote
  5171. lb!Break=lb!Quote|| '||,' ||DefRexxSpecialSepTag||lb!Quote
  5172. lb!DQuote=lb!Quote||lb!Quote
  5173. lb!Left=''
  5174. do while length(lb!Right)>100
  5175. if lb!Left=='' then
  5176. lb!Left=ReplaceString(left(lb!Right,100),lb!Quote,lb!DQuote)
  5177. else
  5178. lb!Left=lb!Left||lb!Break||ReplaceString(left(lb!Right,100),lb!Quote,lb!DQuote)
  5179. lb!Right=substr(lb!Right,100+1)
  5180. end
  5181. return(lb!Left||ReplaceString(lb!Right,lb!Quote,lb!DQuote))
  5182.  
  5183. _RxVar:
  5184. parse arg mb!Cmd,mb!Value
  5185. parse var mb!Cmd "$$RXVAR:" mb!Var
  5186. if mb!Var='' then
  5187. CryAndDie('You must supply a variable name on a "$$RxVar" transformation')
  5188. return('@s@RxVar:' || mb!Var || ':' || mb!Value || ':@e@RxVar')
  5189.  
  5190. ExpandAnyRxVarHacks:
  5191. parse arg nb!Str
  5192. nb!P=pos('@s@RxVar:',nb!Str)
  5193. if nb!P=0 then
  5194. return(nb!Str)
  5195. nb!L=''
  5196. do until nb!P=0
  5197. parse var nb!Str nb!B '@s@RxVar:' nb!Var ':' nb!Value ':@e@RxVar' nb!Str
  5198. nb!C=''
  5199. nb!Add2=''
  5200. do until nb!Value==''
  5201. parse var nb!Value nb!Bit+100 nb!Value
  5202. nb!Bit=ReplaceString(nb!Bit, '"', '""')
  5203. nb!C=nb!C||nb!Var|| '=' || nb!Add2 || '"' || nb!Bit || '"' ||DefRexxSpecialSepTag
  5204. nb!Add2=nb!Var|| '||'
  5205. end
  5206. nb!L=nb!L||nb!B||nb!C
  5207. nb!P=pos('@s@RxVar:',nb!Str)
  5208. end
  5209. return(nb!L||nb!Str)
  5210.  
  5211. InitCondNlCount:
  5212. CondNlCount=0
  5213. return
  5214.  
  5215. _MacroBitNotFoundText:
  5216. if CsReplacement='N' then
  5217. return('')
  5218. else
  5219. return('Macro names & parameters are case sensitive (check case)')
  5220.  
  5221. InitializeHashDefinesForThisCompile:
  5222. call DBG_DEFINING 'Initializing all #defines, got ' || OptionDefineCount || ' /define definitions to load up.'
  5223. drop MACRO?.
  5224. call AddHashDefine '_PPWIZARD_', ''
  5225. if OptionDefineCount<>0 then
  5226. do
  5227. do Index=1 to OptionDefineCount
  5228. call AddHashDefine OptionDefine.Index.Var,OptionDefine.Index.Cont
  5229. end
  5230. end
  5231. call _GetUserOptionsViaDefineSwitch
  5232. return
  5233.  
  5234. _GetUserOptionsViaDefineSwitch:
  5235. call DBG_MACROVALORDEF 'Getting some lesser options (not worth specific commands)'
  5236. call DBGIND 1
  5237. if RexSystemOpSys="UNIX" then
  5238. PathDelimiterChar=':'
  5239. else
  5240. PathDelimiterChar=';'
  5241. PathDelimiterChar=CfgMacro("PATH_DELIMITER_CHAR",PathDelimiterChar)
  5242. if length(PathDelimiterChar)<>1 then
  5243. CryAndDie("Invalid path delimiter (expected 1 only character)")
  5244. RexxLocalVar=CfgMacro("REXX_MAKE_LOCAL_VAR", '@' || '@')
  5245. InfiniteLoopWhen=CfgMacro("INFINITE_MACRO_LOOP_WHEN",20)
  5246. InfiniteIncludeLoopWhen=CfgMacro("INFINITE_INCLUDE_LOOP_WHEN",20)
  5247. call DBGIND-1
  5248. return
  5249.  
  5250. PARMVAL_DEBUG:
  5251. if OptionDebugOn='Y' then
  5252. do
  5253. if OptionParmVal="S" then
  5254. ob!D="SOME"
  5255. else
  5256. ob!D=YorN2OnorOff(OptionParmVal)
  5257. call OptionDebugShow 'PARMVAL', 'Currently set to "' || ob!D || '"'
  5258. end
  5259. return
  5260.  
  5261. PARMVAL_SET:
  5262. pb!Value=translate(arg(1))
  5263. if ProcessedCmdLine='N' then
  5264. do
  5265. call OptionDebugShow 'PARMVAL', 'Setting default to "' || pb!Value || '"'
  5266. DefaultParmVal=pb!Value
  5267. return(0)
  5268. end
  5269. if pb!Value=='' then
  5270. pb!Value=DefaultParmVal
  5271. if pb!Value="SOME" then
  5272. OptionParmVal="S"
  5273. else
  5274. do
  5275. OptionParmVal=IsStringOnOrOffCmd(pb!Value)
  5276. if OptionParmVal='' then
  5277. CryAndDie('Invalid PARMVAL option of "' || pb!Value || '"')
  5278. end
  5279. call PARMVAL_DEBUG
  5280. return
  5281.  
  5282. PARMVAL_GET:
  5283. call PARMVAL_DEBUG
  5284. if OptionParmVal="S" then
  5285. qb!Value="SOME"
  5286. else
  5287. qb!Value=YorN2OnorOff(OptionParmVal)
  5288. return(qb!Value)
  5289.  
  5290. REPLACEMENTTAGS_DEBUG:
  5291. if OptionDebugOn='Y' then
  5292. call OptionDebugShow 'REPLACEMENTTAGS', 'Replace tags now look like "' || StartsMacroReplacement || 'MacroVar' || EndsMacroReplacement || '" and "' || StartsStdSymbolReplacement || 'StandardMacroVar' || EndsMacroReplacement || '", Indirection like "' || MacroIndLeft || 'symbol' || MacroIndRight || '"'
  5293. return
  5294.  
  5295. REPLACEMENTTAGS_SET:
  5296. Tags=arg(1)
  5297. if ProcessedCmdLine='N' then
  5298. do
  5299. call OptionDebugShow 'REPLACEMENTTAGS', 'Setting default value of replacement tags to "' || Tags || '"'
  5300. Default4_ReplacementTags=Tags
  5301. return(0)
  5302. end
  5303. if Tags=='' then
  5304. Tags=Default4_ReplacementTags
  5305. qb!L=length(Tags)
  5306. if qb!L<>4&qb!L<>6 then
  5307. CryAndDie('Tried to set invalid replace tags of "' || Tags || '"')
  5308. StartsMacroReplacement=substr(Tags,1,1)||substr(Tags,3,1)
  5309. StdSymbolReplacementChar=substr(Tags,4,1)
  5310. StartsStdSymbolReplacement=substr(Tags,1,1)||StdSymbolReplacementChar
  5311. EndsMacroReplacement=substr(Tags,2,1)
  5312. if qb!L=6 then
  5313. do
  5314. MacroIndLeft=substr(Tags,5,1)
  5315. MacroIndRight=substr(Tags,6,1)
  5316. end
  5317. EndsVar=' ' ||EndsMacroReplacement
  5318. StartsStdSymbolReplacement_x=StartsStdSymbolReplacement|| 'x'
  5319. CodexNewLine=StartsStdSymbolReplacement|| "NewLine" ||EndsMacroReplacement
  5320. if RexIsAscii='N' then
  5321. do
  5322. CodexHexNewLine=StartsStdSymbolReplacement_x|| "15" ||EndsMacroReplacement
  5323. CodexHexSpace=StartsStdSymbolReplacement_x|| "40" ||EndsMacroReplacement
  5324. CodexHexHash=StartsStdSymbolReplacement_x|| "7B" ||EndsMacroReplacement
  5325. CodexHexDollar=StartsStdSymbolReplacement_x|| "5B" ||EndsMacroReplacement
  5326. CodexHexQuestionMark=StartsStdSymbolReplacement_x|| "1A" ||EndsMacroReplacement
  5327. CodexHexLessThan=StartsStdSymbolReplacement_x|| "4C" ||EndsMacroReplacement
  5328. CodexSemiColon=StartsStdSymbolReplacement_x|| "5E" ||EndsMacroReplacement
  5329. end
  5330. else
  5331. do
  5332. CodexHexNewLine=StartsStdSymbolReplacement_x|| "0A" ||EndsMacroReplacement
  5333. CodexHexSpace=StartsStdSymbolReplacement_x|| "20" ||EndsMacroReplacement
  5334. CodexHexHash=StartsStdSymbolReplacement_x|| "23" ||EndsMacroReplacement
  5335. CodexHexDollar=StartsStdSymbolReplacement_x|| "24" ||EndsMacroReplacement
  5336. CodexHexQuestionMark=StartsStdSymbolReplacement_x|| "3F" ||EndsMacroReplacement
  5337. CodexHexLessThan=StartsStdSymbolReplacement_x|| "3C" ||EndsMacroReplacement
  5338. CodexSemiColon=StartsStdSymbolReplacement_x|| "3B" ||EndsMacroReplacement
  5339. end
  5340. CodexNothing=StartsStdSymbolReplacement_x|| "Nothing" ||EndsMacroReplacement
  5341. call REPLACEMENTTAGS_DEBUG
  5342. return
  5343.  
  5344. REPLACEMENTTAGS_GET:
  5345. call REPLACEMENTTAGS_DEBUG
  5346. return(substr(StartsMacroReplacement,1,1)||EndsMacroReplacement||substr(StartsMacroReplacement,2,1)||substr(StartsStdSymbolReplacement,2,1)||MacroIndLeft||MacroIndRight)
  5347.  
  5348. MACROPARMTAGS_DEBUG:
  5349. if OptionDebugOn='Y' then
  5350. call OptionDebugShow 'MACROPARMTAGS', 'Macro parameters now look like "' || StartsMacroParm || 'MacroParameter' || EndsMacroParm || '"'
  5351. return
  5352.  
  5353. MACROPARMTAGS_SET:
  5354. Tags=arg(1)
  5355. if ProcessedCmdLine='N' then
  5356. do
  5357. call OptionDebugShow 'MACROPARMTAGS', 'Setting default value of macro parameter tags to "' || Tags || '"'
  5358. Default4_MacroParameterTags=Tags
  5359. return(0)
  5360. end
  5361. if Tags=='' then
  5362. Tags=Default4_MacroParameterTags
  5363. if length(Tags)<>3 then
  5364. CryAndDie('Tried to set invalid macro parameter tags of "' || Tags || '"')
  5365. StartsMacroParm=substr(Tags,1,1)||substr(Tags,3,1)
  5366. EndsMacroParm=substr(Tags,2,1)
  5367. HidesMacroParm=substr(Tags,1,1)|| '_' ||substr(Tags,3,1)
  5368. AutoTagSelf=StartsMacroParm|| 'AT' ||EndsMacroParm
  5369. call MACROPARMTAGS_DEBUG
  5370. return
  5371.  
  5372. MACROPARMTAGS_GET:
  5373. call MACROPARMTAGS_DEBUG
  5374. return(substr(StartsMacroParm,1,1)||EndsMacroParm||substr(StartsMacroParm,2,1))
  5375.  
  5376. ProcessDefine:
  5377. Rest=arg(1)
  5378. if DefineMacroReplace='Y' then
  5379. Rest=PerformReplacementsInCmdsParameters(Rest)
  5380. if pos(MarksNewLineInHashDefine,Rest)<>0 then
  5381. do
  5382. Rest=ReplaceString(arg(1),MarksNewLineInHashDefine2,MarksNewLine)
  5383. Rest=ReplaceString(Rest,MarksNewLineInHashDefine,MarksNewLine)
  5384. end
  5385. parse var Rest HashDefineV HashDefineC
  5386. return(AddHashDefine(HashDefineV,strip(HashDefineC),arg(2)))
  5387.  
  5388. ProcessEvaluate:
  5389. Rest=PerformReplacementsInCmdsParameters(arg(1))
  5390. HashDefineAnswerName=GetQuotedText(Rest, "Rest",, "Getting macro name")
  5391. if Rest='' then
  5392. CryAndDie('Evaluate what command?')
  5393. CmdToEvaluate=GetQuotedRest(Rest)
  5394. HashDefineRc=0
  5395. if HashDefineAnswerName='' then
  5396. call ExecRexxCmd CmdToEvaluate
  5397. else
  5398. do
  5399. CmdToEvaluate='EvaluateAnswer = ' ||CmdToEvaluate
  5400. call ExecRexxCmd CmdToEvaluate
  5401. HashDefineRc=AddHashDefine(HashDefineAnswerName,EvaluateAnswer,arg(2))
  5402. end
  5403. return(HashDefineRc)
  5404.  
  5405. MacroExists:
  5406. if symbol('EndsVar') <> 'VAR' then
  5407. return('N')
  5408. if verify(arg(1),EndsVar, 'M') <> 0 then CryAndDie('The macro name "' || arg(1) || '" is invalid (Any of "' || EndsVar || '" are invalid)')
  5409. kb!MacName=arg(1)
  5410. kb!MacNameO=kb!MacName
  5411. kb!RbPos=pos(MacroIndRight,kb!MacName)
  5412. if kb!RbPos<>0 then
  5413. do
  5414. if OptionDebugOn='Y' then
  5415. do
  5416. call DBG_DEFINING '[indirection]: ' ||DebugRightArrow||kb!MacName||DebugLeftArrow
  5417. call DBGIND 1
  5418. end
  5419. do while kb!RbPos<>0
  5420. kb!LbPos=lastpos(MacroIndLeft,kb!MacName,kb!RbPos)
  5421. if kb!LbPos=0 then
  5422. CryAndDie('Could not find a matching "' || MacroIndLeft || '" character for "' || MacroIndRight || '"', 'The invalid macro is:', '  ' ||kb!MacName)
  5423. kb!L=left(kb!MacName,kb!LbPos-1)
  5424. kb!M=substr(kb!MacName,kb!LbPos+1,kb!RbPos-kb!LbPos-1)
  5425. kb!R=substr(kb!MacName,kb!RbPos+1)
  5426. if OptionDebugOn='Y' then
  5427. do
  5428. call DBG_DEFINING 'Looking for: ' ||kb!M
  5429. call DBGIND 1
  5430. end
  5431. kb!RepType=''
  5432. if symbol(kb!M)='VAR' then
  5433. do
  5434. kb!RepType='REXX'
  5435. kb!RepWith=value(kb!M)
  5436. end
  5437. else
  5438. do
  5439. if CsReplacement='N' then
  5440. kb!SavedAs='MACRO?.M?'||c2x(translate(kb!M))
  5441. else
  5442. kb!SavedAs='MACRO?.M?'||c2x(kb!M)
  5443. if symbol(kb!SavedAs)='VAR' then
  5444. do
  5445. kb!RepType='PPWIZARD'
  5446. kb!RepWith=value(kb!SavedAs)
  5447. end
  5448. end
  5449. if OptionDebugOn='Y' then
  5450. do
  5451. if kb!RepType='' then
  5452. call DBG_DEFINING 'No such REXX or PPWIZARD symbol!'
  5453. else
  5454. call DBG_DEFINING kb!RepType|| ' symbol contained: ' ||kb!RepWith
  5455. call DBGIND-1
  5456. end
  5457. if kb!RepType='' then
  5458. do
  5459. if kb!MacName=kb!MacNameO then
  5460. kb!Show=kb!MacName
  5461. else
  5462. kb!Show=kb!MacName|| ' <= "' ||kb!MacNameO
  5463. CryAndDie("Could not find a REXX variable or PPWIZARD macro matching:", '  ' || kb!M, 'In the macro reference:', '  ' ||kb!Show)
  5464. end
  5465. kb!MacName=kb!L||kb!RepWith||kb!R
  5466. if OptionDebugOn='Y' then
  5467. call DBG_DEFINING 'New macro reference is "' ||DebugRightArrow||kb!MacName||DebugLeftArrow
  5468. kb!RbPos=pos(MacroIndRight,kb!MacName)
  5469. end
  5470. if OptionDebugOn='Y' then
  5471. call DBGIND-1
  5472. end
  5473. if pos(MacroIndLeft,kb!MacName)<>0 then
  5474. CryAndDie('Could not find a matching "' || MacroIndRight || '" character for "' || MacroIndLeft || '"', 'The invalid macro is:', '  ' ||kb!MacName)
  5475. rb!Dummy=kb!MacName
  5476. if CsReplacement='N' then
  5477. rb!As='MACRO?.M?'||c2x(translate(kb!MacName))
  5478. else
  5479. rb!As='MACRO?.M?'||c2x(kb!MacName)
  5480. if symbol(rb!As)='VAR' then
  5481. return('Y')
  5482. else
  5483. return('N')
  5484.  
  5485. HandleUndefCommand:
  5486. sb!Ud=PerformReplacementsInCmdsParameters(arg(1))
  5487. if verify(sb!Ud,EndsVar, 'M') <> 0 then CryAndDie('The macro name "' || sb!Ud || '" is invalid (Any of "' || EndsVar || '" are invalid)')
  5488. kb!MacName=sb!Ud
  5489. kb!MacNameO=kb!MacName
  5490. kb!RbPos=pos(MacroIndRight,kb!MacName)
  5491. if kb!RbPos<>0 then
  5492. do
  5493. if OptionDebugOn='Y' then
  5494. do
  5495. call DBG_DEFINING '[indirection]: ' ||DebugRightArrow||kb!MacName||DebugLeftArrow
  5496. call DBGIND 1
  5497. end
  5498. do while kb!RbPos<>0
  5499. kb!LbPos=lastpos(MacroIndLeft,kb!MacName,kb!RbPos)
  5500. if kb!LbPos=0 then
  5501. CryAndDie('Could not find a matching "' || MacroIndLeft || '" character for "' || MacroIndRight || '"', 'The invalid macro is:', '  ' ||kb!MacName)
  5502. kb!L=left(kb!MacName,kb!LbPos-1)
  5503. kb!M=substr(kb!MacName,kb!LbPos+1,kb!RbPos-kb!LbPos-1)
  5504. kb!R=substr(kb!MacName,kb!RbPos+1)
  5505. if OptionDebugOn='Y' then
  5506. do
  5507. call DBG_DEFINING 'Looking for: ' ||kb!M
  5508. call DBGIND 1
  5509. end
  5510. kb!RepType=''
  5511. if symbol(kb!M)='VAR' then
  5512. do
  5513. kb!RepType='REXX'
  5514. kb!RepWith=value(kb!M)
  5515. end
  5516. else
  5517. do
  5518. if CsReplacement='N' then
  5519. kb!SavedAs='MACRO?.M?'||c2x(translate(kb!M))
  5520. else
  5521. kb!SavedAs='MACRO?.M?'||c2x(kb!M)
  5522. if symbol(kb!SavedAs)='VAR' then
  5523. do
  5524. kb!RepType='PPWIZARD'
  5525. kb!RepWith=value(kb!SavedAs)
  5526. end
  5527. end
  5528. if OptionDebugOn='Y' then
  5529. do
  5530. if kb!RepType='' then
  5531. call DBG_DEFINING 'No such REXX or PPWIZARD symbol!'
  5532. else
  5533. call DBG_DEFINING kb!RepType|| ' symbol contained: ' ||kb!RepWith
  5534. call DBGIND-1
  5535. end
  5536. if kb!RepType='' then
  5537. do
  5538. if kb!MacName=kb!MacNameO then
  5539. kb!Show=kb!MacName
  5540. else
  5541. kb!Show=kb!MacName|| ' <= "' ||kb!MacNameO
  5542. CryAndDie("Could not find a REXX variable or PPWIZARD macro matching:", '  ' || kb!M, 'In the macro reference:', '  ' ||kb!Show)
  5543. end
  5544. kb!MacName=kb!L||kb!RepWith||kb!R
  5545. if OptionDebugOn='Y' then
  5546. call DBG_DEFINING 'New macro reference is "' ||DebugRightArrow||kb!MacName||DebugLeftArrow
  5547. kb!RbPos=pos(MacroIndRight,kb!MacName)
  5548. end
  5549. if OptionDebugOn='Y' then
  5550. call DBGIND-1
  5551. end
  5552. if pos(MacroIndLeft,kb!MacName)<>0 then
  5553. CryAndDie('Could not find a matching "' || MacroIndRight || '" character for "' || MacroIndLeft || '"', 'The invalid macro is:', '  ' ||kb!MacName)
  5554. sb!Dummy=kb!MacName
  5555. if CsReplacement='N' then
  5556. SavedAs='MACRO?.M?'||c2x(translate(kb!MacName))
  5557. else
  5558. SavedAs='MACRO?.M?'||c2x(kb!MacName)
  5559. if symbol(SavedAs)='VAR' then
  5560. drop(SavedAs)
  5561. return(0)
  5562.  
  5563. MacroSet:call TRACE "OFF"
  5564.  
  5565. AddHashDefine:
  5566. parse arg HashDefineU,HashDefineC,DefineMode
  5567. if OptionDebugOn='Y' then
  5568. do
  5569. call DBG_DEFINING 'Defining "' || HashDefineU || '" <- ' ||DebugRightArrow||HashDefineC||DebugLeftArrow
  5570. call DBGIND 1
  5571. end
  5572. if verify(HashDefineU,EndsVar, 'M') <> 0 then CryAndDie('The macro name "' || HashDefineU || '" is invalid (Any of "' || EndsVar || '" are invalid)')
  5573. kb!MacName=HashDefineU
  5574. kb!MacNameO=kb!MacName
  5575. kb!RbPos=pos(MacroIndRight,kb!MacName)
  5576. if kb!RbPos<>0 then
  5577. do
  5578. if OptionDebugOn='Y' then
  5579. do
  5580. call DBG_DEFINING '[indirection]: ' ||DebugRightArrow||kb!MacName||DebugLeftArrow
  5581. call DBGIND 1
  5582. end
  5583. do while kb!RbPos<>0
  5584. kb!LbPos=lastpos(MacroIndLeft,kb!MacName,kb!RbPos)
  5585. if kb!LbPos=0 then
  5586. CryAndDie('Could not find a matching "' || MacroIndLeft || '" character for "' || MacroIndRight || '"', 'The invalid macro is:', '  ' ||kb!MacName)
  5587. kb!L=left(kb!MacName,kb!LbPos-1)
  5588. kb!M=substr(kb!MacName,kb!LbPos+1,kb!RbPos-kb!LbPos-1)
  5589. kb!R=substr(kb!MacName,kb!RbPos+1)
  5590. if OptionDebugOn='Y' then
  5591. do
  5592. call DBG_DEFINING 'Looking for: ' ||kb!M
  5593. call DBGIND 1
  5594. end
  5595. kb!RepType=''
  5596. if symbol(kb!M)='VAR' then
  5597. do
  5598. kb!RepType='REXX'
  5599. kb!RepWith=value(kb!M)
  5600. end
  5601. else
  5602. do
  5603. if CsReplacement='N' then
  5604. kb!SavedAs='MACRO?.M?'||c2x(translate(kb!M))
  5605. else
  5606. kb!SavedAs='MACRO?.M?'||c2x(kb!M)
  5607. if symbol(kb!SavedAs)='VAR' then
  5608. do
  5609. kb!RepType='PPWIZARD'
  5610. kb!RepWith=value(kb!SavedAs)
  5611. end
  5612. end
  5613. if OptionDebugOn='Y' then
  5614. do
  5615. if kb!RepType='' then
  5616. call DBG_DEFINING 'No such REXX or PPWIZARD symbol!'
  5617. else
  5618. call DBG_DEFINING kb!RepType|| ' symbol contained: ' ||kb!RepWith
  5619. call DBGIND-1
  5620. end
  5621. if kb!RepType='' then
  5622. do
  5623. if kb!MacName=kb!MacNameO then
  5624. kb!Show=kb!MacName
  5625. else
  5626. kb!Show=kb!MacName|| ' <= "' ||kb!MacNameO
  5627. CryAndDie("Could not find a REXX variable or PPWIZARD macro matching:", '  ' || kb!M, 'In the macro reference:', '  ' ||kb!Show)
  5628. end
  5629. kb!MacName=kb!L||kb!RepWith||kb!R
  5630. if OptionDebugOn='Y' then
  5631. call DBG_DEFINING 'New macro reference is "' ||DebugRightArrow||kb!MacName||DebugLeftArrow
  5632. kb!RbPos=pos(MacroIndRight,kb!MacName)
  5633. end
  5634. if OptionDebugOn='Y' then
  5635. call DBGIND-1
  5636. end
  5637. if pos(MacroIndLeft,kb!MacName)<>0 then
  5638. CryAndDie('Could not find a matching "' || MacroIndRight || '" character for "' || MacroIndLeft || '"', 'The invalid macro is:', '  ' ||kb!MacName)
  5639. sb!Dummy=kb!MacName
  5640. if CsReplacement='N' then
  5641. SavedAs='MACRO?.M?'||c2x(translate(kb!MacName))
  5642. else
  5643. SavedAs='MACRO?.M?'||c2x(kb!MacName)
  5644. if symbol(SavedAs)='VAR' then
  5645. do
  5646. select
  5647. when DefineMode='Y' then
  5648. do
  5649. if OptionDebugOn='Y' then
  5650. call DBG_DEFINING 'User said OK to redefine so no warning'
  5651. end
  5652. when DefineMode='' then
  5653. do
  5654. call OutputWarningToScreen 'R000', 'Redefine of "' || HashDefineU || '".'
  5655. end
  5656. when DefineMode='?' then
  5657. do
  5658. if OptionDebugOn='Y' then
  5659. do
  5660. call DBG_DEFINING 'Macro already defined, conditional definition aborted!'
  5661. call DBGIND-1
  5662. end
  5663. return(0)
  5664. end
  5665. otherwise
  5666. CryAndDie('Unknown define mode of "' || DefineMode || '"')
  5667. end
  5668. end
  5669. call _valueS SavedAs,HashDefineC
  5670. if OptionDebugOn='Y' then
  5671. call DBGIND-1
  5672. return(0)
  5673.  
  5674. PerformReplacementsInCmdsParameters:
  5675. tb!Prms=arg(1)
  5676. if ReplacementsAllowed<> 'Y' then
  5677. return(tb!Prms)
  5678. tb!Prms=ReplaceHashAndStandardDefines(arg(1), "PRM")
  5679. if ExpandXCmd='Y' then
  5680. do
  5681. if pos(StartsStdSymbolReplacement_x,tb!Prms)<>0 then
  5682. tb!Prms=ReplaceTheXCodesWeKnowExist(tb!Prms)
  5683. end
  5684. if pos(MarksNewLine,tb!Prms)<>0 then
  5685. do
  5686. tb!1='Parameters for a PPWIZARD command must never expand to multiple'
  5687. tb!2='lines (contain PPWIZARD #commands)!'
  5688. tb!4='EXPANDED PARAMETERS'
  5689. tb!5='~~~~~~~~~~~~~~~~~~~'
  5690. tb!6=tb!Prms
  5691. CryAndDie(tb!1,tb!2,,tb!4,tb!5,tb!6)
  5692. end
  5693. return(tb!Prms)
  5694.  
  5695. ReplaceMacros:call TRACE "OFF"
  5696. signal _ReplaceMacros
  5697.  
  5698. ReplaceHashAndStandardDefines:
  5699. if ReplacementsAllowed='N' then
  5700. return(arg(1))
  5701.  
  5702. _ReplaceMacros:
  5703. parse arg HashDefineString,HashDefPrefix,HashDefRecord
  5704. ReplLoop=0
  5705. do while pos(StartsMacroReplacement,HashDefineString)<>0
  5706. BeforeCount=ReplaceCount
  5707. HashDefineString=_ReplaceAllHashDefinedVariables(HashDefineString)
  5708. if HashDefRecord='Y' then
  5709. LastLineAfterMacroRep=HashDefineString
  5710. if OptionDebugOn='Y' then
  5711. do
  5712. if BeforeCount<>ReplaceCount then
  5713. do
  5714. if HashDefPrefix='' then
  5715. call DebugOutputAfterReplacement HashDefineString, 'VCMD'
  5716. else
  5717. call DebugOutputAfterReplacement HashDefineString, 'V' ||HashDefPrefix
  5718. end
  5719. end
  5720. if pos(MarksNewLine,HashDefineString)<>0 then
  5721. leave
  5722. if ReplLoop>=InfiniteLoopWhen then
  5723. do
  5724. if InfiniteLoopWhen<>0 then
  5725. do
  5726. InfiniteLoopDetected='Y'
  5727. if ReplLoop=InfiniteLoopWhen then
  5728. do
  5729. OptionDebugOn='Y'
  5730. call DBG 'Infinite loop detected, debug forced on for a few loops'
  5731. call DBGIND 1
  5732. call DBG InfiniteLoopWhen|| ' loops detected, possible actions:'
  5733. call DBGIND 1
  5734. call DBG 'Have have you forgotten to use "#option DefineMacroReplace=ON" somewhere?'
  5735. call DBG 'Use "/define:INFINITE_MACRO_LOOP_WHEN=0"    to turn off detection'
  5736. call DBG 'Use "/define:INFINITE_MACRO_LOOP_WHEN=1000" to increase detection threshold'
  5737. call DBGIND-2
  5738. say ''
  5739. call DebugStateChanged
  5740. end
  5741. say ''
  5742. if ReplLoop>InfiniteLoopWhen+50 then
  5743. CryAndDie("Infinite loop detected (debug turned on above), current line now:", "",HashDefineString)
  5744. end
  5745. end
  5746. ReplLoop=ReplLoop+1
  5747. end
  5748. if InfiniteLoopDetected='Y' then
  5749. CryAndDie("Increase your loop detection value from " || InfiniteLoopWhen || ' with "/define:INFINITE_MACRO_LOOP_WHEN=Value"', "Increase to at least " || ReplLoop || '!')
  5750. if pos(StartsStdSymbolReplacement,HashDefineString)<>0 then
  5751. do
  5752. BeforeCount=ReplaceCount
  5753. HashDefineString=ReplaceStandardDefinitions(HashDefineString)
  5754. if HashDefRecord='Y' then
  5755. LastLineAfterMacroRep=HashDefineString
  5756. if OptionDebugOn='Y' then
  5757. do
  5758. if BeforeCount<>ReplaceCount then
  5759. do
  5760. if HashDefPrefix='' then
  5761. call DebugOutputAfterReplacement HashDefineString, 'SCMD'
  5762. else
  5763. call DebugOutputAfterReplacement HashDefineString, 'S' ||HashDefPrefix
  5764. end
  5765. end
  5766. end
  5767. return(HashDefineString)
  5768.  
  5769. _UnknownStandardSymbol:
  5770. call CryAndDie 'The standard symbol "' || StartsStdSymbolReplacement || SymbolName || EndsMacroReplacement || '" is unknown!'
  5771.  
  5772. ReplaceStandardDefinitions:
  5773. RightBit=arg(1)
  5774. if pos(MarksNewLine,RightBit)<>0 then
  5775. return(RightBit)
  5776. LeftBit=''
  5777. StartPos=pos(StartsStdSymbolReplacement,RightBit)
  5778. do while StartPos<>0
  5779. if StartsStdSymbolReplacement==MarksPhpXml then
  5780. do
  5781. Left4=substr(RightBit,StartPos+2,3)
  5782. if Left4='xml' then
  5783. do
  5784. LeftBit=LeftBit|| '<' ||CodexHexQuestionMark
  5785. RightBit=substr(RightBit,3)
  5786. StartPos=pos(StartsStdSymbolReplacement,RightBit)
  5787. iterate
  5788. end
  5789. if Left4='php' then
  5790. do
  5791. StartPos=pos(StartsStdSymbolReplacement,RightBit,StartPos+2)
  5792. iterate
  5793. end
  5794. if left(Left4,1)=' ' then
  5795. do
  5796. StartPos=pos(StartsStdSymbolReplacement,RightBit,StartPos+2)
  5797. iterate
  5798. end
  5799. end
  5800. EndPos=pos(EndsMacroReplacement,RightBit,StartPos+1)
  5801. if EndPos=0 then
  5802. CryAndDie('Could not find the "' || EndsMacroReplacement || '" end of variable started at: ' ||substr(RightBit,StartPos))
  5803. LeftBit=LeftBit||left(RightBit,StartPos-1)
  5804. SymbolNameC=substr(RightBit,StartPos+2,(EndPos-StartPos)-2)
  5805. RightBit=substr(RightBit,EndPos+1)
  5806. if left(SymbolNameC,1)='x' then
  5807. do
  5808. ReplaceCount=ReplaceCount-1
  5809. SymbolValue=StartsStdSymbolReplacement||SymbolNameC||EndsMacroReplacement
  5810. end
  5811. else
  5812. do
  5813. if OptionDebugOn='Y' then
  5814. call DebugOutputVariableInfo_FOUNDSTDVAR 'Found : ' ||StartsStdSymbolReplacement||SymbolNameC||EndsMacroReplacement
  5815. SymbolName=SymbolNameC
  5816. Left1=left(SymbolName,1)
  5817. if Left1='=' then
  5818. DdCodes=''
  5819. else
  5820. do
  5821. SpcPos=pos(' ',SymbolName)
  5822. if SpcPos=0 then
  5823. DdCodes=''
  5824. else
  5825. do
  5826. DdCodes=translate(substr(SymbolName,SpcPos+1))
  5827. SymbolName=left(SymbolName,SpcPos-1)
  5828. end
  5829. end
  5830. ub!Pos=pos(':',SymbolName)
  5831. if ub!Pos=0 then
  5832. SymbolParms=''
  5833. else
  5834. do
  5835. SymbolParms=substr(SymbolName,ub!Pos+1,length(SymbolName)-ub!Pos)
  5836. SymbolName=left(SymbolName,ub!Pos-1)
  5837. end
  5838. SymbolName=translate(SymbolName)
  5839. Left1=left(SymbolName,1)
  5840. select
  5841. when Left1='?' then
  5842. do
  5843. SymbolName=substr(SymbolName,2)
  5844. if left(SymbolName,1)<> '*' then
  5845. do
  5846. if symbol(SymbolName)<> 'VAR' then
  5847. do
  5848. call DumpVarsIfCompoundVariable SymbolName
  5849. call CryAndDie 'The rexx variable "' || SymbolName || '" is unknown!'
  5850. end
  5851. SymbolValue=_valueG(SymbolName)
  5852. end
  5853. else
  5854. do
  5855. SymbolName=substr(SymbolName,2)
  5856. if right(SymbolName,1)<> '?' then
  5857. ub!Die='Y'
  5858. else
  5859. do
  5860. ub!Die='N'
  5861. SymbolName=left(SymbolName,length(SymbolName)-1)
  5862. end
  5863. SymbolValue=GetEnv(SymbolName,ub!Die)
  5864. end
  5865. end
  5866. when Left1='I' then
  5867. do
  5868. select
  5869. when SymbolName="INPUTFILE" then
  5870. SymbolValue=FormatSsFile(InputFileFull)
  5871. when SymbolName="INPUTCOMPONENT" then
  5872. SymbolValue=FormatSsFile(IncludeFileName)
  5873. when SymbolName="INPUTCOMPONENTLINE" then
  5874. SymbolValue=FormatSsNumber(IncludeLineNumber)
  5875. when SymbolName="INPUTFILETIME" then
  5876. do
  5877. ub!Ts=GetFileTimeStamp(InputFileFull, "D")
  5878. SymbolValue=FormatSsTime(ub!Ts, "INPUTFILETIME")
  5879. end
  5880. when SymbolName="INPUTCOMPONENTTIME" then
  5881. do
  5882. ub!Ts=GetFileTimeStamp(IncludeFileName, "D")
  5883. SymbolValue=FormatSsTime(ub!Ts, "INPUTCOMPONENTTIME")
  5884. end
  5885. when SymbolName="INCLUDELEVEL" then
  5886. SymbolValue=IncludeLevel
  5887. otherwise
  5888. call _UnknownStandardSymbol
  5889. end
  5890. end
  5891. when Left1='S' then
  5892. do
  5893. select
  5894. when SymbolName="SPACE" then
  5895. SymbolValue=CodexHexSpace
  5896. when SymbolName="SEMICOLON" then
  5897. SymbolValue=CodexSemiColon
  5898. when SymbolName="SYNTAXCHECK" then
  5899. do
  5900. SymbolValue=OutSyntaxCode
  5901. if SymbolValue='' then
  5902. CryAndDie("We do not know how to insert syntax checking code (or already inserted)!")
  5903. OutSyntaxCode=''
  5904. end
  5905. when SymbolName="SYNTAXCHECKOFF" then
  5906. do
  5907. OutSyntaxCode=''
  5908. OutSyntaxRc=''
  5909. OutSyntaxCmd=''
  5910. SymbolValue=''
  5911. end
  5912. otherwise
  5913. call _UnknownStandardSymbol
  5914. end
  5915. end
  5916. when Left1='O' then
  5917. do
  5918. select
  5919. when SymbolName="OUTPUTLINE" then
  5920. SymbolValue=FormatSsNumber(CurrentOutLine+1)
  5921. when SymbolName="OUTPUTLEVEL" then
  5922. SymbolValue=OutputLevel
  5923. when SymbolName="OPSYS" then
  5924. SymbolValue=PpWizardOpSys
  5925. when SymbolName="OPSYSSPECIFIC" then
  5926. SymbolValue=PpWizardOpSysREAL
  5927. when SymbolName="OUTPUTFILE" then
  5928. do
  5929. call _FileClose CurrentOutFile
  5930. SymbolValue=FileQueryExists(CurrentOutFile)
  5931. if SymbolValue='' then
  5932. CryAndDie('Could not obtain file name information for the "' || StartsStdSymbolReplacement || 'OutputFile>" variable!')
  5933. SymbolValue=FormatSsFile(SymbolValue)
  5934. end
  5935. otherwise
  5936. call _UnknownStandardSymbol
  5937. end
  5938. end
  5939. when Left1='P' then
  5940. do
  5941. select
  5942. when SymbolName='PROCESSINGMODE' then
  5943. SymbolValue=ProcessingMode
  5944. when SymbolName='PROTECTFROMPPWSTART' then
  5945. SymbolValue=MarksNewLine||HashPrefix||ProtectFromPpwS||MarksNewLine
  5946. when SymbolName='PROTECTFROMPPWEND' then
  5947. SymbolValue=MarksNewLine||ProtectFromPpwE||MarksNewLine
  5948. when SymbolName='PPWIZARDAUTHORHOMEPAGE' then
  5949. SymbolValue=PgmAuthorHomePage
  5950. when SymbolName='PPWIZARDAUTHOR' then
  5951. SymbolValue=PgmAuthor
  5952. when SymbolName='PPWIZARDAUTHOREMAIL' then
  5953. SymbolValue=PgmAuthorEmail
  5954. when SymbolName='PPWIZARDPGM' then
  5955. SymbolValue=FormatSsFile(PpWizardPgmName)
  5956. when SymbolName='PPWIZARDHOMEPAGE' then
  5957. SymbolValue=PgmHomePage
  5958. when SymbolName='PPWIZARDGENERATORMETATAGS' then
  5959. SymbolValue=PgmDefaultHtmlMetaTags
  5960. when SymbolName='PPWIZARDAUTHORBASEWEBDIR' then
  5961. SymbolValue=MyBaseHomeDir
  5962. otherwise
  5963. call _UnknownStandardSymbol
  5964. end
  5965. end
  5966. when Left1='D' then
  5967. do
  5968. select
  5969. when SymbolName='DEBUGON' then
  5970. SymbolValue=OptionDebugOn
  5971. when SymbolName='DOLLAR' then
  5972. SymbolValue=CodexHexDollar
  5973. when SymbolName='DIRSLASH' then
  5974. SymbolValue=RexDirChar
  5975. otherwise
  5976. call _UnknownStandardSymbol
  5977. end
  5978. end
  5979. when SymbolName='NEWLINE' then
  5980. SymbolValue=CodexHexNewLine
  5981. when SymbolName='NEWLINE?' then
  5982. do
  5983. CondNlCount=CondNlCount+1
  5984. SymbolValue="{?WaNtNl?}"
  5985. end
  5986. when SymbolName='/' then
  5987. SymbolValue=OptionXSlash
  5988. when SymbolName='_' then
  5989. SymbolValue=CodexNothing
  5990. when SymbolName='COMPILETIME' then
  5991. SymbolValue=FormatSsTime(PpwCompTs, "COMPILETIME")
  5992. when SymbolName='CMDLINETOTAL' then
  5993. SymbolValue=CmdLineTotal
  5994. when SymbolName='VERSION' then
  5995. SymbolValue=PgmVersion
  5996. when SymbolName='HASH' then
  5997. SymbolValue=CodexHexHash
  5998. when SymbolName='HASHPREFIX' then
  5999. SymbolValue=HashPrefix
  6000. when SymbolName='RESTARTLINE' then
  6001. SymbolValue=MarksNewLine
  6002. when SymbolName='TOTALOUTPUTLINES' then
  6003. SymbolValue=FormatSsNumber(GeneratedLines+1)
  6004. when SymbolName='NEWESTFILEDATETIME' then
  6005. do
  6006. SymbolValue=TsNewestSourcefile
  6007. if SymbolParms<> '' then
  6008. SymbolValue=FormatSsTime(SymbolValue)
  6009. end
  6010. when SymbolName='LESSTHAN' then
  6011. SymbolValue=CodexHexLessThan
  6012. when SymbolName='QUESTIONMARK' then
  6013. SymbolValue=CodexHexQuestionMark
  6014. when SymbolName='BASEDIR' then
  6015. SymbolValue=FormatSsFile(BaseDir4CurrentInputFile)
  6016. when SymbolName='UNIQUE' then
  6017. do
  6018. PPwizardUnique=PPwizardUnique+1
  6019. SymbolValue=FormatSsNumber(PPwizardUnique)
  6020. end
  6021. when SymbolName='TEMPLATEDATAFILE' then
  6022. SymbolValue=FormatSsFile(TemplateDataFile)
  6023. when SymbolName='TMPDIR' then
  6024. do
  6025. ub!D=RexGetNameOfTmpDir()
  6026. if right(ub!D,1)=RexDirChar then
  6027. ub!D=left(ub!D,length(ub!D)-1)
  6028. SymbolValue=ub!D
  6029. end
  6030. when SymbolName='CGISTART' then
  6031. SymbolValue='Content-type: text/html' ||CodexHexNewLine||CodexHexNewLine
  6032. when SymbolName='REXXSKIP' then
  6033. do
  6034. RexxSkipCounter=RexxSkipCounter+1
  6035. RexxLbl=_filespec("WITHOUTEXTN", _filespec("NAME", IncludeFileName)) || '_' ||RexxSkipCounter
  6036. SymbolValue=MarksNewLine||HashPrefix|| 'RexxVar "RexxSkipLbl" = "' || RexxLbl || '"' ||MarksNewLine
  6037. SymbolValue=SymbolValue|| 'signal ' || RexxLbl || ';' ||MarksNewLine
  6038. SymbolValue=SymbolValue||MarksNewLine||HashPrefix|| 'RexxVar "RexxSkipLbl" PUSH' ||MarksNewLine
  6039. end
  6040. when SymbolName='REXXSKIPTO' then
  6041. do
  6042. SymbolValue=MarksNewLine||HashPrefix|| 'RexxVar "RexxSkipLbl" POP' ||MarksNewLine
  6043. SymbolValue=SymbolValue||RexxSkipLbl|| ':' ||MarksNewLine
  6044. end
  6045. when SymbolName='..' then
  6046. do
  6047. call DBGIND 1
  6048. ub!IF=InputFileFull
  6049. ub!Bd=BaseDir4CurrentInputFile
  6050. call DBG 'Base dir "' || ub!Bd || '"'
  6051. call ValidateBaseDirUse ub!BD,ub!IF
  6052. ub!SrcDir=_filespec('Location',ub!IF)
  6053. ub!RelDir=substr(ub!SrcDir,length(ub!Bd)+1)
  6054. call DBG 'Rel dir  "' || ub!RelDir || '"'
  6055. ub!DD=''
  6056. do while ub!RelDir<> ""
  6057. ub!DD=ub!DD|| '..\'
  6058. parse var ub!RelDir . (RexDirChar) ub!RelDir
  6059. end
  6060. SymbolValue=ub!DD
  6061. call DBGIND-1
  6062. end
  6063. when Left1='=' then
  6064. do
  6065. if OptionDebugOn='Y' then
  6066. call DBGIND 1
  6067. call ExecRexxCmd 'SymbolValue = ' ||substr(SymbolNameC,2)
  6068. if OptionDebugOn='Y' then
  6069. call DBGIND-1
  6070. SymbolParms=''
  6071. end
  6072. otherwise
  6073. call _UnknownStandardSymbol
  6074. end
  6075. if DdCodes<> '' then
  6076. do
  6077. do until DdCodes=''
  6078. parse var DdCodes DdCode DdCodes
  6079. if OptionDebugOn='Y' then
  6080. do
  6081. call DebugOutputVariableInfo_FOUNDSTDVAR '$$Bef : ' ||SymbolValue
  6082. call DebugOutputVariableInfo_FOUNDSTDVAR '$$Cmd : ' ||DdCode
  6083. end
  6084. select
  6085.  
  6086. when DdCode='$$DSQ' then
  6087. SymbolValue=QuoteIt(SymbolValue,TryQuoteListDs, 'Y')
  6088.  
  6089. when DdCode='$$SDQ' then
  6090. SymbolValue=QuoteIt(SymbolValue,TryQuoteListSd, 'Y')
  6091.  
  6092. when DdCode='$$AQ' then
  6093. SymbolValue=QuoteIt(SymbolValue, 'ANY', 'Y')
  6094.  
  6095. when DdCode='$$UPPER' then
  6096. SymbolValue=ToUpperCase(SymbolValue)
  6097.  
  6098. when DdCode='$$LOWER' then
  6099. SymbolValue=ToLowerCase(SymbolValue)
  6100.  
  6101. when DdCode='$$ADDCOMMA' then
  6102. SymbolValue=AddCommasToDecimalNumber(SymbolValue)
  6103.  
  6104. when DdCode='$$HTMLQ' then
  6105. SymbolValue=ReplaceString(SymbolValue, '"', '"')
  6106.  
  6107. when DdCode='$$SQX2' then
  6108. SymbolValue=ReplaceString(SymbolValue, "'" , "''")
  6109.  
  6110. when left(DdCode,8)="$$RXVAR:" then
  6111. SymbolValue=_RxVar(DdCode,SymbolValue)
  6112.  
  6113. when DdCode="$$RX'" then
  6114. SymbolValue=_RXQuote(SymbolValue, "'")
  6115.  
  6116. when DdCode='$$RX"' then
  6117. SymbolValue=_RXQuote(SymbolValue, '"')
  6118.  
  6119. when DdCode='$$SPCPLUS' then
  6120. do
  6121. if SymbolValue\=='' then
  6122. SymbolValue=' ' ||SymbolValue
  6123. end
  6124.  
  6125. when DdCode='$$ISBLANK' then
  6126. do
  6127. if SymbolValue='' then
  6128. SymbolValue='Y'
  6129. else
  6130. SymbolValue='N'
  6131. end
  6132.  
  6133. when DdCode='$$RXEXEC' then
  6134. do
  6135. RxExec=''
  6136. call ExecRexxCmd SymbolValue, 'N'
  6137. SymbolValue=RxExec
  6138. end
  6139.  
  6140. otherwise
  6141. do
  6142. UserRexx=CfgMacro("REXX_" || DdCode, '')
  6143. if UserRexx='' then
  6144. CryAndDie('The $$ replacement command of "' || DdCode || '" is unknown!')
  6145. TheMacro=""
  6146. TheName=SymbolName
  6147. TheValue=SymbolValue
  6148. call ExecRexxCmd UserRexx, 'N'
  6149. if OptionDebugOn='Y' then
  6150. do
  6151. if SymbolValue=TheValue then
  6152. do
  6153. call DBGIND 1
  6154. call DebugOutputVariableInfo_FOUNDVARPARMS 'The user rexx code did not modify the "TheValue" variable'
  6155. call DBGIND-1
  6156. end
  6157. end
  6158. SymbolValue=TheValue
  6159. end
  6160. end
  6161. end
  6162. end
  6163. if SymbolParms<> '' then
  6164. CryAndDie('Unexpected parameters on standard macro:',SymbolNameC)
  6165. if OptionDebugOn='Y' then
  6166. call DebugOutputVariableInfo_FOUNDSTDVAR 'Value : ' ||DebugRightArrow||SymbolValue||DebugLeftArrow
  6167. end
  6168. LeftBit=LeftBit||SymbolValue
  6169. ReplaceCount=ReplaceCount+1
  6170. if pos(MarksNewLine,SymbolValue)<>0 then
  6171. leave
  6172. StartPos=pos(StartsStdSymbolReplacement,RightBit)
  6173. end
  6174. return(LeftBit||RightBit)
  6175.  
  6176. FormatSsFile:
  6177. vb!F=arg(1)
  6178. do while SymbolParms<> ''
  6179. parse var SymbolParms vb!Cmd ',' SymbolParms
  6180. vb!F=_filespec(vb!Cmd,vb!F)
  6181. end
  6182. return(vb!F)
  6183.  
  6184. FormatSsNumber:
  6185. if SymbolParms='' then
  6186. return(arg(1))
  6187. else
  6188. do
  6189. wb!R=FormatNumber(arg(1),SymbolParms)
  6190. SymbolParms=''
  6191. return(wb!R)
  6192. end
  6193.  
  6194. FormatSsTime:
  6195. parse arg xb!Ts,xb!CfgSuffix
  6196. xb!Fmt=SymbolParms
  6197. if xb!Fmt<> '' then
  6198. SymbolParms=''
  6199. else
  6200. do
  6201. xb!Fmt=CfgMacro("PPWIZARD_FORMAT_DATETIME", '%c')
  6202. xb!Fmt=CfgMacro("PPWIZARD_FORMAT_" ||xb!CfgSuffix,xb!Fmt)
  6203. end
  6204. xb!Time=FormatTime(xb!Fmt,xb!Ts, "PPWIZARD")
  6205. return(xb!Time)
  6206.  
  6207. GetDefineContents:
  6208. if verify(arg(1),EndsVar, 'M') <> 0 then CryAndDie('The macro name "' || arg(1) || '" is invalid (Any of "' || EndsVar || '" are invalid)')
  6209. kb!MacName=arg(1)
  6210. kb!MacNameO=kb!MacName
  6211. kb!RbPos=pos(MacroIndRight,kb!MacName)
  6212. if kb!RbPos<>0 then
  6213. do
  6214. if OptionDebugOn='Y' then
  6215. do
  6216. call DBG_DEFINING '[indirection]: ' ||DebugRightArrow||kb!MacName||DebugLeftArrow
  6217. call DBGIND 1
  6218. end
  6219. do while kb!RbPos<>0
  6220. kb!LbPos=lastpos(MacroIndLeft,kb!MacName,kb!RbPos)
  6221. if kb!LbPos=0 then
  6222. CryAndDie('Could not find a matching "' || MacroIndLeft || '" character for "' || MacroIndRight || '"', 'The invalid macro is:', '  ' ||kb!MacName)
  6223. kb!L=left(kb!MacName,kb!LbPos-1)
  6224. kb!M=substr(kb!MacName,kb!LbPos+1,kb!RbPos-kb!LbPos-1)
  6225. kb!R=substr(kb!MacName,kb!RbPos+1)
  6226. if OptionDebugOn='Y' then
  6227. do
  6228. call DBG_DEFINING 'Looking for: ' ||kb!M
  6229. call DBGIND 1
  6230. end
  6231. kb!RepType=''
  6232. if symbol(kb!M)='VAR' then
  6233. do
  6234. kb!RepType='REXX'
  6235. kb!RepWith=value(kb!M)
  6236. end
  6237. else
  6238. do
  6239. if CsReplacement='N' then
  6240. kb!SavedAs='MACRO?.M?'||c2x(translate(kb!M))
  6241. else
  6242. kb!SavedAs='MACRO?.M?'||c2x(kb!M)
  6243. if symbol(kb!SavedAs)='VAR' then
  6244. do
  6245. kb!RepType='PPWIZARD'
  6246. kb!RepWith=value(kb!SavedAs)
  6247. end
  6248. end
  6249. if OptionDebugOn='Y' then
  6250. do
  6251. if kb!RepType='' then
  6252. call DBG_DEFINING 'No such REXX or PPWIZARD symbol!'
  6253. else
  6254. call DBG_DEFINING kb!RepType|| ' symbol contained: ' ||kb!RepWith
  6255. call DBGIND-1
  6256. end
  6257. if kb!RepType='' then
  6258. do
  6259. if kb!MacName=kb!MacNameO then
  6260. kb!Show=kb!MacName
  6261. else
  6262. kb!Show=kb!MacName|| ' <= "' ||kb!MacNameO
  6263. CryAndDie("Could not find a REXX variable or PPWIZARD macro matching:", '  ' || kb!M, 'In the macro reference:', '  ' ||kb!Show)
  6264. end
  6265. kb!MacName=kb!L||kb!RepWith||kb!R
  6266. if OptionDebugOn='Y' then
  6267. call DBG_DEFINING 'New macro reference is "' ||DebugRightArrow||kb!MacName||DebugLeftArrow
  6268. kb!RbPos=pos(MacroIndRight,kb!MacName)
  6269. end
  6270. if OptionDebugOn='Y' then
  6271. call DBGIND-1
  6272. end
  6273. if pos(MacroIndLeft,kb!MacName)<>0 then
  6274. CryAndDie('Could not find a matching "' || MacroIndRight || '" character for "' || MacroIndLeft || '"', 'The invalid macro is:', '  ' ||kb!MacName)
  6275. yb!MN=kb!MacName
  6276. if CsReplacement='N' then
  6277. yb!SA='MACRO?.M?'||c2x(translate(kb!MacName))
  6278. else
  6279. yb!SA='MACRO?.M?'||c2x(kb!MacName)
  6280. if symbol(yb!SA)='VAR' then
  6281. return(_valueG(yb!SA))
  6282. if arg(1)=yb!MN then
  6283. yb!New=''
  6284. else
  6285. yb!New=' ("' || yb!MN || '")'
  6286. CryAndDie('Macro named "' || arg(1) || '"' || yb!New || ' does not exist!',_MacroBitNotFoundText())
  6287.  
  6288. _SpecialPrm:
  6289. call DebugOutputVariableInfo_FOUNDVARPARMS "This is a special variable, it's value is: " ||arg(1)
  6290. return
  6291.  
  6292. _DieInvPrm:
  6293. 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())
  6294. return
  6295.  
  6296. ReplaceDefinitionsParameters:
  6297. do ParmIndex=1 to ParmCount
  6298. ParmUsed.ParmIndex='N'
  6299. end
  6300. zb!DieIfNotUsed='N'
  6301. zb!ValPointless='N'
  6302. DefaultCnt=0
  6303. ParmLeftBit=''
  6304. ParmRightBit=VariableCont
  6305. ParmPos=pos(StartsMacroParm,ParmRightBit)
  6306. do while ParmPos<>0
  6307. ParmLeftBit=ParmLeftBit||left(ParmRightBit,ParmPos-1)
  6308. ParmRightBit=substr(ParmRightBit,ParmPos+2)
  6309. EqualPos=pos('=',ParmRightBit)
  6310. MaybeEndPos=pos(EndsMacroParm,ParmRightBit)
  6311. if MaybeEndPos=0 then
  6312. CryAndDie('Incorrect use of macro parameter, no matching "' || EndsMacroParm || '" for "' || StartsMacroParm || '"')
  6313. if EqualPos<>0&EqualPos<MaybeEndPos then
  6314. do
  6315. if CsReplacement='N' then
  6316. ThisParmName=translate(strip(left(ParmRightBit,EqualPos-1)))
  6317. else
  6318. ThisParmName=strip(left(ParmRightBit,EqualPos-1))
  6319. ParmRightBit=substr(ParmRightBit,EqualPos+1)
  6320. ParmDefault=GetQuotedText(ParmRightBit, "ParmRightBit", EndsMacroParm, "Getting default for macro parm " ||ThisParmName)
  6321. HaveDefault='Y'
  6322. CurlyPos=pos(EndsMacroParm,ParmRightBit)
  6323. if CurlyPos=0 then
  6324. CryAndDie("Expected to find '" || EndsMacroParm || "' " || 'after the parameter default of "' || ParmDefault || '"!')
  6325. ParmCmds=left(ParmRightBit,CurlyPos-1)
  6326. ParmRightBit=substr(ParmRightBit,CurlyPos+1)
  6327. FoundIndex=0
  6328. do DefaultIndex=1 to DefaultCnt
  6329. if ThisParmName=PrmDefaultName.DefaultIndex then
  6330. do
  6331. FoundIndex=DefaultIndex
  6332. leave
  6333. end
  6334. end
  6335. if FoundIndex=0 then
  6336. do
  6337. DefaultCnt=DefaultCnt+1
  6338. FoundIndex=DefaultCnt
  6339. end
  6340. PrmDefaultName.FoundIndex=ThisParmName
  6341. PrmDefaultValue.FoundIndex=ParmDefault
  6342. end
  6343. else
  6344. do
  6345. HaveDefault='N'
  6346. if CsReplacement='N' then
  6347. ThisParmName=translate(strip(left(ParmRightBit,MaybeEndPos-1)))
  6348. else
  6349. ThisParmName=strip(left(ParmRightBit,MaybeEndPos-1))
  6350. SpcPos=pos(' ',ThisParmName)
  6351. if SpcPos=0 then
  6352. ParmCmds=''
  6353. else
  6354. do
  6355. ParmCmds=substr(ThisParmName,SpcPos+1)
  6356. ThisParmName=left(ThisParmName,SpcPos-1)
  6357. end
  6358. ParmRightBit=substr(ParmRightBit,MaybeEndPos+1)
  6359. end
  6360. if OptionDebugOn='Y' then
  6361. call DebugOutputVariableInfo_FOUNDVARPARMS 'Parm : ' ||ThisParmName
  6362. FndVarIndex=0
  6363. do ParmIndex=1 to ParmCount
  6364. if ParmName.ParmIndex<> '' then
  6365. do
  6366. if ThisParmName=ParmName.ParmIndex then
  6367. do
  6368. ParmUsed.ParmIndex='Y'
  6369. FndVarIndex=ParmIndex
  6370. end
  6371. end
  6372. end
  6373. if FndVarIndex<>0 then
  6374. do
  6375. zb!IsPassed='Y'
  6376. ReplaceParmWith=ParmValue.FndVarIndex
  6377. end
  6378. else
  6379. do
  6380. zb!IsPassed='N'
  6381. if HaveDefault='Y' then
  6382. ReplaceParmWith=ParmDefault
  6383. else
  6384. do
  6385. if OptionDebugOn='Y' then
  6386. do
  6387. call DBGIND 1
  6388. call DebugOutputVariableInfo_FOUNDVARPARMS 'Parameter not supplied. No default given. Default value stored?'
  6389. end
  6390. do DefaultIndex=1 to DefaultCnt
  6391. if ThisParmName=PrmDefaultName.DefaultIndex then
  6392. do
  6393. ReplaceParmWith=PrmDefaultValue.DefaultIndex
  6394. HaveDefault='Y'
  6395. leave
  6396. end
  6397. end
  6398. if OptionDebugOn='Y' then
  6399. do
  6400. if HaveDefault='N' then
  6401. Ans='Oops - not user defined!'
  6402. else
  6403. Ans='Lucky!'
  6404. call DebugOutputVariableInfo_FOUNDVARPARMS Ans
  6405. call DBGIND-1
  6406. end
  6407. if HaveDefault='N' then
  6408. do
  6409. zb!ReginaBugWorkAround='N'
  6410. select
  6411. when ThisParmName='?' then
  6412. do
  6413. zb!ValPointless='Y'
  6414. zb!ReginaBugWorkAround='Y'
  6415. if OptionDebugOn='Y' then
  6416. call _SpecialPrm 'is all unused parms'
  6417. ReplaceParmWith=''
  6418. do ParmIndex=1 to ParmCount
  6419. if ParmName.ParmIndex<> '' then
  6420. do
  6421. if ParmUsed.ParmIndex='N' then
  6422. do
  6423. if ReplaceParmWith=='' then
  6424. LSPC=''
  6425. else
  6426. LSPC=' '
  6427. if ParmValueT.ParmIndex='NV' then
  6428. ReplaceParmWith=ReplaceParmWith||LSPC||ParmNameC.ParmIndex
  6429. else
  6430. do
  6431. if ParmCmds='' then
  6432. do
  6433. QChar=QuoteIt(ParmValue.ParmIndex,TryQuoteListAny)
  6434. ReplaceParmWith=ReplaceParmWith||LSPC||ParmNameC.ParmIndex|| '=' ||QChar||ParmValue.ParmIndex||QChar
  6435. end
  6436. else
  6437. do
  6438. ReplaceParmWith=ReplaceParmWith||LSPC||StartsMacroParm||ParmNameC.ParmIndex|| ' ' ||ParmCmds||EndsMacroParm
  6439. end
  6440. end
  6441. end
  6442. end
  6443. end
  6444. ParmCmds=''
  6445. end
  6446. when ThisParmName='??' then
  6447. do
  6448. zb!ValPointless='Y'
  6449. zb!ReginaBugWorkAround='Y'
  6450. if OptionDebugOn='Y' then
  6451. call _SpecialPrm 'all parms as rexx array'
  6452. RepWith=''
  6453. ArrayCnt=0
  6454. do ParmIndex=1 to ParmCount
  6455. if ParmName.ParmIndex<> '' then
  6456. do
  6457. ArrayCnt=ArrayCnt+1
  6458. RepWith=RepWith|| 'MP.' || ArrayCnt || ".MPNAME  = " ||QuoteAsRexxLit(ParmNameC.ParmIndex)||DefRexxSpecialSepTag
  6459. RepWith=RepWith|| '@s@RxVar:' || 'MP.' || ArrayCnt || '.MPVALUE' || ':' || ParmValue.ParmIndex || ':@e@RxVar' ||DefRexxSpecialSepTag
  6460. RepWith=RepWith|| 'MP.' || ArrayCnt || ".MPUSED  = '" || ParmUsed.ParmIndex                   || "'" ||DefRexxSpecialSepTag
  6461. RepWith=RepWith|| 'MP.' || ArrayCnt || ".MPTYPE  = '" || ParmValueT.ParmIndex                 || "'" ||DefRexxSpecialSepTag
  6462. end
  6463. end
  6464. ReplaceParmWith=RepWith|| 'MP.0 = ' ||ArrayCnt||DefRexxSpecialSepTag
  6465. ParmCmds=''
  6466. end
  6467. when translate(ThisParmName)='?MACNAME' then
  6468. do
  6469. zb!ReginaBugWorkAround='Y'
  6470. if OptionDebugOn='Y' then
  6471. call _SpecialPrm 'name of macro being expanded'
  6472. ReplaceParmWith=VariableName
  6473. end
  6474. when translate(ThisParmName)='?RESETUSED' then
  6475. do
  6476. zb!ReginaBugWorkAround='Y'
  6477. if OptionDebugOn='Y' then
  6478. call _SpecialPrm 'All parms now marked unused'
  6479. do ParmIndex=1 to ParmCount
  6480. ParmUsed.ParmIndex='N'
  6481. end
  6482. zb!ValPointless='Y'
  6483. ReplaceParmWith=''
  6484. ParmCmds=''
  6485. end
  6486. when ThisParmName='!' then
  6487. do
  6488. zb!DieIfNotUsed="Y"
  6489. zb!ReginaBugWorkAround='Y'
  6490. if OptionDebugOn='Y' then
  6491. call _SpecialPrm 'Empty - It is a parameter validation command'
  6492. ReplaceParmWith=''
  6493. ParmCmds=''
  6494. end
  6495. otherwise
  6496. do
  6497. if zb!ReginaBugWorkAround='N' then
  6498. call _DieInvPrm
  6499. end
  6500. end
  6501. end
  6502. end
  6503. end
  6504. if ParmCmds<> '' then
  6505. do
  6506. ParmCmds=translate(strip(ParmCmds))
  6507. do until ParmCmds=''
  6508. parse var ParmCmds ParmCmd ParmCmds
  6509. if OptionDebugOn='Y' then
  6510. do
  6511. call DBGIND 1
  6512. call DebugOutputVariableInfo_FOUNDVARPARMS '$$Bef: ' ||ReplaceParmWith
  6513. call DebugOutputVariableInfo_FOUNDVARPARMS '$$Cmd: ' ||ParmCmd
  6514. call DBGIND-1
  6515. end
  6516. select
  6517. when ParmCmd='$$PASSAQ' then
  6518. do
  6519. QChar=QuoteIt(ReplaceParmWith, 'ANY')
  6520. ReplaceParmWith=ThisParmName|| '=' ||QChar||ReplaceParmWith||QChar
  6521. end
  6522. when ParmCmd='$$PASSDSQ' then
  6523. do
  6524. QChar=QuoteIt(ReplaceParmWith,TryQuoteListDs)
  6525. ReplaceParmWith=ThisParmName|| '=' ||QChar||ReplaceParmWith||QChar
  6526. end
  6527. when ParmCmd='$$IGNORE' then
  6528. ReplaceParmWith=''
  6529. when ParmCmd='$$ISPASSED' then
  6530. ReplaceParmWith=zb!IsPassed
  6531.  
  6532. when ParmCmd='$$DSQ' then
  6533. ReplaceParmWith=QuoteIt(ReplaceParmWith,TryQuoteListDs, 'Y')
  6534.  
  6535. when ParmCmd='$$SDQ' then
  6536. ReplaceParmWith=QuoteIt(ReplaceParmWith,TryQuoteListSd, 'Y')
  6537.  
  6538. when ParmCmd='$$AQ' then
  6539. ReplaceParmWith=QuoteIt(ReplaceParmWith, 'ANY', 'Y')
  6540.  
  6541. when ParmCmd='$$UPPER' then
  6542. ReplaceParmWith=ToUpperCase(ReplaceParmWith)
  6543.  
  6544. when ParmCmd='$$LOWER' then
  6545. ReplaceParmWith=ToLowerCase(ReplaceParmWith)
  6546.  
  6547. when ParmCmd='$$ADDCOMMA' then
  6548. ReplaceParmWith=AddCommasToDecimalNumber(ReplaceParmWith)
  6549.  
  6550. when ParmCmd='$$HTMLQ' then
  6551. ReplaceParmWith=ReplaceString(ReplaceParmWith, '"', '"')
  6552.  
  6553. when ParmCmd='$$SQX2' then
  6554. ReplaceParmWith=ReplaceString(ReplaceParmWith, "'" , "''")
  6555.  
  6556. when left(ParmCmd,8)="$$RXVAR:" then
  6557. ReplaceParmWith=_RxVar(ParmCmd,ReplaceParmWith)
  6558.  
  6559. when ParmCmd="$$RX'" then
  6560. ReplaceParmWith=_RXQuote(ReplaceParmWith, "'")
  6561.  
  6562. when ParmCmd='$$RX"' then
  6563. ReplaceParmWith=_RXQuote(ReplaceParmWith, '"')
  6564.  
  6565. when ParmCmd='$$SPCPLUS' then
  6566. do
  6567. if ReplaceParmWith\=='' then
  6568. ReplaceParmWith=' ' ||ReplaceParmWith
  6569. end
  6570.  
  6571. when ParmCmd='$$ISBLANK' then
  6572. do
  6573. if ReplaceParmWith='' then
  6574. ReplaceParmWith='Y'
  6575. else
  6576. ReplaceParmWith='N'
  6577. end
  6578.  
  6579. when ParmCmd='$$RXEXEC' then
  6580. do
  6581. RxExec=''
  6582. call ExecRexxCmd ReplaceParmWith, 'N'
  6583. ReplaceParmWith=RxExec
  6584. end
  6585.  
  6586. otherwise
  6587. do
  6588. UserRexx=CfgMacro("REXX_" || ParmCmd, '')
  6589. if UserRexx='' then
  6590. CryAndDie('The $$ replacement command of "' || ParmCmd || '" is unknown!')
  6591. TheMacro=VariableName
  6592. TheName=ThisParmName
  6593. TheValue=ReplaceParmWith
  6594. call ExecRexxCmd UserRexx, 'N'
  6595. if OptionDebugOn='Y' then
  6596. do
  6597. if ReplaceParmWith=TheValue then
  6598. do
  6599. call DBGIND 1
  6600. call DebugOutputVariableInfo_FOUNDVARPARMS 'The user rexx code did not modify the "TheValue" variable'
  6601. call DBGIND-1
  6602. end
  6603. end
  6604. ReplaceParmWith=TheValue
  6605. end
  6606. end
  6607. end
  6608. end
  6609. if OptionDebugOn='Y' then
  6610. do
  6611. call DBGIND 1
  6612. call DebugOutputVariableInfo_FOUNDVARPARMS 'Use : ' ||ReplaceParmWith
  6613. call DBGIND-1
  6614. end
  6615. ParmRightBit=ReplaceParmWith||ParmRightBit
  6616. ParmPos=pos(StartsMacroParm,ParmRightBit)
  6617. end
  6618. ParmLeftBit=ParmLeftBit||ParmRightBit
  6619. if zb!ValPointless='N' then
  6620. do
  6621. if OptionParmVal<> "S" then
  6622. do
  6623. zb!DieIfNotUsed=OptionParmVal
  6624. end
  6625. if zb!DieIfNotUsed='Y' | OptionDebugOn = 'Y' then
  6626. do
  6627. zb!UnUsed=''
  6628. do ParmIndex=1 to ParmCount
  6629. if ParmUsed.ParmIndex='N' then
  6630. do
  6631. 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).'
  6632. if zb!UnUsed='' then
  6633. zb!UnUsed=ParmName.ParmIndex
  6634. else
  6635. zb!UnUsed=zb!UnUsed|| ', ' ||ParmName.ParmIndex
  6636. end
  6637. end
  6638. if zb!DieIfNotUsed='Y' then
  6639. do
  6640. if zb!UnUsed<> '' then
  6641. do
  6642. zb!UnUsed='    ' ||zb!UnUsed
  6643. if DefaultCnt=0 then
  6644. zb!Def='No macro parameters used default values'
  6645. else
  6646. do
  6647. zb!Def=''
  6648. do DefaultIndex=1 to DefaultCnt
  6649. if zb!Def='' then
  6650. zb!Def=PrmDefaultName.DefaultIndex
  6651. else
  6652. zb!Def=zb!Def|| ', ' ||PrmDefaultName.DefaultIndex
  6653. end
  6654. end
  6655. zb!Def='    ' ||zb!Def
  6656. CryAndDie('The "' || VariableName || '" macro was supplied parameters it', 'does not require! These are:', zb!UnUsed, '', 'These macro parameters used default values:',zb!Def)
  6657. end
  6658. end
  6659. end
  6660. end
  6661. if pos('{',ParmLeftBit)<>0 then
  6662. do
  6663. if pos(StartsMacroParm,ParmLeftBit)<>0 then
  6664. CryAndDie('Not all "' || VariableName || '" parameters replaced!')
  6665. ParmLeftBit=ReplaceString(ParmLeftBit,HidesMacroParm,StartsMacroParm)
  6666. end
  6667. return(ParmLeftBit)
  6668.  
  6669. _ReplaceAllHashDefinedVariables:
  6670. RightBit=arg(1)
  6671. LeftBit=''
  6672. ChangesMade='N'
  6673. VarPos=pos(StartsMacroReplacement,RightBit)
  6674. do while VarPos<>0
  6675. LeftBit=LeftBit||left(RightBit,VarPos-1)
  6676. RightBit=substr(RightBit,VarPos+2)
  6677. DelPos=verify(RightBit,EndsVar, 'M')
  6678. if DelPos=0 then
  6679. CryAndDie("Can't find the end of the macro reference at " ||DebugRightArrow||StartsMacroReplacement||RightBit||DebugLeftArrow)
  6680. VariableName=left(RightBit,DelPos-1)
  6681. MacroBeingExpanded=VariableName
  6682. RightBit=strip(substr(RightBit,DelPos), 'L')
  6683. if OptionDebugOn='Y' then
  6684. do
  6685. call DebugOutputVariableInfo_FOUNDVAR 'Found : ' || StartsMacroReplacement || VariableName || ' ...' ||EndsMacroReplacement
  6686. call DBGIND 1
  6687. end
  6688. DefnAsIs='N'
  6689. VariableCont=GetDefineContents(VariableName)
  6690. if OptionDebugOn='Y' then
  6691. do
  6692. call DebugOutputVariableInfo_FOUNDVAR 'Value : ' ||DebugRightArrow||VariableCont||DebugLeftArrow
  6693. call DBGIND 1
  6694. end
  6695. ParmCount=0
  6696. DDCmdCount=0
  6697. PositionalParmCount=0
  6698. EndParmDelimiters=EndsMacroReplacement|| '= '
  6699. Left1=left(RightBit,1)
  6700. do while Left1<>EndsMacroReplacement
  6701. if pos(Left1,ArePositionalChars)<>0 then
  6702. do
  6703. PositionalParmCount=PositionalParmCount+1
  6704. ThisParmNameC='#' ||PositionalParmCount
  6705. if CsReplacement='N' then
  6706. ThisParmName=translate(ThisParmNameC)
  6707. else
  6708. ThisParmName=ThisParmNameC
  6709. ThisParmValType='V'
  6710. if Left1='=' then
  6711. ThisParmVal=GetQuotedText(substr(RightBit,2), "RightBit", EndsMacroReplacement, 'Getting macro parameter''s value for ' ||ThisParmNameC)
  6712. else
  6713. ThisParmVal=GetQuotedText(RightBit, "RightBit", EndsMacroReplacement, 'Getting positional macro parameter''s value for ' ||ThisParmNameC)
  6714. end
  6715. else
  6716. do
  6717. DelPos=verify(RightBit,EndParmDelimiters, 'M')
  6718. if DelPos=0 then
  6719. CryAndDie('Macro reference incorrectly formatted, missing "' || EndsMacroReplacement || '"?')
  6720. ThisParmNameC=strip(left(RightBit,DelPos-1))
  6721. if CsReplacement='N' then
  6722. ThisParmName=translate(ThisParmNameC)
  6723. else
  6724. ThisParmName=ThisParmNameC
  6725. DelChar=substr(RightBit,DelPos,1)
  6726. if DelChar='=' then
  6727. do
  6728. ThisParmVal=GetQuotedText(substr(RightBit,DelPos+1), "RightBit", EndsMacroReplacement, 'Getting macro parameter''s value for ' ||ThisParmNameC)
  6729. ThisParmValType='V'
  6730. end
  6731. else
  6732. do
  6733. RightBit=strip(substr(RightBit,DelPos), 'L')
  6734. if left(ThisParmName,2)<> '$$' then
  6735. do
  6736. ThisParmVal=ThisParmName
  6737. ThisParmValType='NV'
  6738. end
  6739. else
  6740. do
  6741. if OptionDebugOn='Y' then
  6742. call DebugOutputVariableInfo_FOUNDVARPARMS '$$Cmd: ' ||ThisParmName
  6743. select
  6744. when ThisParmName='$$ASIS' then
  6745. DefnAsIs='Y'
  6746. otherwise
  6747. do
  6748. DDCmdCount=DDCmdCount+1
  6749. DDCmd.DDCmdCount=ThisParmName
  6750. end
  6751. end
  6752. Left1=left(RightBit,1)
  6753. iterate
  6754. end
  6755. end
  6756. end
  6757. do ChkIndex=1 to ParmCount
  6758. if ThisParmName=ParmName.ChkIndex then
  6759. CryAndDie('The macro parameter "' || ThisParmName || '" was specified more than once!')
  6760. end
  6761. ParmCount=ParmCount+1
  6762. ParmName.ParmCount=ThisParmName
  6763. ParmNameC.ParmCount=ThisParmNameC
  6764. ParmValue.ParmCount=ThisParmVal
  6765. ParmValueT.ParmCount=ThisParmValType
  6766. Left1=left(RightBit,1)
  6767. end
  6768. if DefnAsIs='Y' then
  6769. do
  6770. if ParmCount<>0 then
  6771. CryAndDie('You wanted "' || VariableName || '" subsituted ASIS but then specified parameters!')
  6772. end
  6773. else
  6774. do
  6775. if ParmCount<>0 then
  6776. VariableCont=ReplaceDefinitionsParameters()
  6777. else
  6778. do
  6779. if pos(StartsMacroParm,VariableCont)<>0 then
  6780. VariableCont=ReplaceDefinitionsParameters()
  6781. else
  6782. VariableCont=ReplaceString(VariableCont,HidesMacroParm,StartsMacroParm)
  6783. end
  6784. end
  6785. if DDCmdCount<>0 then
  6786. do
  6787. do ddIndex=1 to DDCmdCount
  6788. ThisDdCmd=DDCmd.ddIndex
  6789. select
  6790.  
  6791. when ThisDdCmd='$$DSQ' then
  6792. VariableCont=QuoteIt(VariableCont,TryQuoteListDs, 'Y')
  6793.  
  6794. when ThisDdCmd='$$SDQ' then
  6795. VariableCont=QuoteIt(VariableCont,TryQuoteListSd, 'Y')
  6796.  
  6797. when ThisDdCmd='$$AQ' then
  6798. VariableCont=QuoteIt(VariableCont, 'ANY', 'Y')
  6799.  
  6800. when ThisDdCmd='$$UPPER' then
  6801. VariableCont=ToUpperCase(VariableCont)
  6802.  
  6803. when ThisDdCmd='$$LOWER' then
  6804. VariableCont=ToLowerCase(VariableCont)
  6805.  
  6806. when ThisDdCmd='$$ADDCOMMA' then
  6807. VariableCont=AddCommasToDecimalNumber(VariableCont)
  6808.  
  6809. when ThisDdCmd='$$HTMLQ' then
  6810. VariableCont=ReplaceString(VariableCont, '"', '"')
  6811.  
  6812. when ThisDdCmd='$$SQX2' then
  6813. VariableCont=ReplaceString(VariableCont, "'" , "''")
  6814.  
  6815. when left(ThisDdCmd,8)="$$RXVAR:" then
  6816. VariableCont=_RxVar(ThisDdCmd,VariableCont)
  6817.  
  6818. when ThisDdCmd="$$RX'" then
  6819. VariableCont=_RXQuote(VariableCont, "'")
  6820.  
  6821. when ThisDdCmd='$$RX"' then
  6822. VariableCont=_RXQuote(VariableCont, '"')
  6823.  
  6824. when ThisDdCmd='$$SPCPLUS' then
  6825. do
  6826. if VariableCont\=='' then
  6827. VariableCont=' ' ||VariableCont
  6828. end
  6829.  
  6830. when ThisDdCmd='$$ISBLANK' then
  6831. do
  6832. if VariableCont='' then
  6833. VariableCont='Y'
  6834. else
  6835. VariableCont='N'
  6836. end
  6837.  
  6838. when ThisDdCmd='$$RXEXEC' then
  6839. do
  6840. RxExec=''
  6841. call ExecRexxCmd VariableCont, 'N'
  6842. VariableCont=RxExec
  6843. end
  6844.  
  6845. otherwise
  6846. do
  6847. UserRexx=CfgMacro("REXX_" || ThisDdCmd, '')
  6848. if UserRexx='' then
  6849. CryAndDie('The $$ replacement command of "' || ThisDdCmd || '" is unknown!')
  6850. TheMacro=""
  6851. TheName=VariableName
  6852. TheValue=VariableCont
  6853. call ExecRexxCmd UserRexx, 'N'
  6854. if OptionDebugOn='Y' then
  6855. do
  6856. if VariableCont=TheValue then
  6857. do
  6858. call DBGIND 1
  6859. call DebugOutputVariableInfo_FOUNDVARPARMS 'The user rexx code did not modify the "TheValue" variable'
  6860. call DBGIND-1
  6861. end
  6862. end
  6863. VariableCont=TheValue
  6864. end
  6865. end
  6866. end
  6867. end
  6868. if OptionDebugOn='Y' then
  6869. call DBGIND-2
  6870. RightBit=substr(RightBit,2)
  6871. LeftBit=LeftBit||VariableCont
  6872. ReplaceCount=ReplaceCount+1
  6873. if pos(MarksNewLine,LeftBit)<>0 then
  6874. leave
  6875. VarPos=pos(StartsMacroReplacement,RightBit)
  6876. end
  6877. MacroBeingExpanded=''
  6878. TheString=LeftBit||RightBit
  6879. return(TheString)
  6880.  
  6881. CfgMacro:
  6882. ac!M=arg(1)
  6883. if MacroExists(ac!M)='N' then
  6884. do
  6885. ac!V=arg(2)
  6886. ac!Wrd='not'
  6887. end
  6888. else
  6889. do
  6890. ac!V=GetDefineContents(ac!M)
  6891. ac!Wrd='was'
  6892. end
  6893. if OptionDebugOn='Y' then
  6894. call DBG_MACROVALORDEF 'Option(Macro) "' || ac!M || '" ' || ac!Wrd || ' found. Using ' ||DebugRightArrow||ac!V||DebugLeftArrow
  6895. return(ac!V)
  6896.  
  6897. CfgEnv:
  6898. bc!V=arg(1)
  6899. bc!Rc=GetEnv(bc!V)
  6900. if bc!Rc\=='' then
  6901. bc!C='was'
  6902. else
  6903. do
  6904. bc!Rc=arg(2)
  6905. bc!C='not'
  6906. end
  6907. if OptionDebugOn='Y' then
  6908. call DBG 'Option(Env) "' || bc!V || '" ' || bc!C || ' found. Using ' ||DebugRightArrow||bc!Rc||DebugLeftArrow
  6909. return(bc!Rc)
  6910.  
  6911. Define_28:
  6912. RexxTokens='|=+-/%*<>\,;:()&'
  6913. signal LineOut_29
  6914.  
  6915. GenerateOneLine:
  6916. if CondNlCount=0 then
  6917. call GenerateOneLineAsIs arg(1)
  6918. else
  6919. do
  6920. if OptionDebugOn='Y' then
  6921. call DBG 'Looking for Conditional newline codes'
  6922. BefCodeCount=ReplaceCount
  6923. Line2Gen=ReplaceString(arg(1), "{?WaNtNl?}",MarksNewLine)
  6924. if BefCodeCount<>ReplaceCount then
  6925. do
  6926. if OptionDebugOn='Y' then
  6927. call DBG 'Found ' ReplaceCount - BefCodeCount || ' conditional newline codes'
  6928. CondNlCount=CondNlCount-(ReplaceCount-BefCodeCount)
  6929. do until BefCodeCount=ReplaceCount
  6930. BefCodeCount=ReplaceCount
  6931. Line2Gen=ReplaceString(Line2Gen,MarksNewLine||MarksNewLine,MarksNewLine)
  6932. end
  6933. if Line2Gen\=='' then
  6934. do
  6935. if left(Line2Gen,1)=MarksNewLine then
  6936. Line2Gen=substr(Line2Gen,2)
  6937. if Line2Gen\=='' then
  6938. do
  6939. if right(Line2Gen,1)=MarksNewLine then
  6940. Line2Gen=left(Line2Gen,length(Line2Gen)-1)
  6941. end
  6942. end
  6943. end
  6944. do until Line2Gen==''
  6945. parse var Line2Gen This1 (MarksNewLine) Line2Gen
  6946. call GenerateOneLineAsIs This1
  6947. end
  6948. end
  6949. return
  6950.  
  6951. GenerateOneLineAsIs:
  6952. Line2Gen2=arg(1)
  6953. if CheckSpelling='Y';then
  6954. do
  6955. if AllowSpell='Y' & Line2Gen2 <> '' then
  6956. call SpellCheckOneLine Line2Gen2
  6957. end
  6958. if OptionFilterOut='' then
  6959. do
  6960. if HoldingOutput='N' then
  6961. call FileCharOut Line2Gen2||NewLineChars
  6962. else
  6963. HeldOutput=HeldOutput||Line2Gen2||NewLineChars
  6964. GeneratedLines=GeneratedLines+1
  6965. CurrentOutLine=CurrentOutLine+1
  6966. end
  6967. else
  6968. do
  6969. FilterRc=HtmlFilterOut("O",Line2Gen2,CurrentOutFile,CurrentOutLine,GeneratedLines,NewLineChars)
  6970. if Left(FilterRc,3)<> "OK:" then
  6971. CryAndDie(FilterRc)
  6972. else
  6973. do
  6974. NumWritten=substr(FilterRc,4)
  6975. GeneratedLines=GeneratedLines+NumWritten
  6976. CurrentOutLine=CurrentOutLine+NumWritten
  6977. end
  6978. end
  6979. return
  6980.  
  6981. OutputRexxLine:
  6982. RexxLine=arg(1)
  6983. if right(RexxLine,1)=';' then
  6984. RexxLine=left(RexxLine,length(RexxLine)-1)
  6985. if OptionPack='Y' & KeepIndent = 'N' then
  6986. do
  6987. if AllowPack='Y' then
  6988. RexxLine=CompressRexxLine(RexxLine)
  6989. else
  6990. do
  6991. if OptionDebugOn='Y' then
  6992. call DBG 'Not allowed to pack this line'
  6993. end
  6994. end
  6995. ElPos=pos(':',RexxLine)
  6996. if ElPos<>0 then
  6997. do
  6998. PossLabel=strip(left(RexxLine,ElPos-1))
  6999. if datatype(PossLabel, 'S')=1 then
  7000. call GenerateOneLine ''
  7001. end
  7002. if pos(NotEqualInC,RexxLine)<>0 then
  7003. call OutputInformationToScreen '"' || NotEqualInC || '" found.  Did you mean to use "<>" or "\="?'
  7004. call GenerateOneLine RexxLine
  7005. return
  7006.  
  7007. CompressRexxLine:
  7008. RexxLine=arg(1)
  7009. Spos=lastpos("'",RexxLine)
  7010. Dpos=lastpos('"',RexxLine)
  7011. EndPos=max(Spos,Dpos)
  7012. if EndPos=0 then
  7013. return(_CompressRexx(RexxLine))
  7014. else
  7015. do
  7016. Spos=pos("'",RexxLine)
  7017. Dpos=pos('"',RexxLine)
  7018. StartPos=min(Spos,Dpos)
  7019. if StartPos=0 then
  7020. StartPos=max(Spos,Dpos)
  7021. LeftBit=left(RexxLine,StartPos-1)
  7022. RightBit=substr(RexxLine,EndPos+1)
  7023. if right(LeftBit,1, "*") == ' ' then
  7024. LeftSpace=' '
  7025. else
  7026. LeftSpace=''
  7027. if left(RightBit,1, "*") == ' ' then
  7028. RightSpace=' '
  7029. else
  7030. RightSpace=''
  7031. LeftBit=_CompressRexx(LeftBit)
  7032. RightBit=_CompressRexx(RightBit)
  7033. if LeftSpace==' ' then
  7034. do
  7035. if right(LeftBit,1)='=' then
  7036. LeftSpace=''
  7037. end
  7038. LeftBit=_CompressRexx(LeftBit)
  7039. RightBit=_CompressRexx(RightBit)
  7040. return(LeftBit||LeftSpace||substr(RexxLine,StartPos,(EndPos-StartPos)+1)||RightSpace||RightBit)
  7041. end
  7042.  
  7043. _CompressRexx:
  7044. ToCompress=space(arg(1))
  7045. Compressed=''
  7046. TokenPos=verify(ToCompress,RexxTokens, 'M')
  7047. do while TokenPos<>0
  7048. Compressed=Compressed||strip(left(ToCompress,TokenPos-1), 'T')||substr(ToCompress,TokenPos,1)
  7049. ToCompress=strip(substr(ToCompress,TokenPos+1), 'L')
  7050. TokenPos=verify(ToCompress,RexxTokens, 'M')
  7051. end
  7052. return(Compressed||ToCompress)
  7053.  
  7054. LineOut_29:
  7055. call InitializeOneLine
  7056. signal OneLine_30
  7057.  
  7058. InitializeOneLine:
  7059. OneLineLevel=0
  7060. OneLineBuffer=''
  7061. OneLineGCount=0
  7062. return
  7063.  
  7064. InitializeOneLine4ThisLevel:
  7065. OneLineSeperator.OneLineLevel=''
  7066. OneLineStartLoc.OneLineLevel=''
  7067. OneLineStopper.OneLineLevel=''
  7068. OneLineNonPpwCnt.OneLineLevel=0
  7069. OneLineCount.OneLineLevel=0
  7070. return
  7071.  
  7072. AddToOneLine:
  7073. _OneLineBit=arg(1)
  7074. _Word1=word(_OneLineBit,1)
  7075. if translate(_Word1)=CmdHash1Line then
  7076. do
  7077. if OneLineBuffer\=='' then
  7078. do
  7079. OneLineBuffer=OneLineBuffer||OneLineSeperator.OneLineLevel
  7080. end
  7081. call ProcessOneLine subword(_OneLineBit,2),CmdHash1LineEnd
  7082. return('')
  7083. end
  7084. if strip(_OneLineBit)<>OneLineStopper.OneLineLevel then
  7085. do
  7086. OneLineCount.OneLineLevel=OneLineCount.OneLineLevel+1
  7087. OneLineGCount=OneLineGCount+1
  7088. if OneLineGCount=1 then
  7089. do
  7090. if translate(left(_Word1,length(CmdHashDefine)))=CmdHashDefine then
  7091. do
  7092. PpwCmdDivider2=MarksNewLineInHashDefine
  7093. OneLineBuffer=OneLineBuffer||_OneLineBit|| ' '
  7094. end
  7095. else
  7096. do
  7097. PpwCmdDivider2=MarksNewLine
  7098. OneLineNonPpwCnt.OneLineLevel=OneLineNonPpwCnt.OneLineLevel+1
  7099. OneLineBuffer=OneLineBuffer||_OneLineBit
  7100. end
  7101. end
  7102. else
  7103. do
  7104. if left(_Word1,HashPrefixLng)<>HashPrefix then
  7105. do
  7106. if OneLineNonPpwCnt.OneLineLevel=0 then
  7107. OneLineBuffer=OneLineBuffer||_OneLineBit
  7108. else
  7109. OneLineBuffer=OneLineBuffer||OneLineSeperator.OneLineLevel||_OneLineBit
  7110. OneLineNonPpwCnt.OneLineLevel=OneLineNonPpwCnt.OneLineLevel+1
  7111. end
  7112. else
  7113. do
  7114. parse var _OneLineBit _ppwCmd _ppwCmdParm
  7115. _OneLineBit=_ppwCmd|| ' ' ||strip(_ppwCmdParm)
  7116. OneLineBuffer=OneLineBuffer||PpwCmdDivider2||_OneLineBit||PpwCmdDivider2
  7117. end
  7118. end
  7119. return('')
  7120. end
  7121. if OptionDebugOn='Y' then
  7122. call DBG 'End of #( block - ' || OneLineCount.OneLineLevel || ' line(s)'
  7123. OneLineLevel=OneLineLevel-1
  7124. call StackPop "#( Nesting"
  7125. if OneLineLevel<>0 then
  7126. return('')
  7127. else
  7128. do
  7129. _OneLineBit=OneLineBuffer
  7130. call InitializeOneLine
  7131. return(_OneLineBit)
  7132. end
  7133.  
  7134. ProcessOneLine:
  7135. OneLineLevel=OneLineLevel+1
  7136. call StackPush "#( Nesting",,"PPWIZARD's #( command"
  7137. call InitializeOneLine4ThisLevel
  7138. OneLineStartLoc.OneLineLevel=CurrentSourceLocation()
  7139. Rest=PerformReplacementsInCmdsParameters(arg(1))
  7140. if Rest='' then
  7141. OneLineSeperator.OneLineLevel=' '
  7142. else
  7143. do
  7144. OneLineSeperator.OneLineLevel=GetQuotedText(Rest, "Rest")
  7145. end
  7146. if Rest<> '' then
  7147. OneLineStopper.OneLineLevel=GetQuotedText(Rest)
  7148. else
  7149. do
  7150. OneLineStopper.OneLineLevel=arg(2)
  7151. if OneLineStopper.OneLineLevel='' then
  7152. OneLineStopper.OneLineLevel=HashPrefix|| 'OneLineEnd'
  7153. end
  7154. if OptionDebugOn='Y' then
  7155. do
  7156. call DBG 'Line separator      = ' ||DebugRightArrow||OneLineSeperator.OneLineLevel||DebugLeftArrow
  7157. call DBG 'End of block marker = ' || DebugRightArrow || OneLineStopper.OneLineLevel   || DebugLeftArrow || ' (case sensitive!)'
  7158. end
  7159. return(0)
  7160.  
  7161. OneLine_30:
  7162. UserHashCmds=''
  7163. signal CMDNFND_31
  7164.  
  7165. LookForUnknownCmdHandler:
  7166. UserHashCmds=CfgMacro("UNKNOWN_HASH_COMMANDS", '')
  7167. return
  7168.  
  7169. ProcessUnknownHashCommand:
  7170. parse arg HashCmd,HashParms
  7171. CmdGenerates=''
  7172. call ExecRexxCmd UserHashCmds
  7173. if CmdGenerates\=='' then
  7174. do
  7175. do
  7176. if InLoop='Y' &LoopLinesFromFile=0 then
  7177. do
  7178. if IncludeLoopMemBufferNextLine=='' then
  7179. IncludeLoopMemBufferNextLine=CmdGenerates
  7180. else
  7181. IncludeLoopMemBufferNextLine=CmdGenerates||MarksNewLine||IncludeLoopMemBufferNextLine
  7182. end
  7183. else
  7184. do
  7185. if IncludeMemBufferNextLine=='' then
  7186. IncludeMemBufferNextLine=CmdGenerates
  7187. else
  7188. IncludeMemBufferNextLine=CmdGenerates||MarksNewLine||IncludeMemBufferNextLine
  7189. end
  7190. end
  7191. end
  7192. return(0)
  7193.  
  7194. CMDNFND_31:
  7195. OptChar='/'
  7196. CmdLineQL='"' || "'~`!#$%^=(["
  7197. CmdLineQR='"' || "'~`!#$%^=)]"
  7198. signal CmdLine_32
  7199.  
  7200. InitCommandLineOptions:
  7201. Bc02_148='N'
  7202. OptChar1='/'
  7203. OptChar2='-'
  7204. OptionsCmdLine=strip(arg(1))
  7205. OptionDebugOn='N'
  7206. OptionMaxCol=500
  7207. OptionPpwTraceAllowed='N'
  7208. DepDelPrev='N'
  7209. OptionBaseDirectory=''
  7210. InputMasksAllowed='Y'
  7211. OptionPrjExtn='DEF_*'
  7212. CgiOutputFile=''
  7213. OptionCgiModeOn='N'
  7214. ProcessingMode=''
  7215. OptionCloneUsed='N'
  7216. call BuildTitle "HTML"
  7217. call BuildTitle "OTHER"
  7218. call BuildTitle "REXX"
  7219. call BuildTitle "COPY"
  7220. OptionMsgReading="* Reading: {.}{F?}({F})"
  7221. OptionMsgMaking="- Making: {.}{R?}"
  7222. PpwOnOK=''
  7223. PpwOnERROR=''
  7224. if RexSystemOpSys="UNIX" then
  7225. OptionFileSR='NONE'
  7226. else
  7227. OptionFileSR='UNC'
  7228. OptionValidation=''
  7229. OptionValidationRc=''
  7230. OptionDependsOn=''
  7231. OptionWantInfoMsgs='Y'
  7232. OptionHashIncludeCnt=0
  7233. OptionIncludePathCnt=0
  7234. OptionTemplate=''
  7235. OptionQuietDependsOn='N'
  7236. OptionSummary='Y'
  7237. OptionPack='N'
  7238. OptionTranslateFileNames='N'
  7239. OptionFilterIn=''
  7240. OptionFilterOut=''
  7241. OptionDefineCount=0
  7242. OptionKeepRexxCmts='N'
  7243. OptionCompleteAddToToDepFile='Y'
  7244. OptionAtEndCommand=''
  7245. OptionAtEndCommandOkTest=''
  7246. HaveGeneratorTags='N'
  7247. OptionHtmlGeneratorTags=''
  7248. OptionNoDepFileOnWarnings='Y'
  7249. OptionHideCmdS=''
  7250. OptionHideCmdE=''
  7251. OptionHideCmdS_L=0
  7252. OptionHideCmdE_L=0
  7253. OptionForceRebuild='N'
  7254. OptionOutput=''
  7255. OptionOutputDefDir=''
  7256. OptionNoFiles=''
  7257. OptionCopyModeFuzz=0
  7258. Option0FilesPerMaskOk='N'
  7259. Option0FilesTotalOk='N'
  7260. Option0FilesTotalAfterExcludeOk='N'
  7261. OptionXSlash=''
  7262. OptionDeleteOnError='Y'
  7263. return
  7264.  
  7265. InitCommandLineOptions2:
  7266. call DBG 'Set up default extension Handlers'
  7267. call DBGIND 1
  7268. call DBG 'Set EXTN -> Processing mode and default output mask mappings'
  7269. call DBGIND 1
  7270. call ExtnInfoSet "*,it:PM=^LU:HTML^,OM=^LU:{$OutputDir}*.htm^,DM=^LU:^"
  7271. call ExtnInfoSet "v:PM=^LU:OTHER^,OM=^LU:{$OutputDir}*.vbs^,DM=^LU:^"
  7272. if RexSystemOpSys="OS/2" then
  7273. cc!XE="cmd"
  7274. else
  7275. cc!XE="rex"
  7276. call ExtnInfoSet "x:PM=^LU:REXX^,OM=^LU:{$OutputDir}*." || cc!XE || '^,DM=^LU:^'
  7277. call DBGIND-1
  7278. call DBG 'Set EXTN -> Output header mappings'
  7279. call DBGIND 1
  7280. cc!Line=copies('*+',30)
  7281. call StoreOutHeader "|VBS|'" || cc!Line || "|' |'" || cc!Line || "|"
  7282. call StoreOutHeader "|*REXX|/*" || cc!Line || "|* |" || cc!Line || "*/|"
  7283. call DBGIND-1
  7284. call DBG 'Set EXTN -> Syntax handlers'
  7285. call DBGIND 1
  7286. cc!R=PPWIZARD_REGINA_SYNTAX_CMD('N')
  7287. if cc!R='' then
  7288. call StoreSyntaxCheckCode4Header '|*REXX|*|'
  7289. else
  7290. call StoreSyntaxCheckCode4Header '|*REXX|' || cc!R || ' !CheckSyntax!|21924|' || PPWIZARD_REGINA_SYNTAX_LINE_MASK() || '|if arg(1)="!CheckSyntax!" then exit(21924)|'
  7291. call StoreSyntaxCheckCode4Header '|VBS|cscript.exe "{?}" //NOLOGO !CheckSyntax!|21924|({?}, |?:if Wscript.Arguments.Count = 1 then if Wscript.Arguments(0) = "!CheckSyntax!" then wscript.quit(21924)|'
  7292. call DBGIND-1
  7293. call DBGIND-1
  7294. return
  7295.  
  7296. PPWIZARD_REGINA_SYNTAX_CMD:
  7297. dc!TH=arg(1)
  7298. call DBG 'PPWIZARD_REGINA_SYNTAX_CMD(' || dc!TH || ')'
  7299. call DBGIND 1
  7300. dc!R=GetEnv("PPWIZARD_REGINA_SYNTAX_CMD")
  7301. if dc!R='' & dc!TH = 'Y' then
  7302. do
  7303. if RexWhich='REGINA' then
  7304. dc!R='regina'
  7305. else
  7306. do
  7307. if RexSystemOpSys="OS/2" then
  7308. do
  7309. dc!R=GetEnv("COMSPEC", "Y") || ' /C'
  7310. end
  7311. end
  7312. end
  7313. if dc!R<> '' then
  7314. do
  7315. dc!N='{?}'
  7316. if pos(dc!N,dc!R)=0 then
  7317. dc!R=dc!R|| ' "' || dc!N || '"'
  7318. end
  7319. call DBG 'Returning: ' ||dc!R
  7320. call DBGIND-1
  7321. return(dc!R)
  7322.  
  7323. PPWIZARD_REGINA_SYNTAX_LINE_MASK:
  7324. call DBG 'PPWIZARD_REGINA_SYNTAX_LINE_MASK()'
  7325. call DBGIND 1
  7326. ec!M=GetEnv("PPWIZARD_REGINA_SYNTAX_LINE_MASK")
  7327. if ec!M='' then
  7328. ec!M='line {?}: '
  7329. call DBG 'Returning: ' ||ec!M
  7330. call DBGIND-1
  7331. return(ec!M)
  7332.  
  7333. QuickCheckForDebugSwitch:
  7334. OptionsEnvironment=GetEnv('PPWIZARD_OPTIONS')
  7335. ec!LI=translate(OptionsEnvironment|| ' ' || OptionsCmdLine) || ' '
  7336. ec!P=pos(OptChar1|| 'DEBUG ',ec!LI)
  7337. if ec!P=0 then
  7338. ec!P=pos(OptChar2|| 'DEBUG ',ec!LI)
  7339. if ec!P<>0 then
  7340. do
  7341. OptionDebugOn='Y'
  7342. OptionWantInfoMsgs='Y'
  7343. OptionPpwTraceAllowed='Y'
  7344. call DebugStateChanged
  7345. end
  7346. return
  7347.  
  7348. ProcessCommandLine:
  7349. call SetUpPpwizardOptionDefaults
  7350. call InitializeCharCodes
  7351. PpwDoing='Starting to processing parameters (from command line + Environment)'
  7352. call DBG PpwDoing
  7353. InputMaskCount=0
  7354. DebugSwitchUsed='N'
  7355. OptionWantCopyright='Y'
  7356. CmdLineTotal=''
  7357. PpwClDep=''
  7358. call ProcessCommandLineBit "environment",OptionsEnvironment
  7359. PpwDefaultProject=FindProjectFile('ppwizard')
  7360. if PpwDefaultProject<> '' then
  7361. call ProcessCommandLineBit PpwDefaultProject,OptChar|| 'LIST:' || ReplaceString(PpwDefaultProject, ' ', '{x20}')
  7362. call ProcessCommandLineBit "command line",OptionsCmdLine
  7363. call DBG 'Finished Processing : ' ||CmdLineTotal
  7364. PpwDoing=''
  7365. return
  7366.  
  7367. AddToSwitchList:
  7368. fc!ForDep=arg(1)
  7369. fc!ThisParm=ReplaceString(ThisParm, ' ', '{x20}')
  7370. if CmdLineTotal='' then
  7371. CmdLineTotal=fc!ThisParm
  7372. else
  7373. CmdLineTotal=CmdLineTotal|| ' ' ||fc!ThisParm
  7374. if fc!ForDep='Y' then
  7375. do
  7376. if PpwClDep='' then
  7377. PpwClDep=fc!ThisParm
  7378. else
  7379. PpwClDep=PpwClDep|| ' ' ||fc!ThisParm
  7380. end
  7381. return
  7382.  
  7383. ProcessCommandLineBit:
  7384. parse arg gc!What,gc!CmdLine
  7385. call DBGIND 1
  7386. call DBG 'Processing switches - ' ||gc!What
  7387. call DBGIND 1
  7388. do while gc!CmdLine<> ''
  7389. gc!CmdLine=strip(gc!CmdLine)
  7390. gc!QPos=pos(left(gc!CmdLine,1),CmdLineQL)
  7391. if gc!QPos<>0 then
  7392. do
  7393. gc!SQ=substr(CmdLineQL,gc!QPos,1)
  7394. gc!EQ=substr(CmdLineQR,gc!QPos,1)
  7395. call DBG 'Item quoted. Left Quote = ' || gc!SQ || ', Looking for end quote of ' ||gc!EQ
  7396. gc!Start=gc!CmdLine
  7397. gc!CmdLine=substr(gc!CmdLine,2)
  7398. gc!QPos=pos(gc!EQ,gc!CmdLine)
  7399. if gc!QPos=0 then
  7400. UserSyntaxError('Could not find the ending quote of ' || gc!EQ || ' at ==> ' ||gc!Start)
  7401. ThisParm=left(gc!CmdLine,gc!QPos-1)
  7402. gc!CmdLine=substr(gc!CmdLine,gc!QPos+1)
  7403. if gc!CmdLine<> '' then
  7404. do
  7405. if left(gc!CmdLine,1)\==' ' then
  7406. UserSyntaxError('Invalid quoted parameter (space must follow quoted item) at ==> ' ||gc!Start)
  7407. end
  7408. end
  7409. else
  7410. do
  7411. parse var gc!CmdLine ThisParm gc!CmdLine
  7412. end
  7413. ParmType=left(ThisParm,1)
  7414. select
  7415. when ParmType=OptChar1|ParmType=OptChar2 then
  7416. do
  7417. ThisParmT='Switch'
  7418. OptChar=ParmType
  7419. end
  7420. when ParmType='@' then
  7421. ThisParmT='Project'
  7422. when ParmType=';' then
  7423. ThisParmT='Commented out'
  7424. otherwise
  7425. do
  7426. ThisParmT='FileMask'
  7427. ParmType=''
  7428. end
  7429. end
  7430. call DBG ThisParmT|| ' <- "' || ThisParm || '"'
  7431. if ParmType=';' then
  7432. iterate
  7433. call DBGIND 1
  7434. ThisParm=ReplaceCurlyHexCodes(ThisParm)
  7435. PpwDoing='Processing command line: ' ||ThisParm
  7436. if ParmType='@' then
  7437. do
  7438. PrjFile=substr(ThisParm,2)
  7439. PrjFileF=FindProjectFile(PrjFile)
  7440. if PrjFileF='' then
  7441. CryAndDie('The specified project "' || PrjFile || '" does not exist')
  7442. ThisParm=OptChar|| 'LIST:' || ReplaceString(PrjFileF, ' ', '{x20}')
  7443. gc!CmdLine=ThisParm|| ' ' ||gc!CmdLine
  7444. call DBGIND-1
  7445. iterate
  7446. end
  7447. if ParmType='' then
  7448. do
  7449. if InputMasksAllowed='N' then
  7450. CryAndDie('Sorry but no more input masks can be accepted', 'Input mask "' || ThisParm || '" specified in:', '    ' ||gc!What)
  7451. call AddToSwitchList 'N'
  7452. gc!FM=MakeAbsolute(ThisParm)
  7453. gc!FF='?' ||RexDirChar
  7454. if left(gc!FM,2)=gc!FF then
  7455. do
  7456. gc!Find=substr(gc!FM,3)
  7457. gc!FM=FindFile(gc!Find, '!')
  7458. end
  7459. gc!Marker='{ENDBASE}'
  7460. if pos(gc!Marker,gc!FM)<>0 then
  7461. do
  7462. parse var gc!FM gc!BD (gc!Marker) gc!FM
  7463. gc!FM=gc!BD||gc!FM
  7464. call DBG 'Without base dir marker = "' || gc!FM || '"'
  7465. if left(gc!BD,1)='+' then
  7466. gc!BD=substr(gc!BD,2)
  7467. end
  7468. else
  7469. do
  7470. if OptionBaseDirectory<> '' then
  7471. do
  7472. gc!BD=OptionBaseDirectory
  7473. end
  7474. else
  7475. do
  7476. if left(gc!FM,1)='+' then
  7477. gc!BD=substr(gc!FM,2)
  7478. else
  7479. gc!BD=gc!FM
  7480. gc!BD=_filespec('Location',gc!BD)
  7481. end
  7482. end
  7483. call ValidateBaseDirUse gc!BD,gc!FM, 'Y'
  7484. gc!PM=ProcessingMode
  7485. gc!OM=OptionOutput
  7486. gc!DM=OptionDependsOn
  7487. InputMaskCount=InputMaskCount+1
  7488. InputMaskBDir.InputMaskCount=gc!BD
  7489. InputMaskPMode.InputMaskCount=gc!PM
  7490. InputMaskOutMask.InputMaskCount=gc!OM
  7491. InputMaskDepMask.InputMaskCount=gc!DM
  7492. InputMaskCpyFuzz.InputMaskCount=OptionCopyModeFuzz
  7493. InputMask0FilesOk.InputMaskCount=Option0FilesPerMaskOk
  7494. gc!U="<Unknown at this time>"
  7495. if gc!PM='' then
  7496. gc!PM=gc!U
  7497. if gc!OM='' then
  7498. gc!OM=gc!U
  7499. if gc!DM='' then
  7500. gc!DM=gc!U
  7501. call DBG 'Base Directory  = "' || gc!BD || '"'
  7502. call DBG 'Processing Mode = "' || gc!PM || '"'
  7503. call DBG 'Output Mask     = "' || gc!OM || '"'
  7504. call DBG 'Depends On Mask = "' || gc!DM || '"'
  7505. call DBG '0 Files OK      = ' ||Option0FilesPerMaskOk
  7506. call DBG 'Copy Fuzz (sec) = ' ||OptionCopyModeFuzz
  7507. InputMask.InputMaskCount=gc!FM
  7508. call DBGIND-1
  7509. iterate
  7510. end
  7511. ParmPos=verify(ThisParm, ':=', 'M')
  7512. if ParmPos=0 then
  7513. do
  7514. ThisCmd=ThisParm
  7515. ThisCmdOptions=''
  7516. end
  7517. else
  7518. do
  7519. ThisCmd=left(ThisParm,ParmPos-1)
  7520. ThisCmdOptions=substr(ThisParm,ParmPos+1)
  7521. end
  7522. ThisCmd=translate(substr(ThisCmd,2))
  7523. RecordSwitch='Y'
  7524. IsDepSwitch='Y'
  7525. select
  7526. when ThisCmd='PACK' then
  7527. OptionPack=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7528. when ThisCmd='DELETEPREV' then
  7529. DepDelPrev=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7530. when ThisCmd='CRLF' then
  7531. do
  7532. if SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y') = 'Y' then
  7533. NewLineChars=CrLf
  7534. else
  7535. NewLineChars=MarksNewLine
  7536. end
  7537. when ThisCmd='CLONE' then
  7538. do
  7539. if InputMaskCount<>0 then
  7540. UserSyntaxError('Clone must be specified before any file masks!')
  7541. OptionCloneUsed='Y'
  7542. gc!CmdLine='/COPY:' || ThisCmdOptions || ' /CopyRight:N ' ||gc!CmdLine
  7543. OptionSummary='N'
  7544. end
  7545. when ThisCmd='COPY' then
  7546. do
  7547. if ThisCmdOptions<> '' then
  7548. do
  7549. OptionCopyModeFuzz=ThisCmdOptions
  7550. if datatype(OptionCopyModeFuzz, 'W')=0 then
  7551. UserSyntaxError('Invalid /Copy:Fuzz value of "' || OptionCopyModeFuzz || '" supplied!')
  7552. end
  7553. call PModeSwitch ThisCmd
  7554. end
  7555. when ThisCmd='OTHER' then
  7556. call PModeSwitch ThisCmd,ThisCmdOptions
  7557. when ThisCmd='HTML' then
  7558. call PModeSwitch ThisCmd,ThisCmdOptions
  7559. when ThisCmd='REXX' then
  7560. call PModeSwitch ThisCmd,ThisCmdOptions
  7561. when ThisCmd='NOFILES' then
  7562. OptionNoFiles=ThisCmdOptions
  7563. when ThisCmd='OUTPUT' then
  7564. do
  7565. gc!V=ThisCmdOptions
  7566. if right(gc!V,1)=RexDirChar then
  7567. do
  7568. OptionOutputDefDir=gc!V
  7569. call DBG "Setting default output directory"
  7570. end
  7571. else
  7572. do
  7573. call DBG "Setting processing mode"
  7574. OptionOutput=gc!V
  7575. end
  7576. end
  7577. when ThisCmd='DEPENDSON' then
  7578. do
  7579. OptionDependsOn=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7580. if left(OptionDependsOn,1)<> '-' then
  7581. OptionQuietDependsOn='N'
  7582. else
  7583. do
  7584. OptionQuietDependsOn='Y'
  7585. OptionDependsOn=substr(OptionDependsOn,2)
  7586. end
  7587. end
  7588. when ThisCmd='DEPENDSONCOMPLETE' then
  7589. OptionCompleteAddToToDepFile=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7590. when ThisCmd='0OK' then
  7591. do
  7592. if ThisCmdOptions='' then
  7593. ThisCmdOptions='YES,YES,YES'
  7594. parse var ThisCmdOptions gc!P1 ',' gc!P2 ',' gc!P3
  7595. if gc!P1<> '' then
  7596. Option0FilesPerMaskOk=SwitchWantsYesOrNo(ThisCmd,gc!P1, 'Y')
  7597. if gc!P2<> '' then
  7598. Option0FilesTotalOk=SwitchWantsYesOrNo(ThisCmd,gc!P2, 'Y')
  7599. if gc!P3<> '' then
  7600. Option0FilesTotalAfterExcludeOk=SwitchWantsYesOrNo(ThisCmd,gc!P3, 'Y')
  7601. end
  7602. when ThisCmd='TEMPLATE' then
  7603. OptionTemplate=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7604. when ThisCmd='COLOR' | ThisCmd = 'COLOUR' then
  7605. call ColorAllow SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7606. when ThisCmd='COLORCFG' then
  7607. do
  7608. gc!O=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7609. parse var gc!O gc!Var '=' gc!Val
  7610. if gc!Val='' then
  7611. CryAndDie('Incorrectly formatted color configuration of "' || gc!O || '"')
  7612. call ColorCfg gc!Var,gc!Val
  7613. end
  7614. when ThisCmd='BEEP' then
  7615. call BeepsAllow SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7616. when ThisCmd='BC' then
  7617. do
  7618. gc!P=translate(SwitchMustHaveOptions(ThisCmd,ThisCmdOptions))
  7619. parse var gc!P gc!F '=' gc!V
  7620. gc!FV='BC' || ReplaceString(gc!F, '.', '_')
  7621. if gc!V<> 'N' & gc!V <> 'Y' then
  7622. CryAndDie('Expected "Y" or "N" for ' || gc!FV || ' flag')
  7623. if symbol(gc!FV)<> 'VAR' then
  7624. CryAndDie('Invalid backwards compat flag of ' ||gc!FV)
  7625. call value gc!FV,gc!V
  7626. end
  7627. when ThisCmd='WARNINGSRC' then
  7628. do
  7629. if ThisCmdOptions='' then
  7630. WantedWarningRc=1
  7631. else
  7632. do
  7633. WantedWarningRc=GetQuotedText(ThisCmdOptions)
  7634. if datatype(WantedWarningRc, 'W')=0 then
  7635. CryAndDie('Invalid warning return code of "' || WantedWarningRc || '" supplied!')
  7636. end
  7637. end
  7638. when ThisCmd='OUTHEADER' then
  7639. call StoreOutHeader GetQuotedText(ThisCmdOptions)
  7640. when ThisCmd='SYNTAX' then
  7641. call StoreSyntaxCheckCode4Header GetQuotedText(ThisCmdOptions)
  7642. when ThisCmd='EXTNINFO' then
  7643. call ExtnInfoSet ThisCmdOptions
  7644. when ThisCmd='FILENAMES' then
  7645. do
  7646. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7647. OptionTranslateFileNames=translate(strip(ThisCmdOptions))
  7648. if OptionTranslateFileNames<> "LOWER" & OptionTranslateFileNames <> "UPPER" then
  7649. UserSyntaxError('Expected "UPPER" or "LOWER" on the "' || TheCmd || '" command, not "' || ThisCmdOptions || '"!')
  7650. end
  7651. when ThisCmd='DEFINE' then
  7652. do
  7653. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7654. parse var ThisCmdOptions DefineVar'='DefineContents
  7655. OptionDefineCount=OptionDefineCount+1
  7656. OptionDefine.OptionDefineCount.Var=DefineVar
  7657. OptionDefine.OptionDefineCount.Cont=strip(DefineContents)
  7658. end
  7659. when ThisCmd='OPTION' then
  7660. do
  7661. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7662. call ProcessOption ThisCmdOptions
  7663. end
  7664. when ThisCmd='REQUIRE' then
  7665. do
  7666. gc!P=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7667. call ProcessRequireCommon translate(gc!P, ' ', ',')
  7668. end
  7669. when ThisCmd='FILTERINPUT' then
  7670. do
  7671. call NotAvailableUnderNtYet ThisCmd
  7672. OptionFilterIn=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7673. call DoMacroSpaceOperation "ADD", OptionFilterIn, "HtmlFilterIn"
  7674. end
  7675. when ThisCmd='FILTEROUTPUT' then
  7676. do
  7677. call NotAvailableUnderNtYet ThisCmd
  7678. OptionFilterOut=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7679. call DoMacroSpaceOperation "ADD", OptionFilterOut, "HtmlFilterOut"
  7680. end
  7681. when ThisCmd='SPELLSHOWALL' then
  7682. SpellShowEachError=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7683. when ThisCmd='SPELLCHECK' then
  7684. do
  7685. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7686. call LoadSpellingDictionary ThisCmdOptions
  7687. end
  7688. when ThisCmd='SPELLADDWORD' then
  7689. do
  7690. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7691. SpellingAddFile=ThisCmdOptions
  7692. if left(SpellingAddFile,1)<> '-' then
  7693. SpellingPrompts='Y'
  7694. else
  7695. do
  7696. SpellingPrompts='OK'
  7697. SpellingAddFile=substr(SpellingAddFile,2)
  7698. end
  7699. end
  7700. when ThisCmd='**/' then
  7701. OptionKeepRexxCmts=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7702. when ThisCmd='INFO' then
  7703. OptionWantInfoMsgs=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7704. when ThisCmd='#INCLUDE' | ThisCmd = 'INCLUDE' then
  7705. do
  7706. if ThisCmdOptions='' then
  7707. OptionHashIncludeCnt=0
  7708. else
  7709. do
  7710. OptionHashIncludeCnt=OptionHashIncludeCnt+1
  7711. OptionHashInclude.OptionHashIncludeCnt=ThisCmdOptions
  7712. end
  7713. call DBG OptionHashIncludeCnt|| ' /#Include items stored'
  7714. end
  7715. when ThisCmd='BASEDIR' then
  7716. do
  7717. OptionBaseDirectory=MakeAbsolute(ThisCmdOptions)
  7718. call DBG "BASEDIR: " ||OptionBaseDirectory
  7719. end
  7720. when ThisCmd='INCLUDEPATH' then
  7721. do
  7722. call IncludePath ThisCmdOptions
  7723. end
  7724. when ThisCmd='CGI' then
  7725. call TurnCgiModeOn ThisCmdOptions
  7726. when ThisCmd='HTMLGENERATOR' then
  7727. do
  7728. HaveGeneratorTags='Y'
  7729. OptionHtmlGeneratorTags=ThisCmdOptions
  7730. end
  7731. when ThisCmd='EXCLUDE' then
  7732. do
  7733. IsDepSwitch='N'
  7734. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7735. ExcludeList.0=0
  7736. TmpMask=ThisCmdOptions
  7737. call DBG 'Looking for files matching "' || TmpMask || '"'
  7738. if left(TmpMask,1)<> '+' then
  7739. FollowDirs='N'
  7740. else
  7741. do
  7742. FollowDirs='Y'
  7743. TmpMask=substr(TmpMask,2)
  7744. end
  7745. call Files4Mask TmpMask, 'ExcludeList',FollowDirs
  7746. call DBGIND 1
  7747. call DBG 'Found ' || ExcludeList.0 || ' files(s) to exclude'
  7748. call DBGIND 1
  7749. do InputIndex=1 to ExcludeList.0
  7750. TheFile=ExcludeList.InputIndex
  7751. call DBG TheFile
  7752. call _valueS "_EXCLUDE_._EXF_" || c2x(TheFile), 'you used "' || OptChar || ThisCmd || ':' || ThisCmdOptions || '"'
  7753. end
  7754. call DBGIND-2
  7755. end
  7756. when ThisCmd='INC2CACHE' then
  7757. IncludeIntoMemory=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7758. when ThisCmd='PPWTRACE' then
  7759. OptionPpwTraceAllowed=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7760. when ThisCmd='DEBUGTIME' then
  7761. OptionDebugTime=ThisCmdOptions
  7762. when ThisCmd='DEBUGCHARS' then
  7763. call SetDebugChars ThisCmdOptions
  7764. when ThisCmd='HOOK' then
  7765. call RexxHookSet ThisCmd,ThisCmdOptions
  7766. when ThisCmd='REGSYNTAX' then
  7767. do
  7768. if RexWhich='REGINA' then
  7769. call DBG "/RegSyntax has no effect under Regina!"
  7770. NameOfOs2ReginaRexxInterpreter=ThisCmdOptions
  7771. end
  7772. when ThisCmd='REDIRMETHOD' then
  7773. RedirMethod=ThisCmdOptions
  7774. when ThisCmd='DEBUG' then
  7775. do
  7776. call BeepsAllow 'N'
  7777. call ColorAllow 'N'
  7778. call SwitchMustNotHaveOptions ThisCmd,ThisCmdOptions
  7779. DebugSwitchUsed='Y'
  7780. OptionDebugOn='Y'
  7781. OptionWantInfoMsgs='Y'
  7782. OptionPpwTraceAllowed='Y'
  7783. call DebugStateChanged
  7784. end
  7785. when ThisCmd='COPYRIGHT' then
  7786. OptionWantCopyright=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7787. when ThisCmd='XSLASH' then
  7788. do
  7789. YesOrNo=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7790. if YesOrNo='N' then
  7791. OptionXSlash=''
  7792. else
  7793. OptionXSlash=' /'
  7794. end
  7795. when ThisCmd='GETENV' then
  7796. do
  7797. FromEnv=GetEnv(ThisCmdOptions)
  7798. if FromEnv='' then
  7799. CryAndDie('The environment variable "' || ThisCmdOptions || '" does not exist.')
  7800. call DBG 'Contained: ' ||FromEnv
  7801. gc!CmdLine=FromEnv|| ' ' ||gc!CmdLine
  7802. end
  7803. when ThisCmd='INPUT' then
  7804. gc!CmdLine='"' || SwitchMustHaveOptions(ThisCmd, ThisCmdOptions) || '" ' ||gc!CmdLine
  7805. when ThisCmd='LIST' then
  7806. do
  7807. RecordSwitch='N'
  7808. ListFile=FileQueryExists(ThisCmdOptions)
  7809. if ListFile='' then
  7810. CryAndDie('The list file "' || ThisCmdOptions || '" does not exist')
  7811. call DBG 'Processing: "' || ListFile || '"'
  7812. call DBGIND 1
  7813. call FileClose ListFile, 'N'
  7814. LCmt=';' || ';'
  7815. LineNum=0
  7816. SpecList=''
  7817. do while lines(ListFile)<>0
  7818. OneSpec=linein(ListFile)
  7819. if ExtraWhiteSpace=='' then
  7820. OneSpec=strip(OneSpec)
  7821. else
  7822. OneSpec=strip(translate(OneSpec, '', ExtraWhiteSpace, ' '))
  7823. CmtPos=lastpos(LCmt,OneSpec)
  7824. LineNum=LineNum+1
  7825. if CmtPos<>0 then
  7826. OneSpec=strip(left(OneSpec,CmtPos-1), 'T')
  7827. if OneSpec='' | left(OneSpec, 1) = ';' then
  7828. iterate
  7829. OneSpec=ReplaceString(OneSpec, ' ', '{' || 'x20}')
  7830. call DBG 'Line #' || LineNum || ': ' ||OneSpec
  7831. SpecList=SpecList|| ' ' ||OneSpec
  7832. end
  7833. call DBGIND-1
  7834. gc!CmdLine=strip(SpecList)|| ' ' ||gc!CmdLine
  7835. call FileClose ListFile
  7836. end
  7837. when ThisCmd='DEPENDSONWARNINGS' then
  7838. OptionNoDepFileOnWarnings=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7839. when ThisCmd='@EXTN' then
  7840. OptionPrjExtn=ThisCmdOptions
  7841. when ThisCmd='CONSOLEFILE' then
  7842. call UserIsSpecifyingConsoleFileName ThisCmdOptions
  7843. when ThisCmd='ERRORFILE' then
  7844. call UserIsSpecifyingErrorFileName ThisCmdOptions
  7845. when ThisCmd='DEBUGCOLS' then
  7846. do
  7847. TheValue=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7848. OptValid='N'
  7849. if datatype(TheValue, 'W')=1 then
  7850. do
  7851. if TheValue>=0 then
  7852. OptValid='Y'
  7853. end
  7854. if OptValid='N' then
  7855. UserSyntaxError('Invalid /DebugCols value of "' || TheValue || '" supplied!')
  7856. OptionMaxCol=TheValue
  7857. end
  7858. when ThisCmd='DROPFILES' then
  7859. do
  7860. call DBG 'Dropping all stored input file masks'
  7861. InputMaskCount=0
  7862. call SwitchMustNotHaveOptions ThisCmd,ThisCmdOptions
  7863. end
  7864. when ThisCmd='ONOK' then
  7865. PpwOnOK=ThisCmdOptions
  7866. when ThisCmd='ONERROR' then
  7867. do
  7868. PpwOnERROR=ThisCmdOptions
  7869. if SleepSwitch='N' then
  7870. OnExitSleepForError=0
  7871. end
  7872. when ThisCmd='HIDECMD' then
  7873. do
  7874. if translate(ThisCmdOptions)='HTML[]' then
  7875. ThisCmdOptions='<!--[{?}]-->'
  7876. parse var ThisCmdOptions OptionHideCmdS '{?}' OptionHideCmdE
  7877. OptionHideCmdS_L=length(OptionHideCmdS)
  7878. OptionHideCmdE_L=length(OptionHideCmdE)
  7879. if OptionHideCmdS_L=0|OptionHideCmdE_L=0 then
  7880. CryAndDie('Your hide template must include "{?}" to indicate where the', 'command would be and must not start or end the template')
  7881. end
  7882. when ThisCmd='EXEC' then
  7883. do
  7884. call SplitOffRcTest
  7885. call RunExecOrValidateCmd ThisCmd,ExecRcTest,ExecCmd
  7886. end
  7887. when ThisCmd='VALIDATE' then
  7888. do
  7889. call SplitOffRcTest
  7890. OptionValidationRc=ExecRcTest
  7891. OptionValidation=ExecCmd
  7892. end
  7893. when ThisCmd='SLEEP' then
  7894. do
  7895. SleepSwitch='Y'
  7896. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7897. parse var ThisCmdOptions OnExitSleepForOK ',' OnExitSleepForError
  7898. if OnExitSleepForError='' then
  7899. OnExitSleepForError=2
  7900. end
  7901. when ThisCmd='DELETEONERROR' then
  7902. OptionDeleteOnError=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7903. when ThisCmd='BUILDTITLE' then
  7904. do
  7905. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7906. parse var ThisCmdOptions '/' gc!M '/' gc!T
  7907. call BuildTitle gc!M,gc!T
  7908. end
  7909. when ThisCmd='READING' then
  7910. OptionMsgReading=ThisCmdOptions
  7911. when ThisCmd='MAKING' then
  7912. OptionMsgMaking=ThisCmdOptions
  7913. when ThisCmd='FORCEREBUILD' then
  7914. do
  7915. OptionForceRebuild=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7916. IsDepSwitch='N'
  7917. end
  7918. when ThisCmd='FILESR' then
  7919. OptionFileSR=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7920. when ThisCmd='1' then
  7921. do
  7922. call DBG 'Rest of command line is one parameter, quoting => ' ||gc!CmdLine
  7923. gc!CmdLine='"' || gc!CmdLine || '"'
  7924. end
  7925. when ThisCmd='CONSOLE' then
  7926. call ConsoleWriteAllowed SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7927. when ThisCmd='?' then
  7928. UserSyntaxError('?')
  7929. otherwise
  7930. UserSyntaxError('Unknown switch of "' || OptChar || ThisCmd || '" specified')
  7931. end
  7932. call DBGIND-1
  7933. if RecordSwitch='Y' then
  7934. call AddToSwitchList IsDepSwitch
  7935. end
  7936. call DBGIND-3
  7937. return
  7938.  
  7939. UserSyntaxError:
  7940. call AllFollowingOutputGoesToErrorFile
  7941. call CgiStartFatalError
  7942. call DisplayCopyright
  7943. if arg(1)='?' then
  7944. Title='SYNTAX'
  7945. else
  7946. do
  7947. call ColorSet 'ERROR'
  7948. call Line1 "SYNTAX ERROR"
  7949. call Line1 "~~~~~~~~~~~~"
  7950. call Line1 '    ' ||arg(1)
  7951. Title='CORRECT SYNTAX'
  7952. end
  7953. call CgiEndFatalError
  7954. call Line1 ''
  7955. call Line1 Title
  7956. call Line1 copies('~',length(Title))
  7957. call Line1 '    ' || WizName || ' [-Switch1] [[+]InputMask1] [/Switch2] [@Project] ...'
  7958. call Line1 ''
  7959. call Line1 'SOME COMMON SWITCHES'
  7960. call Line1 '~~~~~~~~~~~~~~~~~~~~'
  7961. call Line1 '-Copy  -Html  -Other  -Rexx  (processing modes)'
  7962. call Line1 '-Output:?out\*.html  -DependsOn:-?out\*.*.dep  /DependsOnComplete:y|n'
  7963. call Line1 '/DeletePrev:y|n  '  || '/DeleteOnError:y|n  /ConsoleFile:file  /ErrorFile:file'
  7964. call Line1 '/Define:Macro=Value  '  || '/#Include:file  /Template:file  /Exclude:*.TMP'
  7965. call Line1 '/HideCmd:HowSpec (hide PPWIZARD stuff from GUI editors etc)'
  7966. call Line1 '/CrLf:y|n  /Color:y|n  /List:file (command line)'
  7967. call Line1 '/Debug  /DebugCols:MaxCols'
  7968. call Line1 ''
  7969. call Line1 'Note that switches can start with "-" or "/", in the above I used "-" to mark'
  7970. call Line1 'switches which affect the following input masks and so are more position'
  7971. call Line1 'sensitive than most other switches (which generally work more globally).'
  7972. call Line1 ''
  7973. call Line1 "For more details (and more switches) please see PPWIZARD's documentation at:"
  7974. call Line1 '    http://www.labyrinth.net.au/~dbareis/ppwizard.htm'
  7975. call ColorSet
  7976. call Beeps 2
  7977. if arg(1)<> '?' then
  7978. AbnormalExit(MyLineNumber(), "Invalid Command Line - " ||arg(1))
  7979. else
  7980. do
  7981. parse version ThisRexxVer
  7982. call Line1 ''
  7983. call Line1 'ENVIRONMENTAL INFORMATION'
  7984. call Line1 '~~~~~~~~~~~~~~~~~~~~~~~~~'
  7985. call Line1 'Rexx Version  : ' ||ThisRexxVer
  7986. call Line1 'Operating Syst: ' ||DebugGetOpSysText()
  7987. call Line1 'PPWIZARD      : ' ||PgmVersion
  7988. call Line1 '              : "' || PpWizardPgmName || '"'
  7989. AbnormalExit(MyLineNumber(), "User just wanted version number information")
  7990. end
  7991.  
  7992. SwitchMustHaveOptions:
  7993. parse arg TheCmd,TheOptions
  7994. if TheOptions='' then
  7995. UserSyntaxError('You must supply parameters on the "' || OptChar || TheCmd || '" switch!')
  7996. return(TheOptions)
  7997.  
  7998. SwitchMustNotHaveOptions:
  7999. parse arg TheCmd,TheOptions,Value2Set
  8000. if TheOptions<> '' then
  8001. UserSyntaxError('No parameters are expected for the "' || OptChar || TheCmd || '" switch!')
  8002. return(Value2Set)
  8003.  
  8004. SwitchOptionsValidateAgainstList:
  8005. TheCmd=arg(1)
  8006. TheOption=translate(arg(2))
  8007. ValidList=',' || translate(arg(3)) || ','
  8008. if pos(',' || TheOption || ',',ValidList)<>0 then
  8009. return(TheOption)
  8010. UserSyntaxError('An invalid parameter of "' || TheOption || '" was specified on the "' || OptChar || TheCmd || '" switch!')
  8011.  
  8012. SwitchWantsYesOrNo:
  8013. TheCmd=arg(1)
  8014. TheOption=translate(arg(2))
  8015. Default=arg(3)
  8016. if TheOption='' then
  8017. return(Default)
  8018. else
  8019. return(left(SwitchOptionsValidateAgainstList(TheCmd,TheOption, "Y,N,YES,NO"),1))
  8020.  
  8021. NotAvailableUnderNtYet:
  8022. TheCmd=arg(1)
  8023. if RexWhich='REGINA' then
  8024. UserSyntaxError('"' || OptChar || TheCmd || '" can not be performed under Windows (or regina).... Yet...')
  8025. return
  8026.  
  8027. FindProjectFile:
  8028. hc!PrjFile=arg(1)
  8029. if pos('.',hc!PrjFile)=0 then
  8030. hc!PrjFile=hc!PrjFile|| '.ppw'
  8031. if OptionDebugOn='Y' then
  8032. do
  8033. call DBGIND 1
  8034. call DBG 'Looking for the project file "' || hc!PrjFile || '"'
  8035. call DBGIND 1
  8036. end
  8037. hc!Full=FindFile(hc!PrjFile)
  8038. if OptionDebugOn='Y' then
  8039. do
  8040. call DBGIND 1
  8041. if hc!Full='' then
  8042. call DBG 'Project file not found.'
  8043. else
  8044. call DBG 'Found project file "' || hc!Full || '"'
  8045. call DBGIND-3
  8046. end
  8047. return(hc!Full)
  8048.  
  8049. SplitOffRcTest:
  8050. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  8051. if left(ThisCmdOptions,1)='{' then
  8052. parse var ThisCmdOptions '{' ExecRcTest '}' ExecCmd
  8053. else
  8054. do
  8055. ExecCmd=ThisCmdOptions
  8056. ExecRcTest=''
  8057. end
  8058. return
  8059.  
  8060. RunExecOrValidateCmd:
  8061. parse arg ic!Switch,ic!CmdRc,ic!Cmd
  8062. if OptionDebugOn='Y' then
  8063. call DBG 'Performing ' || OptChar || ic!Switch || ' command'
  8064. ic!Exec=ReplaceString(ic!Cmd, "{?}",CurrentOutFile)
  8065. if left(ic!Exec,1)<> '!' then
  8066. ic!Redirect='Y'
  8067. else
  8068. do
  8069. ic!Redirect='N'
  8070. ic!Exec=substr(ic!Exec,2)
  8071. end
  8072. if ic!Redirect='N' then
  8073. do
  8074. call AddressCmd ic!Exec
  8075. CmdRc=Rc
  8076. end
  8077. else
  8078. do
  8079. TmpFile=RexGetTmpFileName()
  8080. call AddressCmd ic!Exec||RedirectStdOutAndErr2(TmpFile),TmpFile
  8081. CmdRc=Rc
  8082. call _SysFileDelete TmpFile
  8083. end
  8084. if ic!CmdRc<> '' then
  8085. do
  8086. call DBGIND 1
  8087. ic!ExecOk=0
  8088. ic!ExecThis='ic!ExecOk = ' || '(' || ic!CmdRc || ')'
  8089. if ProcessedCmdLine='Y' then
  8090. call ExecRexxCmd ic!ExecThis
  8091. else
  8092. do
  8093. call DBG 'Interpreting: ' ||ic!ExecThis
  8094. interpret ic!ExecThis
  8095. end
  8096. call DBGIND-1
  8097. if\ic!ExecOk then
  8098. CryAndDie('User command failed (CmdRc was ' || CmdRc || '):', '     ' || ic!Exec, 'Test was:', '     ' ||ic!CmdRc)
  8099. end
  8100. return
  8101.  
  8102. MakeAbsolute:
  8103. jc!Path=arg(1)
  8104. if left(jc!Path,1)<> '+' then
  8105. jc!Plus=''
  8106. else
  8107. do
  8108. jc!Path=substr(jc!Path,2)
  8109. jc!Plus='+'
  8110. end
  8111. jc!File=jc!Path
  8112. if left(jc!File,1)='.' |pos(RexDirChar,jc!File)=0 then
  8113. do
  8114. DotSlash='.' ||RexDirChar
  8115. DotDotSlash='.' ||DotSlash
  8116. maDir=GetCurrentDirectory()
  8117. if OptionDebugOn='Y' then
  8118. do
  8119. call DBG 'Converting relative "' || jc!File || '"'
  8120. call DBGIND 1
  8121. end
  8122. if pos(RexDirChar,jc!File)<>0 then
  8123. do
  8124. do forever
  8125. select
  8126. when left(jc!File,2)==DotSlash then
  8127. do
  8128. jc!File=substr(jc!File,3)
  8129. end
  8130. when left(jc!File,3)==DotDotSlash then
  8131. do
  8132. LastChar=right(maDir,1)
  8133. SlashPos=lastpos(RexDirChar,maDir)
  8134. if SlashPos=0|LastChar=RexDirChar|LastChar=':' then
  8135. CryAndDie('The spec "' || jc!Path || '" can not be converted to absolute', 'from the current directory "' || GetCurrentDirectory() || '"')
  8136. maDir=left(maDir,SlashPos-1)
  8137. jc!File=substr(jc!File,4)
  8138. end
  8139. otherwise
  8140. leave
  8141. end
  8142. end
  8143. end
  8144. if right(maDir,1)=RexDirChar then
  8145. jc!File=maDir||jc!File
  8146. else
  8147. jc!File=maDir||RexDirChar||jc!File
  8148. if OptionDebugOn='Y' then
  8149. do
  8150. call DBG 'To Absolute "' || jc!File || '"'
  8151. call DBGIND-1
  8152. end
  8153. end
  8154. return(jc!Plus||jc!File)
  8155.  
  8156. ValidateBaseDirUse:
  8157. parse arg kc!BD,kc!FM,kc!MayHavePlus
  8158. call DBG 'Validating base directory "' || kc!BD || '" against "' || kc!FM || '"'
  8159. if kc!MayHavePlus='Y' then
  8160. do
  8161. if left(kc!FM,1)='+' then
  8162. kc!FM=substr(kc!FM,2)
  8163. end
  8164. if right(kc!BD,1)<>RexDirChar then
  8165. CryAndDie('The base directory "' || kc!Bd || '" does not end with a "' || RexDirChar || '"!')
  8166. if RexSystemOpSys="UNIX" then
  8167. do
  8168. kc!BdU=kc!BD
  8169. kc!FmU=kc!FM
  8170. end
  8171. else
  8172. do
  8173. kc!BdU=translate(kc!BD)
  8174. kc!FmU=translate(kc!FM)
  8175. end
  8176. if kc!BdU\==left(kc!FmU,length(kc!BdU))then
  8177. CryAndDie('The file mask       "' || kc!FmU ||  '"', 'does not begin with "' || kc!BdU || '"')
  8178. return
  8179.  
  8180. ValidatePMode:
  8181. lc!PM=translate(arg(1))
  8182. if pos('|' || lc!PM || '|', '|HTML|REXX|OTHER|COPY|')=0 then
  8183. CryAndDie('Invalid processing mode of "' || lc!PM || '"')
  8184. return(lc!PM)
  8185.  
  8186. PModeSwitch:
  8187. parse arg mc!PM,mc!Prm
  8188. call SwitchMustNotHaveOptions mc!PM,mc!Prm
  8189. ProcessingMode=ValidatePMode(translate(mc!PM))
  8190. if OptionCloneUsed='Y' then
  8191. do
  8192. if ProcessingMode<> 'COPY' then
  8193. UserSyntaxError('Invalid mode of ' ||ProcessingMode)
  8194. end
  8195. return
  8196.  
  8197. BuildTitle:
  8198. parse arg nc!M,nc!T
  8199. if nc!T='' then
  8200. do
  8201. if translate(nc!M)='COPY' then
  8202. nc!T='Copying: "{IS}" -> "{OL}"'
  8203. else
  8204. nc!T='Making ({PM}) - {OL}'
  8205. end
  8206. call value 'PPWBLDTITLE_' ||nc!M,nc!T
  8207. call DBG '/Making Text for ' || nc!M || ' mode is: ' ||nc!T
  8208. return
  8209.  
  8210. CmdLine_32:
  8211. DependsOnFmtVer="FORMAT 00.157"
  8212. call ClearCollectedDependancyInfo
  8213. call ClearDependancyTimeStampCache
  8214. signal DEPENDON_33
  8215.  
  8216. NeedToRemake:
  8217. DepFile4=arg(1)
  8218. if OptionDependsOn='' then
  8219. do
  8220. call DBG 'No dependancy checking enabled - Need to make'
  8221. DepFileName=''
  8222. return("Y")
  8223. end
  8224. DepFileName=GenerateFileName(DepFile4,OptionDependsOn)
  8225. if _NeedToRemakeCheckDependencies()='N' then
  8226. do
  8227. if OptionQuietDependsOn='N' then
  8228. call Line1 ''
  8229. return('N')
  8230. end
  8231. if DepDelPrev='Y' then
  8232. do
  8233. call DBG 'Delete all output dependancy files (made last build)'
  8234. call DBGIND 1
  8235. call FileOpenReadOnly DepFileName
  8236. do while lines(DepFileName)<>0
  8237. oc!Line=linein(DepFileName)
  8238. if oc!Line='' then
  8239. iterate
  8240. parse var oc!Line oc!Type oc!Line
  8241. if oc!Type='output' then
  8242. do
  8243. oc!LastTime=GetQuotedText(oc!Line, "oc!Line")
  8244. call MustDeleteFile oc!LastTime
  8245. end
  8246. end
  8247. call FileClose DepFileName
  8248. call DBGIND-1
  8249. end
  8250. call MustDeleteFile DepFileName
  8251. return('Y')
  8252.  
  8253. ClearCollectedDependancyInfo:
  8254. DepTmp.0=0
  8255. DepIn.0=0
  8256. DepOut.0=0
  8257. return
  8258.  
  8259. ClearDependancyTimeStampCache:
  8260. TimeStampCount=0
  8261. return
  8262.  
  8263. GetFileDateTimeButDontWarnOnError:
  8264. tsFile=arg(1)
  8265. if FileQueryExists(tsFile)=='' then
  8266. Ts=-1
  8267. else
  8268. Ts=GetFileTimeStamp(tsFile)
  8269. return(Ts)
  8270.  
  8271. _ShowDependancyCheckProgress:
  8272. if OptionQuietDependsOn='N' then
  8273. call Line1 '  ?> ' ||arg(1)
  8274. else
  8275. call DBG arg(1)
  8276. return
  8277.  
  8278. _NeedToRemakeCheckDependencies:
  8279. TitleText='Checking Dependencies - "' || _filespec('name', CurrentOutFile) || '"'
  8280. if OptionQuietDependsOn='Y' then
  8281. call DBG TitleText
  8282. else
  8283. do
  8284. call ColorSet 'TITLE'
  8285. call Line1 TitleText
  8286. call Line1 copies('~',length(TitleText))
  8287. call ColorSet
  8288. end
  8289. if OptionForceRebuild='Y' then
  8290. do
  8291. call _ShowDependancyCheckProgress 'The /ForceRebuild switch forces us to rebuild'
  8292. return('Y')
  8293. end
  8294. if FileQueryExists(DepFileName)='' then
  8295. do
  8296. call _ShowDependancyCheckProgress DepFileName|| ' does not exist.'
  8297. return('Y')
  8298. end
  8299. call FileClose DepFileName, 'N'
  8300. OpenRc=FileOpenReadOnly(DepFileName)
  8301. DependLine=linein(DepFileName)
  8302. if DependLine<>DependsOnFmtVer then
  8303. do
  8304. call _ShowDependancyCheckProgress 'Dependency formatting is not at current level'
  8305. call FileClose DepFileName
  8306. return('Y')
  8307. end
  8308. ReMake='N'
  8309. DepLineNum=1
  8310. do while lines(DepFileName)<>0
  8311. DependLine=linein(DepFileName)
  8312. DepLineNum=DepLineNum+1
  8313. if DependLine='' then
  8314. iterate
  8315. call DBG 'Line #' || DepLineNum || ': ' ||DependLine
  8316. call DBGIND 1
  8317. parse var DependLine DepType DependLine
  8318. WhatStamped=GetQuotedText(DependLine, "DependLine")
  8319. LineStamp=GetQuotedRest(DependLine)
  8320. call _ShowDependancyCheckProgress 'Checking: "' || WhatStamped || '"'
  8321. DependantTime=GetDependsStamp("WhatStamped")
  8322. if DependantTime=-1 then
  8323. do
  8324. call _ShowDependancyCheckProgress "Can't locate the dependant file (" || DepType || ")!"
  8325. ReMake='Y'
  8326. call DBGIND-1
  8327. leave
  8328. end
  8329. if DependantTime<>LineStamp then
  8330. do
  8331. call _ShowDependancyCheckProgress "The " || DepType || " dependancy stamp differs from last make."
  8332. ReMake='Y'
  8333. call DBGIND-1
  8334. leave
  8335. end
  8336. call DBGIND-1
  8337. end
  8338. call FileClose DepFileName
  8339. if ReMake='N' then
  8340. call _ShowDependancyCheckProgress 'No need to remake...'
  8341. return(ReMake)
  8342.  
  8343. IsTempFile:
  8344. pc!File=UFILE(arg(1))
  8345. do pc!I=1 to DepTmp.0
  8346. if pc!File=DepTmp.pc!I then
  8347. return(pc!I)
  8348. end
  8349. return(0)
  8350.  
  8351. AddTempFileToDependancyList:call TRACE "OFF"
  8352. parse arg qc!Tf
  8353. qc!Tf=UFile(qc!Tf)
  8354. call DBG 'AddTempFileToDependancyList(' || qc!Tf || ')'
  8355. if IsTempFile(qc!Tf)<>0 then
  8356. return('N')
  8357. DepTmp.0=DepTmp.0+1
  8358. qc!I=DepTmp.0
  8359. DepTmp.qc!I=qc!Tf
  8360. return('Y')
  8361.  
  8362. AddInputFileToDependancyList:call TRACE "OFF"
  8363. parse arg rc!IFile,rc!TS
  8364. rc!IFile=UFile(rc!IFile)
  8365. if rc!TS='' then
  8366. rc!TS=GetDependsStamp("rc!IFile")
  8367. call DBG 'AddInputFileToDependancyList(' || rc!IFile || '): ' ||rc!Ts
  8368. do rc!I=1 to DepIn.0
  8369. if rc!IFile=DepIn.rc!I then
  8370. return('N')
  8371. end
  8372. DepIn.0=DepIn.0+1
  8373. rc!I=DepIn.0
  8374. DepIn.rc!I=rc!IFile
  8375. DepInTs.rc!I=rc!TS
  8376. return('Y')
  8377.  
  8378. AddOutputFileToDependancyList:call TRACE "OFF"
  8379. sc!OFile=arg(1)
  8380. sc!OFile=UFile(sc!OFile)
  8381. call DBG 'AddOutputFileToDependancyList(' || sc!OFile || ')'
  8382. do sc!I=1 to DepOut.0
  8383. if sc!OFile=DepOut.sc!I then
  8384. return('N')
  8385. end
  8386. DepOut.0=DepOut.0+1
  8387. sc!I=DepOut.0
  8388. DepOut.sc!I=sc!OFile
  8389. return('Y')
  8390.  
  8391. DeletingOnError:
  8392. if symbol('DepOut.0') <> 'VAR' then
  8393. return
  8394. if OptionDeleteOnError='N' then
  8395. return
  8396. call DBG 'Deleting any files we created for this build'
  8397. call DBGIND 1
  8398. do tc!I=1 to DepOut.0
  8399. tc!File=DepOut.tc!I
  8400. call _FileClose tc!File
  8401. if FileQueryExists(tc!File)<> "" then
  8402. do
  8403. DeleteRc=_SysFileDelete(tc!File)
  8404. if FileQueryExists(tc!File)<> "" then
  8405. call DBG 'Could not delete "' || tc!File || '"'
  8406. end
  8407. end
  8408. call DBGIND-1
  8409. return
  8410.  
  8411. _OutputDepWhatToFile:
  8412. DepWhat=arg(1)
  8413. DepWhatQ=QuoteIt(DepWhat)
  8414. DepWhat=DepWhatQ||DepWhat||DepWhatQ
  8415. return(DepWhat)
  8416.  
  8417. CreateDependancyFileFromLists:
  8418. if DepFileName='' then
  8419. return
  8420. call DBG 'Making the dependancy file (' || DepFileName || ')'
  8421. call DBGIND 1
  8422. uc!TI=0
  8423. do uc!FI=1 to DepIn.0
  8424. uc!F=DepIn.uc!FI
  8425. uc!Fs=DepInTs.uc!FI
  8426. if IsTempFile(uc!F)=0 then
  8427. do
  8428. uc!Ti=uc!Ti+1
  8429. DepIn.uc!TI=uc!F
  8430. DepInTs.uc!TI=uc!Fs
  8431. end
  8432. end
  8433. DepIn.0=uc!TI
  8434. uc!TI=0
  8435. do uc!FI=1 to DepOut.0
  8436. uc!F=DepOut.uc!FI
  8437. if IsTempFile(uc!F)=0 then
  8438. do
  8439. uc!Ti=uc!Ti+1
  8440. DepOut.uc!TI=uc!F
  8441. end
  8442. end
  8443. DepOut.0=uc!TI
  8444. DepDrop=''
  8445. DepHook=CfgMacro("HOOK_DEPENDSON", '')
  8446. if DepHook<> '' then
  8447. do
  8448. call ExecRexxCmd DepHook
  8449. end
  8450. if DepDrop<> '' then
  8451. call DBG "User hook said don't create dependancy file : " ||DepDrop
  8452. else
  8453. do
  8454. call MakeDirectoryTree _filespec('drive', DepFileName) || _filespec('path',DepFileName)
  8455. call ClearDependancyTimeStampCache
  8456. call FileLineOut DepFileName,DependsOnFmtVer
  8457. call FileLineOut DepFileName, ''
  8458. DepWhatPad=0
  8459. do uc!I=1 to DepOut.0
  8460. if DepOut.uc!I<> '' then
  8461. do
  8462. call DBG 'Add OUTPUT dependancy : ' ||DepOut.uc!I
  8463. OutputFileTs=GetFileDateTimeButDontWarnOnError(DepOut.uc!I)
  8464. call FileLineOut DepFileName, 'output   ' || _OutputDepWhatToFile(DepOut.uc!I) || '   ~' || OutputFileTs || '~'
  8465. end
  8466. end
  8467. call FileLineOut DepFileName, ''
  8468. do uc!I=1 to DepIn.0
  8469. if DepIn.uc!I<> '' then
  8470. do
  8471. call DBG 'Add INPUT  dependancy : ' ||DepIn.uc!I
  8472. call FileLineOut DepFileName, 'input    ' || _OutputDepWhatToFile(DepIn.uc!I) || '   ~' || DepInTs.uc!I || '~'
  8473. end
  8474. end
  8475. call FileClose DepFileName
  8476. end
  8477. call DBGIND-1
  8478. return
  8479.  
  8480. ProcessDependsOn:
  8481. Rest=PerformReplacementsInCmdsParameters(arg(1))
  8482. DepType=translate(GetQuotedText(Rest, "DependsOnList"))
  8483. if DependsOnList='' then
  8484. CryAndDie('No files supplied on "#DependsOn ' || DepType || '" command!')
  8485. do while DependsOnList<> ''
  8486. ThisOne=GetQuotedText(DependsOnList, "DependsOnList")
  8487. select
  8488. when DepType='OUTPUT' then
  8489. Added=AddOutputFileToDependancyList(ThisOne)
  8490. when DepType='INPUT' then
  8491. Added=AddInputFileToDependancyList(ThisOne)
  8492. when DepType='TEMP' then
  8493. Added=AddTempFileToDependancyList(ThisOne)
  8494. otherwise
  8495. CryAndDie('Unknown dependancy type of "' || DepType || '"!')
  8496. end
  8497. if Added='Y' then
  8498. call DBG DepType|| ' dependancy : ' ||ThisOne
  8499. end
  8500. return(0)
  8501.  
  8502. GetDependancyInfo:call TRACE "OFF"
  8503. parse arg vc!Type,vc!Which
  8504. vc!Type=translate(vc!Type)
  8505. if vc!Which='' then
  8506. do
  8507. select
  8508. when vc!Type='INPUT' then
  8509. return(DepIn.0)
  8510. when vc!Type='OUTPUT' then
  8511. return(DepOut.0)
  8512. otherwise
  8513. _GetDependancyInfoErr(vc!Type)
  8514. end
  8515. end
  8516. else
  8517. do
  8518. select
  8519. when vc!Type='INPUT' then
  8520. return(DepIn.vc!Which)
  8521. when vc!Type='INPUTSTAMP' then
  8522. return(DepInTS.vc!Which)
  8523. when vc!Type='OUTPUT' then
  8524. return(DepOut.vc!Which)
  8525. otherwise
  8526. _GetDependancyInfoErr(vc!Type)
  8527. end
  8528. end
  8529.  
  8530. _GetDependancyInfoErr:
  8531. CryAndDie('Invalid dependancy query type of "' || arg(1) || '"')
  8532.  
  8533. GetDependsStamp:
  8534. wc!4WhatVar=arg(1)
  8535. wc!4What=value(wc!4WhatVar)
  8536. if left(wc!4What,1)<> '*' then
  8537. do
  8538. wc!Ret=GetFileDateTimeButDontWarnOnError(wc!4What)
  8539. end
  8540. else
  8541. do
  8542. Stamp4U=translate(wc!4What)
  8543. select
  8544. when abbrev(Stamp4U, "*TODAY")then
  8545. do
  8546. wc!Ret=date('S')
  8547. end
  8548. when Stamp4U="*CMDLINE" then
  8549. do
  8550. wc!Ret=PpwClDep
  8551. end
  8552. when Stamp4U="*PPWPGM" then
  8553. do
  8554. wc!Ret=PgmVersion||' '||FileQuerySize(PpWizardPgmName)||' '||GetFileDateTimeButDontWarnOnError(PpWizardPgmName)
  8555. end
  8556. when abbrev(Stamp4U, "*REXX=")then
  8557. do
  8558. wc!RexxExp=translate(substr(wc!4What,7))
  8559. if pos('DEPVALUE',translate(wc!RexxExp))=0 then
  8560. wc!RexxExp='DepValue = ' ||wc!RexxExp
  8561. DepValue=time('L')
  8562. call ExecRexxCmd wc!RexxExp
  8563. wc!Ret=DepValue
  8564. end
  8565. when abbrev(Stamp4U, "*EXPIRES=")then
  8566. do
  8567. wc!ExpWhen=translate(substr(wc!4What,10))
  8568. parse var wc!ExpWhen wc!ExpCmd ';' wc!ExpTs
  8569. if wc!ExpWhen='NOW' then
  8570. wc!ExpWhen=0
  8571. wc!CurrTs=TimeSTamp()
  8572. if wc!ExpTs='' then
  8573. do
  8574. wc!ExpTs=TimeSTamp(wc!ExpWhen)
  8575. wc!4What=wc!4What|| ';' ||wc!ExpTs
  8576. call value wc!4WhatVar,wc!4What
  8577. end
  8578. if wc!CurrTs<=wc!ExpTs then
  8579. wc!Ret='Tick Tock...'
  8580. else
  8581. wc!Ret='Expired!'
  8582. end
  8583. when abbrev(Stamp4U, "*EXEC=")then
  8584. do
  8585. TheCmd=substr(wc!4What,7)
  8586. TmpFile=RexGetTmpFileName("DEPON???.???")
  8587. call AddressCmd TheCmd||RedirectStdOutAndErr2(TmpFile),TmpFile
  8588. ExecRc=Rc
  8589. call DBG 'Depend value is result of (Rc=' || ExecRc || '): ' ||TheCmd
  8590. call FileClose TmpFile, 'N'
  8591. TheCmdVal=charin(TmpFile,,999999)
  8592. call FileClose TmpFile
  8593. call _SysFileDelete TmpFile
  8594. TheCmdVal=translate(TheCmdVal,, '0D0A1A'x, ' ')
  8595. TheCmdVal='RC=' || ExecRc || '->' ||TheCmdVal
  8596. wc!Ret=TheCmdVal
  8597. end
  8598. when abbrev(Stamp4U, "*FILES=")then
  8599. do
  8600. TheMask=substr(wc!4What,8)
  8601. if left(TheMask,1)<> '+' then
  8602. wc!Sub='N'
  8603. else
  8604. do
  8605. wc!Sub='Y'
  8606. TheMask=substr(TheMask,2)
  8607. end
  8608. call Files4Mask TheMask, 'DepDirList',wc!Sub
  8609. wc!Ret=DepDirList.0|| ' files'
  8610. do DepIndex=1 to DepDirList.0
  8611. wc!F=DepDirList.DepIndex
  8612. call AddTempFileToDependancyList wc!F
  8613. wc!Ret=wc!Ret|| '; ' || wc!F || '=' || GetFileDateTimeButDontWarnOnError(wc!F) || ',' ||FileQuerySize(wc!F)
  8614. end
  8615. end
  8616. otherwise
  8617. CryAndDie('An incorrectly formatted "special" input dependancy was specified', 'You used "' || wc!4What || '"')
  8618. end
  8619. end
  8620. wc!Mx=20000
  8621. wc!L=length(wc!Ret)
  8622. if wc!L>wc!Mx then
  8623. do
  8624. call DBG 'Original STAMP: ' ||wc!Ret
  8625. call DBG 'Stamp is ' || wc!L || ' bytes long, as this is greater than ' || wc!Mx || ' we will convert to a CRC!'
  8626. wc!C=Crc32PrePostConditioning()
  8627. wc!C=UpdateCrc32(wc!C,wc!Ret)
  8628. wc!C=Crc32PrePostConditioning(wc!C)
  8629. wc!Ret='CRC32 ' || Crc32InDisplayableForm(wc!C) || ', length ' ||AddCommasToDecimalNumber(wc!L)
  8630. end
  8631. call DBG 'Stamp: ' ||wc!Ret
  8632. return(wc!Ret)
  8633.  
  8634. DEPENDON_33:
  8635. DoingImport=''
  8636. signal IMPORT_34
  8637.  
  8638. ProcessImport:
  8639. if DoingImport<> '' then
  8640. CryAndDie("Can't nest #import (started at " || DoingImport || ')')
  8641. else
  8642. DoingImport=CurrentSourceLocation()
  8643. ImportParms=PerformReplacementsInCmdsParameters(arg(1))
  8644. if AsIsModeOn='Y' then
  8645. CryAndDie("Please turn off #AsIs mode before importing.")
  8646. call _InitImportAsIsMemories
  8647. ImportFileName=GetQuotedText(ImportParms, "ImportParms")
  8648. if ImportParms='' then
  8649. CryAndDie('#import is missing import type (parm #2)!')
  8650. ImportFileType=translate(GetQuotedText(ImportParms, "ImportParms"))
  8651. if substr(ImportFileType,4)<> '-' then
  8652. DropLine=0
  8653. else
  8654. do
  8655. ImportFileType=left(ImportFileType,3)
  8656. DropLine=1
  8657. end
  8658. FirstChar=left(ImportFileType,1)
  8659. DelimiterSpec=FirstChar||FirstChar||FirstChar
  8660. CustomDelimiter='NO'
  8661. if(ImportFileType==DelimiterSpec)|(ImportFileType==DelimiterSpec|| '-')then
  8662. do
  8663. CustomDelimiter=FirstChar
  8664. TmpFilePart=''
  8665. end
  8666. else
  8667. do
  8668. TmpFilePart=ImportFileType
  8669. if pos('*' || ImportFileType || '*', '*TAB*CMA*FIX*SQL*WRAP*T2H*ML*')=0 then
  8670. CryAndDie('Invalid #import type of "' || ImportFileType || '" specified!')
  8671. end
  8672. if ImportFileType<> 'SQL' then
  8673. do
  8674. if ImportFileName='' then
  8675. CryAndDie('#import has no parameters!')
  8676. call FileClose ImportFileName, 'N'
  8677. FullImportName=FileQueryExists(ImportFileName)
  8678. if FullImportName='' then
  8679. CryAndDie('The #import file "' || ImportFileName || '" does not exist!')
  8680. call ReadingI FullImportName, 'N'
  8681. call AddInputFileToDependancyList FullImportName
  8682. end
  8683. ToInclude=RexGetTmpFileName('I_' || left(TmpFilePart, 4, '_') || '??.???')
  8684. call MustDeleteFile ToInclude
  8685. if ImportParms='' then
  8686. MacroName=''
  8687. else
  8688. MacroName=GetQuotedText(ImportParms, "ImportParms")
  8689. if MacroName='' then
  8690. do
  8691. select
  8692. when ImportFileType='WRAP' then
  8693. MacroName='WRAP'
  8694. when ImportFileType='T2H' then
  8695. MacroName='T2H'
  8696. when ImportFileType='ML' then
  8697. MacroName='ML'
  8698. otherwise
  8699. MacroName='IMPORT'
  8700. end
  8701. end
  8702. call DBG_IMPORT '#import options start with "' || MacroName || '_"'
  8703. call AsIsPrepare ''
  8704. call DBG_IMPORT 'Generating "' || ToInclude || '" for later inclusion (#include).'
  8705. ReplaceNewLineChar=''
  8706. ReplaceTabChar=''
  8707. DisplayingFields=''
  8708. ReplaceNewLineChar=''
  8709. ReplaceTabChar=''
  8710. DoPass2=translate(GetImportValue('DO_PASS_2', 'Y'))
  8711. select
  8712. when ImportFileType='WRAP' then
  8713. ImpLinCnt=HandleLineWrapping()
  8714. when ImportFileType='T2H' then
  8715. ImpLinCnt=HandleTextToHtmlImport()
  8716. otherwise
  8717. do
  8718. select
  8719. when CustomDelimiter<> 'NO' then
  8720. wc!Dfc=CustomDelimiter
  8721. when ImportFileType='TAB' then
  8722. wc!Dfc=TabChar
  8723. when ImportFileType='CMA' then
  8724. wc!Dfc=','
  8725. otherwise
  8726. wc!Dfc=''
  8727. end
  8728. call ImportTablePreparationPass1
  8729. if ImportParms='' then
  8730. do
  8731. if wc!Dfc\=='' then
  8732. ImportParms=ExtractFieldInfoFromSimpleCharDelimitedFile(wc!Dfc)
  8733. end
  8734. call ImportTablePreparationPass2
  8735. select
  8736. when wc!Dfc\=='' then
  8737. ImpLinCnt=HandleSimpleCharDelimitedFile(wc!Dfc)
  8738. when ImportFileType='FIX' then
  8739. ImpLinCnt=HandleFixedFieldFile()
  8740. when ImportFileType='SQL' then
  8741. ImpLinCnt=HandleSQLDataBase()
  8742. when ImportFileType='ML' then
  8743. ImpLinCnt=HandleMultiLineImport()
  8744. otherwise
  8745. CryAndDie('Unknown import type of "' || ImportFileType || '"')
  8746. end
  8747. call ImportTableTermination
  8748. end
  8749. end
  8750. if ImportFileType<> 'SQL' then
  8751. call FileClose FullImportName
  8752. if OptionDebugOn='Y' then
  8753. call DBG_IMPORT 'Imported ' || AddCommasToDecimalNumber(ImpLinCnt) || ' line(s) in "' || ImportFileType || '" mode.'
  8754. call FileClose ToInclude
  8755. call AsIsPrepare ''
  8756. if DoPass2='N' then
  8757. call DBG_IMPORT 'You have disabled PASS2 processing'
  8758. else
  8759. do
  8760. call DBG_IMPORT 'Now #include the generated temporary file ("' || ToInclude || '").'
  8761. call RecursiveIncludeSave
  8762. call ProcessInputFile ToInclude, 'N', 'N'
  8763. call RecursiveIncludeRestore
  8764. call ReadingI
  8765. end
  8766. if GetImportValue('KEEP_TMP_FILE',  OptionDebugOn) = 'N' then
  8767. DeleteRc=_SysFileDelete(ToInclude)
  8768. DoingImport=''
  8769. return(0)
  8770.  
  8771. _ImportValueSpacer:
  8772. if OptionDebugOn='Y' then
  8773. do
  8774. call DBG_MACROVALORDEF ''
  8775. if arg(1)<> '' then
  8776. call DBG_MACROVALORDEF arg(1)
  8777. end
  8778. return
  8779.  
  8780. ImportValueExists:
  8781. xc!Cm=MacroName|| '_' ||arg(1)
  8782. xc!Yn=MacroExists(xc!Cm)
  8783. if OptionDebugOn='Y' then
  8784. call DBG_MACROVALORDEF 'Option(Macro) "' || xc!Cm || '" Exists? : ' ||xc!Yn
  8785. return(xc!Yn)
  8786.  
  8787. GetImportValue:
  8788. yc!V=CfgMacro(MacroName|| '_' ||arg(1),arg(2))
  8789. if ImportFileType<> "WRAP" & ImportFileType <> "T2H" then
  8790. yc!V=ReplaceString(yc!V,StartsMacroParm|| 'Columns' ||EndsMacroParm,DisplayingFields)
  8791. return(yc!V)
  8792.  
  8793. GetImportValue_Tabs:
  8794. ReplaceTabChar=GetImportValue('TAB_CHAR', '')
  8795. return
  8796.  
  8797. GetImportValue_RecordFilter:
  8798. return(PerformReplacementsInCmdsParameters(GetImportValue('RECORD_FILTER', '')))
  8799.  
  8800. GetImportValue_LineFilter:
  8801. LineFilter=PerformReplacementsInCmdsParameters(GetImportValue('LINE_FILTER', ''))
  8802. return
  8803.  
  8804. GetImportValue_Comments:
  8805. call _ImportValueSpacer 'Get comment options'
  8806. call DBGIND 1
  8807. ImportLineCmtChars=GetImportValue( 'LINECMT_CHARS',arg(1))
  8808. ImportInlineCmtChars=GetImportValue('INLINECMT_CHARS',arg(2))
  8809. call DBGIND-1
  8810. return
  8811.  
  8812. IsCmtLine:
  8813. if ImportLineCmtChars='' then
  8814. return(0)
  8815. else
  8816. return(abbrev(arg(1),ImportLineCmtChars))
  8817.  
  8818. ImportOneLine:
  8819. FileLine=linein(FullImportName)
  8820. if ExtraWhiteSpace\=='' then
  8821. FileLine=translate(FileLine, '', ExtraWhiteSpace, ' ')
  8822. if LineFilter<> '' then
  8823. do
  8824. call DBG_IMPORT 'Calling specified line filter'
  8825. call DBGIND 1
  8826. call ExecRexxCmd LineFilter
  8827. call DBGIND-1
  8828. end
  8829. if ImportInlineCmtChars<> '' then
  8830. do
  8831. zc!Pos=pos(ImportInlineCmtChars,FileLine)
  8832. if zc!Pos<>0 then
  8833. FileLine=strip(left(FileLine,zc!Pos-1), 'Trailing')
  8834. end
  8835. if arg(1)='Y' then
  8836. FileLine=AsIs(FileLine)
  8837. if ReplaceNewLineChar\=='' then
  8838. FileLine=ReplaceString(FileLine,MarksNewLine,ReplaceNewLineChar)
  8839. if ReplaceTabChar\=='' then
  8840. FileLine=ReplaceString(FileLine,TabChar,ReplaceTabChar)
  8841. return(FileLine)
  8842.  
  8843. GenerateTagsIfNonEmpty:
  8844. OptionalTags=GetImportValue(arg(1),arg(2))
  8845. if OptionalTags\=='' then
  8846. call PpwLineout ToInclude,OptionalTags
  8847. return
  8848.  
  8849. GenerateProtectStartTags:
  8850. call GenerateTagsIfNonEmpty 'PROTECT_START', StartsStdSymbolReplacement || 'ProtectFromPpwStart' ||EndsMacroReplacement
  8851. return
  8852.  
  8853. GenerateProtectEndTags:
  8854. call GenerateTagsIfNonEmpty 'PROTECT_END',   StartsStdSymbolReplacement || 'ProtectFromPpwEnd' ||EndsMacroReplacement
  8855. return
  8856.  
  8857. GenerateBeforeTags:
  8858. call GenerateTagsIfNonEmpty 'BEFORE',arg(1)
  8859. return
  8860.  
  8861. GenerateAfterTags:
  8862. call GenerateTagsIfNonEmpty 'AFTER',arg(1)
  8863. return
  8864.  
  8865. HandleImportAsIsOptions:
  8866. call _ImportValueSpacer 'Prepare "AS IS" tagging'
  8867. call DBGIND 1
  8868. ImportAsIsMemory=GetImportValue('ASIS_TAGGING',arg(1))
  8869. call DBGIND 1
  8870. call AsIsPrepare ImportAsIsMemory
  8871. call DBGIND-2
  8872. return
  8873.  
  8874. _InitImportAsIsMemories:
  8875. if symbol('ImpMemInit') = 'VAR' then
  8876. return
  8877. ImpMemInit='Y'
  8878. call DBG_IMPORT 'Initializing named #AsIs tags for HTML Importing'
  8879. call DBGIND 1
  8880. call _ClearTempMemory
  8881. call _AddToTempMemory '&', '&'
  8882. call _AddToTempMemory '<', '<'
  8883. call _AddToTempMemory '>', '>'
  8884. call SetupNamedAsIsStorage 'IMPORT_HTML_BASIC',TmpAtCount
  8885. call _ClearTempMemory
  8886. call _AddToTempMemory '╔', '+'
  8887. call _AddToTempMemory '═', '-'
  8888. call _AddToTempMemory '╗', '+'
  8889. call _AddToTempMemory '║', '|'
  8890. call _AddToTempMemory '╝', '+'
  8891. call _AddToTempMemory '╚', '+'
  8892. call _AddToTempMemory '┌', '+'
  8893. call _AddToTempMemory '─', '-'
  8894. call _AddToTempMemory '┐', '+'
  8895. call _AddToTempMemory '│', '|'
  8896. call _AddToTempMemory '┘', '+'
  8897. call _AddToTempMemory '└', '+'
  8898. call SetupNamedAsIsStorage 'IMPORT_HTML_BOXGRAPHIC_TO_BOXTEXT',TmpAtCount
  8899. call DBGIND-1
  8900. return
  8901.  
  8902. _ClearTempMemory:
  8903. TmpAtCount=0
  8904. return
  8905.  
  8906. _AddToTempMemory:
  8907. TmpAtCount=TmpAtCount+1
  8908. ImportB.TmpAtCount=arg(1)
  8909. ImportA.TmpAtCount=arg(2)
  8910. return
  8911.  
  8912. WriteLineToTmpImportFile:call TRACE "OFF"
  8913. call PpwLineout ToInclude,arg(1)
  8914. return
  8915.  
  8916. IMPORT_34:
  8917. signal IMPORTT_35
  8918.  
  8919. ImportTablePreparationPass1:
  8920. call _ImportValueSpacer 'Assorted options'
  8921. call DBGIND 1
  8922. DropBlankLines=translate(GetImportValue('DROP_BLANK_LINES',  'Y'))
  8923. DropLine=GetImportValue('DROP_LINE_COUNT',DropLine)
  8924. ReplaceNewLineChar=GetImportValue('NEWLINE_CHAR', '<BR>')
  8925. call GetImportValue_Tabs
  8926. call GetImportValue_LineFilter
  8927. RecordFilter=GetImportValue_RecordFilter()
  8928. call DBGIND-1
  8929. return
  8930.  
  8931. ImportTablePreparationPass2:
  8932. if ImportParms='' then
  8933. CryAndDie('#import is missing field names (parm #4 onwards)!')
  8934. NumberOfFields=0
  8935. DisplayingFields=0
  8936. do while ImportParms<> ''
  8937. NumberOfFields=NumberOfFields+1
  8938. HeadingInfo=GetQuotedText(ImportParms, "ImportParms")
  8939. ColumnNumber=DisplayingFields+1
  8940. ExtraInfo=''
  8941. if left(HeadingInfo,1)='{' then
  8942. do
  8943. EndPosn=pos('}',HeadingInfo)
  8944. if EndPosn=0 then
  8945. CryAndDie('Leading field codes on heading "' || HeadingInfo || '" invalid (expected "}")')
  8946. ExtraInfo=substr(HeadingInfo,2,EndPosn-2)
  8947. HeadingInfo=substr(HeadingInfo,EndPosn+1)
  8948. if ImportFileType<> 'SQL' then
  8949. do
  8950. parse var ExtraInfo MaybeColumnNumber','ExtraInfo
  8951. if MaybeColumnNumber<> '' & MaybeColumnNumber <> '*' then
  8952. ColumnNumber=MaybeColumnNumber
  8953. end
  8954. end
  8955. FieldHeading.NumberOfFields=HeadingInfo
  8956. FieldExtra.NumberOfFields=ExtraInfo
  8957. if HeadingInfo<> '' then
  8958. do
  8959. FieldColumn.NumberOfFields=ColumnNumber
  8960. DisplayingFields=DisplayingFields+1
  8961. end
  8962. end
  8963. call _ImportValueSpacer 'What happens to blank fields?'
  8964. call DBGIND 1
  8965. if ProcessingMode='HTML' then
  8966. zc!B=' '
  8967. else
  8968. zc!B=''
  8969. ReplaceBlankFields=GetImportValue('BLANK_FIELD',zc!B)
  8970. do Index=1 to DisplayingFields
  8971. RepBlankCol.Index=GetImportValue('BLANK_COLUMN_' ||Index,ReplaceBlankFields)
  8972. end
  8973. call DBGIND-1
  8974. call _ImportValueSpacer 'What do we do with column titles?'
  8975. call DBGIND 1
  8976. if ImportValueExists('HEADER') = 'Y' then
  8977. ForHeader=GetImportValue('HEADER', '!BUG!')
  8978. else
  8979. do
  8980. DefaultColFormatting=GetImportValue('HEADING_COLUMNS',     'ALIGN=CENTER')
  8981. DefaultBeforeData=GetImportValue('HEADING_BEFORE_DATA', '')
  8982. DefaultAfterData=GetImportValue('HEADING_AFTER_DATA',  '')
  8983. ForHeader='<TR>'
  8984. do Index=1 to DisplayingFields
  8985. ThisColFormatting=GetImportValue('HEADING_COLUMN_' ||Index,DefaultColFormatting)
  8986. ThisBeforeData=GetImportValue('HEADING_BEFORE_DATA_' ||Index,DefaultBeforeData)
  8987. ThisAfterData=GetImportValue('HEADING_AFTER_DATA_' ||Index,DefaultAfterData)
  8988. ForHeader=ForHeader|| '<TH ' || ThisColFormatting || '>' || ThisBeforeData || StartsMacroParm || 'Column' || Index || EndsMacroParm || ThisAfterData || '</TH>'
  8989. end
  8990. ForHeader=ForHeader|| '</TR>'
  8991. end
  8992. call DBGIND-1
  8993. call _ImportValueSpacer 'Working out what table data row looks like'
  8994. call DBGIND 1
  8995. if ImportValueExists('RECORD') = 'Y' then
  8996. ForEachRecord=GetImportValue('RECORD', '!BUG!')
  8997. else
  8998. do
  8999. DefaultColFormatting=GetImportValue('RECORD_COLUMNS',     'ALIGN=CENTER')
  9000. DefaultBeforeData=GetImportValue('RECORD_BEFORE_DATA', '')
  9001. DefaultAfterData=GetImportValue('RECORD_AFTER_DATA',  '')
  9002. ForEachRecord='<TR>'
  9003. do Index=1 to DisplayingFields
  9004. ThisColFormatting=GetImportValue('RECORD_COLUMN_' ||Index,DefaultColFormatting)
  9005. ThisBeforeData=GetImportValue('RECORD_BEFORE_DATA_' ||Index,DefaultBeforeData)
  9006. ThisAfterData=GetImportValue('RECORD_AFTER_DATA_' ||Index,DefaultAfterData)
  9007. ForEachRecord=ForEachRecord|| '<TD ' || ThisColFormatting || '>' || ThisBeforeData || StartsMacroParm || 'Column' || Index || EndsMacroParm  || ThisAfterData || '</TD>'
  9008. end
  9009. ForEachRecord=ForEachRecord|| '</TR>'
  9010. end
  9011. call DBGIND-1
  9012. call _ImportValueSpacer 'Start output'
  9013. call DBGIND 1
  9014. call GenerateProtectStartTags
  9015. TableAttribs=GetImportValue('TABLE_ATTRIBS', 'BORDER=4 CELLSPACING=0 CELLPADDING=2')
  9016. if TableAttribs<> '' then
  9017. TableAttribs=' ' ||strip(TableAttribs)
  9018. BeforeRecordsDefault='<TABLE' || TableAttribs || '>'
  9019. call GenerateBeforeTags BeforeRecordsDefault
  9020. call DBG_IMPORT 'Outputting heading fields'
  9021. call DBGIND 1
  9022. call _NewRecord 'H'
  9023. do FieldIndex=1 to NumberOfFields
  9024. call _AddField2Record FieldHeading.FieldIndex
  9025. end
  9026. call GenerateRecordFromFields
  9027. call DBGIND-2
  9028. call GetImportValue_Comments ';', ';' || ';'
  9029. if ProcessingMode='HTML' then
  9030. call HandleImportAsIsOptions "IMPORT_HTML_BASIC"
  9031. return
  9032.  
  9033. ImportTableTermination:
  9034. call GenerateAfterTags '</TABLE>'
  9035. call GenerateProtectEndTags
  9036. return
  9037.  
  9038. HandleFixedFieldFile:
  9039. if OptionDebugOn='Y' then
  9040. call DBG_IMPORT 'Importing fixed field file'
  9041. do FieldIndex=1 to NumberOfFields
  9042. parse var FieldExtra.FieldIndex StartCol'-'EndCol
  9043. if EndCol='' | EndCol = '*' then
  9044. FieldLength=''
  9045. else
  9046. FieldLength=(EndCol-StartCol)+1
  9047. FieldStartCol.FieldIndex=StartCol
  9048. FieldLength.FieldIndex=FieldLength
  9049. end
  9050. ImportFileLine=0
  9051. call DBG_IMPORT 'Reading "' || FullImportName || '"...'
  9052. do while lines(FullImportName)<>0
  9053. CurrentRecord=ImportOneLine('Y')
  9054. ImportFileLine=ImportFileLine+1
  9055. if CurrentRecord='' then
  9056. iterate
  9057. if ImportFileLine<=DropLine then
  9058. iterate
  9059. if IsCmtLine(ImportFileLine)then
  9060. iterate
  9061. call _NewRecord
  9062. do FieldIndex=1 to NumberOfFields
  9063. if FieldLength.FieldIndex='' then
  9064. ThisField=substr(CurrentRecord,FieldStartCol.FieldIndex)
  9065. else
  9066. ThisField=substr(CurrentRecord,FieldStartCol.FieldIndex,FieldLength.FieldIndex)
  9067. call _AddField2Record strip(ThisField)
  9068. end
  9069. if GenerateRecordFromFields()then
  9070. leave
  9071. end
  9072. return(ImportFileLine)
  9073.  
  9074. ExtractFieldInfoFromSimpleCharDelimitedFile:
  9075. call DBG_IMPORT 'Field information not supplied, reading the first record!'
  9076. call DBGIND 1
  9077. if lines(FullImportName)=0 then
  9078. CryAndDie("Can't extract field information from an empty file!")
  9079. bd!Line=ImportOneLine('Y')
  9080. ad!L=bd!Line
  9081. ad!Del=arg(1)
  9082. ad!MinF=0
  9083. ad!MaxF=0
  9084. ad!FC=0
  9085. ad!Q='"'
  9086. ad!Q2='""'
  9087. do while ad!L<> ''
  9088. ad!Fc=ad!Fc+1
  9089. if left(ad!L,1)<>ad!Q then
  9090. do
  9091. ad!DelPos=pos(ad!Del,ad!L)
  9092. if ad!DelPos<>0 then
  9093. do
  9094. ad!F=left(ad!L,ad!DelPos-1)
  9095. ad!L=substr(ad!L,ad!DelPos+1)
  9096. end
  9097. else
  9098. do
  9099. ad!F=ad!L
  9100. ad!L=''
  9101. end
  9102. end
  9103. else
  9104. do
  9105. ad!LookFrom=2
  9106. do forever
  9107. ad!QPos=pos(ad!Q,ad!L,ad!LookFrom)
  9108. if ad!QPos=0 then
  9109. do
  9110. if lines(FullImportName)=0 then
  9111. do
  9112. CryAndDie('Import of line ' || ImportFileLine || ' failed','A record spans more than one line however there are no more lines!',, 'RECORD', '~~~~~~', bd!Line, 'DETECTED AT', '~~~~~~~~~~~',ad!L)
  9113. end
  9114. ad!Ln=ImportOneLine('Y')
  9115. ImportFileLine=ImportFileLine+1
  9116. bd!Line=bd!Line||ad!Ln
  9117. ad!L=ad!L||ReplaceNewLineChar||ad!Ln
  9118. iterate
  9119. end
  9120. if substr(ad!L,ad!QPos+1,1)=ad!Q then
  9121. ad!LookFrom=ad!QPos+2
  9122. else
  9123. leave
  9124. end
  9125. ad!F=ReplaceString(substr(ad!L,2,ad!QPos-2),ad!Q2,ad!Q)
  9126. ad!L=substr(ad!L,ad!QPos+1)
  9127. if ad!L<> '' then
  9128. do
  9129. if left(ad!L,1)<>ad!Del then
  9130. do
  9131. CryAndDie('Import of line ' || ImportFileLine || ' failed','Expected delimiter after field #' || ad!Fc,, 'RECORD', '~~~~~~', bd!Line, 'DETECTED AT', '~~~~~~~~~~~',ad!L)
  9132. end
  9133. ad!L=substr(ad!L,2)
  9134. end
  9135. end
  9136. bd!Fld.ad!Fc=ad!F
  9137. if ad!MaxF<>0 then
  9138. do
  9139. if ad!Fc>=ad!MaxF then
  9140. leave
  9141. end
  9142. end
  9143. if ad!Fc<ad!MinF then
  9144. do
  9145. do while ad!Fc<ad!MinF
  9146. ad!Fc=ad!Fc+1
  9147. bd!Fld.ad!Fc=''
  9148. end
  9149. end
  9150. bd!Fld.0=ad!Fc
  9151. call DBG_IMPORT 'Found ' || bd!Fld.0 || ' fields:'
  9152. call DBGIND 1
  9153. bd!Ret=''
  9154. do bd!i=1 to bd!Fld.0
  9155. bd!F=bd!Fld.bd!i
  9156. call DBG_IMPORT bd!F
  9157. bd!Ret=bd!Ret||QuoteIt(bd!F, "ANY", "Y") || ' '
  9158. end
  9159. DropLine=0
  9160. call DBGIND-2
  9161. return(bd!Ret)
  9162.  
  9163. HandleSimpleCharDelimitedFile:
  9164. FieldDelimiter=arg(1)
  9165. if OptionDebugOn='Y' then
  9166. do
  9167. DelimiterText=c2d(FieldDelimiter)
  9168. if DelimiterText> '32' then
  9169. DelimiterText=DelimiterText|| ' ("' || FieldDelimiter || '")'
  9170. call DBG_IMPORT 'Importing simple delimited file - delimiter = ASCII ' ||DelimiterText
  9171. end
  9172. call DBG_IMPORT 'Reading "' || FullImportName || '"...'
  9173. ImportFileLine=0
  9174. do while lines(FullImportName)<>0
  9175. CurrentRecord=ImportOneLine('Y')
  9176. ImportFileLine=ImportFileLine+1
  9177. if CurrentRecord='' then
  9178. do
  9179. if DropBlankLines='Y' then
  9180. iterate
  9181. end
  9182. if ImportFileLine<=DropLine then
  9183. iterate
  9184. if IsCmtLine(CurrentRecord)then
  9185. iterate
  9186. call _NewRecord
  9187. ad!L=CurrentRecord
  9188. ad!Del=FieldDelimiter
  9189. ad!MinF=NumberOfFields
  9190. ad!MaxF=NumberOfFields
  9191. ad!FC=0
  9192. ad!Q='"'
  9193. ad!Q2='""'
  9194. do while ad!L<> ''
  9195. ad!Fc=ad!Fc+1
  9196. if left(ad!L,1)<>ad!Q then
  9197. do
  9198. ad!DelPos=pos(ad!Del,ad!L)
  9199. if ad!DelPos<>0 then
  9200. do
  9201. ad!F=left(ad!L,ad!DelPos-1)
  9202. ad!L=substr(ad!L,ad!DelPos+1)
  9203. end
  9204. else
  9205. do
  9206. ad!F=ad!L
  9207. ad!L=''
  9208. end
  9209. end
  9210. else
  9211. do
  9212. ad!LookFrom=2
  9213. do forever
  9214. ad!QPos=pos(ad!Q,ad!L,ad!LookFrom)
  9215. if ad!QPos=0 then
  9216. do
  9217. if lines(FullImportName)=0 then
  9218. do
  9219. CryAndDie('Import of line ' || ImportFileLine || ' failed','A record spans more than one line however there are no more lines!',, 'RECORD', '~~~~~~', CurrentRecord, 'DETECTED AT', '~~~~~~~~~~~',ad!L)
  9220. end
  9221. ad!Ln=ImportOneLine('Y')
  9222. ImportFileLine=ImportFileLine+1
  9223. CurrentRecord=CurrentRecord||ad!Ln
  9224. ad!L=ad!L||ReplaceNewLineChar||ad!Ln
  9225. iterate
  9226. end
  9227. if substr(ad!L,ad!QPos+1,1)=ad!Q then
  9228. ad!LookFrom=ad!QPos+2
  9229. else
  9230. leave
  9231. end
  9232. ad!F=ReplaceString(substr(ad!L,2,ad!QPos-2),ad!Q2,ad!Q)
  9233. ad!L=substr(ad!L,ad!QPos+1)
  9234. if ad!L<> '' then
  9235. do
  9236. if left(ad!L,1)<>ad!Del then
  9237. do
  9238. CryAndDie('Import of line ' || ImportFileLine || ' failed','Expected delimiter after field #' || ad!Fc,, 'RECORD', '~~~~~~', CurrentRecord, 'DETECTED AT', '~~~~~~~~~~~',ad!L)
  9239. end
  9240. ad!L=substr(ad!L,2)
  9241. end
  9242. end
  9243. cd!Fld.ad!Fc=ad!F
  9244. if ad!MaxF<>0 then
  9245. do
  9246. if ad!Fc>=ad!MaxF then
  9247. leave
  9248. end
  9249. end
  9250. if ad!Fc<ad!MinF then
  9251. do
  9252. do while ad!Fc<ad!MinF
  9253. ad!Fc=ad!Fc+1
  9254. cd!Fld.ad!Fc=''
  9255. end
  9256. end
  9257. cd!Fld.0=ad!Fc
  9258. do cd!i=1 to cd!Fld.0
  9259. call _AddField2Record cd!Fld.cd!i
  9260. end
  9261. if GenerateRecordFromFields()then
  9262. leave
  9263. end
  9264. return(ImportFileLine)
  9265.  
  9266. _NewRecord:
  9267. RecordType=arg(1)
  9268. if RecordType='H' then
  9269. ThisRecordsCodes=ForHeader
  9270. else
  9271. ThisRecordsCodes=ForEachRecord
  9272. FieldCounter=0
  9273. ColumnCounter=0
  9274. DroppedCounter=0
  9275. NonBlankFieldCounter=0
  9276. return
  9277.  
  9278. _AddField2Record:
  9279. FieldCounter=FieldCounter+1
  9280. if FieldHeading.FieldCounter='' then
  9281. do
  9282. DroppedCounter=DroppedCounter+1
  9283. Dropped.DroppedCounter=arg(1)
  9284. end
  9285. else
  9286. do
  9287. ColumnCounter=ColumnCounter+1
  9288. NewValue=arg(1)
  9289. if NewValue='' then
  9290. NewValue=RepBlankCol.ColumnCounter
  9291. else
  9292. NonBlankFieldCounter=NonBlankFieldCounter+1
  9293. SaveAsIndex=FieldColumn.FieldCounter
  9294. Column.SaveAsIndex=NewValue
  9295. end
  9296. return
  9297.  
  9298. GenerateRecordFromFields:
  9299. call DBGIND 1
  9300. if DropBlankLines='Y' then
  9301. do
  9302. if NonBlankFieldCounter=0 then
  9303. do
  9304. call DBG_IMPORT 'Dropping record as all fields were blank'
  9305. call DBGIND-1
  9306. return(0)
  9307. end
  9308. end
  9309. if RecordFilter<> '' then
  9310. do
  9311. if RecordType<> 'H' then
  9312. do
  9313. Column.0=ColumnCounter
  9314. Dropped.0=DroppedCounter
  9315. call DBG_IMPORT 'Calling specified filter'
  9316. call DBGIND 1
  9317. Remove=''
  9318. call ExecRexxCmd RecordFilter
  9319. if Remove<> '' then
  9320. do
  9321. if abbrev(Remove, "EOF:")then
  9322. do
  9323. call DBG_IMPORT 'This Record and all following dropped ==> ' ||Remove
  9324. call DBGIND-2
  9325. return(1)
  9326. end
  9327. else
  9328. do
  9329. call DBG_IMPORT 'Record dropped ==> ' ||Remove
  9330. call DBGIND-2
  9331. return(0)
  9332. end
  9333. end
  9334. call DBGIND-1
  9335. end
  9336. end
  9337. do ThisOne=1 to ColumnCounter
  9338. ThisRecordsCodes=ReplaceString(ThisRecordsCodes,StartsMacroParm|| 'Column' ||ThisOne||EndsMacroParm,Column.ThisOne)
  9339. end
  9340. if ThisRecordsCodes<> '' then
  9341. do
  9342. call DBG_IMPORT 'Generating: ' ||DebugRightArrow||ThisRecordsCodes||DebugLeftArrow
  9343. call PpwLineout ToInclude,ThisRecordsCodes
  9344. end
  9345. call DBGIND-1
  9346. return(0)
  9347.  
  9348. PpwLineout:
  9349. parse arg gFile,gLine
  9350. do until gLine==''
  9351. parse var gLine This1 (MarksNewLine) gLine
  9352. if 0<>charout(gFile,This1||NewLineChars)then
  9353. do
  9354. IoReason=FileDescription(gFile)
  9355. CryAndDie('Write to "' || gFile || '" failed (' || IoReason || ')!')
  9356. end
  9357. end
  9358. return
  9359.  
  9360. IMPORTT_35:
  9361. signal REXXSQL_36
  9362.  
  9363. LoadRexxSql:
  9364. signal on SYNTAX name RexxSqlMissing
  9365. dd!Rc=RXFuncAdd('SQLLoadFuncs', 'rexxsql', 'SQLLoadFuncs')
  9366. call DBG_IMPORT "RXFuncAdd(rexxsql.dll), RC = " ||dd!Rc
  9367. call SQLLoadFuncs
  9368. call DBG_IMPORT "rexxsql.dll functions loaded"
  9369. return
  9370.  
  9371. RexxSqlMissing:
  9372. ed!Em="Can't locate/load rexxsql.dll (Mark Hessling's SQL support)!"
  9373. ed!Reason='UNKNOWN'
  9374. signal on SYNTAX name RexxSqlEmFailed
  9375. if RexWhich='REGINA' then
  9376. do
  9377. ed!Tmp=RxFuncErrMsg()
  9378. ed!Reason=ed!Tmp
  9379. end
  9380.  
  9381. RexxSqlEmFailed:
  9382. CryAndDie(ed!Em, 'REASON:',ed!Reason)
  9383.  
  9384. ed!Line:
  9385. ed!Count=ed!Count+1
  9386. ed!L.ed!Count=arg(1)
  9387. return
  9388.  
  9389. ErrorSql:
  9390. do ed!I=1 to 10
  9391. ed!L.ed!I=''
  9392. end
  9393. ed!Count=0
  9394. do ed!I=1 to arg()
  9395. call ed!Line arg(ed!I)
  9396. end
  9397. if ed!Count>6 then
  9398. ed!Count=6
  9399. signal on NOVALUE name SqlVarMissing1
  9400. if ed!L.1='' then
  9401. do
  9402. ed!Count=1
  9403. ed!L.1='REXXSQL ' || SQLCA.FUNCTION || '() call failed.'
  9404. end
  9405. call ed!Line ''
  9406. if sqlca.intcode=-1 Then
  9407. do
  9408. call ed!Line 'SQLCODE:' sqlca.sqlcode
  9409. call ed!Line 'SQLERRM:' sqlca.sqlerrm
  9410. call ed!Line 'SQLTEXT:' sqlca.sqltext
  9411. end
  9412. else
  9413. do
  9414. call ed!Line 'INTCODE:' sqlca.intcode
  9415. call ed!Line 'INTERRM:' sqlca.interrm
  9416. end
  9417.  
  9418. SqlVarMissing2:
  9419. CryAndDie(ed!L.1,ed!L.2,ed!L.3,ed!L.4,ed!L.5,ed!L.6,ed!L.7,ed!L.8,ed!L.9,ed!L.10)
  9420.  
  9421. SqlVarMissing1:
  9422. call ed!Line 'The REXXSQL variable "' || condition('D') || '" is unknown.'
  9423. call ed!Line "ErrorSQL() was trying to display REXXSQL information..."
  9424. signal SqlVarMissing2
  9425.  
  9426. HandleSqlDataBase:
  9427. if OptionDebugOn='Y' then
  9428. do
  9429. call DBG_IMPORT "Importing SQL via Mark Hessling's REXXSQL interface"
  9430. call DBGIND 1
  9431. end
  9432. call LoadRexxSql
  9433. fd!Imported=0
  9434. call DBG_IMPORT "REXXSQL VERSION: " || SqlVariable("VERSION")
  9435. do FieldIndex=1 to NumberOfFields
  9436. fd!FNAME=FieldExtra.FieldIndex
  9437. if fd!FNAME='' then
  9438. fd!FNAME=FieldHeading.FieldIndex
  9439. FieldName.FieldIndex=fd!FNAME
  9440. end
  9441. if OptionDebugOn='Y' then
  9442. do
  9443. call SqlVariable "DEBUG", GetImportValue('SQL_DEBUG', '3')
  9444. end
  9445. fd!Id="SQL"
  9446. fd!UserId=GetImportValue('SQL_USERID',   "")
  9447. fd!Password=GetImportValue('SQL_USERPW',   "")
  9448. fd!DataSourceId=GetImportValue('SQL_DATABASE', "")
  9449. if fd!DataSourceId='' then
  9450. CryAndDie('An SQL database was not specified')
  9451. fd!Server=GetImportValue('SQL_SERVER',   "")
  9452. call DBG_IMPORT "Connecting to the database"
  9453. if SQLConnect(fd!Id,fd!UserId,fd!Password,fd!DataSourceId,fd!Server)<0 then
  9454. ErrorSql('Connection failed to "' || fd!DataSourceId || '", have you set up ODBC datasource (control panel)?')
  9455. call DBG_IMPORT "DATABASE INFO: " || SqlGetInfo(fd!Id, 'DBMSNAME')
  9456. fd!Cmds=GetImportValue('SQL_COMMANDS', "")
  9457. if fd!Cmds<> '' then
  9458. do
  9459. call DBGIND 1
  9460. do fd!I=1 to words(fd!Cmds)
  9461. fd!Mac=word(fd!Cmds,fd!I)
  9462. fd!Cmd=GetDefineContents(fd!Mac)
  9463. if left(fd!Cmd,1)<> '-' then
  9464. fd!Doe='Y'
  9465. else
  9466. do
  9467. fd!Doe='N'
  9468. fd!Cmd=substr(fd!Cmd,2)
  9469. end
  9470. call DBG_IMPORT "Executing: " ||fd!Cmd
  9471. fd!Rc=SQLCommand(fd!Mac,fd!Cmd)
  9472. call DBGIND 1
  9473. if fd!Rc>=0 then
  9474. call DBG_IMPORT "OK, RC=" ||fd!Rc
  9475. else
  9476. do
  9477. if fd!Doe='Y' then
  9478. ErrorSql('User command from "' || fd!Mac || '" failed!')
  9479. if sqlca.intcode=-1 Then
  9480. do
  9481. fd!1='SQLCODE:' sqlca.sqlcode
  9482. fd!2='SQLERRM:' sqlca.sqlerrm
  9483. fd!3='SQLTEXT:' sqlca.sqltext
  9484. end
  9485. else
  9486. do
  9487. fd!1='INTCODE:' sqlca.intcode
  9488. fd!2='INTERRM:' sqlca.interrm
  9489. fd!3=''
  9490. end
  9491. call DBG_IMPORT "Command failed"
  9492. call DBG_IMPORT fd!1
  9493. call DBG_IMPORT fd!2
  9494. call DBG_IMPORT fd!3
  9495. end
  9496. call DBGIND-1
  9497. end
  9498. call DBGIND-1
  9499. end
  9500. fd!Query=GetImportValue('SQL_QUERY', "")
  9501. if fd!Query='' then
  9502. CryAndDie('An SQL query was not specified')
  9503. if SqlPrepare('SQLQUERY',fd!Query)<0 then
  9504. ErrorSql()
  9505. if OptionDebugOn='Y' then
  9506. do
  9507. call DBG_IMPORT "Returned Column information"
  9508. call DBGIND 1
  9509. fd!Attribs=SqlGetInfo(fd!Id, 'DESCRIBECOLUMNS')
  9510. if sqlca.intcode<0 then
  9511. fd!Attribs='NAME TYPE SIZE SCALE NULLABLE PRECISION'
  9512. fd!Pad2=0
  9513. do fd!I=1 to words(fd!Attribs)
  9514. fd!This=word(fd!Attribs,fd!I)
  9515. if length(fd!This)>fd!Pad2 then
  9516. fd!Pad2=length(fd!This)
  9517. end
  9518. fd!NumCols=SqlDescribe('SQLQUERY', 'fd!Det')
  9519. if fd!NumCols<0 then
  9520. ErrorSql()
  9521. do fd!ColIndex=1 to fd!NumCols
  9522. call DBG_IMPORT "Query Field " ||fd!ColIndex
  9523. call DBGIND 1
  9524. do fd!I=1 to words(fd!Attribs)
  9525. fd!Attrib=word(fd!Attribs,fd!I)
  9526. fd!Value=value('fd!Det.COLUMN.' || fd!Attrib || '.fd!ColIndex')
  9527. if left(fd!Value,1)='' | right(fd!Value, 1) = '' then
  9528. fd!Value='""'
  9529. call DBG_IMPORT right(fd!Attrib,fd!Pad2)|| ' = ' ||fd!Value
  9530. end
  9531. call DBGIND-1
  9532. end
  9533. call DBGIND-1
  9534. end
  9535. if SqlOpen('SQLQUERY')<0 then
  9536. ErrorSql()
  9537. fd!Rc=SqlFetch('SQLQUERY')
  9538. do while fd!Rc>0
  9539. call _NewRecord
  9540. do FieldIndex=1 to NumberOfFields
  9541. fd!ColVar='SQLQUERY.' ||FieldName.FieldIndex
  9542. if fd!Imported=0 then
  9543. do
  9544. if symbol(fd!ColVar)<> 'VAR' then
  9545. CryAndDie('The query did not return a field called "' || FieldName.FieldIndex || '"')
  9546. end
  9547. call _AddField2Record value(fd!ColVar)
  9548. end
  9549. fd!Imported=fd!Imported+1
  9550. if GenerateRecordFromFields()then
  9551. leave
  9552. fd!Rc=SqlFetch('SQLQUERY')
  9553. end
  9554. if fd!Rc<0 then
  9555. ErrorSql()
  9556. if SqlClose('SQLQUERY')<0 then
  9557. ErrorSql()
  9558. if SqlDispose('SQLQUERY')<0 then
  9559. ErrorSql()
  9560. call DBG_IMPORT "Disconnecting from the database"
  9561. if SQLDisconnect(fd!Id)<0 then
  9562. ErrorSql()
  9563. if OptionDebugOn='Y' then
  9564. call DBGIND-1
  9565. return(fd!Imported)
  9566.  
  9567. REXXSQL_36:
  9568. signal IMPORTTX_37
  9569.  
  9570. HandleTextToHtmlImport:
  9571. if ProcessingMode<> 'HTML' then
  9572. CryAndDie("Text to html file importing is only allowed when generating HTML")
  9573. if ImportParms<> '' then
  9574. CryAndDie('There are too many parameters on the T2H #import!')
  9575. UrlNameVar=StartsMacroParm|| 'Url' ||EndsMacroParm
  9576. UrlTypeVar=StartsMacroParm|| 'UrlType' ||EndsMacroParm
  9577. HeadingVar=StartsMacroParm|| 'Heading' ||EndsMacroParm
  9578. call GenerateProtectStartTags
  9579. call GenerateBeforeTags '<PRE><FONT SIZE=-1>'
  9580. T2hFilter=GetImportValue_RecordFilter()
  9581. call GetImportValue_LineFilter
  9582. call GetImportValue_Tabs
  9583. BlankLinesTo=GetImportValue('BLANK_LINES_TO', '')
  9584. HttpLink=GetImportValue('HTTP_LINK',   '<A HREF="' || UrlTypeVar || UrlNameVar || '" TARGET=_top>' || UrlTypeVar || UrlNameVar || '</A>')
  9585. FtpLink=GetImportValue('FTP_LINK',    '<A HREF="' || UrlTypeVar || UrlNameVar || '">' || UrlTypeVar || UrlNameVar || '</A>')
  9586. MailLink=GetImportValue('MAILTO_LINK', '<A HREF="mailto:' || UrlNameVar || '">' || UrlNameVar || '</A>')
  9587. DefaultAllStd=UpperCase||LowerCase||DecimalDigits
  9588. AlwaysOkInUrl=GetImportValue('ALWAYS_OK_IN_URL_CHARS',DefaultAllStd)
  9589. if AlwaysOkInUrl\=='' then
  9590. DefaultAllStd=''
  9591. ExtraValidHttpChar=GetImportValue('EXTRA_VALID_HTTP_CHARS',         DefaultAllStd || './?%+:~_')
  9592. ExtraValidFtpChar=GetImportValue('EXTRA_VALID_FTP_CHARS',ExtraValidHttpChar)
  9593. ExtraValidEmailName=GetImportValue('EXTRA_VALID_EMAIL_NAME_CHARS',   DefaultAllStd || '_.')
  9594. ExtraValidEmailSvr=GetImportValue('EXTRA_VALID_EMAIL_SVR_CHARS',    DefaultAllStd || '_.')
  9595. ValidEmailDelimiters=GetImportValue('EXTRA_VALID_EMAIL_DELIMITERS',   " '" || '",;')
  9596. ValidInHttpUrl=AlwaysOkInUrl||ExtraValidHttpChar
  9597. ValidInFtpUrl=AlwaysOkInUrl||ExtraValidFtpChar
  9598. ValidInEmailL=AlwaysOkInUrl||ExtraValidEmailName
  9599. ValidInEmailR=AlwaysOkInUrl||ExtraValidEmailSvr
  9600. call GetImportValue_Comments '', ''
  9601. if ProcessingMode='HTML' then
  9602. call HandleImportAsIsOptions "IMPORT_HTML_BASIC IMPORT_HTML_BOXGRAPHIC_TO_BOXTEXT"
  9603. T2hLineNumber=0
  9604. call DBG_IMPORT 'Reading "' || FullImportName || '"...'
  9605. do while lines(FullImportName)<>0
  9606. T2hFileLine=ImportOneLine('Y')
  9607. T2hLineNumber=T2hLineNumber+1
  9608. if IsCmtLine(T2hFileLine)then
  9609. iterate
  9610. if T2hFileLine='' then
  9611. do
  9612. if BlankLinesTo\=='' then
  9613. T2hNewLine=BlankLinesTo
  9614. else
  9615. T2hNewLine=''
  9616. end
  9617. else
  9618. do
  9619. T2hNewLine=T2hFileLine
  9620. if MailLink\=='' then
  9621. T2hNewLine=_MakeTextImportEmailChanges(T2hNewLine,ValidInEmailL,ValidInEmailR,ValidEmailDelimiters,MailLink)
  9622. if HttpLink\=='' then
  9623. T2hNewLine=_MakeTextImportLinkChanges(T2hNewLine, 'http:',ValidInHttpUrl,HttpLink)
  9624. if FtpLink\=='' then
  9625. T2hNewLine=_MakeTextImportLinkChanges(T2hNewLine, 'ftp:',ValidInFtpUrl,FtpLink)
  9626. end
  9627. if T2hFilter<> '' then
  9628. do
  9629. call DBG_IMPORT 'Calling specified filter'
  9630. call DBGIND 1
  9631. Remove=''
  9632. call ExecRexxCmd T2hFilter
  9633. if Remove<> '' then
  9634. do
  9635. if abbrev(Remove, "EOF:")then
  9636. do
  9637. call DBG_IMPORT 'This Record and all following dropped ==> ' ||Remove
  9638. call DBGIND-1
  9639. leave
  9640. end
  9641. else
  9642. do
  9643. call DBG_IMPORT 'Record dropped ==> ' ||Remove
  9644. call DBGIND-1
  9645. iterate
  9646. end
  9647. end
  9648. call DBGIND-1
  9649. end
  9650. call PpwLineout ToInclude,T2hNewLine
  9651. end
  9652. call GenerateAfterTags '</FONT></PRE>'
  9653. call GenerateProtectEndTags
  9654. return(T2hLineNumber)
  9655.  
  9656. _MakeTextImportLinkChanges:
  9657. parse arg RightBit,UrlType,tlOkInUrl,tlTransformSpec
  9658. LeftBit=''
  9659. UrlPos=pos(UrlType,RightBit)
  9660. lUrlType=length(UrlType)
  9661. do while UrlPos<>0
  9662. LeftBit=LeftBit||left(RightBit,UrlPos-1)
  9663. RightBit=substr(RightBit,UrlPos+lUrlType)
  9664. NotUrlCharPos=verify(RightBit,tlOkInUrl)
  9665. if NotUrlCharPos=0 then
  9666. do
  9667. TheUrl=RightBit
  9668. RightBit=''
  9669. end
  9670. else
  9671. do
  9672. TheUrl=left(RightBit,NotUrlCharPos-1)
  9673. RightBit=substr(RightBit,NotUrlCharPos)
  9674. end
  9675. UrlBit=ReplaceString(tlTransformSpec,UrlTypeVar,UrlType)
  9676. UrlBit=ReplaceString(UrlBit,UrlNameVar,TheUrl)
  9677. LeftBit=LeftBit||UrlBit
  9678. UrlPos=pos(UrlType,RightBit)
  9679. end
  9680. return(LeftBit||RightBit)
  9681.  
  9682. _MakeTextImportEmailChanges:
  9683. parse arg RightBit,tlOkInEmailName,tlOkInEmailSvr,tlDelimiters,tlTransformSpec
  9684. LeftBit=''
  9685. SnailPos=pos('@',RightBit)
  9686. do while SnailPos<>0
  9687. lRightBit=length(RightBit)
  9688. if SnailPos=1|SnailPos=lRightBit then
  9689. do
  9690. LeftBit=LeftBit||left(RightBit,SnailPos)
  9691. RightBit=substr(RightBit,SnailPos+1)
  9692. end
  9693. else
  9694. do
  9695. LeftPos=SnailPos-1
  9696. do until LeftPos=0
  9697. OneChar=substr(RightBit,LeftPos,1)
  9698. if pos(OneChar,tlDelimiters)<>0 then
  9699. do
  9700. LeftPos=LeftPos+1
  9701. leave
  9702. end
  9703. LeftPos=LeftPos-1
  9704. end
  9705. if LeftPos=0 then
  9706. LeftPos=LeftPos+1
  9707. EmailLeftBit=substr(RightBit,LeftPos,SnailPos-LeftPos)
  9708. RightPos=SnailPos+1
  9709. do until RightPos>lRightBit
  9710. OneChar=substr(RightBit,RightPos,1)
  9711. if pos(OneChar,tlDelimiters)<>0 then
  9712. do
  9713. RightPos=RightPos-1
  9714. leave
  9715. end
  9716. RightPos=RightPos+1
  9717. end
  9718. if RightPos>lRightBit then
  9719. RightPos=lRightBit
  9720. if substr(RightBit,RightPos,1)='.' then
  9721. RightPos=RightPos-1
  9722. EmailRightBit=substr(RightBit,SnailPos+1,RightPos-SnailPos)
  9723. if verify(EmailLeftBit,tlOkInEmailName)<>0|verify(EmailRightBit,tlOkInEmailSvr)<>0|pos('.',EmailRightBit)=0 then
  9724. do
  9725. LeftBit=LeftBit||left(RightBit,SnailPos)
  9726. RightBit=substr(RightBit,SnailPos+1)
  9727. end
  9728. else
  9729. do
  9730. EmailBit=ReplaceString(tlTransformSpec,UrlTypeVar, 'mailto:')
  9731. EmailBit=ReplaceString(EmailBit,UrlNameVar,EmailLeftBit|| '@' ||EmailRightBit)
  9732. LeftBit=LeftBit||left(RightBit,LeftPos-1)||EmailBit
  9733. RightBit=substr(RightBit,RightPos+1)
  9734. end
  9735. end
  9736. SnailPos=pos('@',RightBit)
  9737. end
  9738. return(LeftBit||RightBit)
  9739.  
  9740. IMPORTTX_37:
  9741. signal IMPORTWR_38
  9742.  
  9743. HandleLineWrapping:
  9744. if ImportParms<> '' then
  9745. CryAndDie('There are too many parameters on the WRAP #import!')
  9746. DropBlankLines=translate(GetImportValue('DROP_BLANK_LINES',  'Y'))
  9747. call GetImportValue_Tabs
  9748. WrapFilter=GetImportValue_RecordFilter()
  9749. call GetImportValue_LineFilter
  9750. call GetImportValue_Comments ';', ';' || ';'
  9751. if ProcessingMode='HTML' then
  9752. call HandleImportAsIsOptions ""
  9753. WrapLineNumber=0
  9754. NewDoubleQuote='" || d2c(34) || "'
  9755. call DBG_IMPORT 'Reading "' || FullImportName || '"...'
  9756. do while lines(FullImportName)<>0
  9757. WrapLine=ImportOneLine('Y')
  9758. WrapLineNumber=WrapLineNumber+1
  9759. if WrapLine='' then
  9760. do
  9761. if DropBlankLines='Y' then
  9762. iterate
  9763. end
  9764. if IsCmtLine(WrapLine)then
  9765. iterate
  9766. if WrapFilter='' then
  9767. do
  9768. RebuildCmd='"' || ReplaceString(WrapLine, '"', NewDoubleQuote) || '"'
  9769. SafeQuote=QuoteIt(RebuildCmd,TryQuoteListAny)
  9770. call PpwLineout ToInclude,StartsMacroReplacement||MacroName|| ' Line=' ||SafeQuote||RebuildCmd||SafeQuote||EndsMacroReplacement
  9771. end
  9772. else
  9773. do
  9774. call DBG_IMPORT 'Calling filter for line #' ||WrapLineNumber
  9775. call DBGIND 1
  9776. Remove=''
  9777. call ExecRexxCmd WrapFilter
  9778. if Remove<> '' then
  9779. do
  9780. if abbrev(Remove, "EOF:")then
  9781. do
  9782. call DBG_IMPORT 'This Record and all following dropped ==> ' ||Remove
  9783. call DBGIND-1
  9784. leave
  9785. end
  9786. else
  9787. do
  9788. call DBG_IMPORT 'Line dropped ==> ' ||Remove
  9789. call DBGIND-1
  9790. iterate
  9791. end
  9792. end
  9793. call DBGIND-1
  9794. call PpwLineout ToInclude,WrapLine
  9795. end
  9796. end
  9797. return(WrapLineNumber)
  9798.  
  9799. IMPORTWR_38:
  9800. MultiLineImportInProgress='N'
  9801. signal I_ML_39
  9802.  
  9803. HandleMultiLineImport:
  9804. if OptionDebugOn='Y' then
  9805. call DBG_IMPORT 'Importing multi line record file'
  9806. mlDelimiter=GetImportValue('DELIMITER',         '=')
  9807. mlLineSep=GetImportValue('SEPARATOR',         ' ')
  9808. mlStripL=translate(GetImportValue('STRIP_LEADING', 'Y'))
  9809. mlLineCmtChar=GetImportValue('LINE_COMMENT_CHAR',LineComment)
  9810. if mlLineCmtChar='' then
  9811. mlLineCmtChar=' '
  9812. call GetImportValue_LineFilter
  9813. MultiLineFilter=PerformReplacementsInCmdsParameters(GetImportValue('MULTILINE_FILTER', ''))
  9814. drop mlFIndex?.
  9815. do FieldIndex=1 to NumberOfFields
  9816. parse value translate(FieldExtra.FieldIndex)with FieldName ',' FieldOptions
  9817. if FieldName='' then
  9818. CryAndDie('No {field name} supplied for field #' ||FieldIndex)
  9819. call _valueS 'mlFIndex?.mli?' ||c2x(FieldName),FieldOptions
  9820. MlFieldName.FieldIndex=FieldName
  9821. end
  9822. MultiLineImportInProgress='Y'
  9823. LastMlStoredAs=''
  9824. ImportFileLine=0
  9825. LastCommentLine=''
  9826. call DBG_IMPORT 'Reading "' || FullImportName || '"...'
  9827. call _MlNewRecord
  9828. do while lines(FullImportName)<>0
  9829. MultiLine=strip(ImportOneLine('N'))
  9830. ImportFileLine=ImportFileLine+1
  9831. if MultiLine='' then
  9832. do
  9833. if MlFieldCnt<>0 then
  9834. do
  9835. gd!Eof=_MlGenerateRecord()
  9836. call _MlNewRecord
  9837. if gd!Eof then
  9838. leave
  9839. end
  9840. end
  9841. else
  9842. do
  9843. if left(MultiLine,1)=LineComment then
  9844. iterate
  9845. if MultiLineFilter<> '' then
  9846. do
  9847. call DBG_IMPORT 'Calling specified multi line filter'
  9848. call DBGIND 1
  9849. Remove=''
  9850. call ExecRexxCmd MultiLineFilter
  9851. if Remove<> '' then
  9852. do
  9853. if abbrev(Remove, "EOF:")then
  9854. do
  9855. call DBG_IMPORT 'Line #' || ImportFileLine || ' to EOF dropped ==> ' ||Remove
  9856. call DBGIND-1
  9857. leave
  9858. end
  9859. else
  9860. do
  9861. call DBG_IMPORT 'Line #' || ImportFileLine || ' dropped ==> ' ||Remove
  9862. call DBGIND-1
  9863. iterate
  9864. end
  9865. end
  9866. call DBGIND-1
  9867. end
  9868. parse var MultiLine MultiVar (mlDelimiter) MultiValue
  9869. if mlStripL='Y' then
  9870. MultiValue=strip(MultiValue, 'L')
  9871. else
  9872. do
  9873. if left(MultiValue,1)=' ' then
  9874. MultiValue=substr(MultiValue,2)
  9875. end
  9876. if MultiVar<> '' then
  9877. call _MlRememberFieldsValue strip(MultiVar, 'T'),MultiValue
  9878. else
  9879. do
  9880. if LastMlStoredAs='' then
  9881. CryAndDie('Line #' || ImportFileLine || ': No field to continue!')
  9882. mlNew=_valueG(LastMlStoredAs)||mlLineSep||MultiValue
  9883. call _valueS LastMlStoredAs,mlNew
  9884. end
  9885. end
  9886. end
  9887. call FileClose FullImportName
  9888. if MlFieldCnt<>0 then
  9889. call _MlGenerateRecord
  9890. MultiLineImportInProgress='N'
  9891. return(ImportFileLine)
  9892.  
  9893. _MlNewRecord:
  9894. call _NewRecord
  9895. MlFieldCnt=0
  9896. drop mlFValues?.
  9897. return
  9898.  
  9899. _MlRememberFieldsValue:
  9900. parse arg FieldN,FieldV
  9901. UFieldN=translate(FieldN)
  9902. StoredAs='mlFIndex?.mli?' ||c2x(UFieldN)
  9903. if symbol(StoredAs)<> 'VAR' then
  9904. CryAndDie('Line #' || ImportFileLine || ' - Unknown field name of "' || FieldN || '"')
  9905. FieldOptions=_valueG(StoredAs)
  9906. StoredAs='mlFValues?.mlv?' ||c2x(UFieldN)
  9907. LastMlStoredAs=StoredAs
  9908. if symbol(StoredAs)='VAR' then
  9909. CryAndDie('Line #' || ImportFileLine || ' - Field name of "' || FieldN || '" specified more than once')
  9910. if FieldV='' then
  9911. do
  9912. if pos('NONBLANK',FieldOptions)<>0 then
  9913. CryAndDie('Line #' || ImportFileLine || ' - Field "' || FieldN || '" contains a blank value')
  9914. end
  9915. if pos('NOASIS',FieldOptions)=0 then
  9916. call _valueS StoredAs,AsIs(FieldV)
  9917. else
  9918. call _valueS StoredAs,FieldV
  9919. MlFieldCnt=MlFieldCnt+1
  9920. return
  9921.  
  9922. _MlGenerateRecord:
  9923. do FieldIndex=1 to NumberOfFields
  9924. FieldName=MlFieldName.FieldIndex
  9925. StoredAs='mlFValues?.mlv?' ||c2x(FieldName)
  9926. if symbol(StoredAs)='VAR' then
  9927. call _AddField2Record _valueG(StoredAs)
  9928. else
  9929. do
  9930. FieldOptions=_valueG('mlFIndex?.mli?' ||c2x(FieldName))
  9931. if pos('REQUIRED',FieldOptions)<>0 then
  9932. CryAndDie('Line #' || ImportFileLine || ' - Required field "' || FieldName || '" was not specified')
  9933. call _AddField2Record ''
  9934. end
  9935. end
  9936. hd!Eof=GenerateRecordFromFields()
  9937. LastMlStoredAs=''
  9938. return(hd!Eof)
  9939.  
  9940. GetMlField:call TRACE "OFF"
  9941. if MultiLineImportInProgress<> 'Y' then
  9942. CryAndDie('GetMlField(): Multi line import is not in progress!')
  9943. FieldName=translate(arg(1))
  9944. StoredAs='mlFValues?.mlv?' ||c2x(FieldName)
  9945. if symbol(StoredAs)='VAR' then
  9946. return(_valueG(StoredAs))
  9947. CryAndDie('Line #' || ImportFileLine || ' - GetMlField(): Field "' || FieldName || '" is unknown!')
  9948.  
  9949. I_ML_39:
  9950. call LoopInit
  9951. signal LOOP_40
  9952.  
  9953. LoopInit:
  9954. InLoop='N'
  9955. LoopCnt=0
  9956. LoopLine=1
  9957. LoopID=0
  9958. LoopContinueIndex=0
  9959. LoopFirstLineNumber=-1
  9960. LoopAtEndLineNumber=-1
  9961. LoopIfNesting=-1
  9962. LoopLinesFromFile=-1
  9963. return
  9964.  
  9965. LoopPush:
  9966. SavedAs=arg(1)
  9967. SFI_InLoop.SavedAs=InLoop
  9968. SFI_LoopCnt.SavedAs=LoopCnt
  9969. SFI_LoopLine.SavedAs=LoopLine
  9970. SFI_LoopLinesFromFile.SavedAs=LoopLinesFromFile
  9971. SFI_LoopFirstLineNumber.SavedAs=LoopFirstLineNumber
  9972. SFI_LoopAtEndLineNumber.SavedAs=LoopAtEndLineNumber
  9973. SFI_LoopIfNesting.SavedAs=LoopIfNesting
  9974. SFI_LoopContIndex.SavedAs=LoopContinueIndex
  9975. do SaveIndex=1 to LoopCnt
  9976. SavedPpwLoop.SaveIndex.SavedAs=PpwLoop.SaveIndex
  9977. end
  9978. call LoopInit
  9979. return
  9980.  
  9981. LoopPop:
  9982. SavedAs=arg(1)
  9983. InLoop=SFI_InLoop.SavedAs
  9984. LoopCnt=SFI_LoopCnt.SavedAs
  9985. LoopLine=SFI_LoopLine.SavedAs
  9986. LoopLinesFromFile=SFI_LoopLinesFromFile.SavedAs
  9987. LoopFirstLineNumber=SFI_LoopFirstLineNumber.SavedAs
  9988. LoopAtEndLineNumber=SFI_LoopAtEndLineNumber.SavedAs
  9989. LoopIfNesting=SFI_LoopIfNesting.SavedAs
  9990. LoopContinueIndex=SFI_LoopContIndex.SavedAs
  9991. do SaveIndex=1 to LoopCnt
  9992. PpwLoop.SaveIndex=SavedPpwLoop.SaveIndex.SavedAs
  9993. end
  9994. return
  9995.  
  9996. ProcessLoopStart:
  9997. if InLoop='Y' then
  9998. CryAndDie("Can't nest loops (within one source file)", "The outer loop starts on line " ||LoopFirstLineNumber)
  9999. InLoop='Y'
  10000. LoopID=LoopID+1
  10001. LoopCnt=0
  10002. LoopLine=1
  10003. id!A=arg(1)
  10004. if id!A="" then
  10005. id!LoopType=''
  10006. else
  10007. do
  10008. id!A=PerformReplacementsInCmdsParameters(id!A)
  10009. parse var id!A id!LoopType id!A
  10010. id!LoopType=translate(id!LoopType)
  10011. select
  10012. when id!LoopType='FOR' then
  10013. do
  10014. parse value translate(id!A)with id!Var "=" id!Strt " TO " id!End
  10015. if id!End="" then
  10016. CryAndDie("Incorrect FOR spec ==> " ||id!A)
  10017. id!Var=strip(id!Var)
  10018. id!Strt=strip(id!Strt)
  10019. call _valueS id!Var,id!Strt
  10020. end
  10021. when id!LoopType='SET' then
  10022. do
  10023. if translate(word(id!A,1))<> 'COUNTER' then
  10024. id!Var='SetLoopVar' ||LoopID
  10025. else
  10026. do
  10027. id!Var=word(id!A,2)
  10028. id!A=subword(id!A,3)
  10029. end
  10030. id!SetCnt=0
  10031. id!InitSet=''
  10032. id!LoopSetCnt=0
  10033. id!IndexList=''
  10034. id!NewArray='SETITEMS' ||LoopID
  10035. do while id!A<> ''
  10036. id!SetName=GetQuotedText(id!A, "id!A")
  10037. if pos('=',id!SetName)<>0 then
  10038. do
  10039. parse var id!SetName id!SetName '=' id!Rest
  10040. parse var id!Rest '{' id!Del '}' id!2Split
  10041. if id!2Split=='' then
  10042. do
  10043. id!Del=' '
  10044. id!2Split=id!Rest
  10045. end
  10046. call ArraySplit id!SetName,id!2Split,id!Del
  10047. end
  10048. id!SetVAR="SET_" ||id!SetName
  10049. id!SetStem=id!SetName|| '.'
  10050. id!SetCnt=id!SetCnt+1
  10051. id!IndexVar='id!' ||id!SetCnt
  10052. id!InitSet=id!InitSet|| 'do ' || id!IndexVar || ' = 1 to ' || id!SetStem || '0; '
  10053. if id!SetCnt<>1 then
  10054. id!IndexList=id!IndexList|| ' || '
  10055. id!IndexList=id!IndexList|| '"' || id!SetVar || '=' || id!SetStem || '" || ' || id!IndexVar || ' || ";"'
  10056. end
  10057. id!InitSet=id!InitSet|| 'id!LoopSetCnt=id!LoopSetCnt+1; '
  10058. id!InitSet=id!InitSet||id!NewArray|| '.id!LoopSetCnt=strip(' || id!IndexList || '); '
  10059. do id!I=1 to id!SetCnt
  10060. id!InitSet=id!InitSet|| 'end; '
  10061. end
  10062. call ExecRexxCmd id!InitSet
  10063. call _valueS id!NewArray|| '.0',id!LoopSetCnt
  10064. id!End=id!LoopSetCnt
  10065. call _valueS id!Var,1
  10066. end
  10067. otherwise
  10068. CryAndDie('Invalid loop specification (command "' || id!LoopType || '" unknown)')
  10069. end
  10070. end
  10071. if id!LoopType='FOR' | id!LoopType = 'SET' then
  10072. do
  10073. call DBG 'Adding FOR/SET loop lines'
  10074. LoopCnt=LoopCnt+1
  10075. PpwLoop.LoopCnt='#if [' || id!Var || ' > ' || id!End || ']'
  10076. LoopCnt=LoopCnt+1
  10077. PpwLoop.LoopCnt='#break'
  10078. LoopCnt=LoopCnt+1
  10079. PpwLoop.LoopCnt='#endif'
  10080. if id!LoopType='SET' then
  10081. do
  10082. call DBG 'Adding SET loop lines for ' || id!LoopSetCnt || ' loops'
  10083. LoopCnt=LoopCnt+1
  10084. PpwLoop.LoopCnt='#evaluate ^^ ^<' || '??' || id!NewArray || '.' || id!Var || '>^'
  10085. end
  10086. end
  10087. LoopFirstLineNumber=IncludeLineNumber
  10088. LoopIfNesting=IfNesting
  10089. if IncludeMemBufferNextLine=='' then
  10090. LoopLinesFromFile=1
  10091. else
  10092. LoopLinesFromFile=0
  10093. LengthEndCmd=length(CmdHashLoopE)
  10094. FoundEnd='N'
  10095. do forever
  10096. if LoopLinesFromFile=1 then
  10097. do
  10098. if IncludeFileLines()=0 then
  10099. leave
  10100. LoopCnt=LoopCnt+1
  10101. PpwLoop.LoopCnt=IncludeFileLineIn()
  10102. InputLines=InputLines+1
  10103. end
  10104. else
  10105. do
  10106. if IncludeMemBufferNextLine=='' then
  10107. leave
  10108. LoopCnt=LoopCnt+1
  10109. parse var IncludeMemBufferNextLine PpwLoop.LoopCnt (MarksNewLine) IncludeMemBufferNextLine
  10110. end
  10111. id!MaybeEnd=left(strip(translate(PpwLoop.LoopCnt,,TabChar), 'L'),LengthEndCmd)
  10112. if id!MaybeEnd=CmdHashLoopE then
  10113. do
  10114. FoundEnd='Y'
  10115. LoopCnt=LoopCnt-1
  10116. if LoopCnt=0 then
  10117. CryAndDie("No commands found in body of loop!")
  10118. leave
  10119. end
  10120. end
  10121. LoopAtEndLineNumber=IncludeLineNumber
  10122. if FoundEnd='N' then
  10123. do
  10124. if LoopLinesFromFile then
  10125. eLoop='EOF'
  10126. else
  10127. eLoop='end of macro'
  10128. CryAndDie('Could not find "' || CmdHashLoopE || '" before ' || eLoop, 'Searched ' || LoopCnt || ' line(s)')
  10129. end
  10130. if id!LoopType='FOR' | id!LoopType = 'SET' then
  10131. do
  10132. call DBG 'Adding FOR/SET loop lines'
  10133. LoopCnt=LoopCnt+1
  10134. PpwLoop.LoopCnt='#RexxVar ^' || id!Var || '^ + 1'
  10135. LoopContinueIndex=LoopCnt
  10136. end
  10137. else
  10138. do
  10139. LoopContinueIndex=1
  10140. end
  10141. call DBG 'Loop is ' || LoopCnt || ' line(s) long and ends on line ' ||AddCommasToDecimalNumber(IncludeLineNumber)
  10142. return(0)
  10143.  
  10144. GetLoopLineIntoFileLine:
  10145. FileLine=PpwLoop.LoopLine
  10146. if LoopLinesFromFile then
  10147. IncludeLineNumber=LoopFirstLineNumber+LoopLine
  10148. LoopLine=LoopLine+1
  10149. if LoopLine>LoopCnt then
  10150. LoopLine=1
  10151. return(FileLine)
  10152.  
  10153. ProcessLoopBreak:
  10154. call DBG 'Exiting loop'
  10155. InLoop='N'
  10156. IfNesting=LoopIfNesting
  10157. IncludeLineNumber=LoopAtEndLineNumber
  10158. return(0)
  10159.  
  10160. ProcessLoopContinue:
  10161. LoopLine=LoopContinueIndex
  10162. call DBG 'Back to "start" of loop - Loop Line #' ||LoopContinueIndex
  10163. IfNesting=LoopIfNesting
  10164. return(0)
  10165.  
  10166. LOOP_40:
  10167. _RestrictKeyMinimum=CharsLUN
  10168. _giCounter=0
  10169. signal GetId_41
  10170.  
  10171. GetIdPrepare:call TRACE "OFF"
  10172. giHandle=arg(1)
  10173. giUniqueId=translate(arg(2))
  10174. interpret 'drop GI?'  || giHandle || '.'
  10175. call _valueS 'GI?'  || giHandle || '.GI?UID',giUniqueId
  10176. return
  10177.  
  10178. SetId:call TRACE "OFF"
  10179. giHandle=arg(1)
  10180. giName=arg(2)
  10181. giId=arg(3)
  10182. giSaveAsPrefix='GI?'  || giHandle || '.GI?'
  10183. if giName\=='' then
  10184. do
  10185. if _valueG(giSaveAsPrefix|| 'UID') = 'Y' then
  10186. CryAndDie("You have asked for UNIQUE ID's to be generated. Don't use SetId()!!!")
  10187. giKeySavedAs=giSaveAsPrefix|| 'KEY_' ||c2x(giName)
  10188. if symbol(giKeySavedAs)='VAR' then
  10189. CryAndDie('SetId(): The KEY of "' || giName || '" has already been used')
  10190. call _valueS giKeySavedAs,giId
  10191. end
  10192. IdSavedAs=giSaveAsPrefix|| 'ID_' ||c2x(giId)
  10193. if symbol(IdSavedAs)='VAR' then
  10194. CryAndDie('SetId(): The ID of "' || giId || '" has already been used')
  10195. call _valueS IdSavedAs, ''
  10196. return('')
  10197.  
  10198. GetId:call TRACE "OFF"
  10199. giHandle=arg(1)
  10200. giType=translate(arg(2))
  10201. giName=arg(3)
  10202. giSaveAsPrefix='GI?'  || giHandle || '.GI?'
  10203. giUniqueId=_valueG(giSaveAsPrefix|| 'UID')
  10204. if giUniqueId<> 'Y' then
  10205. do
  10206. giKeySavedAs=giSaveAsPrefix|| 'KEY_' ||c2x(giName)
  10207. if symbol(giKeySavedAs)='VAR' then
  10208. return(_valueG(giKeySavedAs))
  10209. end
  10210. GiMaxLength=''
  10211. select
  10212. when giType="MAXCHARS" then
  10213. do
  10214. CanBeDuplicated='Y'
  10215. GiMaxLength=arg(5)
  10216. if GiMaxLength='' then
  10217. GiMaxLength=8
  10218. giId=_Id_2_(giName,arg(4))
  10219. if length(giId)>GiMaxLength then
  10220. giId=left(giId,GiMaxLength)
  10221. end
  10222. when giType="C2X" then
  10223. do
  10224. CanBeDuplicated='N'
  10225. giId=_Id_c2x(giName,arg(4))
  10226. end
  10227. when giType="2_" then
  10228. do
  10229. CanBeDuplicated='Y'
  10230. giId=_Id_2_(giName,arg(4))
  10231. end
  10232. otherwise
  10233. CryAndDie('GetId(): Invalid type of "' || giType || '" specified')
  10234. end
  10235. if CanBeDuplicated='Y' then
  10236. do
  10237. IdSavedAs=giSaveAsPrefix|| 'ID_' ||c2x(giId)
  10238. if symbol(IdSavedAs)='VAR' then
  10239. do
  10240. GiIndex=1
  10241. do forever
  10242. if GiMaxLength='' then
  10243. giTryId=giId||GiIndex
  10244. else
  10245. do
  10246. giChopLength=GiMaxLength-length(GiIndex)
  10247. if length(giId)>giChopLength then
  10248. giTryId=left(giId,giChopLength)||GiIndex
  10249. else
  10250. giTryId=giId||GiIndex
  10251. end
  10252. GiIndex=GiIndex+1
  10253. IdSavedAs=giSaveAsPrefix|| 'ID_' ||c2x(giTryId)
  10254. if symbol(IdSavedAs)<> 'VAR' then
  10255. do
  10256. giId=giTryId
  10257. leave
  10258. end
  10259. end
  10260. end
  10261. call _valueS IdSavedAs, ''
  10262. end
  10263. if giUniqueId<> 'Y' then
  10264. call _valueS giKeySavedAs,giId
  10265. return(giId)
  10266.  
  10267. _Id_2_:
  10268. parse arg KeyR,RestrictTo
  10269. RestrictTo=_RestrictKeyMinimum||RestrictTo
  10270. KeyL=''
  10271. InvPos=verify(KeyR,RestrictTo)
  10272. do while InvPos<>0
  10273. KeyL=KeyL||left(KeyR,InvPos-1)|| '_'
  10274. KeyR=substr(KeyR,InvPos+1)
  10275. InvPos=verify(KeyR,RestrictTo)
  10276. end
  10277. KeyL=strip(KeyL||KeyR,, '_')
  10278. do until BeforeCount=ReplaceCount
  10279. BeforeCount=ReplaceCount
  10280. KeyL=ReplaceString(KeyL, "__", "_")
  10281. end
  10282. if KeyL='' then
  10283. return('_')
  10284. else
  10285. return(KeyL)
  10286.  
  10287. _Id_c2x:
  10288. parse arg KeyR,RestrictTo
  10289. RestrictTo=_RestrictKeyMinimum||RestrictTo
  10290. KeyL=''
  10291. InvPos=verify(KeyR,RestrictTo)
  10292. do while InvPos<>0
  10293. KeyL=KeyL||left(KeyR,InvPos-1)|| 'x' ||c2x(substr(KeyR,InvPos,1))
  10294. KeyR=substr(KeyR,InvPos+1)
  10295. InvPos=verify(KeyR,RestrictTo)
  10296. end
  10297. return(KeyL||KeyR)
  10298.  
  10299. GetId_41:
  10300. call GetIdPrepare "IMAGEHW"
  10301. Add2Stem=''
  10302. _ValCharsHttp=UpperCase||LowerCase||DecimalDigits|| "./?%+:~_-,"
  10303. _ValCharsFtp=_ValCharsHttp
  10304. signal Evaluate_42
  10305.  
  10306. _ScaleSide:
  10307. parse arg SideBefore,SideScale
  10308. PercentPos=pos('%',SideScale)
  10309. if PercentPos=0 then
  10310. return(SideScale)
  10311. else
  10312. return((SideBefore*left(SideScale,PercentPos-1))%100)
  10313.  
  10314. _GetSizeTags:
  10315. if OptionDebugOn='Y' then
  10316. do
  10317. call DBGIND 1
  10318. call DBG_EVALUATE 'Real size = ' || ImageWidth || 'x' ||ImageHeight
  10319. call DBGIND-1
  10320. end
  10321. ImgScaleW=ImageScaleW
  10322. ImgScaleH=ImageScaleH
  10323. if ImgScaleW='?' | ImgScaleH = '?' then
  10324. do
  10325. if ImgScaleW='?' then
  10326. do
  10327. NewHeight=_ScaleSide(ImageHeight,ImgScaleH)
  10328. ImgScaleW=(NewHeight*100)%ImageHeight|| '%'
  10329. NewWidth=_ScaleSide(ImageWidth,ImgScaleW)
  10330. end
  10331. else
  10332. do
  10333. NewWidth=_ScaleSide(ImageWidth,ImgScaleW)
  10334. ImgScaleH=(NewWidth*100)%ImageWidth|| '%'
  10335. NewHeight=_ScaleSide(ImageHeight,ImgScaleH)
  10336. end
  10337. end
  10338. else
  10339. do
  10340. NewWidth=_ScaleSide(ImageWidth,ImgScaleW)
  10341. NewHeight=_ScaleSide(ImageHeight,ImgScaleH)
  10342. end
  10343. if ImageOldFormat='Y' then
  10344. ImageReturn='WIDTH='  || NewWidth || ' HEIGHT=' ||NewHeight
  10345. else
  10346. ImageReturn='WIDTH="' || NewWidth || '" HEIGHT="' || NewHeight || '"'
  10347. if ImageCacheKey<> '' then
  10348. call value ImageCacheKey,ImageReturn
  10349. return(ImageReturn)
  10350.  
  10351. CheckFileInfo:
  10352. parse arg iFile,iType,iId,iExpected
  10353. if iId==iExpected then
  10354. return
  10355. call FileClose iFile
  10356. Line1='"' || iFile || '" does not appear to be a "' || iType || '" file.'
  10357. Line2='It is ' || FileQuerySize(iFile) || ' bytes long. '
  10358. if iId=='' then
  10359. Line2=Line2|| 'This appears to be too short.'
  10360. else
  10361. Line2=Line2|| 'The ID is "x' || c2x(iId) || '" (expected "x' || c2x(iExpected) || '")'
  10362. CryAndDie(Line1,Line2)
  10363.  
  10364. _GetGifSize:
  10365. GifFormatId=left(charin(ImageFile,1,6),3)
  10366. call CheckFileInfo ImageFile, 'GIF', GifFormatId, 'GIF'
  10367. WidthLow=charin(ImageFile,,1)
  10368. WidthHigh=charin(ImageFile,,1)
  10369. ImageWidth=c2d(WidthHigh||WidthLow)
  10370. HeightLow=charin(ImageFile,,1)
  10371. HeightHigh=charin(ImageFile,,1)
  10372. ImageHeight=c2d(HeightHigh||HeightLow)
  10373. call FileClose ImageFile
  10374. return(_GetSizeTags())
  10375.  
  10376. _GetPngSize:
  10377. PngFormatId=charin(ImageFile,1,8)
  10378. call CheckFileInfo ImageFile, 'PNG', PngFormatId, '89'x || 'PNG' || '0D 0A 1A 0A'x
  10379. PngFormatId=charin(ImageFile,,4)
  10380. PngFormatId=charin(ImageFile,,4)
  10381. call CheckFileInfo ImageFile, 'PNG', PngFormatId, 'IHDR'
  10382. ImageWidth=c2d(charin(ImageFile,,4))
  10383. ImageHeight=c2d(charin(ImageFile,,4))
  10384. call FileClose ImageFile
  10385. return(_GetSizeTags())
  10386.  
  10387. _GetJpgSize:
  10388. FileType=c2x(Charin(ImageFile,1,2))
  10389. call CheckFileInfo ImageFile, 'JPEG', FileType, "FFD8"
  10390. NxtSeg=3
  10391. ImageHeight="IMAGEHEIGHT"
  10392. Type=''
  10393. do while(Type<> "D9") & (NxtSeg <> -1) & (Imageheight = "IMAGEHEIGHT")
  10394. NxtSeg=_ReadJpgSegment(NxtSeg)
  10395. end
  10396. call FileClose ImageFile
  10397. return(_GetSizeTags())
  10398.  
  10399. _ReadJpgSegment:
  10400. SegPos=arg(1)
  10401. Marker=c2x(charIn(ImageFile,SegPos))
  10402. if Marker<> "FF" then
  10403. return(-1)
  10404. Type=c2x(charIn(ImageFile))
  10405. Res=SegPos+2
  10406. select
  10407. when Type="01" | Type >= "D0" & Type <= "D9" then
  10408. SegmentLength=0
  10409. otherwise
  10410. SegmentLength=c2d(CharIn(ImageFile,,2))
  10411. End
  10412. Res=Res+SegmentLength
  10413. if Type="C0" | Type = "C2" then
  10414. do
  10415. Imagebps=c2d(CharIn(ImageFile))
  10416. ImageHeight=c2d(CharIn(ImageFile,,2))
  10417. ImageWidth=c2d(CharIn(ImageFile,,2))
  10418. end
  10419. return(Res)
  10420.  
  10421. GetImageHeightWidth:call TRACE "OFF"
  10422. parse arg ImageFile,ImageScaleW,ImageScaleH,ImageOldFormat,ImageNoCache
  10423. if ImageScaleW='' then
  10424. ImageScaleW='100%'
  10425. if ImageScaleH='' then
  10426. ImageScaleH='?'
  10427. if OptionDebugOn='Y' then
  10428. call DBG_EVALUATE 'GetImageHeightWidth("' || ImageFile || '", "' || ImageScaleW || '", "' || ImageScaleH || '")'
  10429. if ImageNoCache='Y' then
  10430. ImageCacheKey=''
  10431. else
  10432. do
  10433. ImageCacheKey='I_' || ImageFile || '_w' || c2x(ImageScaleW) || '_h' || c2x(ImageScaleH) || '_f' ||ImageOldFormat
  10434. ImageCacheKey=GetId("IMAGEHW", 'MAXCHARS',ImageCacheKey,,200)
  10435. if symbol(ImageCacheKey)='VAR' then
  10436. do
  10437. if OptionDebugOn='N' then
  10438. return(value(ImageCacheKey))
  10439. else
  10440. do
  10441. SizeString=value(ImageCacheKey)
  10442. call DBG_EVALUATE 'Returning "' || SizeString || '" (from cache)'
  10443. return(SizeString)
  10444. end
  10445. end
  10446. end
  10447. DotPos=lastpos('.',ImageFile)
  10448. if DotPos=0 then
  10449. CryAndDie('Unknown graphic file type on "' || ImageFile || '".')
  10450. ImageExtn=translate(substr(ImageFile,DotPos+1))
  10451. if FileQueryExists(ImageFile)='' then
  10452. do
  10453. CryAndDie('Graphic file "' || ImageFile || '" does not exist.')
  10454. return('')
  10455. end
  10456. call DBGIND 1
  10457. select
  10458. when ImageExtn='GIF' then
  10459. SizeString=_GetGifSize()
  10460. when ImageExtn='PNG' then
  10461. SizeString=_GetPngSize()
  10462. when ImageExtn='JPG' | ImageExtn = 'JPEG' then
  10463. SizeString=_GetJpgSize()
  10464. otherwise
  10465. CryAndDie('Currently only support "GIF", "JPEG" & "PNG" files.')
  10466. end
  10467. if OptionDebugOn='Y' then
  10468. call DBG_EVALUATE 'Returning "' || SizeString || '"'
  10469. call DBGIND-1
  10470. return(SizeString)
  10471.  
  10472. ToUpperCase:call TRACE "OFF"
  10473. if OptionDebugOn='Y' then
  10474. call DBG_EVALUATE 'ToUpperCase()'
  10475. call GetUserLcCfg
  10476. return(translate(arg(1),CfgUpper,CfgLower))
  10477.  
  10478. ToLowerCase:call TRACE "OFF"
  10479. if OptionDebugOn='Y' then
  10480. call DBG_EVALUATE 'ToLowerCase()'
  10481. call GetUserLcCfg
  10482. return(translate(arg(1),CfgLower,CfgUpper))
  10483.  
  10484. EnsureFileHasCorrectCase:call TRACE "OFF"
  10485. cFileI=arg(1)
  10486. if OptionTranslateFileNames='N' then
  10487. return(cFileI)
  10488. if OptionTranslateFileNames='UPPER' then
  10489. cFileO=translate(cFileI)
  10490. else
  10491. cFileO=translate(cFileI,LowerCase,UpperCase)
  10492. if OptionDebugOn='Y' then
  10493. do
  10494. if cFileI<>cFileO then
  10495. do
  10496. call DBG_EVALUATE 'A files case was adjusted'
  10497. call DBGIND 1
  10498. call DBG_EVALUATE 'FROM: "' || cFileI || '"'
  10499. call DBG_EVALUATE '  TO: "' || cFileO || '"'
  10500. call DBGIND-1
  10501. end
  10502. end
  10503. return(cFileO)
  10504.  
  10505. GetAmPmTime:call TRACE "OFF"
  10506. return(GetAmPmTimeFromHhMmSs(time('N'),arg(1),arg(2)))
  10507.  
  10508. GetAmPmTimeFromHhMmSs:call TRACE "OFF"
  10509. parse arg jd!PT,jd!AddSS,jd!AmPm
  10510. if jd!AmPm='' then
  10511. jd!AmPm='am;pm'
  10512. parse var jd!AmPm jd!AmTxt ';' jd!PmTxt
  10513. if pos(':',jd!PT)=0 then
  10514. parse var jd!PT jd!HH 3 jd!MM 5 jd!SS
  10515. else
  10516. parse var jd!PT jd!HH ':' jd!MM ':' jd!SS
  10517. if jd!HH>=12 then
  10518. jd!AmPm=jd!PmTxt
  10519. else
  10520. jd!AmPm=jd!AmTxt
  10521. if jd!HH>12 then
  10522. jd!HH=jd!HH-12
  10523. jd!HH=jd!HH+0
  10524. jd!MM=right(jd!MM,2, '0')
  10525. if jd!AddSS='' then
  10526. do
  10527. if jd!SS='' then
  10528. jd!AddSS='N'
  10529. else
  10530. jd!AddSS='Y'
  10531. end
  10532. if jd!AddSS='N' then
  10533. jd!SS=''
  10534. else
  10535. jd!SS=':' || right(jd!SS, 2, '0')
  10536. jd!T=jd!HH|| ':' ||jd!MM||jd!SS||jd!AmPm
  10537. return(jd!T)
  10538.  
  10539. AddCommasToDecimalNumber:procedure;call TRACE "OFF"
  10540. kd!Str=strip(arg(1))
  10541. if pos(',',kd!Str)<>0 then
  10542. return(kd!Str)
  10543. kd!P=pos('.',kd!Str)
  10544. if kd!P=0 then
  10545. kd!After=''
  10546. else
  10547. do
  10548. if kd!P=1 then
  10549. return("0" ||kd!Str)
  10550. kd!After=substr(kd!Str,kd!P+1)
  10551. kd!Str=left(kd!Str,kd!P-1)
  10552. end
  10553. kd!Str=reverse(kd!Str)
  10554. kd!With=""
  10555. do while length(kd!Str)>3
  10556. kd!With=kd!With||left(kd!Str,3)|| ','
  10557. kd!Str=substr(kd!Str,4)
  10558. end
  10559. kd!With=kd!With||kd!Str
  10560. kd!With=reverse(kd!With)
  10561. if kd!After<> '' then
  10562. kd!With=kd!With|| '.' ||kd!After
  10563. return(kd!With)
  10564.  
  10565. PadString:procedure;call TRACE "OFF"
  10566. parse arg TheString,TheMaxSize,PadType
  10567. StringSize=length(TheString)
  10568. if StringSize>=TheMaxSize then
  10569. return(TheString)
  10570. SpacesRequired=TheMaxSize-StringSize
  10571. if PadType='R' then
  10572. return(copies(' ',SpacesRequired)||TheString)
  10573. else
  10574. do
  10575. if PadType<> 'C' then
  10576. return(TheString||copies(' ',SpacesRequired))
  10577. else
  10578. do
  10579. SpacesOnLeft=SpacesRequired%2
  10580. return(copies(' ', SpacesOnLeft) || TheString || copies(' ',SpacesRequired-SpacesOnLeft))
  10581. end
  10582. end
  10583.  
  10584. BreakAt:call TRACE "OFF"
  10585. parse arg ld!Max,ld!Str,ld!Chars,ld!With
  10586. if ld!Chars=='' then
  10587. ld!Chars=CfgMacro("PPWIZARD_BREAKAT_AFTER", './:#')
  10588. if ld!With='' then
  10589. ld!With=CfgMacro("PPWIZARD_BREAKAT_USE",   '<br>')
  10590. baPos=pos('-',ld!Max)
  10591. if baPos=0 then
  10592. baMinSize=ld!Max%3
  10593. else
  10594. parse var ld!Max baMinSize'-'ld!Max
  10595. ld!Rc=''
  10596. do while length(ld!Str)>ld!Max
  10597. ld!Left=left(ld!Str,ld!Max)
  10598. ld!Str=substr(ld!Str,ld!Max+1)
  10599. ld!BestPos=0
  10600. ld!CharList=ld!Chars
  10601. do while ld!CharList\==''
  10602. ld!ThisChar=left(ld!CharList,1)
  10603. ld!CharList=substr(ld!CharList,2)
  10604. ld!Pos=lastpos(ld!ThisChar,ld!Left)
  10605. if ld!Pos>ld!BestPos then
  10606. do
  10607. ld!BestPos=ld!Pos
  10608. end
  10609. end
  10610. if ld!Rc<> '' then
  10611. ld!Rc=ld!Rc||ld!With
  10612. if ld!BestPos=0 then
  10613. ld!Rc=ld!Rc||ld!Left
  10614. else
  10615. do
  10616. ld!Rc=ld!Rc||left(ld!Left,ld!BestPos)
  10617. ld!Str=substr(ld!Left,ld!BestPos+1)||ld!Str
  10618. end
  10619. end
  10620. if ld!Rc<> '' then
  10621. return(ld!Rc||ld!With||ld!Str)
  10622. else
  10623. return(ld!Rc||ld!Str)
  10624.  
  10625. Wbr:call TRACE "OFF"
  10626. parse arg md!Str,md!Chars,md!Use,md!Min
  10627. if md!Use='' then
  10628. md!Use=CfgMacro("PPWIZARD_WBR_USE", '<wbr>')
  10629. if md!Chars=='' then
  10630. md!Chars=CfgMacro("PPWIZARD_WBR_AFTER", '/\?&')
  10631. if md!Min='' then
  10632. md!Min=CfgMacro("PPWIZARD_WBR_MIN",0)
  10633. md!Rc=''
  10634. md!Start=1
  10635. do while md!Str\==''
  10636. md!Pos=verify(md!Str,md!Chars, 'M',md!Start)
  10637. if md!Pos=0 then
  10638. leave
  10639. if md!Pos<md!Min then
  10640. do
  10641. md!Start=md!Pos+1
  10642. iterate
  10643. end
  10644. md!Rc=md!Rc||left(md!Str,md!Pos)||md!Use
  10645. md!Str=substr(md!Str,md!Pos+1)
  10646. md!Start=1
  10647. end
  10648. md!Rc=md!Rc||md!Str
  10649. return(md!Rc)
  10650.  
  10651. MacroGet:call TRACE "OFF"
  10652. if OptionDebugOn='Y' then
  10653. call DBG_EVALUATE 'MacroGet()'
  10654. GotValue=GetDefineContents(arg(1))
  10655. if OptionDebugOn='Y' then
  10656. call DBG_EVALUATE 'MacroGet("' || arg(1) || '") = ' ||DebugRightArrow||GotValue||DebugLeftArrow
  10657. return(GotValue)
  10658.  
  10659. Defined:call TRACE "OFF"
  10660. if OptionDebugOn='N' then
  10661. return(MacroExists(arg(1)))
  10662. else
  10663. do
  10664. call DBG_EVALUATE 'Defined("' || arg(1) || '")?'
  10665. call DBGIND 1
  10666. nd!Yn=MacroExists(arg(1))
  10667. call DBG_EVALUATE 'Returning: ' ||nd!Yn
  10668. call DBGIND-1
  10669. return(nd!Yn)
  10670. end
  10671.  
  10672. DataSave:call TRACE "OFF"
  10673. if OptionDebugOn='Y' then
  10674. call DBG_EVALUATE 'DataSave()'
  10675. parse arg StoreApp,StoreKey,StoreData
  10676. call _valueS "DSAP_" || c2x(StoreApp) || '.DSKY_' ||c2x(StoreKey),StoreData
  10677. return
  10678.  
  10679. DataGet:call TRACE "OFF"
  10680. if OptionDebugOn='Y' then
  10681. call DBG_EVALUATE 'DataGet()'
  10682. parse arg StoreApp,StoreKey,StoreDefault
  10683. DataVarName="DSAP_" || c2x(StoreApp) || '.DSKY_' ||c2x(StoreKey)
  10684. if symbol(DataVarName)<> 'VAR' then
  10685. return(StoreDefault)
  10686. else
  10687. return(_valueG(DataVarName))
  10688.  
  10689. UrlEncode:call TRACE "OFF"
  10690. if OptionDebugOn='Y' then
  10691. call DBG_EVALUATE 'UrlEncode()'
  10692. UrlIn=arg(1)
  10693. ueCmd=translate(arg(2))
  10694. SpaceToPlus='N'
  10695. select
  10696. when ueCmd='TO%' then
  10697. do
  10698. UrlBadChars=arg(3)
  10699. if UrlBadChars=='' then
  10700. UrlBadChars='+<>%"/?# '
  10701. end
  10702. when ueCmd='TO%EXCEPT' then
  10703. do
  10704. UrlOkChars=arg(3)
  10705. if UrlOkChars=='' then
  10706. UrlOkChars=CharsLUN|| '-._'
  10707. UrlBadChars=space(translate(xrange('00'x, 'FF'x), '',UrlOkChars),0)
  10708. if pos(' ',UrlOkChars)=0 then
  10709. UrlBadChars=UrlBadChars|| ' '
  10710. end
  10711. when ueCmd='ENCODEALL' then
  10712. UrlBadChars=xrange('00'x, 'FF'x)
  10713. otherwise
  10714. CryAndDie('Invalid UrlEncode() command of "' || ueCmd || '"')
  10715. end
  10716. UrlOut=''
  10717. UrlCount=length(UrlIn)
  10718. do CharPosn=1 to UrlCount
  10719. ThisChar=substr(UrlIn,CharPosn,1)
  10720. if pos(ThisChar,UrlBadChars)=0 then
  10721. UrlOut=UrlOut||ThisChar
  10722. else
  10723. do
  10724. if ThisChar==' ' & SpaceToPlus = 'Y' then
  10725. UrlOut=UrlOut|| '+'
  10726. else
  10727. UrlOut=UrlOut|| '%' || right(c2x(ThisChar), 2, '0')
  10728. end
  10729. end
  10730. return(UrlOut)
  10731.  
  10732. UrlDecode:call TRACE "OFF"
  10733. if OptionDebugOn='Y' then
  10734. call DBG_EVALUATE 'UrlDecode()'
  10735. parse arg UrlIn,udCmd
  10736. UrlPlusIsSpace='Y'
  10737. if udCmd<> '' then
  10738. do
  10739. if translate(udCmd)='LEAVE+' then
  10740. UrlPlusIsSpace='N'
  10741. else
  10742. CryAndDie('Invalid UrlDecode() command of "' || udCmd || '"')
  10743. end
  10744. UrlOut=''
  10745. CharPosn=1
  10746. UrlCount=length(UrlIn)
  10747. do while CharPosn<=UrlCount
  10748. ThisChar=substr(UrlIn,CharPosn,1)
  10749. CharPosn=CharPosn+1
  10750. if UrlPlusIsSpace<> 'N' & ThisChar = '+' then
  10751. ThisChar=' '
  10752. else
  10753. do
  10754. if ThisChar='%' then
  10755. do
  10756. ThisChar=substr(UrlIn,CharPosn,2)
  10757. CharPosn=CharPosn+2
  10758. if CharPosn>(UrlCount+1)then
  10759. CryAndDie('Invalid URL encoding of "%' || strip(ThisChar) || '" at end of URL')
  10760. ThisChar=x2c(ThisChar)
  10761. end
  10762. end
  10763. UrlOut=UrlOut||ThisChar
  10764. end
  10765. return(UrlOut)
  10766.  
  10767. Warning:call TRACE "OFF"
  10768. call OutputWarningToScreen arg(1),arg(2)
  10769. return(0)
  10770.  
  10771. Error:call TRACE "OFF"
  10772. 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)
  10773. return(0)
  10774.  
  10775. Info:call TRACE "OFF"
  10776. call OutputInformationToScreen arg(1)
  10777. return(0)
  10778.  
  10779. DieIfIoErrorOccurred:call TRACE "OFF"
  10780. od!F=arg(1)
  10781. if OptionDebugOn='Y' then
  10782. call DBG_EVALUATE 'DieIfIoErrorOccurred("' || od!F || '")'
  10783. FileState=FileState(od!F)
  10784. if FileState='READY' then
  10785. return
  10786. IoReason=FileDescription(od!F)
  10787. if IoReason\=='NOTREADY:EOF' then
  10788. do
  10789. if RexWhich='REGINA' & IoReason = '' then
  10790. do
  10791. if OptionDebugOn='Y' then
  10792. do
  10793. call DBG 'DieIfIoErrorOccurred(): Bug first reported to Mark Hessling 3/10/99 for 0.08h beta'
  10794. call DBGIND 1
  10795. call DBG 'I/O failure on "' || od!F || '" (' || IoReason || ').'
  10796. call DBGIND-1
  10797. end
  10798. return
  10799. end
  10800. call _FileClose od!F
  10801. call CryAndDie 'I/O failure on "' || od!F || '" (' || IoReason || ').'
  10802. end
  10803. return
  10804.  
  10805. _ValidateIcLevel:
  10806. pd!L=arg(1)
  10807. if pd!L='' then
  10808. pd!L=IncludeLevel
  10809. if datatype(pd!L, 'WholeNumber')<>1 then
  10810. return(0)
  10811. if pd!L<1|pd!L>IncludeLevel then
  10812. return(0)
  10813. return(pd!L)
  10814.  
  10815. InputComponentLevel:call TRACE "OFF"
  10816. if OptionDebugOn='Y' then
  10817. call DBG_EVALUATE 'InputComponentLevel()'
  10818. qd!L=_ValidateIcLevel(arg(1))
  10819. if qd!L=0 then
  10820. return('')
  10821. else
  10822. return(IncludeFileName.qd!L)
  10823.  
  10824. InputComponentLineLevel:call TRACE "OFF"
  10825. if OptionDebugOn='Y' then
  10826. call DBG_EVALUATE 'InputComponentLineLevel()'
  10827. rd!L=_ValidateIcLevel(arg(1))
  10828. if rd!L=0 then
  10829. return('')
  10830. else
  10831. return(GetLineNumber4Level(rd!L))
  10832.  
  10833. GetLineNumber4Level:
  10834. sd!L=arg(1)
  10835. if sd!L=IncludeLevel then
  10836. return(IncludeLineNumber)
  10837. else
  10838. return(_IncludeLineNumber.sd!L)
  10839.  
  10840. FileSlashReduction:call TRACE "OFF"
  10841. parse arg td!F,td!M
  10842. if td!M='' then
  10843. td!M=OptionFileSR
  10844. call DBG 'FileSlashReduction(' || td!F || ') in "' || td!M || '" mode'
  10845. call DBGIND 1
  10846. td!M=translate(td!M)
  10847. if td!M<> 'NONE' then
  10848. do
  10849. if td!M='UNC' then
  10850. do
  10851. parse var td!F td!P+1 td!F
  10852. end
  10853. else
  10854. do
  10855. if td!M<> 'ALL' then
  10856. CryAndDie('Invalid file slash reduction mode of "' || td!M || '"')
  10857. else
  10858. do
  10859. td!P=''
  10860. end
  10861. end
  10862. do until td!PC=ReplaceCount
  10863. td!PC=ReplaceCount
  10864. td!F=ReplaceString(td!F,RexDirChar||RexDirChar,RexDirChar)
  10865. end
  10866. td!F=td!P||td!F
  10867. end
  10868. call DBG 'Returning "' || td!F || '"'
  10869. call DBGIND-1
  10870. return(td!F)
  10871.  
  10872. GenerateFileName:call TRACE "OFF"
  10873. parse arg ud!SrcFile,ud!EdtMsk
  10874. if OptionDebugOn='Y' then
  10875. do
  10876. call DBG 'GenerateFileName(' || ud!SrcFile || ') using "' || ud!EdtMsk || '"'
  10877. call DBGIND 1
  10878. call DBG 'Current directory is "' || GetCurrentDirectory() || '"'
  10879. end
  10880. ShortName=_filespec('name',ud!SrcFile)
  10881. ShortNameNE=_filespec('withoutextn',ShortName)
  10882. InputPath=_filespec('location',ud!SrcFile)
  10883. ud!Full=ReplaceString(ud!EdtMsk, "?",InputPath)
  10884. ud!Full=ReplaceString(ud!Full, "*.*",ShortName)
  10885. ud!Full=ReplaceString(ud!Full, "*",ShortNameNE)
  10886. ud!Full=ReplaceString(ud!Full, "{$PATH}",InputPath)
  10887. ud!Full=ReplaceString(ud!Full, "{$BASE}",ShortNameNE)
  10888. ud!Full=ReplaceString(ud!Full, "{$SHORT}",ShortName)
  10889. ud!Full=ReplaceString(ud!Full, "{$FULL}",ud!SrcFile)
  10890. ud!Full=ReplaceString(ud!Full, "{$OutputDir}",OptionOutputDefDir)
  10891. if pos('{$path}',ud!Full)<>0 then
  10892. do
  10893. call DBGIND 1
  10894. ud!Bd=BaseDir4CurrentInputFile
  10895. call DBG '{$path} found, base directory is "' || ud!Bd || '"'
  10896. call ValidateBaseDirUse ud!BD,ud!SrcFile
  10897. ud!SrcDir=_filespec('Location',ud!SrcFile)
  10898. ud!RelDir=substr(ud!SrcDir,length(ud!Bd)+1)
  10899. call DBG '{$path} = "' || ud!RelDir || '"'
  10900. ud!Full=ReplaceString(ud!Full, "{$path}",ud!RelDir)
  10901. call DBGIND-1
  10902. end
  10903. ud!Full=FileSlashReduction(ud!Full)
  10904. ud!Full=EnsureFileHasCorrectCase(ud!Full)
  10905. if OptionDebugOn='Y' then
  10906. call DBG 'Generated Name = "' || ud!Full || '"'
  10907. if OptionDebugOn='Y' then
  10908. call DBGIND 1
  10909. call MakeDirectoryTree _filespec('drive', ud!Full) || _filespec('path',ud!Full)
  10910. if OptionDebugOn='Y' then
  10911. call DBGIND-2
  10912. return(ud!Full)
  10913.  
  10914. ProcessNext:call TRACE "OFF"
  10915. if OptionDebugOn='Y' then
  10916. call DBG_EVALUATE 'ProcessNext()'
  10917. do
  10918. if InLoop='Y' &LoopLinesFromFile=0 then
  10919. do
  10920. if IncludeLoopMemBufferNextLine=='' then
  10921. IncludeLoopMemBufferNextLine=arg(1)
  10922. else
  10923. IncludeLoopMemBufferNextLine=arg(1)||MarksNewLine||IncludeLoopMemBufferNextLine
  10924. end
  10925. else
  10926. do
  10927. if IncludeMemBufferNextLine=='' then
  10928. IncludeMemBufferNextLine=arg(1)
  10929. else
  10930. IncludeMemBufferNextLine=arg(1)||MarksNewLine||IncludeMemBufferNextLine
  10931. end
  10932. end
  10933. return
  10934.  
  10935. Tabs2Spaces:call TRACE "OFF"
  10936. if OptionDebugOn='Y' then
  10937. call DBG_EVALUATE 'Tabs2Spaces()'
  10938.  
  10939. ExpandTabs:
  10940. parse arg t2sRightBit,t2sTabWidth
  10941. if pos('09'x,t2sRightBit)=0 then
  10942. return(t2sRightBit)
  10943. t2sLeftBit=''
  10944. t2sLeftBitL=0
  10945. t2sTabPos=pos('09'x,t2sRightBit)
  10946. if t2sTabWidth='' then
  10947. t2sTabWidth=8
  10948. do while t2sTabPos<>0
  10949. t2sLeftBit=t2sLeftBit||left(t2sRightBit,t2sTabPos-1)
  10950. t2sLeftBitL=t2sLeftBitL+(t2sTabPos-1)
  10951. Spaces4Tab=t2sTabWidth-((t2sLeftBitL+1)//t2sTabWidth)
  10952. t2sLeftBit=t2sLeftBit||copies(' ',Spaces4Tab)
  10953. t2sLeftBitL=t2sLeftBitL+Spaces4Tab
  10954. t2sRightBit=substr(t2sRightBit,t2sTabPos+1)
  10955. t2sTabPos=pos('09'x,t2sRightBit)
  10956. end
  10957. return(t2sLeftBit||t2sRightBit)
  10958.  
  10959. RexxVarDefined:call TRACE "OFF"
  10960. if OptionDebugOn='Y' then
  10961. call DBG_EVALUATE 'RexxVarDefined()'
  10962. vsValue=symbol(arg(1))
  10963. if vsValue='BAD' then
  10964. do
  10965. vsLength=length(arg(1))
  10966. if symbol(copies('A', vsLength)) <> 'BAD' then
  10967. Reason=''
  10968. else
  10969. Reason='A symbol length of "' || vsLength || ' bytes seems to be too long for your rexx interpreter!'
  10970. CryAndDie('RexxVarDefined()', 'Invalid symbol of "' || arg(1) || '" passed.',Reason)
  10971. end
  10972. if vsValue='VAR' then
  10973. return(1)
  10974. else
  10975. return(0)
  10976.  
  10977. ReplaceCurlyHexCodes:call TRACE "OFF"
  10978. if OptionDebugOn='Y' then
  10979. call DBG_EVALUATE 'ReplaceCurlyHexCodes()'
  10980. Before=arg(1)
  10981. RightBit=Before
  10982. LeftBit=''
  10983. StartPos=pos('{x',RightBit)
  10984. do while StartPos<>0
  10985. Codes2=substr(RightBit,StartPos+2,2)
  10986. if datatype(Codes2, 'X') <> 1 | substr(RightBit, StartPos+4, 1) <> '}' then
  10987. do
  10988. LeftBit=LeftBit||left(RightBit,StartPos+1)
  10989. RightBit=substr(RightBit,StartPos+2)
  10990. end
  10991. else
  10992. do
  10993. LeftBit=LeftBit||left(RightBit,StartPos-1)||x2c(Codes2)
  10994. RightBit=substr(RightBit,StartPos+5)
  10995. end
  10996. StartPos=pos('{x',RightBit)
  10997. end
  10998. LeftBit=LeftBit||RightBit
  10999. if OptionDebugOn='Y' then
  11000. do
  11001. if Before<>LeftBit then
  11002. call DebugOutputAfterReplacement LeftBit, '{xXX}'
  11003. end
  11004. return(LeftBit)
  11005.  
  11006. RandomString:call TRACE "OFF"
  11007. parse arg RsString,RsPickFrom
  11008. if RsPickFrom='' then
  11009. RsPickFrom=DecimalDigits||UpperCase
  11010. RsMax=length(RsPickFrom)
  11011. QPos=pos('?',RsString)
  11012. do while QPos<>0
  11013. RsString=left(RsString,QPos-1)||substr(RsPickFrom,random(1,RsMax),1)||substr(RsString,QPos+1)
  11014. QPos=pos('?',RsString)
  11015. end
  11016. return(RsString)
  11017.  
  11018. _FindFileInPathList:
  11019. parse arg vd!Look4,vd!PathList
  11020. call DBGIND 1
  11021. if OptionDebugOn='Y' then
  11022. call DBG_EVALUATE 'Searching for "' || vd!Look4 || '" in "' || vd!PathList || '"'
  11023. if RexSystemOpSys="UNIX" then
  11024. vd!SepChar=':'
  11025. else
  11026. vd!SepChar=';'
  11027. vd!Found=''
  11028. do while vd!PathList<> ''
  11029. parse var vd!PathList vd!Path (vd!SepChar) vd!PathList
  11030. if right(vd!Path,1)<>RexDirChar then
  11031. vd!Path=vd!Path||RexDirChar
  11032. vd!Found=_FileQueryExists(vd!Path||vd!Look4)
  11033. if vd!Found<> '' then
  11034. leave
  11035. end
  11036. if OptionDebugOn='Y' then
  11037. call DBG_EVALUATE 'Found "' || vd!Found || '"'
  11038. call DBGIND-1
  11039. return(vd!Found)
  11040.  
  11041. FindFileInPath:call TRACE "OFF"
  11042. parse arg wd!Look4,wd!LookIn
  11043. if RexSystemOpSys="UNIX" then
  11044. wd!SepChar=':'
  11045. else
  11046. wd!SepChar=';'
  11047. if OptionDebugOn='Y' then
  11048. call DBG_EVALUATE 'FindFileInPath(): Looking for "' || wd!Look4 || '" in "' || wd!LookIn || '"'
  11049. call DBGIND 1
  11050. wd!Searched=''
  11051. do while wd!LookIn<> ''
  11052. parse var wd!LookIn wd!ThisBit (wd!SepChar) wd!LookIn
  11053. if wd!ThisBit='' then
  11054. iterate
  11055. wd!Left1=left(wd!ThisBit,1)
  11056. select
  11057. when wd!Left1='*' then
  11058. do
  11059. wd!LookIn=GetEnv(substr(wd!ThisBit,2))||wd!SepChar||wd!LookIn
  11060. end
  11061. when wd!Left1='+' then
  11062. do
  11063. wd!Comb=substr(wd!ThisBit,2)
  11064. wd!Mask=wd!Comb
  11065. if right(wd!Mask,1)<>RexDirChar then
  11066. wd!Mask=wd!Mask||RexDirChar
  11067. wd!Mask=wd!Mask|| '*.*'
  11068. wd!List.0=0
  11069. call Dirs4Mask wd!Mask, 'wd!List', 'Y'
  11070. do wd!Index=1 to wd!List.0
  11071. wd!Comb=wd!Comb||wd!SepChar||wd!List.wd!Index
  11072. end
  11073. wd!LookIn=wd!Comb||wd!SepChar||wd!LookIn
  11074. end
  11075. otherwise
  11076. do
  11077. if wd!Searched='' then
  11078. wd!Searched=wd!ThisBit
  11079. else
  11080. wd!Searched=wd!Searched||wd!SepChar||wd!ThisBit
  11081. end
  11082. end
  11083. end
  11084. wd!Found=_FindFileInPathList(wd!Look4,wd!Searched)
  11085. if wd!Found<> '' then
  11086. wd!Found=FileQueryExists(wd!Found)
  11087. if OptionDebugOn='Y' then
  11088. call DBG_EVALUATE 'Result: "' || wd!Found || '"'
  11089. call DBGIND-1
  11090. return(wd!Found)
  11091.  
  11092. IncludePath:call TRACE "OFF"
  11093. xd!P=arg(1)
  11094. if xd!P='' then
  11095. OptionIncludePathCnt=0
  11096. else
  11097. do
  11098. OptionIncludePathCnt=OptionIncludePathCnt+1
  11099. OptionIncludePath.OptionIncludePathCnt=xd!P
  11100. end
  11101. return
  11102.  
  11103. FindFile:call TRACE "OFF"
  11104. parse arg yd!Look4,yd!Die
  11105. yd!Found=''
  11106. if OptionDebugOn='Y' then
  11107. call DBG_EVALUATE 'FindFile(): Looking for "' || yd!Look4 || '"'
  11108. call DBGIND 1
  11109. if yd!Found='' then
  11110. do
  11111. call DBG_EVALUATE 'Looking in current directory'
  11112. yd!Found=FileQueryExists(yd!Look4)
  11113. end
  11114. if yd!Found='' then
  11115. do
  11116. if symbol("InputFileFull") = 'VAR' then
  11117. do
  11118. call DBG_EVALUATE 'Looking in same directory the input file "' || InputFileFull || '"'
  11119. yd!Found=_filespec('Location',InputFileFull)||yd!Look4
  11120. if FileQueryExists(yd!Found)='' then
  11121. yd!Found=''
  11122. end
  11123. end
  11124. if yd!Found='' then
  11125. do
  11126. do yd!Index=1 to OptionIncludePathCnt until yd!Found<> ''
  11127. yd!Found=FindFileInPath(yd!Look4,OptionIncludePath.yd!Index)
  11128. end
  11129. end
  11130. if yd!Found='' then
  11131. yd!Found=FindFileInPath(yd!Look4, '*PPWIZARD_INCLUDE')
  11132. if yd!Found='' then
  11133. yd!Found=FindFileInPath(yd!Look4, '*INCLUDE')
  11134. if yd!Found='' then
  11135. do
  11136. call DBG_EVALUATE 'Looking in same directory as PPWIZARD'
  11137. parse source . . yd!Found
  11138. yd!Found=_filespec('Location',yd!Found)||yd!Look4
  11139. if FileQueryExists(yd!Found)='' then
  11140. yd!Found=''
  11141. end
  11142. if yd!Found<> '' then
  11143. yd!Found=FileQueryExists(yd!Found)
  11144. if OptionDebugOn='Y' then
  11145. call DBG_EVALUATE 'Result: "' || yd!Found || '"'
  11146. if yd!Found='' then
  11147. do
  11148. if yd!Die<> '' then
  11149. do
  11150. if yd!Die='!' then
  11151. yd!T=''
  11152. else
  11153. yd!T=yd!Die|| ' '
  11154. CryAndDie('The ' || yd!T || 'file "' || yd!Look4 || '" could not be found!')
  11155. end
  11156. end
  11157. call DBGIND-1
  11158. return(yd!Found)
  11159.  
  11160. _SysSearchPath:call TRACE "OFF"
  11161. return(FindFileInPath(arg(2), '*' ||arg(1)))
  11162.  
  11163. SSTRIP:call TRACE "OFF"
  11164. parse arg zd!S,zd!M,zd!C
  11165. if zd!M=='' then
  11166. zd!M='B'
  11167. if zd!C=='' then
  11168. zd!C='00'x
  11169. zd!S=translate(zd!S, '', zd!C, ' ')
  11170. return(strip(zd!S,zd!M))
  11171.  
  11172. Add2:call TRACE "OFF"
  11173. parse arg ae!V,ae!S
  11174. if ae!S<> '' then
  11175. Add2Stem=ae!S|| '.'
  11176. if Add2Stem='' then
  11177. CryAndDie("Add to which array?")
  11178. ae!CV=Add2Stem|| '0'
  11179. if symbol(ae!CV)<> 'VAR' then
  11180. ae!C=0
  11181. else
  11182. ae!C=value(ae!CV)
  11183. ae!C=ae!C+1
  11184. call value Add2Stem||ae!C,ae!V
  11185. call value ae!CV,ae!C
  11186. return(ae!C)
  11187.  
  11188. OptionGet:call TRACE "OFF"
  11189. if OptionDebugOn='Y' then
  11190. call DBG_EVALUATE 'OptionGet()'
  11191. call DBGIND 1
  11192. be!Ans=OptionGetValue(arg(1))
  11193. call DBGIND-1
  11194. return(be!Ans)
  11195.  
  11196. OptionSet:call TRACE "OFF"
  11197. if OptionDebugOn='Y' then
  11198. call DBG_EVALUATE 'OptionSet()'
  11199. call DBGIND 1
  11200. call OptionSetValue arg(1),arg(2)
  11201. call DBGIND-1
  11202. return
  11203.  
  11204. MakeWebLinks:call TRACE "OFF"
  11205. parse arg ce!R,ce!ProtU,ce!T
  11206. ce!Prot=ce!ProtU|| '://'
  11207. ce!Pos=pos(ce!Prot,ce!R)
  11208. if ce!Pos=0 then
  11209. return(ce!R)
  11210. if ce!ProtU='ftp' then
  11211. ce!Valid=_ValCharsFtp
  11212. else
  11213. ce!Valid=_ValCharsHttp
  11214. ce!ProtL=length(ce!Prot)
  11215. if ce!T='' then
  11216. ce!T='<a href="{URL}">{URL}</a>'
  11217. ce!L=''
  11218. do until ce!Pos=0
  11219. ce!L=ce!L||left(ce!R,ce!Pos-1)
  11220. ce!R=substr(ce!R,ce!Pos)
  11221. ce!Pos=verify(ce!R,ce!Valid, 'N')
  11222. if ce!Pos=0 then
  11223. do
  11224. ce!Url=ce!R
  11225. ce!R=''
  11226. end
  11227. else
  11228. do
  11229. ce!Url=left(ce!R,ce!Pos-1)
  11230. ce!R=substr(ce!R,ce!Pos)
  11231. end
  11232. ce!Insert=ReplaceString(ce!T, "{URL}",ce!Url)
  11233. ce!Insert=ReplaceString(ce!Insert, "{URL-}",substr(ce!Url,ce!ProtL+1))
  11234. ce!L=ce!L||ce!Insert
  11235. ce!Pos=pos(ce!Prot,ce!R)
  11236. end
  11237. return(ce!L||ce!R)
  11238.  
  11239. TimeStamp:call TRACE "OFF"
  11240. parse arg de!CmdList,de!Ts
  11241. de!AddSec=0
  11242. do while de!CmdList<> ''
  11243. parse var de!CmdList de!Cmd de!CmdList
  11244. de!Unit=translate(right(de!Cmd,1))
  11245. de!Units=left(de!Cmd,length(de!Cmd)-1)
  11246. select
  11247. when de!Unit='W' then
  11248. de!CmdSec=de!Units*604800
  11249. when de!Unit='D' then
  11250. de!CmdSec=de!Units*86400
  11251. when de!Unit='H' then
  11252. de!CmdSec=de!Units*3600
  11253. when de!Unit='M' then
  11254. de!CmdSec=de!Units*60
  11255. when de!Unit='S' then
  11256. de!CmdSec=de!Units
  11257. otherwise
  11258. de!CmdSec=de!Cmd
  11259. end
  11260. de!AddSec=de!AddSec+de!CmdSec
  11261. end
  11262. if de!Ts='' then
  11263. do
  11264. de!Bd=basedate()
  11265. de!Sec=time('S')
  11266. end
  11267. else
  11268. do
  11269. de!Bd=basedate(left(de!Ts,8))
  11270. parse value substr(de!Ts,9)with de!HH+2 de!MM+2 de!SS
  11271. de!Sec=(de!HH*3600)+(de!MM*60)+de!SS
  11272. end
  11273. de!TotSec=de!Sec+de!AddSec
  11274. de!PlusDay=de!TotSec%86400
  11275. de!Sec=de!TotSec//86400
  11276. de!Date=Bd2Date(de!Bd+de!PlusDay)
  11277. de!HH=right(de!Sec%3600,2, '0')
  11278. de!Sec=de!Sec//3600
  11279. de!MM=right(de!Sec%60,2, '0')
  11280. de!Sec=de!Sec//60
  11281. de!SS=right(de!Sec,2, '0')
  11282. return(de!Date||de!HH||de!MM||de!SS)
  11283.  
  11284. ArraySplit:call TRACE "OFF"
  11285. parse arg ee!Stem,ee!Value,ee!Del,ee!Spaces,ee!KeepBlank
  11286. ee!Stem=ee!Stem|| '.'
  11287. if ee!Del=='' then
  11288. ee!Del=' '
  11289. if ee!Spaces='' then
  11290. ee!Spaces='B'
  11291. ee!Cnt=0
  11292. do while ee!Value\==''
  11293. parse var ee!Value ee!Before (ee!Del) ee!Value
  11294. if ee!Spaces<> 'K' then
  11295. do
  11296. if ee!Spaces='BM' then
  11297. ee!Before=space(ee!Before)
  11298. else
  11299. ee!Before=strip(ee!Before,ee!Spaces)
  11300. end
  11301. if ee!Before='' then
  11302. do
  11303. if ee!KeepBlank<> 'Y' then
  11304. iterate
  11305. end
  11306. ee!Cnt=ee!Cnt+1
  11307. call _valueS ee!Stem||ee!Cnt,ee!Before
  11308. end
  11309. call _valueS ee!Stem|| '0',ee!Cnt
  11310. return(ee!Cnt)
  11311.  
  11312. ArrayRemoveDup:
  11313. parse arg fe!Stem,fe!MaxInRow
  11314. if fe!MaxInRow='' then
  11315. fe!MaxRpt=0
  11316. else
  11317. fe!MaxRpt=fe!MaxInRow-1
  11318. fe!Stem=fe!Stem|| '.'
  11319. fe!End=value(fe!Stem|| '0')
  11320. fe!DstI=0
  11321. fe!Last=''
  11322. fe!RepeatCnt=0
  11323. do fe!SrcI=1 to fe!End
  11324. fe!Value=value(fe!Stem||fe!SrcI)
  11325. if fe!Value\==fe!Last then
  11326. fe!RepeatCnt=0
  11327. else
  11328. do
  11329. if fe!SrcI<>1 then
  11330. do
  11331. fe!RepeatCnt=fe!RepeatCnt+1
  11332. if fe!RepeatCnt>fe!MaxRpt then
  11333. iterate
  11334. end
  11335. end
  11336. fe!Last=fe!Value
  11337. fe!DstI=fe!DstI+1
  11338. call value fe!Stem||fe!DstI,fe!Value
  11339. end
  11340. call value fe!Stem|| '0',fe!DstI
  11341. return(fe!DstI)
  11342.  
  11343. ArrayTranslate:
  11344. parse arg ge!Stem,ge!Spaces,ge!Case
  11345. ge!Stem=ge!Stem|| '.'
  11346. if ge!Spaces='' then
  11347. ge!Spaces='B'
  11348. ge!End=value(ge!Stem|| '0')
  11349. do ge!SrcI=1 to ge!End
  11350. ge!Value=value(ge!Stem||ge!SrcI)
  11351. if ge!Spaces<> 'K' then
  11352. do
  11353. if ge!Spaces='BM' then
  11354. ge!Value=space(ge!Value)
  11355. else
  11356. ge!Value=strip(ge!Value,ge!Spaces)
  11357. end
  11358. if ge!Case<> '' then
  11359. do
  11360. if ge!Case='L' then
  11361. ge!Value=ToLowerCase(ge!Value)
  11362. else
  11363. ge!Value=ToUpperCase(ge!Value)
  11364. end
  11365. call value ge!Stem||ge!SrcI,ge!Value
  11366. end
  11367. return(ge!End)
  11368.  
  11369. ReverseArray:
  11370.  
  11371. ArrayReverse:call TRACE "OFF"
  11372. if OptionDebugOn='Y' then
  11373. call DBG_EVALUATE 'ReverseArray()'
  11374. riArray=translate(arg(1))|| '.'
  11375. riCount=_valueG(riArray||0)
  11376. riHalfWay=riCount%2
  11377. do riFrom=1 to riHalfWay
  11378. riTo=(riCount-riFrom)+1
  11379. riTemp=_valueG(riArray||riFrom)
  11380. call _valueS riArray||riFrom,_valueG(riArray||riTo)
  11381. call _valueS riArray||riTo,riTemp
  11382. end
  11383. return(riCount)
  11384.  
  11385. MakeDirectoryTree:call TRACE "OFF"
  11386. parse arg he!Tree,he!Die
  11387. if he!Die='' then
  11388. he!Die='N'
  11389. if right(he!Tree,1)=RexDirChar then
  11390. he!Tree=left(he!Tree,length(he!Tree)-1)
  11391. if he!Tree='' then
  11392. return(0)
  11393. if OptionDebugOn='Y' then
  11394. do
  11395. call DBG 'MakeDirectoryTree("' || he!Tree || '")'
  11396. call DBGIND 1
  11397. end
  11398. if DirQueryExists(he!Tree)<> '' then
  11399. do
  11400. if OptionDebugOn='Y' then
  11401. do
  11402. call DBG 'Directory already exists (no need to make)'
  11403. call DBGIND-1
  11404. end
  11405. return(0)
  11406. end
  11407. if RexSystemOpSys="DOS" then
  11408. he!Dq=''
  11409. else
  11410. he!Dq='"'
  11411. if RexSystemOpSys="UNIX" then
  11412. MakeDirCmd='mkdir '
  11413. else
  11414. MakeDirCmd='md '
  11415. SearchFromPosn=1
  11416. do until SlashPosn=0
  11417. SlashPosn=pos(RexDirChar,he!Tree,SearchFromPosn)
  11418. if SlashPosn<>1 then
  11419. do
  11420. if SlashPosn=0 then
  11421. MakeDir=he!Tree
  11422. else
  11423. MakeDir=left(he!Tree,SlashPosn-1)
  11424. DirBit=filespec('name',MakeDir)
  11425. if right(MakeDir,1)<> ':' & DirBit <> '.' & DirBit <> '..' then
  11426. do
  11427. if OptionDebugOn='N' then
  11428. call AddressCmd MakeDirCmd||he!Dq||MakeDir||he!Dq||AllCmdOutput2Nul()
  11429. else
  11430. do
  11431. TmpMkDirFile=RexGetTmpFileName()
  11432. call AddressCmd MakeDirCmd||he!Dq||MakeDir||he!Dq||RedirectStdOutAndErr2(TmpMkDirFile),TmpMkDirFile
  11433. if Rc=0 then
  11434. call DBG 'Made Directory "' || MakeDir || '"'
  11435. call _SysFileDelete TmpMkDirFile
  11436. end
  11437. end
  11438. end
  11439. SearchFromPosn=SlashPosn+1
  11440. end
  11441. if DirQueryExists(he!Tree)<> '' then
  11442. he!Rc=0
  11443. else
  11444. do
  11445. he!Rc=3
  11446. he!T='We failed to create the "' || he!Tree || '" directory!'
  11447. if OptionDebugOn='Y' then
  11448. call DBG he!T
  11449. if he!Die<> 'N' then
  11450. CryAndDie(he!T)
  11451. end
  11452. if OptionDebugOn='Y' then
  11453. call DBGIND-1
  11454. return(he!Rc)
  11455.  
  11456. HhMmSs2Seconds:
  11457. parse value arg(1)with he!HH+2 he!MM+2 he!SS
  11458. return((he!HH*3600)+(he!MM*60)+he!SS)
  11459.  
  11460. AreFilesEqual:
  11461. parse arg ie!F1,ie!F2,ie!Fuzz
  11462. if ie!Fuzz='' then
  11463. ie!Fuzz=0
  11464. call DBG 'AreFilesEqual?: "' || ie!F1 || '" <-> "' || ie!F2 || '" (Fuzziness of ' || ie!Fuzz || ' seconds)'
  11465. call DBGIND 1
  11466. if FileQueryExists(ie!F1)='' then
  11467. ie!Rc='The file "' || ie!F1 || '" does not exist.'
  11468. else
  11469. do
  11470. if FileQueryExists(ie!F2)='' then
  11471. ie!Rc='The file "' || ie!F2 || '" does not exist.'
  11472. else
  11473. do
  11474. ie!1s=stream(ie!F1, 'c', 'query size')
  11475. ie!2s=stream(ie!F2, 'c', 'query size')
  11476. ie!1t=GetFileTimeStamp(ie!F1, 'Q')
  11477. ie!2t=GetFileTimeStamp(ie!F2, 'Q')
  11478. call DBG 'SRC: ' || ie!1s || ' - ' ||ie!1t
  11479. call DBG 'DST: ' || ie!2s || ' - ' ||ie!2t
  11480. if ie!1s<>ie!2s then
  11481. ie!Rc='File sizes differ'
  11482. else
  11483. do
  11484. parse var ie!1t ie!1dd+8 ie!1dt
  11485. parse var ie!2t ie!2dd+8 ie!2dt
  11486. if ie!1dd<>ie!2dd then
  11487. ie!Rc='Files created on different days'
  11488. else
  11489. do
  11490. ie!Diff=abs(HhMmSs2Seconds(ie!2dt)-HhMmSs2Seconds(ie!1dt))
  11491. call DBG '     Files differ by ' || ie!Diff || ' seconds'
  11492. if ie!Diff>ie!Fuzz then
  11493. ie!Rc='Files differ by more than ' || ie!Fuzz || ' seconds.'
  11494. else
  11495. ie!Rc=''
  11496. end
  11497. end
  11498. end
  11499. end
  11500. call DBG 'Rc = "' || ie!Rc || '"'
  11501. call DBGIND-1
  11502. return(ie!Rc)
  11503.  
  11504. FileCopy:call TRACE "OFF"
  11505. parse arg je!Src,je!Dst,je!When,je!ContOnError
  11506. call DBG 'Copy "' || je!Src || '" to "' || je!Dst || '"?'
  11507. if FileQueryExists(je!Src)='' then
  11508. do
  11509. if je!ContOnError<> 'Y' then
  11510. CryAndDie('The FileCopy() source file "' || je!Src || '" does not exist...')
  11511. return(2)
  11512. end
  11513. call DBGIND 1
  11514. je!When=translate(je!When)
  11515. je!Do=''
  11516. select
  11517. when je!When='' then
  11518. je!Do='We always copy'
  11519. when left(je!When,5)='EQUAL' then
  11520. do
  11521. parse var je!When . ':' je!Fuzz
  11522. je!Do=AreFilesEqual(je!Src,je!Dst,je!Fuzz)
  11523. end
  11524. otherwise
  11525. CryAndDie('Unknown FileCopy() mode of "' || je!When || '"')
  11526. end
  11527. if je!Do<> '' then
  11528. call DBG 'Source will be copied: ' ||je!Do
  11529. else
  11530. do
  11531. call DBG 'The source does not need copying'
  11532. call DBGIND-1
  11533. return(0)
  11534. end
  11535. call AddInputFileToDependancyList je!Src
  11536. call AddOutputFileToDependancyList je!Dst
  11537. je!QSD='"' || je!Src || '" "' || je!Dst || '"'
  11538. select
  11539. when RexSystemOpSys="UNIX" then
  11540. je!CpyS='cp --force --verbose'
  11541. when RexSystemOpSys="WIN32" then
  11542. do
  11543. if RexSystemOpSysREAL="WINNT" then
  11544. je!CpyS='copy /B'
  11545. else
  11546. je!CpyS='copy /Y /B'
  11547. end
  11548. when RexSystemOpSys="OS/2" then
  11549. je!CpyS='copy'
  11550. otherwise
  11551. je!CpyS='copy'
  11552. end
  11553. CopyCmd=je!CpyS|| ' ' ||je!QSD
  11554. TmpMkDirFile=RexGetTmpFileName()
  11555. je!CpyRc=AddressCmd(CopyCmd||RedirectStdOutAndErr2(TmpMkDirFile),TmpMkDirFile)
  11556. if je!CpyRc=0 then
  11557. call DBG 'File successfully copied'
  11558. else
  11559. do
  11560. call DBG 'Copy failed'
  11561. if je!ContOnError<> 'Y' then
  11562. do
  11563. do je!i=1 to 5
  11564. je!L.je!i=linein(TmpMkDirFile)
  11565. end
  11566. call FileDelete TmpMkDirFile, 'N'
  11567. CryAndDie('File copy failed (Rc=' || je!CpyRc || ')!', 'From: "' || je!Src || '"', 'To  : "' || je!Dst || '"', "",je!L.1,je!L.2,je!L.3,je!L.4,je!L.5)
  11568. end
  11569. end
  11570. call FileDelete TmpMkDirFile, 'N'
  11571. call DBGIND-1
  11572. return(je!CpyRc)
  11573.  
  11574. QuoteAsRexxLit:call TRACE "OFF"
  11575. return( "'" || ReplaceString(arg(1), "'", "''") || "'" )
  11576.  
  11577. FormatNumber:call TRACE "OFF"
  11578. parse arg ke!Numb,ke!Fmt
  11579. if ke!Fmt='' then
  11580. ke!Fmt='%,%N'
  11581. if OptionDebugOn='Y' then
  11582. do
  11583. call DBG_EVALUATE 'FormatInt(' || ke!Numb || ') - ' ||ke!Fmt
  11584. call DBGIND 1
  11585. end
  11586. parse var ke!Numb ke!Int '.' ke!Rem
  11587. ke!Comma='N'
  11588. ke!R=''
  11589. ke!Pos=pos('%',ke!Fmt)
  11590. ke!LN=ke!Numb
  11591. do while ke!Pos<>0
  11592. ke!R=ke!R||left(ke!Fmt,ke!Pos-1)
  11593. ke!C=substr(ke!Fmt,ke!Pos+1,1)
  11594. ke!Fmt=substr(ke!Fmt,ke!Pos+2)
  11595. ke!Div=0
  11596. ke!N=''
  11597. ke!Ac='N'
  11598. select
  11599. when ke!C='?' then
  11600. do
  11601. parse var ke!Fmt ke!1 ',' ke!2 ';' ke!Fmt
  11602. if ke!LN=1 then
  11603. ke!N=ke!1
  11604. else
  11605. ke!N=ke!2
  11606. end
  11607. when ke!C='N' then
  11608. do
  11609. ke!N=ke!Numb
  11610. ke!LN=ke!N
  11611. ke!Ac='Y'
  11612. end
  11613. when ke!C='I' then
  11614. do
  11615. ke!N=ke!Int
  11616. ke!LN=ke!N
  11617. ke!Ac='Y'
  11618. end
  11619. when ke!C='1' then
  11620. ke!N=left(ke!Rem,1, '0')
  11621. when ke!C='2' then
  11622. ke!N=left(ke!Rem,2, '0')
  11623. when ke!C='3' then
  11624. ke!N=left(ke!Rem,3, '0')
  11625. when ke!C='4' then
  11626. ke!N=left(ke!Rem,4, '0')
  11627. when ke!C='R' then
  11628. ke!N=ke!Rem
  11629. when ke!C='K' then
  11630. ke!Div=1024
  11631. when ke!C='k' then
  11632. ke!Div=1000
  11633. when ke!C='M' then
  11634. ke!Div=1024*1024
  11635. when ke!C='m' then
  11636. ke!Div=1000*1000
  11637. when ke!C=',' then
  11638. ke!Comma='Y'
  11639. when ke!C='_' then
  11640. ke!N=' '
  11641. when ke!C='%' then
  11642. ke!N='%'
  11643. otherwise
  11644. ke!N='%' ||ke!C
  11645. end
  11646. if ke!Div<>0 then
  11647. do
  11648. ke!N=ke!Numb%ke!Div
  11649. parse value ke!Numb/ke!Div with . '.' ke!Rem
  11650. ke!Div=0
  11651. ke!Ac='Y'
  11652. ke!LN=ke!N
  11653. end
  11654. if ke!Ac='Y' then
  11655. do
  11656. if ke!Comma='Y' then
  11657. ke!N=AddCommasToDecimalNumber(ke!N)
  11658. end
  11659. ke!R=ke!R||ke!N
  11660. ke!Pos=pos('%',ke!Fmt)
  11661. end
  11662. ke!R=ke!R||ke!Fmt
  11663. if OptionDebugOn='Y' then
  11664. do
  11665. call DBG_EVALUATE 'Returning: ' ||ke!R
  11666. call DBGIND-1
  11667. end
  11668. return(ke!R)
  11669.  
  11670. FormatTime:call TRACE "OFF"
  11671. parse arg le!Fmt,le!Ts,le!Pre
  11672. if le!Ts='' then
  11673. le!Ts=TimeStamp()
  11674. if le!Pre='' then
  11675. le!Pre='FORMATTIME'
  11676. if OptionDebugOn='Y' then
  11677. do
  11678. call DBG_EVALUATE 'FormatTime(' || le!Ts || ')'
  11679. call DBGIND 1
  11680. end
  11681. if le!Fmt=='' then
  11682. le!Fmt=CfgMacro(le!Pre|| '_DEFAULT_TIME_FORMAT', '%c')
  11683. parse var le!Ts le!YYYY+4 le!MM+2 le!DD+2 le!HH+2 le!Min+2 le!SS
  11684. le!R=''
  11685. le!Pos=pos('%',le!Fmt)
  11686. do while le!Pos<>0
  11687. le!R=le!R||left(le!Fmt,le!Pos-1)
  11688. le!C=substr(le!Fmt,le!Pos+1,1)
  11689. le!Fmt=substr(le!Fmt,le!Pos+2)
  11690. if le!HH>12 then
  11691. le!II=le!HH-12
  11692. else
  11693. le!II=le!HH+0
  11694. if le!II=0 then
  11695. le!II=12
  11696. select
  11697. when le!C='d' then
  11698. le!N=le!DD
  11699. when le!C='e' then
  11700. le!N=right(le!DD+0,2, ' ')
  11701. when le!C='#' then
  11702. le!N=le!DD+0
  11703. when le!C='m' then
  11704. le!N=le!MM
  11705. when le!C='y' then
  11706. le!N=right(le!YYYY,2)
  11707. when le!C='Y' then
  11708. le!N=le!YYYY
  11709. when le!C='H' then
  11710. le!N=le!HH
  11711. when le!C='!' then
  11712. le!N=le!HH+0
  11713. when le!C='I' then
  11714. le!N=right(le!II,2, '0')
  11715. when le!C='@' then
  11716. le!N=le!II
  11717. when le!C='M' then
  11718. le!N=le!Min
  11719. when le!C='S' then
  11720. le!N=le!SS
  11721. when le!C='j' then
  11722. le!N=right(BaseDate(le!Ts)-basedate(le!YYYY|| '0101')+1, 3, '0')
  11723. when le!C='$' then
  11724. le!N=BaseDate(le!Ts)-basedate(le!YYYY|| '0101')+1
  11725. when le!C='Z' then
  11726. le!N=''
  11727. when le!C='%' then
  11728. le!N='%'
  11729. when le!C='_' then
  11730. le!N=' '
  11731. when le!C='a' then
  11732. do
  11733. le!N=CfgMacro(le!Pre|| '_DAY_NAMES_SHORT',    'Mon Tue Wed Thu Fri Sat Sun')
  11734. le!N=word(le!N,(BaseDate(le!Ts)//7)+1)
  11735. end
  11736. when le!C='A' then
  11737. do
  11738. le!N=CfgMacro(le!Pre|| '_DAY_NAMES_LONG',    'Monday Tuesday Wednesday Thursday Friday Saturday Sunday')
  11739. le!N=word(le!N,(BaseDate(le!Ts)//7)+1)
  11740. end
  11741. when le!C='b' then
  11742. do
  11743. le!N=CfgMacro(le!Pre|| '_MONTH_NAMES_SHORT', 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec')
  11744. le!N=word(le!N,le!MM)
  11745. end
  11746. when le!C='B' then
  11747. do
  11748. le!N=CfgMacro(le!Pre|| '_MONTH_NAMES_LONG',  'January February March April May June July August September October November December')
  11749. le!N=word(le!N,le!MM)
  11750. end
  11751. when le!C='p' then
  11752. do
  11753. if le!HH>=12 then
  11754. le!N=CfgMacro(le!Pre|| '_PM_TEXT', 'pm')
  11755. else
  11756. le!N=CfgMacro(le!Pre|| '_AM_TEXT', 'am')
  11757. end
  11758. when le!C='x' then
  11759. do
  11760. le!N=CfgMacro(le!Pre|| '_DATE_FORMAT', '%a %b %# %Y')
  11761. le!Fmt=le!N||le!Fmt
  11762. le!N=''
  11763. end
  11764. when le!C='X' then
  11765. do
  11766. le!N=CfgMacro(le!Pre|| '_TIME_FORMAT', '%@:%M:%S%p')
  11767. le!Fmt=le!N||le!Fmt
  11768. le!N=''
  11769. end
  11770. when le!C='c' then
  11771. do
  11772. le!N=CfgMacro(le!Pre|| '_DATE_TIME_FORMAT', '%x at %X')
  11773. le!Fmt=le!N||le!Fmt
  11774. le!N=''
  11775. end
  11776. when le!C='D' then
  11777. do
  11778. le!Fmt='%m/%d/%y' ||le!Fmt
  11779. le!N=''
  11780. end
  11781. when le!C='v' then
  11782. do
  11783. le!Fmt='%e-%b-%Y' ||le!Fmt
  11784. le!N=''
  11785. end
  11786. when le!C='R' then
  11787. do
  11788. le!Fmt='%H:%M' ||le!Fmt
  11789. le!N=''
  11790. end
  11791. when le!C='r' then
  11792. do
  11793. le!Fmt='%I:%M:%S%p' ||le!Fmt
  11794. le!N=''
  11795. end
  11796. when le!C='T' then
  11797. do
  11798. le!Fmt='%H:%M:%S' ||le!Fmt
  11799. le!N=''
  11800. end
  11801. otherwise
  11802. le!N='%' ||le!C
  11803. end
  11804. le!R=le!R||le!N
  11805. le!Pos=pos('%',le!Fmt)
  11806. end
  11807. le!R=le!R||le!Fmt
  11808. if OptionDebugOn='Y' then
  11809. do
  11810. call DBG_EVALUATE 'Returning: ' ||le!R
  11811. call DBGIND-1
  11812. end
  11813. return(le!R)
  11814.  
  11815. GetCurrentDirectory:call TRACE "OFF"
  11816. me!Dir=DirGetCurrent()
  11817. if OptionDebugOn='Y' then
  11818. call DBG 'Current Directory = "' || me!Dir || '"'
  11819. return(me!Dir)
  11820.  
  11821. HtmlGeneratorTags:call TRACE "OFF"
  11822. parse arg ne!T,ne!G
  11823. if ne!G='Y' then
  11824. do
  11825. ne!R=OptionHtmlGeneratorTags
  11826. OptionHtmlGeneratorTags=ne!T
  11827. end
  11828. else
  11829. do
  11830. ne!R=HtmlGeneratorTags
  11831. HtmlGeneratorTags=ne!T
  11832. end
  11833. return(ne!R)
  11834.  
  11835. SortArray:
  11836.  
  11837. ArraySort:call TRACE "OFF"
  11838. if OptionDebugOn='Y' then
  11839. call DBG_EVALUATE 'ArraySort()'
  11840. parse arg oe!Array,oe!KeyFrom,oe!KeyTo,oe!Strict
  11841. oe!Array=translate(oe!Array)|| '.'
  11842. oe!Count=_valueG(oe!Array||0)
  11843. do oe!I=1 to oe!Count
  11844. oe!DATA.oe!I=_valueG(oe!Array||oe!I)
  11845. end
  11846. oe!DATA.0=oe!Count
  11847. if oe!KeyFrom=='' then
  11848. do
  11849. oe!SepKey='N'
  11850. call DBG_EVALUATE 'No separate key array'
  11851. end
  11852. else
  11853. do
  11854. oe!SepKey='Y'
  11855. oe!KEY.0=oe!DATA.0
  11856. if oe!KeyFrom=='@' then
  11857. do
  11858. if symbol('CfgLower') = 'VAR' then
  11859. do
  11860. call GetUserLcCfg
  11861. oe!KeyFrom=CfgLower
  11862. oe!KeyTo=CfgUpper
  11863. end
  11864. else
  11865. do
  11866. oe!KeyFrom=LowerCase
  11867. oe!KeyTo=UpperCase
  11868. end
  11869. end
  11870. if datatype(oe!KeyFrom, 'W')==1 then
  11871. do
  11872. call DBG_EVALUATE 'Separate key array built from columns ' || oe!KeyFrom || ' - ' ||oe!KeyTo
  11873. if oe!KeyTo='' then
  11874. oe!Length=0
  11875. else
  11876. oe!Length=oe!KeyTo-oe!KeyFrom
  11877. do oe!I=1 to oe!KEY.0
  11878. if oe!Length=0 then
  11879. do
  11880. oe!KEY.oe!I=substr(oe!DATA.oe!I,oe!KeyFrom)
  11881. end
  11882. else
  11883. do
  11884. oe!KEY.oe!I=substr(oe!DATA.oe!I,oe!KeyFrom,oe!Length)
  11885. end
  11886. end
  11887. end
  11888. else
  11889. do
  11890. if oe!KeyTo=='' then
  11891. do
  11892. oe!From=oe!KeyFrom|| '.'
  11893. call DBG_EVALUATE 'Separate key array built and passed by caller - ' ||oe!From
  11894. oe!D=oe!KEY.0
  11895. oe!K=_valueG(oe!From|| "0")
  11896. if oe!D<>oe!K then
  11897. CryAndDie("User supplied sort key array does not have correct number of elements!", "The data array has " || oe!D || " elements while the key array has " ||oe!K)
  11898. do oe!I=1 to oe!KEY.0
  11899. oe!KEY.oe!I=_valueG(oe!From||oe!I)
  11900. end
  11901. end
  11902. else
  11903. do
  11904. call DBG_EVALUATE 'Separate key array built by translation'
  11905. do oe!I=1 to oe!KEY.0
  11906. oe!KEY.oe!I=translate(oe!DATA.oe!I,oe!KeyTo,oe!KeyFrom)
  11907. end
  11908. end
  11909. end
  11910. end
  11911. oe!M=1
  11912. do while(9*oe!M+4)<oe!Count
  11913. oe!M=oe!M*3+1
  11914. end
  11915. do while oe!M>0
  11916. oe!K=oe!Count-oe!M
  11917. do oe!J=1 to oe!K
  11918. oe!Index1=oe!J
  11919. do while oe!Index1>0
  11920. oe!Index2=oe!Index1+oe!M
  11921. if oe!SepKey='N' then
  11922. do
  11923. oe!Val1=oe!DATA.oe!Index1
  11924. oe!Val2=oe!DATA.oe!Index2
  11925. end
  11926. else
  11927. do
  11928. oe!Val1=oe!Key.oe!Index1
  11929. oe!Val2=oe!Key.oe!Index2
  11930. end
  11931. if oe!Strict='Y' then
  11932. oe!Greater=oe!Val1>>oe!Val2
  11933. else
  11934. oe!Greater=oe!Val1>oe!Val2
  11935. if oe!Greater then
  11936. do
  11937. oe!Temp=oe!DATA.oe!Index1
  11938. oe!DATA.oe!Index1=oe!DATA.oe!Index2
  11939. oe!DATA.oe!Index2=oe!Temp
  11940. if oe!SepKey='Y' then
  11941. do
  11942. oe!Temp=oe!Key.oe!Index1
  11943. oe!Key.oe!Index1=oe!Key.oe!Index2
  11944. oe!Key.oe!Index2=oe!Temp
  11945. end
  11946. end
  11947. else
  11948. leave
  11949. oe!Index1=oe!Index1-oe!M
  11950. end
  11951. end
  11952. oe!M=oe!M%3
  11953. end
  11954. oe!Count=_valueG(oe!Array||0)
  11955. do oe!I=1 to oe!Count
  11956. call _valueS oe!Array||oe!I,oe!DATA.oe!I
  11957. end
  11958. Drop oe!DATA.
  11959. Drop oe!KEY.
  11960. return(oe!Count)
  11961.  
  11962. FileNameRelative:call TRACE "OFF"
  11963. parse arg pe!F,pe!Rel,pe!If
  11964. if pe!If='' then
  11965. pe!If=2
  11966. if pe!Rel='' then
  11967. pe!Rel=DirGetCurrent()
  11968. pe!S=RexDirChar
  11969. pe!S2=pe!S||pe!S
  11970. if right(pe!Rel,1)<>pe!S then
  11971. pe!Rel=pe!Rel||pe!S
  11972. if left(pe!F,2)=pe!S2|left(pe!Rel,2)=pe!S2 then
  11973. return(pe!F)
  11974. pe!P=compare(ufile(pe!Rel),ufile(pe!F))
  11975. if pe!P=0|right(pe!F,1)=pe!S then
  11976. Die('The file "' || pe!F || '" appears to be a directory!')
  11977. else
  11978. do
  11979. if pe!P=1 then
  11980. return(pe!F)
  11981. pe!P=min(lastpos(pe!S,pe!Rel,pe!P),lastpos(pe!S,pe!F,pe!P))+1
  11982. pe!Fc=substr(pe!F,pe!P)
  11983. pe!Fr=substr(pe!Rel,pe!P)
  11984. pe!Cnt=0
  11985. pe!P=pos(pe!S,pe!Fr)
  11986. do while pe!P<>0
  11987. pe!Cnt=pe!Cnt+1
  11988. pe!P=pos(pe!S,pe!Fr,pe!P+1)
  11989. end
  11990. pe!Rel=copies('..' ||pe!S,pe!Cnt)||pe!Fc
  11991. select
  11992. when datatype(pe!If, 'W')then
  11993. do
  11994. if pe!Cnt<=pe!If then
  11995. pe!F=pe!Rel
  11996. end
  11997. when translate(pe!If)='S' then
  11998. do
  11999. if length(pe!Rel)<=length(pe!F)then
  12000. pe!F=pe!Rel
  12001. end
  12002. otherwise
  12003. pe!F=pe!Rel
  12004. end
  12005. end
  12006. return(pe!F)
  12007.  
  12008. Files4Mask:call TRACE "OFF"
  12009. parse arg qe!Msk,qe!Stm,qe!Fol,qe!Srt
  12010. if qe!Fol='' then
  12011. qe!Fol='N'
  12012. if qe!Srt='' then
  12013. qe!Srt='Y'
  12014. call DBG 'Files4Mask("' || qe!Msk || '"): Follow Directories = "' || qe!Fol || '"'
  12015. call DBGIND 1
  12016. call _valueS qe!Stm|| '.0',0
  12017. if RexxHookGetFileList='' then
  12018. do
  12019. if qe!Fol='N' then
  12020. qe!Fol=''
  12021. else
  12022. qe!Fol='S'
  12023. call DBG 'Using "_SysFileTree()" as "GetFileList" hook not used'
  12024. call _SysFileTree qe!Msk,qe!Stm, 'F' ||qe!Fol
  12025. end
  12026. else
  12027. do
  12028. call DBG 'Not using "_SysFileTree()" as user specified use of "' || RexxHookGetFileList || '"'
  12029. glfTmpFile=RexGetTmpFileName()
  12030. call MustDeleteFile glfTmpFile
  12031. glfLocn=_filespec('Location',qe!Msk)
  12032. glfName=_filespec('Name',qe!Msk)
  12033. call CallHook "GETFILELIST",,glfLocn,glfName,qe!Fol,glfTmpFile
  12034. if FileQueryExists(glfTmpFile)='' then
  12035. CryAndDie('"' || RexxHookGetFileList || '" did not create the file list!')
  12036. glfLine=0
  12037. glfCount=0
  12038. do while lines(glfTmpFile)<>0
  12039. CurrentLine=linein(glfTmpFile)
  12040. glfLine=glfLine+1
  12041. if CurrentLine<> '' then
  12042. do
  12043. FullFile=FileQueryExists(CurrentLine)
  12044. if FullFile='' then
  12045. CryAndDie('"' || RexxHookGetFileList || '" specified an invalid file of "' || CurrentLine || '" on line #' ||glfLine)
  12046. glfCount=glfCount+1
  12047. call _valueS qe!Stm|| '.' ||glfCount,CurrentLine
  12048. end
  12049. end
  12050. call FileClose glfTmpFile
  12051. call _valueS qe!Stm|| '.0',glfCount
  12052. if OptionDebugOn='N' then
  12053. call MustDeleteFile glfTmpFile
  12054. end
  12055. if qe!Srt<> 'N' then
  12056. call ArraySort qe!Stm, '@'
  12057. call DBGIND-1
  12058. return
  12059.  
  12060. Dirs4Mask:call TRACE "OFF"
  12061. parse arg re!Msk,re!Stm,re!Fol,re!Srt
  12062. if re!Fol='' then
  12063. re!Fol='N'
  12064. if re!Srt='' then
  12065. re!Srt='Y'
  12066. call DBG 'Dirs4Mask("' || re!Msk || '"): Follow Directories = "' || re!Fol || '"'
  12067. call DBGIND 1
  12068. call _valueS re!Stm|| '.0',0
  12069. if re!Fol='N' then
  12070. re!Fol=''
  12071. else
  12072. re!Fol='S'
  12073. call _SysFileTree re!Msk,re!Stm, 'D' ||re!Fol
  12074. if re!Srt<> 'N' then
  12075. call ArraySort re!Stm, '@'
  12076. call DBGIND-1
  12077. return
  12078.  
  12079. _FileWriteFailed:
  12080. CryAndDie('Write to "' || arg(1) || '" failed (' || FileDescription(arg(1)) || ')!')
  12081.  
  12082. FileLineOut:call TRACE "OFF"
  12083. parse arg se!File,se!Line
  12084. if 0=lineout(se!File,se!Line)then
  12085. return
  12086. _FileWriteFailed(se!File)
  12087.  
  12088. FileCharOut:call TRACE "OFF"
  12089. if 0=charout(CurrentOutFile,arg(1))then
  12090. return
  12091. _FileWriteFailed(CurrentOutFile)
  12092.  
  12093. QuoteIt:call TRACE "OFF"
  12094. parse arg te!Q4,te!TryQ,te!What
  12095. if te!What='' then
  12096. te!What='N'
  12097. if te!TryQ='' then
  12098. te!TryQ='"' || "'"
  12099. else
  12100. do
  12101. if translate(te!TryQ)='ANY' then
  12102. te!TryQ=TryQuoteListAny
  12103. end
  12104. te!I=verify(te!TryQ,te!Q4)
  12105. if te!I=0 then
  12106. CryAndDie('QuoteIt(): Could not find suitable quote for ' ||DebugRightArrow||te!Q4||DebugLeftArrow)
  12107. else
  12108. do
  12109. te!Q=substr(te!TryQ,te!I,1)
  12110. if te!What='N' then
  12111. return(te!Q)
  12112. else
  12113. return(te!Q||te!Q4||te!Q)
  12114. end
  12115.  
  12116. FileGetTmpName:call TRACE "OFF"
  12117. return(RexGetTmpFileName(arg(1)))
  12118.  
  12119. FileClose:call TRACE "OFF"
  12120. parse arg te!F,te!C
  12121. if te!C='' then
  12122. te!C='Y'
  12123. if te!C<> 'N' then
  12124. call DieIfIoErrorOccurred te!F
  12125. call _FileClose te!F
  12126. return
  12127.  
  12128. MustDeleteFile:call TRACE "OFF"
  12129. call FileDelete arg(1)
  12130. return
  12131.  
  12132. FileDelete:call TRACE "OFF"
  12133. parse arg te!F,te!D
  12134. if te!D='' then
  12135. te!D='Y'
  12136. if OptionDebugOn='Y' then
  12137. do
  12138. call DBG_EVALUATE 'FileDelete(' || te!F || ') : MustDelete = ' ||te!D
  12139. call DBGIND 1
  12140. end
  12141. call _FileClose te!F
  12142. if FileQueryExists(te!F)='' then
  12143. do
  12144. te!Rc=0
  12145. if OptionDebugOn='Y' then
  12146. call DBG_EVALUATE 'File does not exist'
  12147. end
  12148. else
  12149. do
  12150. if OptionDebugOn='Y' then
  12151. call DBG_EVALUATE 'Deleting the file'
  12152. call _FileClose te!F
  12153. if OptionDebugOn='Y' then
  12154. call DBGIND 1
  12155. te!Rc=_SysFileDelete(te!F)
  12156. if OptionDebugOn='Y' then
  12157. call DBGIND-1
  12158. if FileQueryExists(te!F)="" then
  12159. te!Rc=0
  12160. else
  12161. do
  12162. if te!D<> 'N' then
  12163. CryAndDie('Could not delete "' || te!F || '", it must be in use (DosRc=' || DeleteRc || ')...')
  12164. if te!Rc=0 then
  12165. te!Rc=987
  12166. end
  12167. end
  12168. if OptionDebugOn='Y' then
  12169. do
  12170. call DBG_EVALUATE 'Rc = ' ||te!Rc
  12171. call DBGIND-1
  12172. end
  12173. return(te!Rc)
  12174.  
  12175. QueryExists:
  12176.  
  12177. FileQueryExists:call TRACE "OFF"
  12178. parse arg ue!F,ue!ME
  12179. if ue!ME='' then
  12180. ue!ME='N'
  12181. if ue!F='' then
  12182. CryAndDie('The filename "" is invalid!')
  12183. else
  12184. do
  12185. ue!Rc=_FileQueryExists(ue!F)
  12186. if ue!Rc='' & ue!ME <> 'N' then
  12187. CryAndDie('The filename "' || ue!F || '" does not exist!')
  12188. return(ue!Rc)
  12189. end
  12190.  
  12191. Bd2Date:call TRACE "OFF"
  12192. parse arg ve!Bd,ve!Fmt,ve!Cfg,ve!T
  12193. ve!S=_Bd2Date(ve!Bd)
  12194. if ve!Fmt<> "" then
  12195. do
  12196. if ve!T="" then
  12197. ve!T='000000'
  12198. ve!S=FormatTime(ve!Fmt,ve!S||ve!T,ve!Cfg)
  12199. end
  12200. return(ve!S)
  12201.  
  12202. FileQueryDateTime:call TRACE "OFF"
  12203. parse arg ve!F,ve!Fmt,ve!Cfg,ve!D
  12204. if ve!D='' then
  12205. ve!D='Y'
  12206. if OptionDebugOn='Y' then
  12207. do
  12208. call DBG_EVALUATE 'FileQueryDateTime(' || ve!F || ') : Fmt = ' ||ve!Fmt
  12209. call DBGIND 1
  12210. end
  12211. ve!Ts=GetFileTimeStamp(ve!F, 'Q')
  12212. if ve!Ts=-1 then
  12213. do
  12214. if ve!D='N' then
  12215. ve!Ft=''
  12216. else
  12217. CryAndDie('Failed getting file time for "' || ve!F || '"')
  12218. end
  12219. else
  12220. do
  12221. ve!Ft=FormatTime(ve!Fmt,ve!Ts,ve!Cfg)
  12222. end
  12223. call DBGIND-1
  12224. return(ve!Ft)
  12225.  
  12226. GetFileTimeStamp:call TRACE "OFF"
  12227. parse arg we!FN,we!OnErr,we!Fmt
  12228. we!OnErr=translate(we!OnErr)
  12229. if OptionDebugOn='Y' then
  12230. do
  12231. call DBG_EVALUATE 'GetFileTimeStamp("' || we!FN || '")'
  12232. call DBGIND 1
  12233. end
  12234. we!ST=FileInMemoryTimeStamp(we!FN)
  12235. if we!ST='' then
  12236. do
  12237. we!FT=_FileQueryDateTime(we!FN)
  12238. if OptionDebugOn='Y' then
  12239. call DBG_EVALUATE 'Is time stamped : "' || we!FT || '"'
  12240. if we!FT='' then
  12241. do
  12242. we!M='The file "' || we!FN || '" does not exist.'
  12243. select
  12244. when we!OnErr='Q' then
  12245. call DBG we!M
  12246. when we!OnErr='D' then
  12247. CryAndDie(we!M)
  12248. otherwise
  12249. call OutputWarningToScreen 'TS00',we!M
  12250. end
  12251. if OptionDebugOn='Y' then
  12252. call DBGIND-1
  12253. return(-1)
  12254. end
  12255. we!FT=space(we!FT)
  12256. parse var we!FT Month'-'Day'-'Year' 'Hour':'Minute':'Second
  12257. if Year<80 then
  12258. Year=100+Year
  12259. Year=1900+Year
  12260. we!ST=Year||Month||Day||Hour||Minute||Second
  12261. end
  12262. if we!Fmt<> '' then
  12263. do
  12264. call DBG_EVALUATE 'Time Stamp      : "' || we!ST || '"'
  12265. we!ST=FormatTime(we!Fmt,we!ST)
  12266. end
  12267. if OptionDebugOn='Y' then
  12268. do
  12269. call DBG_EVALUATE 'Returning       : "' || we!ST || '"'
  12270. call DBGIND-1
  12271. end
  12272. return(we!ST)
  12273.  
  12274. Evaluate_42:
  12275. TraceBpListsLoaded=''
  12276. TraceAutoAliasCnt=0
  12277. TraceAutoAliasMax=0
  12278. TraceLineInBuffer=""
  12279. signal ExecCmd_43
  12280.  
  12281. ExecRexxCmd:
  12282. parse arg InterpretThisAsPassed,xe!Exp
  12283. if xe!Exp='Y' then
  12284. InterpretThisRexx=PerformReplacementsInCmdsParameters(InterpretThisAsPassed)
  12285. else
  12286. InterpretThisRexx=InterpretThisAsPassed
  12287. if RexWhich='REGINA' then
  12288. xe!UseEos=MarksNewLine
  12289. else
  12290. xe!UseEos=';'
  12291. InterpretThisRexx=ExpandAnyRxVarHacks(InterpretThisRexx)
  12292. InterpretThisRexx=ReplaceEos(InterpretThisRexx)
  12293. InterpretThis=InterpretThisRexx
  12294. if OptionDebugOn='Y' then
  12295. call DBG_INTERPRET 'ExecRexxCmd(' || AddCommasToDecimalNumber(length(InterpretThisRexx)) || ' bytes): ' ||DebugRightArrow||InterpretThisRexx||DebugLeftArrow
  12296. call DBGIND 1
  12297. if OptionPpwTrace='OFF' then
  12298. TraceBreakPoint=''
  12299. else
  12300. call SetUpBp strip(CfgMacro('REXX_BP', ''))
  12301. if OptionDebugOn='Y' then
  12302. do
  12303. if bitand(DebugLevel,SeeRexxTrace)==SeeRexxTrace then
  12304. do
  12305. if RexWhich='REGINA' then
  12306. xe!Def='OFF'
  12307. else
  12308. xe!Def='INTERMEDIATES'
  12309. TraceLevel4Rexx=translate(CfgMacro('REXXTRACE',xe!Def))
  12310. if TraceLevel4Rexx<> 'OFF' then
  12311. InterpretThis='TRACE ' || TraceLevel4Rexx || ';' || InterpretThisRexx || ';call TRACE "OFF";'
  12312. call Line1 ''
  12313. call Line1 '---------- START REXX CODE (RexxTrace=' || TraceLevel4Rexx || ') ----------'
  12314. end
  12315. end
  12316. signal ON SYNTAX NAME _SyntaxErrorDuringInterpret
  12317. signal ON NOVALUE NAME _UnknownVariableDuringInterpret
  12318. InitializedBp='N'
  12319. TraceLineInBuffer=""
  12320. PrevTracedLine=''
  12321. interpret InterpretThis
  12322. TraceBreakPoint=''
  12323. if OptionDebugOn='Y' then
  12324. do
  12325. if bitand(DebugLevel,SeeRexxTrace)==SeeRexxTrace then
  12326. do
  12327. call Line1 '---------- END   REXX CODE (RexxTrace=' || TraceLevel4Rexx || ') ----------'
  12328. call Line1 ''
  12329. end
  12330. end
  12331. call DBGIND-1
  12332. return
  12333.  
  12334. _UnknownVariableDuringInterpret:
  12335. TrappingLine=SIGL
  12336. call TRACE "OFF"
  12337. call CommonTrapHandler TrappingLine, 'N', 'Unknown Variable', condition('D'),space(InterpretThisRexx),TraceBreakPoint
  12338.  
  12339. _SyntaxErrorDuringInterpret:
  12340. TrappingLine=SIGL
  12341. call TRACE "OFF"
  12342. call CommonTrapHandler TrappingLine, 'S', 'Reason',errortext(Rc),space(InterpretThisRexx),TraceBreakPoint
  12343.  
  12344. ReplaceEos:
  12345. return(ReplaceString(arg(1),DefRexxSpecialSepTag,xe!UseEos))
  12346.  
  12347. SetUpBp:
  12348. TraceBreakPoint=arg(1)
  12349. if TraceBreakPoint<> '' then
  12350. do
  12351. if left(TraceBreakPoint,1)='=' then
  12352. do
  12353. xe!Mac=strip(substr(TraceBreakPoint,2))
  12354. if MacroExists(xe!Mac)='N' then
  12355. do
  12356. xe!T='The breakpoint macro "' || xe!Mac || '" does not exist!'
  12357. if arg(2)<> 'U' then
  12358. CryAndDie(xe!T, 'The "REXX_BP" macro contains an invalid value')
  12359. else
  12360. do
  12361. call ColorSet 'ERROR'
  12362. call Line1 xe!T
  12363. call Beeps
  12364. TraceBreakPoint="?"
  12365. end
  12366. end
  12367. else
  12368. do
  12369. TraceBreakPoint=GetDefineContents(xe!Mac)
  12370. TraceBreakPoint='=' ||ReplaceEos(PerformReplacementsInCmdsParameters(TraceBreakPoint))
  12371. end
  12372. end
  12373. else
  12374. do
  12375. if TraceBreakPoint<> '?' & left(TraceBreakPoint, 1) = '?' then
  12376. do
  12377. TraceBreakPoint='=if (' || strip(substr(TraceBreakPoint, 2)) || ') then; do; rtStop="Y"; end;'
  12378. end
  12379. end
  12380. end
  12381. return
  12382.  
  12383. AddToBpSearch:
  12384. RtSearchText=RtSearchText|| '{SOL}' || space(arg(1)) || '{EOL}'
  12385. return
  12386.  
  12387. TraceLineIn:
  12388. if TraceLineInBuffer="" then
  12389. do
  12390. xe!RL=linein()
  12391. xe!Tmp=_ConsoleWriteAllowed
  12392. _ConsoleWriteAllowed='N'
  12393. call line1 xe!RL
  12394. _ConsoleWriteAllowed=xe!Tmp
  12395. end
  12396. else
  12397. do
  12398. parse var TraceLineInBuffer xe!RL '{NL}' TraceLineInBuffer
  12399. call line1 xe!RL
  12400. end
  12401. return(strip(xe!RL))
  12402.  
  12403. UserBreakPoint:call TRACE "OFF"
  12404. RtUserBreakPoint='Y'
  12405. signal _UserBreakPoint
  12406.  
  12407. RexxTrace:call TRACE "OFF"
  12408. RtUserBreakPoint='N'
  12409.  
  12410. _UserBreakPoint:
  12411. signal on NOVALUE name RexxTrapUninitializedVariable
  12412. signal on SYNTAX name RexxTrapSyntaxError
  12413. parse arg rtText,rtDumpList,rtDbgCmd,rtDbgTrapped
  12414. rtSay='$TRACE: ' ||rtText
  12415. call ColorSet 'RexxTrace'
  12416. call Line1 rtSay
  12417. call ColorSet 'RexxOther'
  12418. RtSearchText=''
  12419. call AddToBpSearch rtText
  12420. if rtDbgTrapped<> 'Y' then
  12421. do
  12422. rtThis=''
  12423. if rtDbgCmd='Y' then
  12424. do
  12425. rtThis=PrevTracedLine|| ' ' ||rtText
  12426. PrevTracedLine=rtText
  12427. end
  12428. else
  12429. rtThis=rtDumpList
  12430. if rtThis<> '' then
  12431. do
  12432. if rtThis<> '?' then
  12433. call DumpVarsInExpression rtThis, '', '', 'TraceVarSay'
  12434. else
  12435. do
  12436. call Line1 'ALL KNOWN VARIABLES'
  12437. call Line1 '~~~~~~~~~~~~~~~~~~~'
  12438. call DumpVarsInExpression InterpretThisRexx, '', '', 'TraceVarSay'
  12439. end
  12440. end
  12441. end
  12442. call Line1 ''
  12443. if RtUserBreakPoint='Y' | rtDbgTrapped = 'Y' then
  12444. rtStop='Y'
  12445. else
  12446. do
  12447. if TraceBreakPoint='' then
  12448. rtStop='N'
  12449. else
  12450. do
  12451. select
  12452. when TraceBreakPoint='?' then
  12453. rtStop='Y'
  12454. when left(TraceBreakPoint,1)='=' then
  12455. do
  12456. rtStop='N'
  12457. xe!B=BeepsAllow('N')
  12458. call ExecuteUsersTraceCmd substr(TraceBreakPoint,2)
  12459. call BeepsAllow xe!B
  12460. end
  12461. otherwise
  12462. do
  12463. if pos(TraceBreakPoint,RtSearchText)<>0 then
  12464. rtStop='Y'
  12465. else
  12466. rtStop='N'
  12467. end
  12468. end
  12469. end
  12470. end
  12471. if rtStop='N' then
  12472. return
  12473. call LoadBpLists
  12474. TraceLineInBuffer=strip(CfgMacro('REXX_BP_AUTO_CMD', ''))
  12475. do forever
  12476. call ColorSet 'PromptText'
  12477. call Char1 'BreakPoint (' || BpAliasCnt || ' aliases) => '
  12478. call ColorSet 'RexxOther'
  12479. rtCmd=TraceLineIn()
  12480. if rtCmd='' then
  12481. do
  12482. call ColorSet
  12483. return
  12484. end
  12485. rtCmdU=translate(rtCmd)
  12486. select
  12487. when left(rtCmd,1)='/' then
  12488. do
  12489. EqPos=pos('=',rtCmd)
  12490. if EqPos<>0 then
  12491. do
  12492. call AddBpAlias rtCmd, "user"
  12493. STo=SaveBpAliasFile()
  12494. if STo='' then
  12495. STxt='Done (not permanently saved)!'
  12496. else
  12497. STxt='Done, saved to "' || STo || '".'
  12498. call ColorSet 'HIGHLIGHT'
  12499. call Line1 STxt
  12500. call ColorSet 'RexxOther'
  12501. end
  12502. else
  12503. do
  12504. rtAlias=strip(substr(rtCmd,2))
  12505. if left(rtAlias,1)='#' | datatype(rtAlias, 'W')then
  12506. do
  12507. if left(rtAlias,1)='#' then
  12508. rtAliasI=strip(substr(rtAlias,2))
  12509. else
  12510. rtAliasI=rtAlias
  12511. if rtAliasI>TraceAutoAliasCnt then
  12512. do
  12513. call ColorSet 'ERROR'
  12514. call Line1 '#Alias "#' || rtAliasI || '" does not exist!'
  12515. call ColorSet 'RexxOther'
  12516. call Beeps
  12517. iterate
  12518. end
  12519. rtAliasI=(TraceAutoAliasCnt-rtAliasI)+1
  12520. rtCmd=Aalias.rtAliasI
  12521. end
  12522. else
  12523. do
  12524. xe!Mac="REXX_BP_ALIAS:" ||rtAlias
  12525. if MacroExists(xe!Mac)='Y' then
  12526. rtCmd=GetDefineContents(xe!Mac)
  12527. else
  12528. do
  12529. rtCmd=FindBpAlias(rtAlias)
  12530. if rtCmd='' then
  12531. do
  12532. call ColorSet 'ERROR'
  12533. call Line1 'Alias "' || rtAlias || '" not found!'
  12534. call ColorSet 'RexxOther'
  12535. call Beeps
  12536. iterate
  12537. end
  12538. end
  12539. end
  12540. TraceLineInBuffer=rtCmd
  12541. iterate
  12542. end
  12543. end
  12544. when left(rtCmd,1)='?' then
  12545. do
  12546. xe!Rest=substr(rtCmdU,2)
  12547. rtCmdU=word(xe!Rest,1)
  12548. call ColorSet 'RexxOther'
  12549. select
  12550. when rtCmdU='' then
  12551. do
  12552. call Line1 rtText
  12553. end
  12554. when abbrev('VARIABLES',rtCmdU)then
  12555. do
  12556. if words(xe!Rest)=1 then
  12557. do
  12558. call Line1 'ALL KNOWN VARIABLES'
  12559. call Line1 '~~~~~~~~~~~~~~~~~~~'
  12560. call DumpVarsInExpression InterpretThisRexx, '', '', 'TraceVarSay'
  12561. end
  12562. else
  12563. do
  12564. xe!Exists=''
  12565. xe!Unknown=''
  12566. do xe!I=2 to words(xe!Rest)
  12567. xe!V=word(xe!Rest,xe!I)
  12568. if symbol(xe!V)='VAR' then
  12569. xe!Exists=xe!Exists|| ' ' ||xe!V
  12570. else
  12571. xe!Unknown=xe!Unknown|| ' ' ||xe!V
  12572. end
  12573. if xe!Unknown<> '' then
  12574. do
  12575. call ColorSet 'ERROR'
  12576. call Line1 'Unknown Variables: ' ||strip(xe!Unknown)
  12577. call ColorSet 'RexxOther'
  12578. end
  12579. if xe!Exists<> '' then
  12580. call DumpVarsInExpression xe!Exists, '', '', 'TraceVarSay'
  12581. end
  12582. end
  12583. when abbrev('LOCATION',rtCmdU)then
  12584. call Line1 'AT: ' ||CurrentSourceLocation()
  12585. when abbrev('ALIASES',rtCmdU)then
  12586. do
  12587. call Line1 'ALL ALIASES'
  12588. call Line1 '~~~~~~~~~~~'
  12589. do Index=1 to BpAliasCnt
  12590. call Line1 left(BpAlias.Index.BpAName,BpLongestAlias)|| ' = ' ||BpAlias.Index.BpAValue
  12591. end
  12592. end
  12593. when abbrev('#ALIASES',rtCmdU)then
  12594. do
  12595. if TraceAutoAliasCnt=0 then
  12596. do
  12597. call ColorSet 'ERROR'
  12598. call Line1 'No commands have been remembered yet!'
  12599. call Beeps
  12600. end
  12601. else
  12602. do
  12603. MaxLng=length(TraceAutoAliasCnt)
  12604. call Line1 'ALL # ALIASES'
  12605. call Line1 '~~~~~~~~~~~~~'
  12606. do Index=1 to TraceAutoAliasCnt
  12607. IndexR=(TraceAutoAliasCnt-Index)+1
  12608. call Line1 '/#' || left(IndexR, MaxLng)  || ' = ' ||Aalias.Index
  12609. end
  12610. end
  12611. end
  12612. when abbrev('MACRO',rtCmdU)then
  12613. do
  12614. xe!Mac=word(rtCmd,2)
  12615. if MacroExists(xe!Mac)='N' then
  12616. do
  12617. call ColorSet 'ERROR'
  12618. call Line1 'The macro "' || xe!Mac || '" does not exist'
  12619. call Beeps
  12620. end
  12621. else
  12622. do
  12623. xe!T='MACRO: ' ||xe!Mac
  12624. call ColorSet 'HIGHLIGHT'
  12625. call line1 xe!T
  12626. call line1 copies('~',length(xe!T))
  12627. call ColorSet 'INFO'
  12628. call Char1 '"'
  12629. call ColorSet 'RexxOther'
  12630. call Char1 GetDefineContents(xe!Mac)
  12631. call ColorSet 'INFO'
  12632. call Line1 '"'
  12633. end
  12634. end
  12635. otherwise
  12636. do
  12637. call ColorSet 'ERROR'
  12638. call Line1 'Unknown ? command of "' || rtCmd || '"!'
  12639. call Beeps
  12640. end
  12641. end
  12642. call ColorSet 'RexxOther'
  12643. end
  12644. when rtCmdU='BP' then
  12645. do
  12646. call ColorSet 'PromptText'
  12647. call Char1 "New Breakpoint (blank = none) => "
  12648. call ColorSet 'RexxOther'
  12649. call SetUpBp TraceLineIn(), 'U'
  12650. end
  12651. otherwise
  12652. do
  12653. if ExecuteUsersTraceCmd(rtCmd)=0 then
  12654. do
  12655. if AddAutoAlias(rtCmd)<>0 then
  12656. call SaveBpAliasFile
  12657. end
  12658. end
  12659. end
  12660. end
  12661. Die("NeverGetsHere:Trace")
  12662.  
  12663. TraceVarSay:
  12664. call ColorSet 'RexxOther'
  12665. call Line1 "      | " ||arg(1)
  12666. call ColorSet 'RexxOther'
  12667. call AddToBpSearch arg(1)
  12668. return
  12669.  
  12670. ExecuteUsersTraceCmd:
  12671. signal ON SYNTAX NAME _SyntaxErrorDuringExecuteUsersTraceCmd
  12672. signal ON NOVALUE NAME _UnknownVariableDuringExecuteUsersTraceCmd
  12673. interpret arg(1)
  12674. return(0)
  12675.  
  12676. _SyntaxErrorDuringExecuteUsersTraceCmd:
  12677. ErrNo=Rc
  12678. call ColorSet 'ERROR'
  12679. call Line1 'SYNTAX ERROR: ' ||errortext(ErrNo)
  12680. call ColorSet 'RexxOther'
  12681. call Line1 ''
  12682. call Beeps
  12683. return(1)
  12684.  
  12685. _UnknownVariableDuringExecuteUsersTraceCmd:
  12686. call ColorSet 'ERROR'
  12687. call Line1 'The rexx variable "' || condition('D') || '" is unknown!'
  12688. call ColorSet 'RexxOther'
  12689. call Line1 ''
  12690. call Beeps
  12691. return(1)
  12692.  
  12693. LoadBpLists:
  12694. TraceBpList=CfgMacro('REXX_BP_ALIAS_FILES', '')
  12695. if TraceBpList<>TraceBpListsLoaded then
  12696. TraceBpListsLoaded=''
  12697. if TraceAutoAliasMax=0 then
  12698. do
  12699. TraceAutoAliasMax=CfgMacro('REXX_BP_MAX_AUTO_CMD',22)
  12700. if datatype(TraceAutoAliasMax, 'W')=0 then
  12701. TraceAutoAliasMax=22
  12702. if TraceAutoAliasMax<10 then
  12703. TraceAutoAliasMax=22
  12704. end
  12705. if TraceBpListsLoaded<> '' then
  12706. return
  12707. BpSaveTo=''
  12708. BpList=TraceBpList
  12709. BpAliasCnt=0
  12710. BpFileNumb=0
  12711. BpLongestAlias=0
  12712. do while BpList<> ''
  12713. parse var BpList BpList1';'BpList
  12714. BpFileNumb=BpFileNumb+1
  12715. if BpFileNumb=1 then
  12716. BpSaveTo=BpList1
  12717. if BpList1='' then
  12718. iterate
  12719. BpList1=FindFile(BpList1)
  12720. if BpList1='' then
  12721. iterate
  12722. call FileClose BpList1, 'N'
  12723. BpListLine=0
  12724. do while lines(BpList1)<>0
  12725. CurrentLine=strip(linein(BpList1))
  12726. BpListLine=BpListLine+1
  12727. if CurrentLine='' | left(CurrentLine, 1) = ';' then
  12728. iterate
  12729. AliasSource='line #' || BpListLine || ' of ' ||BpList1
  12730. call AddBpAlias CurrentLine,AliasSource,BpFileNumb
  12731. end
  12732. call FileClose BpList1
  12733. end
  12734. TraceBpListsLoaded=TraceBpList
  12735. return
  12736.  
  12737. AddBpAlias:
  12738. parse arg AliasCmd,AliasSrc,FromFile
  12739. parse var AliasCmd '/'BpAliasName'='BpAliasValue
  12740. if BpAliasValue='' then
  12741. do
  12742. call DBG 'Alias Command from ' || AliasSrc || ' incorrectly formatted!'
  12743. return
  12744. end
  12745. BpAliasName=translate(BpAliasName)
  12746. if left(BpAliasName,1)=='#' then
  12747. do
  12748. call AddAutoAlias BpAliasValue
  12749. return
  12750. end
  12751. if length(BpAliasName)>BpLongestAlias then
  12752. BpLongestAlias=length(BpAliasName)
  12753. FoundIndex=0
  12754. do Index=1 to BpAliasCnt
  12755. if BpAliasName=BpAlias.Index.BpAName then
  12756. do
  12757. FoundIndex=Index
  12758. leave
  12759. end
  12760. end
  12761. if FoundIndex<>0 then
  12762. do
  12763. if FromFile<> '' then
  12764. return
  12765. end
  12766. else
  12767. do
  12768. BpAliasCnt=BpAliasCnt+1
  12769. FoundIndex=BpAliasCnt
  12770. end
  12771. BpAlias.FoundIndex.BpAName=BpAliasName
  12772. BpAlias.FoundIndex.BpAValue=BpAliasValue
  12773. BpAlias.FoundIndex.BpFNumb=FromFile
  12774. return
  12775.  
  12776. FindBpAlias:
  12777. BpAliasName=translate(strip(arg(1)))
  12778. do Index=1 to BpAliasCnt
  12779. if BpAliasName=BpAlias.Index.BpAName then
  12780. return(BpAlias.Index.BpAValue)
  12781. end
  12782. return('')
  12783.  
  12784. SaveBpAliasFile:
  12785. if BpSaveTo='' then
  12786. return('')
  12787. call MustDeleteFile BpSaveTo
  12788. call lineout BpSaveTo, ';***'
  12789. call lineout BpSaveTo, ';*** Automatically saved at: ' ||NiceDateTime()
  12790. call lineout BpSaveTo, ';***'
  12791. call lineout BpSaveTo, ''
  12792. FoundF='N'
  12793. do Index=1 to BpAliasCnt
  12794. if BpAlias.Index.BpFNumb=1 then
  12795. do
  12796. if FoundF='N' then
  12797. call lineout BpSaveTo, ';--- Loaded From File ---'
  12798. FoundF='Y'
  12799. call lineout BpSaveTo, '/' || BpAlias.Index.BpAName || '=' ||BpAlias.Index.BpAValue
  12800. end
  12801. end
  12802. call FileClose BpSaveTo
  12803. FoundU='N'
  12804. do Index=1 to BpAliasCnt
  12805. if BpAlias.Index.BpFNumb=''then
  12806. do
  12807. if FoundU='N' then
  12808. do
  12809. if FoundF='Y' then
  12810. call lineout BpSaveTo, ''
  12811. call lineout BpSaveTo, ';--- User Modified This Session ---'
  12812. end
  12813. FoundU='Y'
  12814. call lineout BpSaveTo, '/' || BpAlias.Index.BpAName || '=' ||BpAlias.Index.BpAValue
  12815. end
  12816. end
  12817. call FileClose BpSaveTo
  12818. if TraceAutoAliasCnt<>0 then
  12819. do
  12820. call lineout BpSaveTo, ''
  12821. call lineout BpSaveTo, ';--- Last Few Commands Used ---'
  12822. do Index=1 to TraceAutoAliasCnt
  12823. IndexN=(TraceAutoAliasCnt-Index)+1
  12824. call lineout BpSaveTo, '/#' || IndexN  || '=' ||Aalias.Index
  12825. end
  12826. end
  12827. call FileClose BpSaveTo
  12828. return(BpSaveTo)
  12829.  
  12830. FindAutoAlias:
  12831. FindWhat=arg(1)
  12832. do FndIndex=1 to TraceAutoAliasCnt
  12833. if FindWhat=Aalias.FndIndex then
  12834. return(FndIndex)
  12835. end
  12836. return(0)
  12837.  
  12838. DeleteAutoAlias:
  12839. DelIndex=arg(1)
  12840. do DelIndexT=DelIndex to TraceAutoAliasCnt-1
  12841. DelIndexF=DelIndexT+1
  12842. Aalias.DelIndexT=Aalias.DelIndexF
  12843. end
  12844. TraceAutoAliasCnt=TraceAutoAliasCnt-1
  12845. return
  12846.  
  12847. AddAutoAlias:
  12848. SaveWhat=strip(arg(1))
  12849. if SaveWhat='' then
  12850. return(0)
  12851. FoundAt=FindAutoAlias(SaveWhat)
  12852. if FoundAt<>0 then
  12853. call DeleteAutoAlias FoundAt
  12854. if TraceAutoAliasCnt>=TraceAutoAliasMax then
  12855. call DeleteAutoAlias 1
  12856. TraceAutoAliasCnt=TraceAutoAliasCnt+1
  12857. Aalias.TraceAutoAliasCnt=SaveWhat
  12858. return(TraceAutoAliasCnt)
  12859.  
  12860. ExecCmd_43:
  12861. ExpandXEarly='N'
  12862. ExpandXLate='N'
  12863. ExpandXCmd='N'
  12864. signal EndExpandX
  12865.  
  12866. EXPANDX_DEBUG:
  12867. if OptionDebugOn='Y' then
  12868. do
  12869. if ExpandX='NONE' then
  12870. call OptionDebugShow 'EXPANDX', 'X codes are never expanded'
  12871. else
  12872. call OptionDebugShow 'EXPANDX', 'X codes are expanded "' || ExpandX || '"'
  12873. end
  12874. return
  12875.  
  12876. EXPANDX_GET:
  12877. call EXPANDX_DEBUG
  12878. return(ExpandX)
  12879.  
  12880. EXPANDX_SET:
  12881. ExpandX=translate(arg(1))
  12882. if ProcessedCmdLine='N' then
  12883. do
  12884. call OptionDebugShow 'EXPANDX', 'Setting default value of "X" var expansion to "' || EXPANDX || '"'
  12885. Default4_EXPANDX=ExpandX
  12886. return(0)
  12887. end
  12888. if ExpandX=='' then
  12889. ExpandX=Default4_EXPANDX
  12890. ExpandXEarly='N'
  12891. ExpandXLate='N'
  12892. ExpandXCmd='N'
  12893. if ExpandX<> 'NONE' then
  12894. do
  12895. TmpList=translate(ExpandX)
  12896. do while TmpList<> ''
  12897. parse var TmpList ThisItem','TmpList
  12898. select
  12899. when ThisItem='COMMAND' then
  12900. ExpandXCmd='Y'
  12901. when ThisItem='EARLY' then
  12902. ExpandXEarly='Y'
  12903. when ThisItem='LATE' then
  12904. ExpandXLate='Y'
  12905. otherwise
  12906. CryAndDie('Unknown EXPANDX option of "' || ThisItem || '"')
  12907. end
  12908. end
  12909. end
  12910. call EXPANDX_DEBUG
  12911. return
  12912.  
  12913. SetXCode:call TRACE "OFF"
  12914. parse arg ye!N,ye!V
  12915. ye!XN='XVAR?.X?' ||c2x(translate(ye!N))
  12916. call _valueS ye!XN,ye!V
  12917. return
  12918.  
  12919. InitializeCharCodes:
  12920. call DBG_DEFINING 'Initializing <' || '?x00-FF> codes + <' || '?xRexxEos> + some others'
  12921. do CharCode=0 to 255
  12922. call _valueS 'XVAR?.X?' ||c2x(translate(d2x(CharCode,2))),d2c(CharCode)
  12923. end
  12924. call _valueS 'XVAR?.X?'  || c2x(translate("RexxEos")),MarksNewLine
  12925. call _valueS 'XVAR?.X?'  || c2x(translate("Nothing")), ""
  12926. Val='<' || '?xml version="1.0" encoding="UTF-8"?>' ||MarksNewLine
  12927. Val=Val|| '<' || '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">' ||MarksNewLine
  12928. Val=Val|| '<html xmlns="http://www.w3.org/1999/xhtm" xml:lang="en" lang="en">' ||MarksNewLine
  12929. call _valueS 'XVAR?.X?'  || c2x(translate("HTML10")),Val
  12930. return
  12931.  
  12932. ExpandXCodes:call TRACE "OFF"
  12933.  
  12934. RepXCodes:
  12935. if pos(StartsStdSymbolReplacement_x,arg(1))=0 then
  12936. return(arg(1))
  12937.  
  12938. ReplaceTheXCodesWeKnowExist:
  12939. LeftBit=''
  12940. RightBit=arg(1)
  12941. StartPos=pos(StartsStdSymbolReplacement_x,RightBit)
  12942. do while StartPos<>0
  12943. ReplaceCount=ReplaceCount+1
  12944. EndPos=pos(EndsMacroReplacement,RightBit,StartPos+1)
  12945. XVarName='XVAR?.X?' ||c2x(translate(substr(RightBit,StartPos+3,(EndPos-StartPos)-3)))
  12946. if symbol(XVarName)='VAR' then
  12947. LeftBit=LeftBit||left(RightBit,StartPos-1)||_valueG(XVarName)
  12948. else
  12949. do
  12950. CryAndDie(StartsStdSymbolReplacement_x||substr(RightBit,StartPos+3,(EndPos-StartPos)-3)||EndsMacroReplacement|| ' is not defined (use "#RexxVar =x=" command)!')
  12951. end
  12952. RightBit=substr(RightBit,EndPos+1)
  12953. StartPos=pos(StartsStdSymbolReplacement_x,RightBit)
  12954. end
  12955. if OptionDebugOn='Y' then
  12956. call DebugOutputAfterReplacement LeftBit||RightBit, '?xXX'
  12957. return(LeftBit||RightBit)
  12958.  
  12959. EndExpandX:
  12960. call InitOnExitProcessing
  12961. signal OnExit_44
  12962.  
  12963. InitOnExitProcessing:
  12964. OnExitCnt=0
  12965. LinesFromOnExit='N'
  12966. do ze!I=1 to 100
  12967. OnExitLst.ze!I=''
  12968. end
  12969. return
  12970.  
  12971. SetUpOnExitProcessingIfEndOfMainFile:
  12972. if IncludeLevel=1 then
  12973. do
  12974. if OnExitCnt<>0 then
  12975. do
  12976. call DBG ''
  12977. call DBG '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
  12978. call DBG '!!! "#OnExit" processing follows !!!'
  12979. call DBG '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
  12980. call DBG ''
  12981. call DBGIND 1
  12982. ze!All=''
  12983. do ze!I=1 to 100
  12984. ze!Txt=OnExitLst.ze!I
  12985. if ze!Txt\=='' then
  12986. do
  12987. call DBG 'FROM: ' ||OnExitLoc.ze!I
  12988. call DBGIND 1
  12989. call DBG 'SLOT #' || ze!I || ': ' ||ze!Txt
  12990. call DBGIND-1
  12991. if ze!All='' then
  12992. ze!All=ze!Txt
  12993. else
  12994. ze!All=ze!All||MarksNewLine||ze!Txt
  12995. end
  12996. end
  12997. call DBGIND-1
  12998. IncludeMemBufferNextLine=ze!All
  12999. LinesFromOnExit='Y'
  13000. OnExitCnt=0
  13001. return('Y')
  13002. end
  13003. end
  13004. return('N')
  13005.  
  13006. ProcessOnExit:
  13007. af!R=strip(arg(1))
  13008. if left(af!R,1)<> '#' then
  13009. af!Slot=50
  13010. else
  13011. do
  13012. af!Slot=substr(word(af!R,1),2)
  13013. af!R=subword(af!R,2)
  13014. if translate(af!Slot)='EXEC' then
  13015. do
  13016. af!R=PerformReplacementsInCmdsParameters(af!R)
  13017. if left(af!R,1)='{' then
  13018. parse var af!R '{' af!RcTest '}' af!R
  13019. else
  13020. do
  13021. af!R=af!R
  13022. af!RcTest=''
  13023. end
  13024. if OptionValidation<> '' then
  13025. CryAndDie("Already have a command specified for execution!")
  13026. OptionValidation=af!R
  13027. OptionValidationRc=af!RcTest
  13028. return(0)
  13029. end
  13030. end
  13031. if af!R='' then
  13032. CryAndDie('No #OnExit text specified!')
  13033. if datatype(af!Slot, 'W')=0|af!Slot<1|af!Slot>100 then
  13034. CryAndDie('Invalid slot number of "' || af!Slot || '"')
  13035. call DBG '#OnExit (slot #' || af!Slot || ') we will process => ' ||DebugRightArrow||af!R||DebugLeftArrow
  13036. OnExitCnt=OnExitCnt+1
  13037. if OnExitLst.af!Slot='' then
  13038. do
  13039. OnExitLst.af!Slot=af!R
  13040. OnExitLoc.af!Slot=CurrentSourceLocation()
  13041. end
  13042. else
  13043. do
  13044. if af!Slot<>50 then
  13045. CryAndDie('You are attempting to reuse #OnExit slot ' || af!Slot, 'The slot was already used at ' || OnExitLoc.af!Slot, 'Only slot 50 can be reused.')
  13046. OnExitLst.af!Slot=OnExitLst.af!Slot||MarksNewLine||af!R
  13047. end
  13048. return(0)
  13049.  
  13050. OnExit_44:
  13051. IncludeIntoMemory=''
  13052. signal Include_45
  13053.  
  13054. RecursiveIncludeSave:
  13055. call LoopPush IncludeLevel
  13056. _DebugCurrentFileNumber.IncludeLevel=DebugCurrentFileNumber
  13057. _IncludeMemHandle.IncludeLevel=IncludeMemHandle
  13058. _IncludeEofLine.IncludeLevel=IncludeEofLine
  13059. _IncludeFragmentSpec.IncludeLevel=IncludeFragmentSpec
  13060. _IncludeLineNumber.IncludeLevel=IncludeLineNumber
  13061. _IncludeMemBufferNextLine.IncludeLevel=IncludeMemBufferNextLine
  13062. _IncludeLoopMemBufferNextLine.IncludeLevel=IncludeLoopMemBufferNextLine
  13063. _EofForced.IncludeLevel=EofForced
  13064. EofForced=''
  13065. return
  13066.  
  13067. RecursiveIncludeRestore:
  13068. DebugCurrentFileNumber=_DebugCurrentFileNumber.IncludeLevel
  13069. IncludeMemHandle=_IncludeMemHandle.IncludeLevel
  13070. IncludeEofLine=_IncludeEofLine.IncludeLevel
  13071. IncludeFragmentSpec=_IncludeFragmentSpec.IncludeLevel
  13072. IncludeLineNumber=_IncludeLineNumber.IncludeLevel
  13073. IncludeMemBufferNextLine=_IncludeMemBufferNextLine.IncludeLevel
  13074. IncludeLoopMemBufferNextLine=_IncludeLoopMemBufferNextLine.IncludeLevel
  13075. EofForced=_EofForced.IncludeLevel
  13076. IncludeFileName=IncludeFileName.IncludeLevel
  13077. call HandleIncludeFragment
  13078. call LoopPop IncludeLevel
  13079. return
  13080.  
  13081. FileInMemoryTimeStamp:
  13082. fimFullFileName=arg(1)
  13083. if RexSystemOpSys="UNIX" then
  13084. ifHandle='_IF_' || c2x(fimFullFileName) || '.'
  13085. else
  13086. ifHandle='_IF_' || c2x(translate(fimFullFileName)) || '.'
  13087. if symbol(ifHandle|| '!TS') <> 'VAR' then
  13088. return('')
  13089. else
  13090. do
  13091. Ts=_valueG(ifHandle|| '!TS')
  13092. if OptionDebugOn='Y' then
  13093. call DBG 'Cached Timestamp: "' || Ts || '"'
  13094. return(Ts)
  13095. end
  13096.  
  13097. IncludeFileOpen:
  13098. ifFullFileName=arg(1)
  13099. ifLoad2Mem=arg(2)
  13100. if RexSystemOpSys="UNIX" then
  13101. ifHandle='_IF_' || c2x(ifFullFileName) || '.'
  13102. else
  13103. ifHandle='_IF_' || c2x(translate(ifFullFileName)) || '.'
  13104. if symbol(ifHandle|| '0') = 'VAR' then
  13105. do
  13106. if OptionDebugOn='Y' then
  13107. call DBG '"' || ifFullFileName || '" will be read from memory cache'
  13108. return(_valueG(ifHandle|| '0') || ';' ||ifHandle)
  13109. end
  13110. call FileClose ifFullFileName, 'N'
  13111. OpenRc=FileOpenReadOnly(ifFullFileName)
  13112. if ifLoad2Mem='' then
  13113. ifLoad2Mem=IncludeIntoMemory
  13114. if ifLoad2Mem='N' then
  13115. do
  13116. if OptionDebugOn='Y' then
  13117. call DBG 'Will read "' || ifFullFileName || '" directly from file'
  13118. return('')
  13119. end
  13120. if OptionDebugOn='Y' then
  13121. call DBG 'Will read "' || ifFullFileName || '" into memory cache'
  13122. Ts=GetFileTimeStamp(ifFullFileName)
  13123. call _valueS ifHandle|| '!TS',Ts
  13124. ifLineNum=0
  13125. do while lines(ifFullFileName)<>0
  13126. ifLineNum=ifLineNum+1
  13127. ifLineTxt=linein(ifFullFileName)
  13128. call _valueS ifHandle||ifLineNum,ifLineTxt
  13129. end
  13130. call _valueS ifHandle|| '0',ifLineNum
  13131. call FileClose ifFullFileName
  13132. if OptionDebugOn='Y' then
  13133. do
  13134. call DBGIND 1
  13135. call DBG 'Read ' || AddCommasToDecimalNumber(ifLineNum) || ' lines'
  13136. call DBGIND-1
  13137. end
  13138. return(ifLineNum|| ';' ||ifHandle)
  13139.  
  13140. IncludeFileClose:
  13141. if IncludeMemHandle='' then
  13142. do
  13143. call FileClose IncludeFileName
  13144. end
  13145. return
  13146.  
  13147. IncludeFileLines:
  13148. if IncludeMemHandle='' then
  13149. return(lines(IncludeFileName))
  13150. else
  13151. return(IncludeLineNumber<IncludeEofLine)
  13152.  
  13153. IncludeFileLineIn:
  13154. IncludeLineNumber=IncludeLineNumber+1
  13155. if IncludeMemHandle='' then
  13156. ifLineTxt=linein(IncludeFileName)
  13157. else
  13158. ifLineTxt=_valueG(IncludeMemHandle||IncludeLineNumber)
  13159. if ExtraWhiteSpace=='' then
  13160. return(ifLineTxt)
  13161. else
  13162. return(translate(ifLineTxt, '', ExtraWhiteSpace, ' '))
  13163.  
  13164. Include_45:
  13165. SummaryUserAllBldCount=0
  13166. SummaryUserOverallCount=0
  13167. SummaryUserThisBldCount=0
  13168. signal Summary_46
  13169.  
  13170. Summary:call TRACE "OFF"
  13171. parse arg SummaryLeft,SummaryRight,SummaryMode
  13172. SummaryLeft=strip(SummaryLeft)
  13173. SummaryMode1=translate(left(SummaryMode,1))
  13174. select
  13175. when SummaryMode1='D' then
  13176. do
  13177. call DBG "Don't" || ' want "' || SummaryLeft || '" in any summaries'
  13178. call _valueS '!SUMMDROP.!' ||c2x(SummaryLeft),CurrentSourceLocation()
  13179. end
  13180. when SummaryMode1='O' then
  13181. do
  13182. SummaryUserOverallCount=SummaryUserOverallCount+1
  13183. SummaryUserOverallL.SummaryUserOverallCount=SummaryLeft
  13184. SummaryUserOverallR.SummaryUserOverallCount=SummaryRight
  13185. end
  13186. when SummaryMode1='A' then
  13187. do
  13188. SummaryUserAllBldCount=SummaryUserAllBldCount+1
  13189. SummaryUserAllBldL.SummaryUserAllBldCount=SummaryLeft
  13190. SummaryUserAllBldR.SummaryUserAllBldCount=SummaryRight
  13191. end
  13192. otherwise
  13193. do
  13194. SummaryUserThisBldCount=SummaryUserThisBldCount+1
  13195. SummaryUserThisBldL.SummaryUserThisBldCount=SummaryLeft
  13196. SummaryUserThisBldR.SummaryUserThisBldCount=SummaryRight
  13197. end
  13198. end
  13199. return
  13200.  
  13201. GenerateUserSummaryThisBuild:
  13202. do SummLine=1 to SummaryUserThisBldCount
  13203. call AddSummaryLine SummaryUserThisBldL.SummLine,SummaryUserThisBldR.SummLine
  13204. end
  13205. SummaryUserThisBldCount=0
  13206. return
  13207.  
  13208. GenerateUserSummaryAllBuilds:
  13209. do SummLine=1 to SummaryUserAllBldCount
  13210. call AddSummaryLine SummaryUserAllBldL.SummLine,SummaryUserAllBldR.SummLine
  13211. end
  13212. return
  13213.  
  13214. GenerateUserSummaryOverall:
  13215. do SummLine=1 to SummaryUserOverallCount
  13216. call AddSummaryLine SummaryUserOverallL.SummLine,SummaryUserOverallR.SummLine
  13217. end
  13218. return
  13219.  
  13220. AboutToGenerateSummary:
  13221. MaxSummaryLeft=0
  13222. SummaryLines=0
  13223. call Line1 ''
  13224. if arg(1)<> 'N' then
  13225. do
  13226. TitleText='Summary'
  13227. call ColorSet 'TITLE'
  13228. call Line1 TitleText
  13229. call Line1 copies('~',length(TitleText))
  13230. call ColorSet
  13231. end
  13232. return
  13233.  
  13234. AddSummaryLine:
  13235. parse arg SummaryLeft,SummaryRight
  13236. SummaryLeft=strip(SummaryLeft)
  13237. DropSym='!SUMMDROP.!' ||c2x(SummaryLeft)
  13238. if symbol(DropSym)='VAR' then
  13239. do
  13240. call DBG 'Summary line for "' || SummaryLeft || '" unwanted (dropped at ' || _valueG(DropSym) || ')'
  13241. return
  13242. end
  13243. if length(SummaryLeft)>MaxSummaryLeft then
  13244. MaxSummaryLeft=length(SummaryLeft)
  13245. SummaryLines=SummaryLines+1
  13246. SummaryL.SummaryLines=SummaryLeft
  13247. SummaryR.SummaryLines=SummaryRight
  13248. return
  13249.  
  13250. GenerateSummaryLines:
  13251. call ColorSet 'SUMMARY'
  13252. do SummLine=1 to SummaryLines
  13253. call Line1 "   " || left(SummaryL.SummLine, MaxSummaryLeft) || ': ' ||SummaryR.SummLine
  13254. end
  13255. call ColorSet
  13256. return
  13257.  
  13258. Summary_46:
  13259. PpwCompTime=NiceDateTime()
  13260. PpwCompTs=TimeStamp()
  13261. InputInterfaceVer="98.131"
  13262. OutputInterfaceVer="98.132"
  13263. call SetEnv "PPWIZARD_VER_II",InputInterfaceVer
  13264. call SetEnv "PPWIZARD_VER_OI",OutputInterfaceVer
  13265. ProtectPrefix='{PROTECT_' || time('Seconds') || '}'
  13266. ProtectFromPpwS="option PUSH LeaveBlankLines=YES KeepIndent=YES linecomment='NULL' LineContinuation='NULL' HashPrefix='" || ProtectPrefix || "'"
  13267. ProtectFromPpwE=ProtectPrefix|| 'option POP'
  13268. call QuickCheckForDebugSwitch
  13269. signal on NOVALUE name RexxTrapUninitializedVariable
  13270. signal on SYNTAX name RexxTrapSyntaxError
  13271. signal on HALT name RexxCtrlC
  13272. TrapHandler='FULL'
  13273. call InitCommandLineOptions2
  13274. call ProcessCommandLine
  13275. if InputMaskCount=0 then
  13276. do
  13277. if OptionNoFiles="" then
  13278. UserSyntaxError("No input masks specified and no default configured (/NOFILES)")
  13279. else
  13280. do
  13281. call ProcessCommandLineBit "/NOFILES",OptionNoFiles
  13282. if InputMaskCount=0 then
  13283. UserSyntaxError("No input masks specified and /NOFILES did not include a file mask!")
  13284. end
  13285. end
  13286. call CheckRexxInterpreter 'Y'
  13287. call DebugShowAsMuchEnvironmentDetailAsPossible
  13288. PpwUserDescription='PPWIZARD version ' || PgmVersion || ' on ' || PpWizardOpSysREAL ||  ', FREE tool for Windows, OS/2, DOS and UNIX by ' || PgmAuthor || ' (' || PgmHomePage || ')'
  13289. PgmDefaultHtmlMetaTags='<meta name="GENERATOR" content="' || PpwUserDescription || '"' || OptionXSlash || '>'
  13290. if HaveGeneratorTags='N' then
  13291. OptionHtmlGeneratorTags=PgmDefaultHtmlMetaTags
  13292. if OptionCloneUsed='Y' then
  13293. do
  13294. if InputMaskCount<2 then
  13295. UserSyntaxError('No clone destination supplied!')
  13296. CloneOutputMask=InputMask.InputMaskCount||RexDirChar|| '{' || '$path}' || RexDirChar || '*.*'
  13297. call ProcessCommandLineBit "CLONE", OptChar || 'Output:' || ReplaceString(CloneOutputMask, ' ', '{x20}')
  13298. InputMaskCount=InputMaskCount-1
  13299. end
  13300. InputMasksAllowed='N'
  13301. InpFileCount=0
  13302. InpFileCountActuallyMade=0
  13303. AllSameExtn=''
  13304. do SpecIndex=1 to InputMaskCount
  13305. InputList.0=0
  13306. TmpMask=InputMask.SpecIndex
  13307. call DBG 'Looking for files matching "' || TmpMask || '"'
  13308. if left(TmpMask,1)<> '+' then
  13309. FollowDirs='N'
  13310. else
  13311. do
  13312. FollowDirs='Y'
  13313. TmpMask=substr(TmpMask,2)
  13314. end
  13315. call Files4Mask TmpMask, 'InputList',FollowDirs
  13316. call DBGIND 1
  13317. call DBG 'Found ' || InputList.0 || ' files(s)'
  13318. call DBGIND 1
  13319. if InputList.0=0 then
  13320. do
  13321. call CheckForNotBeingAbleToExecAnything
  13322. WeWantToDie='Y'
  13323. if LookLikeASingleFile(TmpMask)='Y' then
  13324. do
  13325. if OptionDebugOn='N' then
  13326. do
  13327. call BeepsAllow 'N'
  13328. call ColorAllow 'N'
  13329. OptionDebugOn='Y'
  13330. OptionWantInfoMsgs='Y'
  13331. call DebugStateChanged
  13332. call DBG 'Debug forced on as we seem to have a file find problem!'
  13333. call DBGIND 1
  13334. call DBG 'We could not find "' || TmpMask || '", yet it seems to exist! We will solder on!'
  13335. call DBG 'Please send redirected output to "' || PgmAuthor || '" (' || PgmAuthorEmail || ')'
  13336. call DBG 'You could easily use a "GetFileList" ' || OptChar || 'Hook to workaround this.'
  13337. call DBGIND 1
  13338. call Files4Mask TmpMask, 'InputList',FollowDirs
  13339. call DBGIND-2
  13340. call DBG 'Turning off debug again'
  13341. OptionDebugOn='N'
  13342. call DebugStateChanged
  13343. end
  13344. InputList.0=1
  13345. InputList.1=TmpMask
  13346. WeWantToDie='N'
  13347. end
  13348. if WeWantToDie='Y' then
  13349. do
  13350. if InputMask0FilesOk.SpecIndex='Y' then
  13351. call DBG 'You indicated that 0 files were OK...'
  13352. else
  13353. do
  13354. Left1=left(InputMask.SpecIndex,1)
  13355. if Left1<> '-' & Left1 <> '/' then
  13356. Extra=''
  13357. else
  13358. Extra=' (all switches under ' || PpWizardOpSysREAL || ' must start with "' || OptChar || '")'
  13359. UserSyntaxError('No input files matched "' || InputMask.SpecIndex || '"' ||Extra)
  13360. end
  13361. end
  13362. end
  13363. do InputIndex=1 to InputList.0
  13364. TheFile=InputList.InputIndex
  13365. call DBG TheFile
  13366. InpFileCount=InpFileCount+1
  13367. InpFile.InpFileCount=TheFile
  13368. InpFileMaskIndex.InpFileCount=SpecIndex
  13369. DotPos=lastpos('.',TheFile)
  13370. if DotPos<>0 then
  13371. do
  13372. FileExtn=translate(substr(TheFile,DotPos+1))
  13373. if InpFileCount=1 then
  13374. AllSameExtn=FileExtn
  13375. if AllSameExtn<>FileExtn then
  13376. AllSameExtn=''
  13377. end
  13378. end
  13379. call DBGIND-2
  13380. end
  13381. if InpFileCount=0 then
  13382. do
  13383. if Option0FilesTotalOk='N' then
  13384. UserSyntaxError('No files matched any of the input file masks (' || InputMaskCount || ') supplied!')
  13385. end
  13386. if AllSameExtn<> '' then
  13387. do
  13388. call DBG 'All input files end in the same extension (".' || AllSameExtn || '")'
  13389. call DBGIND 1
  13390. if OptionPrjExtn='' then
  13391. call DBG 'User has turned off Extensions based project files'
  13392. else
  13393. do
  13394. ExtnFile=ReplaceString(OptionPrjExtn, '*',AllSameExtn)
  13395. ExtnFile=FindProjectFile(ExtnFile)
  13396. if ExtnFile<> '' then
  13397. call ProcessCommandLineBit ExtnFile,OptChar|| 'LIST:' || ReplaceString(ExtnFile, ' ', '{x20}')
  13398. end
  13399. call DBGIND-1
  13400. end
  13401. if NewLineChars==CrLf then
  13402. LinesEndWith="CR followed by LF"
  13403. else
  13404. LinesEndWith="LF only"
  13405. call DBG 'Output lines are terminated with ' ||LinesEndWith
  13406. call DBG 'HTML Generator Tags are ' ||DebugRightArrow||OptionHtmlGeneratorTags||DebugLeftArrow
  13407. if OptionWantCopyright='Y' then
  13408. do
  13409. if OptionQuietDependsOn='N' then
  13410. call DisplayCopyright
  13411. end
  13412. call DebugStateChanged
  13413. if IncludeIntoMemory='' then
  13414. do
  13415. if InpFileCount=1 then
  13416. IncludeIntoMemory='N'
  13417. else
  13418. IncludeIntoMemory='Y'
  13419. end
  13420. call DBG 'Will read files into memory cache: ' ||IncludeIntoMemory
  13421. LastProcessingMode=ProcessingMode
  13422. LastOptionOutput=OptionOutput
  13423. LastOptionDependsOn=OptionDependsOn
  13424. PpwExitRc=0
  13425. ActuallyProcessed=0
  13426. FailedProcessingWarning=0
  13427. do InputIndex=1 to InpFileCount
  13428. ThisFile=InpFile.InputIndex
  13429. if symbol("_EXCLUDE_._EXF_" || c2x(ThisFile)) = 'VAR' then
  13430. do
  13431. call DBG ThisFile|| ' excluded - ' || _valueG("_EXCLUDE_._EXF_" ||c2x(ThisFile))
  13432. iterate
  13433. end
  13434. ActuallyProcessed=ActuallyProcessed+1
  13435. call _valueS "_EXCLUDE_._EXF_" || c2x(ThisFile), "Already processed"
  13436. SpecIndex=InpFileMaskIndex.InputIndex
  13437. BaseDir4CurrentInputFile=InputMaskBDir.SpecIndex
  13438. bf!Pm=InputMaskPMode.SpecIndex
  13439. bf!Om=InputMaskOutMask.SpecIndex
  13440. bf!Dm=InputMaskDepMask.SpecIndex
  13441. CopyModeFuzz=InputMaskCpyFuzz.SpecIndex
  13442. if bf!Om='' then
  13443. do
  13444. if OptionCloneUsed='Y' then
  13445. bf!Om=CloneOutputMask
  13446. end
  13447. call DBG 'In 02.148 backwards compatability mode? : ' ||Bc02_148
  13448. if Bc02_148='Y' then
  13449. do
  13450. if bf!Pm='' then
  13451. bf!Pm=LastProcessingMode
  13452. if bf!Om='' then
  13453. bf!Om=LastOptionOutput
  13454. if bf!Dm='' then
  13455. bf!Dm=LastOptionDependsOn
  13456. end
  13457. else
  13458. do
  13459. if bf!Om='' then
  13460. do
  13461. bf!Om=GetEiOrLu(ThisFile, 'OM',LastOptionOutput)
  13462. if bf!Om='' then
  13463. CryAndDie('No default output mask configured for "' || ThisFile || '"', "See /ExtnInfo")
  13464. end
  13465. if bf!Pm='' then
  13466. do
  13467. bf!Pm=GetEiOrLu(ThisFile, 'PM',LastProcessingMode)
  13468. if bf!Pm='' then
  13469. CryAndDie('No default processing mode configured "' || ThisFile || '"', "See /ExtnInfo")
  13470. end
  13471. if bf!Dm='' then
  13472. bf!Dm=GetEiOrLu(ThisFile, 'DM',LastOptionDependsOn)
  13473. end
  13474. ProcessingMode=bf!Pm
  13475. OptionOutput=bf!Om
  13476. OptionDependsOn=bf!Dm
  13477. if OptionTemplate='' then
  13478. GenerateRc=GenerateOutput(ThisFile, '')
  13479. else
  13480. GenerateRc=GenerateOutput(OptionTemplate,ThisFile)
  13481. if GenerateRc>PpwExitRc then
  13482. PpwExitRc=GenerateRc
  13483. if OptionDebugOn='Y' then
  13484. call DBG 'The Exit Rc is currently "' || PpwExitRc || '"'
  13485. end
  13486. if ActuallyProcessed=0 then
  13487. do
  13488. if InpFileCount<>0 then
  13489. do
  13490. if Option0FilesTotalAfterExcludeOk='N' then
  13491. UserSyntaxError('All input files (' || InpFileCount || ') were excluded by you!')
  13492. end
  13493. end
  13494. call OutputAnySpellingAdditions
  13495. if OptionQuietDependsOn='Y' &InpFileCountActuallyMade=0 then
  13496. OptionSummary='N'
  13497. if OptionSummary='Y' then
  13498. do
  13499. if ActuallyProcessed<>1 then
  13500. do
  13501. call AboutToGenerateSummary
  13502. call GenerateUserSummaryOverall
  13503. call AddSummaryLine 'Operating Syst' ,PpWizardOpSys
  13504. call AddSummaryLine 'Rexx Version' ,RexVersionInfo
  13505. if InpFileCount=InpFileCountActuallyMade then
  13506. call AddSummaryLine '# files' ,InpFileCount
  13507. else
  13508. call AddSummaryLine '# files made' ,InpFileCountActuallyMade || ' out of ' ||InpFileCount
  13509. call AddSummaryLine 'Exit Code' ,PpwExitRc
  13510. if FailedProcessingWarning<>0 then
  13511. call AddSummaryLine '# Warnings' ,FailedProcessingWarning
  13512. call AddSummaryLine 'Elapsed Time'     ,trunc(time('Elapsed'), 2) || ' seconds'
  13513. call GenerateSummaryLines
  13514. end
  13515. end
  13516. ThatsAllFolks(PpwExitRc)
  13517.  
  13518. GetSourceFileDateTimeDieOnError:
  13519. DateTimeRc=GetFileDateTimeButDontWarnOnError(arg(1))
  13520. if DateTimeRc=-1 then
  13521. CryAndDie('Could not get date/time stamp of "' || arg(1) || '".')
  13522. return(DateTimeRc)
  13523.  
  13524. InitLuCaseCfg:
  13525. CfgLower=''
  13526. CfgUpper=''
  13527. return
  13528.  
  13529. GetUserLcCfg:
  13530. if CfgLower=='' then
  13531. do
  13532. CfgLower=CfgMacro("PPWIZARD_LOWERCASE",LowerCase)
  13533. CfgUpper=CfgMacro("PPWIZARD_UPPERCASE",UpperCase)
  13534. end
  13535. return
  13536.  
  13537. GenerateOutput:
  13538. InputFile=arg(1)
  13539. TemplateDataFile=arg(2)
  13540. call ClearCollectedDependancyInfo
  13541. if OptionTemplate='' then
  13542. do
  13543. call DBG 'Main file is not a template, no point loading into memory'
  13544. InFile=InputFile
  13545. ForceBaseFile2Mem='N'
  13546. end
  13547. else
  13548. do
  13549. call DBG 'Main file is a template'
  13550. InFile=TemplateDataFile
  13551. ForceBaseFile2Mem=''
  13552. end
  13553. CurrentOutFile=GenerateFileName(InFile,OptionOutput)
  13554. call ClearDependancyTimeStampCache
  13555. InputFileFull=FileQueryExists(InputFile)
  13556. if NeedToRemake(InFile)='N' then
  13557. return(0)
  13558. if OptionDependsOn='' then
  13559. do
  13560. if ProcessingMode='COPY' then
  13561. do
  13562. cf!Rc=AreFilesEqual(InputFileFull,CurrentOutFile,CopyModeFuzz)
  13563. if cf!Rc='' then
  13564. return(0)
  13565. end
  13566. end
  13567. InpFileCountActuallyMade=InpFileCountActuallyMade+1
  13568. if OptionWantCopyright='Y' then
  13569. do
  13570. if OptionQuietDependsOn='Y' then
  13571. call DisplayCopyright
  13572. end
  13573. cf!T=value('PPWBLDTITLE_' ||ProcessingMode)
  13574. cf!T=ReplaceString(cf!T, '{IS}', _filespec('N',InputFileFull))
  13575. cf!T=ReplaceString(cf!T, '{OS}', _filespec('N',CurrentOutFile))
  13576. cf!T=ReplaceString(cf!T, '{ID}', _filespec('L',InputFileFull))
  13577. cf!T=ReplaceString(cf!T, '{OD}', _filespec('L',CurrentOutFile))
  13578. cf!T=ReplaceString(cf!T, '{IL}',InputFileFull)
  13579. cf!T=ReplaceString(cf!T, '{OL}',CurrentOutFile)
  13580. cf!T=ReplaceString(cf!T, '{PM}',ProcessingMode)
  13581. call ColorSet 'TITLE'
  13582. call Line1 cf!T
  13583. if ProcessingMode<> 'COPY' then
  13584. call Line1 copies('~',length(cf!T))
  13585. call ColorSet
  13586. if OptionTemplate='' then
  13587. TmpTemplate=''
  13588. else
  13589. TmpTemplate=TemplateDataFile
  13590. call RexxHookSetBuildingParms InFile,CurrentOutFile,TmpTemplate
  13591. if RexxHookBefore<> '' then
  13592. call CallHook "BEFORE"
  13593. call SetUpOptionsForThisBuild
  13594. Dummy=time('Reset')
  13595. call DBGINDInit
  13596. call InitLuCaseCfg
  13597. call StackInitForBuild
  13598. call CompletelyInitializeAutoTagState
  13599. call InitINTERCEPTCode
  13600. call InitTransformationCode
  13601. call InitOutputHold
  13602. call InitializeCharCodes
  13603. call InitializeDefineRexx
  13604. call InitializeOneLine
  13605. call InitCondNlCount
  13606. call InitOnExitProcessing
  13607. call InitNextId
  13608. DebugIncludeNumber=0
  13609. Warnings=0
  13610. LineSourceBeingProcessed='?'
  13611. GeneratedLines=0
  13612. InputLines=0
  13613. PartialLine=''
  13614. IncludeLevel=0
  13615. EofForced=''
  13616. LineQueued=''
  13617. PPwizardUnique=0
  13618. StackCnt=0
  13619. OptionStackCnt=0
  13620. HtmlGeneratorTags=OptionHtmlGeneratorTags
  13621. AsIsModeOn='N'
  13622. if OptionCompleteAddToToDepFile='Y' then
  13623. do
  13624. call AddInputFileToDependancyList "*PpwPgm"
  13625. call AddInputFileToDependancyList "*CmdLine"
  13626. end
  13627. call PrepareSpellingForThisBuild
  13628. TsNewestSourcefile=GetSourceFileDateTimeDieOnError(PpWizardPgmName)
  13629. call InitializeHashDefinesForThisCompile
  13630. IfNesting=0
  13631. IfState.WantLines.0='Y'
  13632. IfState.IfTrue.0='Y'
  13633. IfState.InTrue.0='Y'
  13634. WantLineCache='Y'
  13635. GenerateRc=0
  13636. call CheckRexxInterpreter
  13637. if ProcessingMode='COPY' then
  13638. do
  13639. cf!Rc=FileCopy(InputFileFull,CurrentOutFile)
  13640. call CreateDependancyFileFromLists
  13641. return(0)
  13642. end
  13643. OutputLevel=0
  13644. Ok2OutputHeader='Y'
  13645. call HaveNewOutputFile CurrentOutFile,,'N',ProcessingMode
  13646. do cf!HI=1 to OptionHashIncludeCnt
  13647. cf!List=OptionHashInclude.cf!HI
  13648. do while cf!List<> ''
  13649. parse var cf!List cf!This (PathDelimiterChar) cf!List
  13650. if cf!This<> '' then
  13651. do
  13652. call DBG '/#Include "' ||cf!This
  13653. GenerateRc=GenerateRc+ProcessInputFile(cf!This)
  13654. end
  13655. end
  13656. end
  13657. GenerateRc=GenerateRc+ProcessInputFile(InputFile,,ForceBaseFile2Mem)
  13658. if GenerateRc=0 then
  13659. do
  13660. call StackValidation
  13661. if OptionDebugOn='Y' then
  13662. call DBG 'Generation successful so far, look for nesting and other errors'
  13663. select
  13664. when IfNesting<>0 then
  13665. do
  13666. do Index=1 to IfNesting
  13667. NestingLevel=(IfNesting-Index)+1
  13668. call DBG 'Missing #endif at EOF - Nesting Level #' ||NestingLevel||MatchesIfDebugText(NestingLevel)
  13669. end
  13670. CryAndDie('Missing #endif at EOF' ||MatchesIfDebugText(IfNesting))
  13671. end
  13672. when StackCnt<>0 then
  13673. do
  13674. do Index=1 to StackCnt
  13675. NestingLevel=(StackCnt-Index)+1
  13676. call DBG 'Missing #RexxVar pop at EOF - Nesting Level #' ||NestingLevel||MatchesStackPushDebugText(NestingLevel)
  13677. end
  13678. CryAndDie('Incorrect #RexxVar push/pop nesting at EOF' ||MatchesStackPushDebugText(StackCnt))
  13679. end
  13680. when OptionStackCnt<>0 then
  13681. do
  13682. do Index=1 to OptionStackCnt
  13683. NestingLevel=(OptionStackCnt-Index)+1
  13684. call DBG 'Missing pop() at EOF - Nesting Level #' ||NestingLevel||MatchesOptionStackPushDebugText(NestingLevel)
  13685. end
  13686. CryAndDie('Missing #Option pop at EOF' ||MatchesOptionStackPushDebugText(OptionStackCnt))
  13687. end
  13688. when AutoTagStateCnt<>0 then
  13689. do
  13690. do Index=1 to AutoTagStateCnt
  13691. NestingLevel=(AutoTagStateCnt-Index)+1
  13692. call DBG 'Missing #AutoTagState- at EOF - Nesting Level #' ||NestingLevel||MatchesAutoTagStateIncDebugText(NestingLevel)
  13693. end
  13694. CryAndDie('Missing #AutoTagState- at EOF' ||MatchesAutoTagStateIncDebugText(AutoTagStateCnt))
  13695. end
  13696. when DefRexxVar<> '' then
  13697. CryAndDie('Missing #DefineRexx[+] at EOF', 'Block started at ' ||DefRexxStartLoc)
  13698. when OutputLevel>1 then
  13699. CryAndDie('Missing ' || OutputLevel - 1 || ' #output command(s) at EOF')
  13700. when OutputHoldLvl<>0 then
  13701. CryAndDie('Missing #OutputHold (end) at EOF', 'LAST Block started at ' ||OutHold_.OutputHoldLvl.!OutpHoldStartLoc)
  13702. otherwise
  13703. call DieIfHoldingOutput
  13704. end
  13705. if GeneratedLines=0 then
  13706. call OutputWarningToScreen 'GEN0', 'No output lines generated'
  13707. if OptionDebugOn='Y' then
  13708. call DBG 'No fatal errors detected so far'
  13709. end
  13710. call _FileClose CurrentOutFile
  13711. if RexxHookAfter<> '' then
  13712. call CallHook "AFTER"
  13713. if GenerateRc=0 then
  13714. do
  13715. if OptionDebugOn='Y' then
  13716. call DBG 'Looks OK so far, look for even more errors'
  13717. if PartialLine<> '' then
  13718. CryAndDie('A line continued to EOF')
  13719. call DoSyntaxCheckingOnFileIfEnabled CurrentOutFile
  13720. if OptionValidation<> '' then
  13721. do
  13722. ToExec=ReplaceHashAndStandardDefines(OptionValidation)
  13723. call RunExecOrValidateCmd 'VALIDATE',OptionValidationRc,ToExec
  13724. end
  13725. if Warnings<>0 then
  13726. do
  13727. FailedProcessingWarning=FailedProcessingWarning+1
  13728. GenerateRc=WantedWarningRc
  13729. end
  13730. if OptionNoDepFileOnWarnings='Y' &Warnings<>0 then
  13731. call DBG 'Dependancy file not created as warnings exist'
  13732. else
  13733. call CreateDependancyFileFromLists
  13734. if OptionSummary='Y' then
  13735. do
  13736. if InpFileCount=1 then
  13737. call AboutToGenerateSummary
  13738. else
  13739. call AboutToGenerateSummary 'N'
  13740. call GenerateUserSummaryThisBuild
  13741. call GenerateUserSummaryAllBuilds
  13742. if InpFileCount=1 then
  13743. call GenerateUserSummaryOverall
  13744. if Warnings<>0 then
  13745. call AddSummaryLine 'Warnings'        ,'YES (' || AddCommasToDecimalNumber(Warnings) || ')'
  13746. if InpFileCount=1 then
  13747. do
  13748. call AddSummaryLine 'Operating Syst' ,PpWizardOpSys
  13749. call AddSummaryLine 'Rexx Version' ,RexVersionInfo
  13750. end
  13751. call AddSummaryLine 'Return Code' ,GenerateRc
  13752. call AddSummaryLine 'Elapsed Time'        ,trunc(time('Elapsed'), 2) || ' seconds'
  13753. call GenerateSummaryLines
  13754. end
  13755. end
  13756. call Line1 ''
  13757. call RexxHookSetBuildingParms
  13758. return(GenerateRc)
  13759.  
  13760. MyLineNumber:
  13761. return(SIGL)
  13762.  
  13763. HandleIncludeFragment:
  13764. df!U=translate(IncludeFragmentSpec)
  13765. select
  13766. when left(df!U,3)='SE:' then
  13767. do
  13768. parse var IncludeFragmentSpec +3 df!Del +1 df!S (df!Del) df!E (df!Del) df!Crap
  13769. if df!Crap<> '' then
  13770. do
  13771. IncludeLevel=IncludeLevel-1
  13772. if IncludeLevel<>0 then
  13773. call RecursiveIncludeRestore
  13774. CryAndDie('The "SE:" fragment spec:', '    ' || IncludeFragmentSpec, 'is not correctly formatted. ("' || df!Crap || '" was unexpected)')
  13775. end
  13776. end
  13777. otherwise
  13778. do
  13779. df!S=IncludeFragmentSpec
  13780. df!E=df!S
  13781. end
  13782. end
  13783. IncludeFragmentS=df!S
  13784. IncludeFragmentE=df!E
  13785. return
  13786.  
  13787. ProcessInputFile:
  13788. parse arg RequestedFile,ef!AddToDepFile,ef!ForceLoad2Mem,IncludeFragmentSpec
  13789. call HandleIncludeFragment
  13790. IncludeLineNumber=0
  13791. IncludeMemBufferNextLine=''
  13792. IncludeLoopMemBufferNextLine=''
  13793. DebugIncludeNumber=DebugIncludeNumber+1
  13794. DebugCurrentFileNumber=DebugIncludeNumber
  13795. IncludeFileName=FindFile(RequestedFile)
  13796. if IncludeFileName='' then
  13797. do
  13798. if IncludeLevel<>0 then
  13799. call RecursiveIncludeRestore
  13800. CryAndDie('File "' || RequestedFile || '" does not exist!')
  13801. end
  13802. IncludeLevel=IncludeLevel+1
  13803. IncludeFileName.IncludeLevel=IncludeFileName
  13804. if IncludeLevel>=InfiniteIncludeLoopWhen then
  13805. do
  13806. if InfiniteIncludeLoopWhen<>0 then
  13807. do
  13808. say 'Infinite #include loop detected, at level #' ||IncludeLevel
  13809. say 'Use "/define:INFINITE_INCLUDE_LOOP_WHEN=0"   to turn off detection'
  13810. say 'Use "/define:INFINITE_INCLUDE_LOOP_WHEN=100" to increase detection threshold etc'
  13811. IncludeLevel=IncludeLevel-1
  13812. call RecursiveIncludeRestore
  13813. CryAndDie("We seem to be in an infinite #include loop!")
  13814. end
  13815. end
  13816. MemUpdateIndex=0
  13817. do IncIndex=1 to IncludeLevel-1
  13818. if RexSystemOpSys="UNIX" then
  13819. IncSame=(IncludeFileName=IncludeFileName.IncIndex)
  13820. else
  13821. IncSame=(translate(IncludeFileName)=translate(IncludeFileName.IncIndex))
  13822. if IncSame=1 then
  13823. do
  13824. if _IncludeMemHandle.IncIndex<> '' then
  13825. call DBG 'File already being processed, already reading from memory cache!'
  13826. else
  13827. do
  13828. call DBG 'File already being processed, forcing use from memory cache'
  13829. call _FileClose IncludeFileName
  13830. MemUpdateIndex=IncIndex
  13831. ef!ForceLoad2Mem='Y'
  13832. end
  13833. leave
  13834. end
  13835. end
  13836. if ef!AddToDepFile<> 'N' then
  13837. call AddInputFileToDependancyList(/*RequestedFile*/IncludeFileName)
  13838. call ReadingI
  13839. ThisDateTime=GetSourceFileDateTimeDieOnError(IncludeFileName)
  13840. if ThisDateTime>TsNewestSourcefile then
  13841. TsNewestSourcefile=ThisDateTime
  13842. parse value IncludeFileOpen(IncludeFileName,ef!ForceLoad2Mem)with IncludeEofLine ';' IncludeMemHandle
  13843. if MemUpdateIndex<>0 then
  13844. do
  13845. _IncludeMemHandle.MemUpdateIndex=IncludeMemHandle
  13846. _IncludeEofLine.MemUpdateIndex=IncludeEofLine
  13847. end
  13848. if IncludeFragmentS<> '' then
  13849. do
  13850. call DBG 'Looking for the start of the fragment: ' ||IncludeFragmentS
  13851. do while IncludeFileLines()<>0
  13852. InputLines=InputLines+1
  13853. FileLine=IncludeFileLineIn()
  13854. if pos(IncludeFragmentS,FileLine)<>0 then
  13855. leave
  13856. end
  13857. if IncludeFileLines()=0 then
  13858. do
  13859. ef!FR=IncludeFragmentS
  13860. ef!FN=IncludeFileName
  13861. ef!LP=IncludeLineNumber
  13862. IncludeLevel=IncludeLevel-1
  13863. if IncludeLevel<>0 then
  13864. call RecursiveIncludeRestore
  13865. CryAndDie('Did not find the START of the code fragment "' || ef!FR || '" (searched ' || AddCommasToDecimalNumber(ef!LP) || ' lines in "' || ef!FN || '")')
  13866. end
  13867. call DBG 'Found it'
  13868. end
  13869. do forever
  13870. LastLineAfterMacroRep=''
  13871. select
  13872. when IncludeLoopMemBufferNextLine\=='' then
  13873. do
  13874. ef!LC='<<#{'
  13875. parse var IncludeLoopMemBufferNextLine FileLine (MarksNewLine) IncludeLoopMemBufferNextLine
  13876. LastLine=FileLine
  13877. LineSrc='M'
  13878. if OptionDebugOn='Y' then
  13879. call DebugShowCurrentLineWithLineNumber FileLine,ef!LC
  13880. end
  13881. when InLoop='Y' &LoopLinesFromFile=0 then
  13882. do
  13883. ef!LC='<<ML'
  13884. FileLine=GetLoopLineIntoFileLine()
  13885. LastLine=FileLine
  13886. LineSrc='M'
  13887. if OptionDebugOn='Y' then
  13888. call DebugShowCurrentLineWithLineNumber FileLine,ef!LC
  13889. end
  13890. when IncludeMemBufferNextLine\=='' then
  13891. do
  13892. ef!LC='<<<<'
  13893. parse var IncludeMemBufferNextLine FileLine (MarksNewLine) IncludeMemBufferNextLine
  13894. LastLine=FileLine
  13895. LineSrc='M'
  13896. if LinesFromOnExit='Y' then
  13897. LastFileLine=FileLine
  13898. if OptionDebugOn='Y' then
  13899. call DebugShowCurrentLineWithLineNumber FileLine,ef!LC
  13900. end
  13901. when LineQueued\=='' then
  13902. do
  13903. call FlushQueuedOutput
  13904. iterate
  13905. end
  13906. when InLoop='Y' |IncludeFileLines()<>0 then
  13907. do
  13908. if EofForced<> '' then
  13909. do
  13910. if OptionDebugOn='Y' then
  13911. call DBG '#EOF (at ' || EofForced || ') told us to stop processing this file any further'
  13912. if SetUpOnExitProcessingIfEndOfMainFile()='Y' then
  13913. iterate
  13914. leave
  13915. end
  13916. if InLoop='Y' then
  13917. do
  13918. FileLine=GetLoopLineIntoFileLine()
  13919. ef!LC='<<FL'
  13920. end
  13921. else
  13922. do
  13923. InputLines=InputLines+1
  13924. FileLine=IncludeFileLineIn()
  13925. ef!LC=''
  13926. end
  13927. LastFileLine=FileLine
  13928. LastLine=FileLine
  13929. LineSrc='F'
  13930. if OptionDebugOn='Y' then
  13931. call DebugShowCurrentLineWithLineNumber FileLine,ef!LC
  13932. if IncludeFragmentE<> '' then
  13933. do
  13934. if pos(IncludeFragmentE,FileLine)<>0 then
  13935. do
  13936. call DBG 'Found the end of the fragment'
  13937. IncludeFragmentE=''
  13938. leave
  13939. end
  13940. end
  13941. if OptionFilterIn<> '' then
  13942. do
  13943. FileLine=HtmlFilterIn("I",FileLine,IncludeFileName,IncludeLineNumber,InputLines,MarksNewLine)
  13944. if pos(MarksNewLine,FileLine)<>0 then
  13945. do
  13946. IncludeMemBufferNextLine=FileLine
  13947. iterate
  13948. end
  13949. if left(FileLine,1)=NullChar then
  13950. do
  13951. if FileLine=NullChar then
  13952. iterate
  13953. else
  13954. CryAndDie(substr(FileLine,2))
  13955. end
  13956. end
  13957. end
  13958. otherwise
  13959. do
  13960. if SetUpOnExitProcessingIfEndOfMainFile()='Y' then
  13961. iterate
  13962. leave
  13963. end
  13964. end
  13965. if LineSrc<> 'F' then
  13966. do
  13967. LineContinued='N'
  13968. Word1=word(FileLine,1)
  13969. end
  13970. else
  13971. do
  13972. if InterceptCode<> '' then
  13973. do
  13974. if FileLine=InterceptOffMarker then
  13975. do
  13976. if OptionDebugOn='Y' then
  13977. call DBG 'Intercepted line looks like end of block, not processed'
  13978. end
  13979. else
  13980. do
  13981. BeforeLine=FileLine
  13982. call ExecRexxCmd InterceptCode
  13983. if OptionDebugOn='Y' then
  13984. do
  13985. if BeforeLine==FileLine then
  13986. call DBG 'Intercepted line was not changed'
  13987. else
  13988. call DBG 'Intercepted Line changed to ' ||DebugRightArrow||FileLine||DebugLeftArrow
  13989. end
  13990. if BeforeLine\==FileLine then
  13991. do
  13992. if pos(MarksNewLine,FileLine)<>0 then
  13993. do
  13994. do
  13995. if InLoop='Y' &LoopLinesFromFile=0 then
  13996. do
  13997. if IncludeLoopMemBufferNextLine=='' then
  13998. IncludeLoopMemBufferNextLine=FileLine
  13999. else
  14000. IncludeLoopMemBufferNextLine=FileLine||MarksNewLine||IncludeLoopMemBufferNextLine
  14001. end
  14002. else
  14003. do
  14004. if IncludeMemBufferNextLine=='' then
  14005. IncludeMemBufferNextLine=FileLine
  14006. else
  14007. IncludeMemBufferNextLine=FileLine||MarksNewLine||IncludeMemBufferNextLine
  14008. end
  14009. end
  14010. iterate
  14011. end
  14012. end
  14013. end
  14014. end
  14015. if NextIdReplOn='Y' then
  14016. do
  14017. NidReplaceCount=ReplaceCount
  14018. FileLine=ReplaceString(FileLine,NextIdMarker,NextIdNew)
  14019. if NidReplaceCount<>ReplaceCount then
  14020. NextIdUsed='Y'
  14021. end
  14022. if AsIsModeOn='Y' then
  14023. FileLine=ExpandAsIsTags(FileLine)
  14024. if AutoTagOn='Y' then
  14025. FileLine=AutoTag(FileLine)
  14026. if pos(TabChar,FileLine)<>0 then
  14027. do
  14028. if OptionDebugOn='Y' then
  14029. call DBG 'Tab(s) found'
  14030. select
  14031. when OptionTabs='W' then
  14032. do
  14033. call OutputWarningToScreen 'T000', 'There are TABS in the source (converted to spaces)!'
  14034. FileLine=translate(FileLine, ' ',TabChar)
  14035. end
  14036. when OptionTabs='T' then
  14037. do
  14038. FileLine=translate(FileLine, ' ',TabChar)
  14039. end
  14040. when OptionTabs='E' then
  14041. do
  14042. FileLine=ExpandTabs(FileLine,WidthOfTab)
  14043. end
  14044. otherwise
  14045. do
  14046. end
  14047. end
  14048. end
  14049. if OptionHideCmdS_L<>0 then
  14050. do
  14051. PosS=pos(OptionHideCmdS,FileLine)
  14052. if PosS<>0 then
  14053. do
  14054. if OptionDebugOn='Y' then
  14055. do
  14056. call DBG 'At least one hidden command'
  14057. call DBGIND 1
  14058. end
  14059. RightBit=FileLine
  14060. LeftBit=''
  14061. do while PosS<>0
  14062. PosE=pos(OptionHideCmdE,RightBit,PosS)
  14063. if PosE=0 then
  14064. CryAndDie('Found start of hidden command ("' || OptionHideCmd || '"), but not the end!')
  14065. Hidden=strip(substr(RightBit,PosS+OptionHideCmdS_L,(PosE-PosS)-OptionHideCmdS_L))
  14066. if OptionDebugOn='Y' then
  14067. call DBG 'Found: ' ||DebugRightArrow||Hidden||DebugLeftArrow
  14068. LeftBit=LeftBit||left(RightBit,PosS-1)||Hidden
  14069. RightBit=substr(RightBit,PosE+OptionHideCmdE_L)
  14070. PosS=pos(OptionHideCmdS,RightBit)
  14071. end
  14072. FileLine=LeftBit||RightBit
  14073. if OptionDebugOn='Y' then
  14074. do
  14075. call DBG 'NewLine: ' ||DebugRightArrow||FileLine||DebugLeftArrow
  14076. call DBGIND-1
  14077. end
  14078. end
  14079. end
  14080. FileLine=strip(FileLine, 'T')
  14081. CmtPos=lastpos(InLineComment,FileLine)
  14082. if CmtPos<>0 then
  14083. do
  14084. AddToEnd=''
  14085. if right(FileLine,1)=LineContChar then
  14086. do
  14087. Right2=right(FileLine,2)
  14088. if Right2=LineContAddNewLine|Right2=LineContAddNewLineObs|Right2=LineContWithoutSpace|Right2=LineContWithSpace|Right2=LineContDefault then
  14089. do
  14090. AddToEnd=' ' ||Right2
  14091. end
  14092. end
  14093. FileLine=strip(left(FileLine,CmtPos-1), 'T')||AddToEnd
  14094. end
  14095. if ProcessingMode='REXX' then
  14096. do
  14097. if OptionDebugOn='N' then
  14098. do
  14099. if OptionKeepRexxCmts='N' &right(FileLine,2)=RexxCmtEnd then
  14100. do
  14101. StartCmtPos=lastpos(RexxCmtStart,FileLine)
  14102. if StartCmtPos<>0 then
  14103. do
  14104. if StartCmtPos=0 then
  14105. FileLine=''
  14106. else
  14107. FileLine=strip(left(FileLine,StartCmtPos-1), 'T')
  14108. if FileLine='' then
  14109. iterate
  14110. end
  14111. end
  14112. end
  14113. end
  14114. if LineContChar=NullChar then
  14115. LineContinued='N'
  14116. else
  14117. do
  14118. if right(FileLine,1)<>LineContChar then
  14119. LineContinued='N'
  14120. else
  14121. do
  14122. Right2=right(FileLine,2)
  14123. MainBit=strip(left(FileLine,length(FileLine)-2), 'T')
  14124. select
  14125. when Right2=LineContWithoutSpace then
  14126. do
  14127. LineContinued='Y'
  14128. FileLine=MainBit
  14129. end
  14130. when Right2=LineContWithSpace|Right2=LineContDefault then
  14131. do
  14132. FileLine=MainBit
  14133. LineContinued='YS'
  14134. end
  14135. when Right2=LineContAddNewLine then
  14136. do
  14137. LineContinued='Y'
  14138. FileLine=MainBit||CodexNewLine
  14139. end
  14140. when Right2=LineContAddNewLineObs then
  14141. do
  14142. call WarnAboutDepreciatedFeature 'Line continuation using downarrow.  Replace with -> "%\"'
  14143. LineContinued='Y'
  14144. FileLine=MainBit||CodexNewLine
  14145. end
  14146. otherwise
  14147. LineContinued='N'
  14148. end
  14149. end
  14150. end
  14151. if FileLine='' then
  14152. do
  14153. if LeaveBlankLines='N' then
  14154. do
  14155. if OptionDebugOn='Y' then
  14156. call DebugShowLineDropped "Blank Line"
  14157. if LineContinued='N' & PartialLine \== '' then
  14158. do
  14159. do
  14160. if InLoop='Y' &LoopLinesFromFile=0 then
  14161. do
  14162. if IncludeLoopMemBufferNextLine=='' then
  14163. IncludeLoopMemBufferNextLine=PartialLine
  14164. else
  14165. IncludeLoopMemBufferNextLine=PartialLine||MarksNewLine||IncludeLoopMemBufferNextLine
  14166. end
  14167. else
  14168. do
  14169. if IncludeMemBufferNextLine=='' then
  14170. IncludeMemBufferNextLine=PartialLine
  14171. else
  14172. IncludeMemBufferNextLine=PartialLine||MarksNewLine||IncludeMemBufferNextLine
  14173. end
  14174. end
  14175. PartialLine=''
  14176. end
  14177. iterate
  14178. end
  14179. end
  14180. Word1=word(FileLine,1)
  14181. if left(Word1,1)=LineComment then
  14182. do
  14183. if LineContinued='N' & PartialLine \== '' then
  14184. do
  14185. if OptionDebugOn='Y' then
  14186. call DebugWarning 'Line continuation ends with a comment line'
  14187. do
  14188. if InLoop='Y' &LoopLinesFromFile=0 then
  14189. do
  14190. if IncludeLoopMemBufferNextLine=='' then
  14191. IncludeLoopMemBufferNextLine=PartialLine
  14192. else
  14193. IncludeLoopMemBufferNextLine=PartialLine||MarksNewLine||IncludeLoopMemBufferNextLine
  14194. end
  14195. else
  14196. do
  14197. if IncludeMemBufferNextLine=='' then
  14198. IncludeMemBufferNextLine=PartialLine
  14199. else
  14200. IncludeMemBufferNextLine=PartialLine||MarksNewLine||IncludeMemBufferNextLine
  14201. end
  14202. end
  14203. PartialLine=''
  14204. end
  14205. iterate
  14206. end
  14207. if LineSrc='F' then
  14208. do
  14209. if KeepIndent='N' then
  14210. FileLine=strip(FileLine, 'L')
  14211. else
  14212. FileLine=LeftIndent||FileLine
  14213. end
  14214. if PartialLine<> '' then
  14215. do
  14216. if left(Word1,HashPrefixLng)<>HashPrefix then
  14217. do
  14218. PartialLine=PartialLine||FileLine
  14219. end
  14220. else
  14221. do
  14222. parse var FileLine TheHashCmd TheRest
  14223. TheRest=strip(TheRest)
  14224. FileLine=TheHashCmd|| ' ' ||TheRest
  14225. PartialLine=PartialLine||PpwCmdDivider1||FileLine||PpwCmdDivider1
  14226. if LineContinued='YS' then
  14227. LineContinued='Y'
  14228. end
  14229. end
  14230. if LineContinued='N' then
  14231. do
  14232. if PartialLine\=='' then
  14233. do
  14234. do
  14235. if InLoop='Y' &LoopLinesFromFile=0 then
  14236. do
  14237. if IncludeLoopMemBufferNextLine=='' then
  14238. IncludeLoopMemBufferNextLine=PartialLine
  14239. else
  14240. IncludeLoopMemBufferNextLine=PartialLine||MarksNewLine||IncludeLoopMemBufferNextLine
  14241. end
  14242. else
  14243. do
  14244. if IncludeMemBufferNextLine=='' then
  14245. IncludeMemBufferNextLine=PartialLine
  14246. else
  14247. IncludeMemBufferNextLine=PartialLine||MarksNewLine||IncludeMemBufferNextLine
  14248. end
  14249. end
  14250. PartialLine=''
  14251. iterate
  14252. end
  14253. end
  14254. else
  14255. do
  14256. if PartialLine=='' then
  14257. do
  14258. PartialLine=FileLine
  14259. if translate(left(Word1,length(CmdHashDefine)))=CmdHashDefine then
  14260. PpwCmdDivider1=MarksNewLineInHashDefine
  14261. else
  14262. PpwCmdDivider1=MarksNewLine
  14263. end
  14264. if LineContinued='YS' then
  14265. PartialLine=PartialLine|| ' '
  14266. iterate
  14267. end
  14268. end
  14269. if OneLineLevel<>0 then
  14270. do
  14271. FileLine=AddToOneLine(FileLine)
  14272. if FileLine=='' then
  14273. iterate
  14274. else
  14275. do
  14276. do
  14277. if InLoop='Y' &LoopLinesFromFile=0 then
  14278. do
  14279. if IncludeLoopMemBufferNextLine=='' then
  14280. IncludeLoopMemBufferNextLine=FileLine
  14281. else
  14282. IncludeLoopMemBufferNextLine=FileLine||MarksNewLine||IncludeLoopMemBufferNextLine
  14283. end
  14284. else
  14285. do
  14286. if IncludeMemBufferNextLine=='' then
  14287. IncludeMemBufferNextLine=FileLine
  14288. else
  14289. IncludeMemBufferNextLine=FileLine||MarksNewLine||IncludeMemBufferNextLine
  14290. end
  14291. end
  14292. LastFileLine=FileLine
  14293. iterate
  14294. end
  14295. end
  14296. if left(Word1,HashPrefixLng)=HashPrefix then
  14297. do
  14298. parse var FileLine HashCmd SecondWordEtc
  14299. HashCmd=translate(HashCmd)
  14300. HashRc='?'
  14301. select
  14302. when HashCmd=CmdHashIf then
  14303. do
  14304. HashRc=ProcessHashIfTest(FileLine)
  14305. end
  14306. when HashCmd=CmdHashIfDef then
  14307. do
  14308. HashRc=ProcessHashIfTest(FileLine)
  14309. end
  14310. when HashCmd=CmdHashIfnDef then
  14311. do
  14312. HashRc=ProcessHashIfTest(FileLine)
  14313. end
  14314. when HashCmd=CmdHashElseifL|HashCmd=CmdHashElseifS then
  14315. HashRc=ProcessHashElse(SecondWordEtc)
  14316. when HashCmd=CmdHashEndifL|HashCmd=CmdHashEndifS then
  14317. HashRc=ProcessHashEndif(SecondWordEtc)
  14318. otherwise
  14319. end
  14320. if HashRc<> '?' then
  14321. do
  14322. if HashRc<> 'OK' then
  14323. call CryAndDie 'Hash command failed, Rc = ' ||HashRc
  14324. else
  14325. do
  14326. WantLineCache=WantLine()
  14327. iterate
  14328. end
  14329. end
  14330. end
  14331. if WantLineCache='N' then
  14332. do
  14333. if OptionDebugOn='Y' then
  14334. call DebugShowLineDropped "False"
  14335. iterate
  14336. end
  14337. if left(Word1,HashPrefixLng)=HashPrefix then
  14338. do
  14339. call ProcessHashCommand FileLine
  14340. end
  14341. else
  14342. do
  14343. if DefRexxVar<> '' then
  14344. do
  14345. call AddDefineRexxLine FileLine
  14346. iterate
  14347. end
  14348. if ReplacementsAllowed='Y' then
  14349. do
  14350. NowCount=ReplaceCount
  14351. FileLine=ReplaceHashAndStandardDefines(FileLine,, 'Y')
  14352. if ExpandXEarly='Y' then
  14353. do
  14354. if pos(StartsStdSymbolReplacement_x,FileLine)<>0 then
  14355. FileLine=ReplaceTheXCodesWeKnowExist(FileLine)
  14356. end
  14357. if NowCount<>ReplaceCount then
  14358. do
  14359. if pos(MarksNewLine,FileLine)<>0 then
  14360. do
  14361. do
  14362. if InLoop='Y' &LoopLinesFromFile=0 then
  14363. do
  14364. if IncludeLoopMemBufferNextLine=='' then
  14365. IncludeLoopMemBufferNextLine=FileLine
  14366. else
  14367. IncludeLoopMemBufferNextLine=FileLine||MarksNewLine||IncludeLoopMemBufferNextLine
  14368. end
  14369. else
  14370. do
  14371. if IncludeMemBufferNextLine=='' then
  14372. IncludeMemBufferNextLine=FileLine
  14373. else
  14374. IncludeMemBufferNextLine=FileLine||MarksNewLine||IncludeMemBufferNextLine
  14375. end
  14376. end
  14377. iterate
  14378. end
  14379. end
  14380. if ExpandXLate='Y' then
  14381. do
  14382. if pos(StartsStdSymbolReplacement_x,FileLine)<>0 then
  14383. FileLine=ReplaceTheXCodesWeKnowExist(FileLine)
  14384. end
  14385. end
  14386. if TransformCodeLvl<>0 then
  14387. do
  14388. ef!Drop='N'
  14389. do ef!TNumb=TransformCodeLvl to 1 by-1 until DoPrevious<> 'Y'
  14390. call DBG 'Executing #transform #' ||ef!TNumb
  14391. ef!TF=TransformCode.ef!TNumb
  14392. if ef!TF='' then
  14393. leave
  14394. call DBGIND 1
  14395. FileRest=FileLine
  14396. FileAfter=''
  14397. AppendWith=''
  14398. Remove=''
  14399. DoPrevious='N'
  14400. do until FileRest==''
  14401. parse var FileRest FileLine (MarksNewLine) FileRest
  14402. Remove=''
  14403. BeforeLine=FileLine
  14404. call ExecRexxCmd ef!TF
  14405. if Remove<> '' then
  14406. call DBG 'Transform line dropped ==> ' ||Remove
  14407. else
  14408. do
  14409. FileAfter=FileAfter||AppendWith||FileLine
  14410. AppendWith=MarksNewLine
  14411. if OptionDebugOn='Y' then
  14412. do
  14413. if BeforeLine==FileLine then
  14414. call DBG 'Line was not transformed'
  14415. else
  14416. call DBG 'Line transformed to ' ||DebugRightArrow||FileLine||DebugLeftArrow
  14417. end
  14418. end
  14419. end
  14420. call DBGIND-1
  14421. if FileAfter='' & Remove <> '' then
  14422. do
  14423. ef!Drop='Y'
  14424. leave
  14425. end
  14426. FileLine=FileAfter
  14427. end
  14428. if ef!Drop='Y' then
  14429. iterate
  14430. end
  14431. if LineSrc='M' then
  14432. do
  14433. LineQueued=LineQueued||FileLine
  14434. iterate
  14435. end
  14436. do until FileLine == ''
  14437. parse var FileLine This1 (MarksNewLine) FileLine
  14438. if  ProcessingMode  = 'REXX' then
  14439. call OutputRexxLine This1
  14440. else
  14441. do
  14442. if  ProcessingMode <> 'HTML' then
  14443. call GenerateOneLine This1
  14444. else
  14445. do
  14446. if  ProcessingMode  = 'HTML' & HtmlGeneratorTags <> '' then
  14447. do
  14448. This1U  = translate(This1)
  14449. InsertTags = 'N'
  14450. InsBef     = ''
  14451. InsAft     = ''
  14452. LookFor = "<HEAD>"
  14453. TagPos  = pos(LookFor, This1U)
  14454. if  TagPos <> 0 then
  14455. do
  14456. InsertTags = "Y"
  14457. InsBef     = MarksNewLine
  14458. InsAft     = InsBef
  14459. InsertAt   = TagPos + length(LookFor)
  14460. end
  14461. else
  14462. do
  14463. LookFor = "<BODY"
  14464. TagPos  = pos(LookFor, This1U)
  14465. if  TagPos <> 0 then
  14466. do
  14467. InsertTags = "Y"
  14468. InsBef     = '<head>' || MarksNewLine || '  '
  14469. InsAft     = MarksNewLine || '</head>' || MarksNewLine
  14470. InsertAt   = TagPos
  14471. end
  14472. end
  14473. if  InsertTags = 'Y' then
  14474. do
  14475. call DBG 'Found "' || LookFor || '" so inserted HTML generator tags'
  14476. cf!Ins = ReplaceHashAndStandardDefines(HtmlGeneratorTags)
  14477. cf!Ins = RepXCodes(cf!Ins)
  14478. cf!Ins = InsBef || cf!Ins || InsAft
  14479. FileLine = insert(cf!Ins, This1, InsertAt-1) || MarksNewLine || FileLine
  14480. HtmlGeneratorTags = ''
  14481. iterate
  14482. end
  14483. end
  14484. call GenerateOneLine This1
  14485. end
  14486. end
  14487. end
  14488. end
  14489. end
  14490. EofForced=''
  14491. call IncludeFileClose
  14492. if IncludeFragmentE<> '' then
  14493. CryAndDie('Did not find the END of the code fragment "' || IncludeFragmentE || '" (in "' || IncludeFileName || '")!')
  14494. IncludeLevel=IncludeLevel-1
  14495. if OptionDebugOn='Y' then
  14496. call DBG 'Finished processing the input file'
  14497. return(0)
  14498.  
  14499. FlushQueuedOutput:
  14500. if LineQueued=='' then
  14501. return
  14502. LineSrc='Q'
  14503. FileLine=LineQueued
  14504. LineQueued=''
  14505. if OptionDebugOn='Y' then
  14506. call DebugShowCurrentLineWithLineNumber FileLine, '>>>>'
  14507. do until FileLine == ''
  14508. parse var FileLine This1 (MarksNewLine) FileLine
  14509. if  ProcessingMode  = 'REXX' then
  14510. call OutputRexxLine This1
  14511. else
  14512. do
  14513. if  ProcessingMode <> 'HTML' then
  14514. call GenerateOneLine This1
  14515. else
  14516. do
  14517. if  ProcessingMode  = 'HTML' & HtmlGeneratorTags <> '' then
  14518. do
  14519. This1U  = translate(This1)
  14520. InsertTags = 'N'
  14521. InsBef     = ''
  14522. InsAft     = ''
  14523. LookFor = "<HEAD>"
  14524. TagPos  = pos(LookFor, This1U)
  14525. if  TagPos <> 0 then
  14526. do
  14527. InsertTags = "Y"
  14528. InsBef     = MarksNewLine
  14529. InsAft     = InsBef
  14530. InsertAt   = TagPos + length(LookFor)
  14531. end
  14532. else
  14533. do
  14534. LookFor = "<BODY"
  14535. TagPos  = pos(LookFor, This1U)
  14536. if  TagPos <> 0 then
  14537. do
  14538. InsertTags = "Y"
  14539. InsBef     = '<head>' || MarksNewLine || '  '
  14540. InsAft     = MarksNewLine || '</head>' || MarksNewLine
  14541. InsertAt   = TagPos
  14542. end
  14543. end
  14544. if  InsertTags = 'Y' then
  14545. do
  14546. call DBG 'Found "' || LookFor || '" so inserted HTML generator tags'
  14547. cf!Ins = ReplaceHashAndStandardDefines(HtmlGeneratorTags)
  14548. cf!Ins = RepXCodes(cf!Ins)
  14549. cf!Ins = InsBef || cf!Ins || InsAft
  14550. FileLine = insert(cf!Ins, This1, InsertAt-1) || MarksNewLine || FileLine
  14551. HtmlGeneratorTags = ''
  14552. iterate
  14553. end
  14554. end
  14555. call GenerateOneLine This1
  14556. end
  14557. end
  14558. end
  14559. return
  14560.  
  14561. OutputInformationToScreen:
  14562. if OptionWantInfoMsgs='Y' then
  14563. do
  14564. InfoText=arg(1)
  14565. if IncludeLevel=0 then
  14566. LineText=''
  14567. else
  14568. LineText='(@' || AddCommasToDecimalNumber(IncludeLineNumber) || ')'
  14569. call ColorSet 'INFO'
  14570. call Line1 ReadingIndent()|| '  ' || LineText || 'INFO: ' ||InfoText
  14571. call ColorSet
  14572. end
  14573. return
  14574.  
  14575. ProcessHashCommand:
  14576. HashCmdMc=word(arg(1),1)
  14577. HashCmd=translate(HashCmdMc)
  14578. HashCmdParms=subword(arg(1),2)
  14579. select
  14580. when HashCmd=CmdHashDefine then
  14581. return(ProcessDefine(HashCmdParms))
  14582. when HashCmd=CmdHashDefinePlus then
  14583. return(ProcessDefine(HashCmdParms, 'Y'))
  14584. when HashCmd=CmdHashRexxVar then
  14585. return(ProcessRexxVar(HashCmdParms))
  14586. when HashCmd=CmdHashEvaluateL|HashCmd=CmdHashEvaluateS then
  14587. return(ProcessEvaluate(HashCmdParms))
  14588. when HashCmd=CmdHashEvaluatePlusL|HashCmd=CmdHashEvaluatePlusS then
  14589. return(ProcessEvaluate(HashCmdParms, 'Y'))
  14590. when HashCmd=CmdHashAutoTag then
  14591. do
  14592. ProcessRc=ProcessAutoTag(HashCmdParms)
  14593. return(ProcessRc)
  14594. end
  14595. when HashCmd=CmdHashUndefL|HashCmd=CmdHashUndefS then
  14596. return(HandleUndefCommand(HashCmdParms))
  14597. when HashCmd=CmdHashOption then
  14598. return(ProcessOption(HashCmdParms))
  14599. when HashCmd=CmdHashLoopS then
  14600. return(ProcessLoopStart(HashCmdParms))
  14601. when HashCmd=CmdHashLoopBreak then
  14602. return(ProcessLoopBreak(HashCmdParms))
  14603. when HashCmd=CmdHashLoopContinue then
  14604. return(ProcessLoopContinue(HashCmdParms))
  14605. when HashCmd=CmdHashInclude then
  14606. do
  14607. IncludeParms=strip(PerformReplacementsInCmdsParameters(HashCmdParms))
  14608. if IncludeParms="" then
  14609. return(CryAndDie("No filename specified on #include line!"))
  14610. QuoteChar=left(IncludeParms,1)
  14611. if QuoteChar<> '"' & QuoteChar <> "'" & QuoteChar <> "<" then
  14612. do
  14613. parse var IncludeParms IncludeName Fragment
  14614. end
  14615. else
  14616. do
  14617. if QuoteChar="<" then
  14618. QuoteChar='>'
  14619. IncludeParms=substr(IncludeParms,2)
  14620. QuotePos=pos(QuoteChar,IncludeParms)
  14621. if QuotePos=0 then
  14622. CryAndDie('Could not find the ending quote for the included filename')
  14623. IncludeName=left(IncludeParms,QuotePos-1)
  14624. Fragment=substr(IncludeParms,QuotePos+1)
  14625. if IncludeName='' then
  14626. CryAndDie('Invalid #include command, no filename passed!')
  14627. end
  14628. if Fragment<> '' then
  14629. Fragment=GetQuotedText(Fragment)
  14630. call RecursiveIncludeSave
  14631. call ProcessInputFile IncludeName,,,Fragment
  14632. call RecursiveIncludeRestore
  14633. call ReadingI
  14634. return(0)
  14635. end
  14636. when HashCmd=CmdHashImport then
  14637. return(ProcessImport(HashCmdParms))
  14638. when HashCmd=CmdHashOutput then
  14639. return(ProcessHashOutput(HashCmdParms))
  14640. when HashCmd=CmdHashOutputHold then
  14641. return(ProcessHashOutputHold(HashCmdParms))
  14642. when HashCmd=CmdHashDefineRexx then
  14643. return(ProcessDefineRexx(HashCmdParms))
  14644. when HashCmd=CmdHashDefineRexxPlus then
  14645. return(ProcessDefineRexx(HashCmdParms, 'Y'))
  14646. when HashCmd=CmdHashDefineIfReq then
  14647. return(ProcessDefine(HashCmdParms, '?'))
  14648. when HashCmd=CmdHash1Line then
  14649. return(ProcessOneLine(HashCmdParms,CmdHash1LineEnd))
  14650. when HashCmd=CmdHashOneLine then
  14651. return(ProcessOneLine(HashCmdParms))
  14652. when HashCmd=CmdHashMacroSpace then
  14653. do
  14654. call NotAvailableUnderNtYet HashCmd
  14655. Rest=PerformReplacementsInCmdsParameters(HashCmdParms)
  14656. MsCommand=translate(GetQuotedText(Rest, "Rest"))
  14657. MsFile=GetQuotedText(Rest, "Rest")
  14658. if Rest='' then
  14659. MsFunction=''
  14660. else
  14661. MsFunction=GetQuotedText(Rest)
  14662. if MsCommand<> 'ADD' & MsCommand <> 'DROP' then
  14663. CryAndDie('The macro space command "' || MsCommand || '" is unknown!')
  14664. if FileQueryExists(MsFile)='' then
  14665. CryAndDie('The rexx file "' || MsFile || '" does not exist!')
  14666. call DoMacroSpaceOperation MsCommand,MsFile,MsFunction
  14667. return(0)
  14668. end
  14669. when HashCmd=CmdHashAsIs then
  14670. return(ProcessAsIs(HashCmdParms))
  14671. when HashCmd=CmdHashWarningL|HashCmd=CmdHashWarningS then
  14672. return(ProcessHashWarning(HashCmdParms))
  14673. when HashCmd=CmdHashInfo then
  14674. do
  14675. InfoMsg=PerformReplacementsInCmdsParameters(HashCmdParms)
  14676. InfoMsg=GetQuotedRest(InfoMsg)
  14677. call OutputInformationToScreen InfoMsg
  14678. return(0)
  14679. end
  14680. when HashCmd=CmdHashPush then
  14681. return(ProcessPush(HashCmdParms))
  14682. when HashCmd=CmdHashPop then
  14683. return(ProcessPop(HashCmdParms))
  14684. when HashCmd=CmdHashAutoTagState then
  14685. return(ProcessAutoTagState(HashCmdParms))
  14686. when HashCmd=CmdHashAutoTagClear then
  14687. return(ProcessAutoTagClear(HashCmdParms))
  14688. when HashCmd=CmdHashDependsOn then
  14689. return(ProcessDependsOn(HashCmdParms))
  14690. when HashCmd=CmdHashOnExit then
  14691. return(ProcessOnExit(HashCmdParms))
  14692. when HashCmd=CmdHashEof then
  14693. do
  14694. if HashCmdParms<> '' then
  14695. do
  14696. EndifCounter=GetQuotedText(HashCmdParms)
  14697. EndifCounter=PerformReplacementsInCmdsParameters(EndifCounter)
  14698. if datatype(EndifCounter, 'W')=0 then
  14699. CryAndDie('Invalid #endif simulate count of "' || EndifCounter || '" supplied!')
  14700. do EndifIndex=1 to EndifCounter
  14701. call ProcessHashEndif
  14702. end
  14703. end
  14704. EofForced=CurrentSourceLocation()
  14705. return(0)
  14706. end
  14707. when HashCmd=CmdHashTransform then
  14708. return(ProcessTransform(HashCmdParms))
  14709. when HashCmd=CmdHashIntercept then
  14710. return(ProcessIntercept(HashCmdParms,HashCmdMc))
  14711. when HashCmd=CmdHashSystem then
  14712. return(ProcessSystem(HashCmdParms))
  14713. when HashCmd=CmdHashDebug then
  14714. return(ProcessHashDebug(HashCmdParms))
  14715. when HashCmd=CmdHashRequire then
  14716. return(ProcessRequire(HashCmdParms))
  14717. when HashCmd=CmdHashNextId then
  14718. return(ProcessNextId(HashCmdParms))
  14719. when HashCmd=CmdHashErrorL|HashCmd=CmdHashErrorS then
  14720. call ProcessHashError HashCmdParms
  14721. otherwise
  14722. do
  14723. if UserHashCmds='' then
  14724. call LookForUnknownCmdHandler
  14725. if UserHashCmds<> '' then
  14726. return(ProcessUnknownHashCommand(HashCmd,HashCmdParms))
  14727. if HashCmd=CmdHashLoopE then
  14728. CryAndDie('Missing "' || CmdHashLoopS || '" command')
  14729. else
  14730. CryAndDie("Invalid '#' command line of: " ||HashCmd)
  14731. end
  14732. end
  14733. return(0)
  14734.  
  14735. ProcessHashError:
  14736. ErrorMsg=GetQuotedRest(PerformReplacementsInCmdsParameters(arg(1)))
  14737. ErrorMsg=ReplaceString(ErrorMsg, '{NL}',MarksNewLine)
  14738. CryAndDie(ErrorMsg)
  14739.  
  14740. IsStringOnOrOffCmd:
  14741. OoCmd=translate(arg(1))
  14742. if OoCmd='+' | OoCmd = 'YES' |  OoCmd = 'ON' then
  14743. return('Y')
  14744. else
  14745. do
  14746. if OoCmd='-' | OoCmd = 'NO' |  OoCmd = 'OFF' then
  14747. return('N')
  14748. end
  14749. return('')
  14750.  
  14751. SetOnorOffVariable:
  14752. parse arg OnOffSrc,VarName
  14753. OnOrOffText=translate(GetQuotedText(OnOffSrc))
  14754. OnOrOff=IsStringOnOrOffCmd(OnOrOffText)
  14755. if OnOrOff='' then
  14756. CryAndDie(HashCmd|| ' command does not specify a correct value value (ON/OFF)!')
  14757. call _valueS VarName,OnOrOff
  14758. return(0)
  14759.  
  14760. DisplayCopyright:
  14761. if CopyrightDisplayed='N' then
  14762. do
  14763. if symbol("WizName") <> "VAR" then
  14764. WizName='PPWIZARD.REX'
  14765. call ColorSet 'HIGHLIGHT'
  14766. call Line1 '[]---------------------------------------------------------[]'
  14767. call Line1 '| ' || WizName || ': Version ' || PgmVersion || ' (' || PgmAuthorEmail || ')   |'
  14768. call Line1 '| ' || PgmAuthorHomePage || '            |'
  14769. call Line1 '| (C)opyright ' || PgmAuthor || ' 1997-2002. ALL RIGHTS RESERVED. |'
  14770. call Line1 '[]---------------------------------------------------------[]'
  14771. call ColorSet
  14772. call Line1 ''
  14773. CopyrightDisplayed='Y'
  14774. end
  14775. return
  14776.  
  14777. CheckRexxInterpreter:
  14778. if RexWhich='REGINA' then
  14779. do
  14780. if pos(RexVerRegina,GetEnv("PPWIZARD_TEST_REGINA_VER") || ' ' ||SupportedReginaVersions)<>0 then
  14781. return(0)
  14782. criText='The Regina "' || RexVerRegina || '" interpreter is unsupported, use ' || SupportedReginaVersions || ' instead! I recommend "' || RecommendedReginaVersions || '"'
  14783. if arg(1)='Y' then
  14784. call DBG criText
  14785. else
  14786. call OutputWarningToScreen 'URI0',criText
  14787. return(1)
  14788. end
  14789. return(0)
  14790.  
  14791. NiceDateTime:
  14792. return(date('Weekday') || ', ' || date() || ' ' ||GetAmPmTime())
  14793.  
  14794. GetInputFileNameAndLine:call TRACE "OFF"
  14795.  
  14796. CurrentSourceLocation:
  14797. if IncludeLevel<>0 then
  14798. return('line ' || AddCommasToDecimalNumber(IncludeLineNumber) || ' of "' || IncludeFileName || '"')
  14799. else
  14800. do
  14801. if arg(1, 'E')then
  14802. return(arg(1))
  14803. else
  14804. return("unknown")
  14805. end
  14806.  
  14807. GetLineBeingProcessed:call TRACE "OFF"
  14808. return(strip(LastLine))
  14809.  
  14810. GetFileLineBeingProcessed:call TRACE "OFF"
  14811. return(strip(LastFileLine))
  14812.  
  14813. DumpVarsIfCompoundVariable:
  14814. if pos('.',arg(1))<>0 then
  14815. ExpressionKilledUs=arg(1)
  14816. return
  14817.  
  14818. CheckForNotBeingAbleToExecAnything:
  14819. if RexWhich='REGINA' then
  14820. do
  14821. if RexSystemOpSys="UNIX" then
  14822. Exe=''
  14823. else
  14824. Exe='.exe'
  14825. RexxExe="rexx" ||Exe
  14826. ReginaExe="regina" ||Exe
  14827. DoWhat='Test for use of buggy regina "' || ReginaExe || '" rather than "' || RexxExe || '" executable'
  14828. call DBG DoWhat
  14829. TmpFile=RexGetTmpFileName()
  14830. call AddressCmd 'echo ' ||DoWhat||RedirectStdOutAndErr2(TmpFile),TmpFile
  14831. if FileQueryExists(TmpFile)='' then
  14832. do
  14833. Line1="Can't execute shell functions!"
  14834. if RexSystemOpSys<> "UNIX" then
  14835. do
  14836. Line3='It''s possible that your "TMP" or "TEMP" environment variables'
  14837. Line4='are corrupt.'
  14838. end
  14839. else
  14840. do
  14841. Line3='If you used regina''s "' || ReginaExe || '" executable then try the "' || RexxExe || '"'
  14842. Line4='one instead!'
  14843. end
  14844. Line5='Could not create "' || TmpFile || '"'
  14845. Line7='Please report the problem to "' || PgmAuthorEmail || '" (please attach'
  14846. Line8='zipped output with "' || OptChar  || 'debug" switch used)!'
  14847. CryAndDie(Line1, '', Line3, Line4, Line5, '',Line7,Line8)
  14848. end
  14849. call _SysFileDelete TmpFile
  14850. call DBG 'Looks OK to me!'
  14851. end
  14852. return
  14853.  
  14854. LookLikeASingleFile:
  14855. FileName=arg(1)
  14856. call DBG 'No files matched "' || FileName || '", does it look like a single file?'
  14857. if verify(FileName, '*?', 'M')<>0 then
  14858. NormalFile='N'
  14859. else
  14860. do
  14861. if FileQueryExists(FileName)='' then
  14862. NormalFile='N'
  14863. else
  14864. NormalFile='Y'
  14865. end
  14866. call DBGIND 1
  14867. call DBG 'Normal File: ' ||NormalFile
  14868. call DBGIND-1
  14869. return(NormalFile)
  14870.  
  14871. CryAndDie:
  14872. SynErrLine=SIGL
  14873. SynErrLineC=AddCommasToDecimalNumber(SynErrLine)
  14874. call DBGINDInit
  14875. call DBG 'Fatal Error Detected (at line ' || SynErrLineC || ' of ppwizard)'
  14876. call DBGIND 1
  14877. PpwSize=FileQuerySize(PpWizardPgmName)
  14878. if PpwSize<> '' then
  14879. PpwSize=AddCommasToDecimalNumber(PpwSize)
  14880. PpwDateTime=GetFileTimeStamp(PpWizardPgmName)
  14881. call AllFollowingOutputGoesToErrorFile
  14882. call ColorSet 'ERROR'
  14883. call Line1 ''
  14884. call Line1 copies('!!',38)
  14885. call Line1 copies('!!', 15) || '[ Fatal  Error ]' || copies('!!',15)
  14886. call Line1 copies('!!',38)
  14887. call CgiStartFatalError
  14888. if IncludeLevel<>0 then
  14889. do
  14890. LastFileLine=strip(LastFileLine)
  14891. LastLine=strip(LastLine)
  14892. call Line1 'Location  : ' ||CurrentSourceLocation()
  14893. ef!S=GetIncludeStack()
  14894. if ef!S<> '' then
  14895. call Line1 'File Stack: ' ||ef!S
  14896. call Line1 'File Line : ' ||LastFileLine
  14897. if LastLine<>LastFileLine then
  14898. call Line1 'Fail Line : ' ||LastLine
  14899. if LastLineAfterMacroRep<> '' &LastLine<>LastLineAfterMacroRep&LastFileLine<>LastLineAfterMacroRep then
  14900. call Line1 'After Repl: ' ||LastLineAfterMacroRep
  14901. if MacroBeingExpanded<> '' then
  14902. call Line1 'Expanding : ' || StartsMacroReplacement || MacroBeingExpanded || ' ...' ||EndsMacroReplacement
  14903. end
  14904. else
  14905. do
  14906. if PpwDoing<> '' then
  14907. call Line1 'Doing What: ' ||PpwDoing
  14908. end
  14909. call SeeAlsoFile 10
  14910. call Line1 'Detected @: Line ' || SynErrLineC || ' of ' || _filespec('name', PpWizardPgmName) || ' (v' || PgmVersion || ')'
  14911. call Line1 'PPWIZARD  : Length ' || PpwSize || ' bytes.  TimeStamped ' ||PpwDateTime
  14912. call Line1 'Running In: ' || DebugGetOpSysText() || ', ' ||RexVersionInfo
  14913. call Line1 'Reason'
  14914. call Line1 '~~~~~~'
  14915. LastArg=1
  14916. do LineIndex=1 to arg()
  14917. if arg(LineIndex)<> '' then
  14918. LastArg=LineIndex
  14919. end
  14920. do LineIndex=1 to LastArg
  14921. call Line1 arg(LineIndex)
  14922. end
  14923. if ExpressionKilledUs<> '' then
  14924. call DumpVarsInExpression ExpressionKilledUs,, "KNOWN VARIABLES"
  14925. call CgiEndFatalError
  14926. call Line1 copies('!!',38)
  14927. call Line1 ''
  14928. call Line1 ''
  14929. call ColorSet
  14930. call Beeps
  14931. if RexxHookError<> '' then
  14932. do
  14933. do LineIndex=1 to LastArg
  14934. call SetEnv "PPWH_ERROR" ||LineIndex,arg(LineIndex)
  14935. end
  14936. call CallHook "ERROR",,LastArg
  14937. do LineIndex=1 to LastArg
  14938. call SetEnv "PPWH_ERROR" || LineIndex, ''
  14939. end
  14940. end
  14941. AbnormalExit(SynErrLine)
  14942.  
  14943. RexSystemFailure:
  14944. FailedAt=SIGL
  14945. if TrapHandler='FULL' then
  14946. call DBG 'RexSystemFailure(REXSYSTM.XH routine failed)'
  14947. call DisplayCopyright
  14948. call RexDumpSystemInfo
  14949. say ''
  14950. if TrapHandler='FULL' then
  14951. CryAndDie(arg(1))
  14952. say 'ERROR'
  14953. say '~~~~~'
  14954. say arg(1)
  14955. call CallErrorHookForSimpleOneLiner arg(1)
  14956. ExitNowCallingAnyHandlers(FailedAt)
  14957.  
  14958. CallErrorHookForSimpleOneLiner:
  14959. if RexxHookError<> '' then
  14960. do
  14961. call SetEnv "PPWH_ERROR1",arg(1)
  14962. call CallHook "ERROR",,1
  14963. call SetEnv "PPWH_ERROR1", ''
  14964. end
  14965. return
  14966.  
  14967. AbnormalExit:
  14968. call DBG 'AbnormalExit(' || arg(1) || ') called.'
  14969. if arg(2)<> '' then
  14970. call CallErrorHookForSimpleOneLiner arg(2)
  14971. ThatsAllFolks(arg(1))
  14972.  
  14973. ThatsAllFolks:
  14974. ff!Rc=arg(1)
  14975. call DBG 'ThatsAllFolks() called to exit program.'
  14976. if CurrentOutFile<> '' then
  14977. call _FileClose CurrentOutFile
  14978. if IncludeLevel<>0 then
  14979. do
  14980. do FileIndex=1 to IncludeLevel
  14981. call _FileClose IncludeFileName.FileIndex
  14982. end
  14983. end
  14984. call CloseCgiFileIfOpen
  14985. if OptionFilterIn<> '' then
  14986. call DoMacroSpaceOperation "DROP", OptionFilterIn,  "HtmlFilterIn",  "QUIET"
  14987. if OptionFilterOut<> '' then
  14988. call DoMacroSpaceOperation "DROP", OptionFilterOut, "HtmlFilterOut", "QUIET"
  14989. call DBG 'Exiting with a return code of ' ||ff!Rc
  14990. if OptionCgiModeOn='N' then
  14991. do
  14992. if ff!Rc<=1 then
  14993. OnExitSleepFor=OnExitSleepForOk
  14994. else
  14995. OnExitSleepFor=OnExitSleepForError
  14996. if OnExitSleepFor<>0 then
  14997. do
  14998. call DBG 'Sleeping for ' || OnExitSleepFor || ' second(s)'
  14999. call _SysSleep OnExitSleepFor
  15000. end
  15001. end
  15002. ExitNowCallingAnyHandlers(ff!Rc)
  15003.  
  15004. _ReplaceConsoleHandlers:
  15005. parse arg ff!Val,ff!Bef,ff!Aft
  15006. ff!Before='{' || ff!Bef || '}'
  15007. if pos(ff!Before,ff!Val)<>0 then
  15008. do
  15009. if ff!Aft='' then
  15010. do
  15011. call Line1 'No value known for "' || ff!Before || '"' ||d2c(7)
  15012. call Sleep 3
  15013. return('')
  15014. end
  15015. ff!Val=ReplaceString(ff!Val,ff!Before,ff!Aft)
  15016. end
  15017. return(ff!Val)
  15018.  
  15019. _CallExitHandler:
  15020. gf!Handler=arg(1)
  15021. gf!Type=arg(2)
  15022. if gf!Handler<> '' then
  15023. do
  15024. call DBG 'A ' || gf!Type || ' exit handler exists...'
  15025. call DBGIND 1
  15026. gf!Handler=_ReplaceConsoleHandlers(gf!Handler, 'ConsoleFile',ConsoleFile)
  15027. gf!Handler=_ReplaceConsoleHandlers(gf!Handler, 'ErrorFile',ConsoleErrorFile)
  15028. if gf!Handler<> '' then
  15029. call AddressCmd gf!Handler
  15030. call DBGIND-1
  15031. end
  15032. return
  15033.  
  15034. ExitNowCallingAnyHandlers:
  15035. hf!Rc=arg(1)
  15036. if hf!Rc=0|hf!Rc=1 then
  15037. call _CallExitHandler PpwOnOK, "success"
  15038. else
  15039. do
  15040. call DeletingOnError
  15041. call _CallExitHandler PpwOnERROR, "failure"
  15042. end
  15043. call ColorSet 'RESET'
  15044. exit(hf!Rc)
  15045. signal INDENT_47
  15046.  
  15047. EXTRAINDENT_DEBUG:
  15048. if OptionDebugOn='Y' then
  15049. call OptionDebugShow 'EXTRAINDENT', 'Extra left indent is now "' || LeftIndent || '"'
  15050. return
  15051.  
  15052. EXTRAINDENT_GET:
  15053. call EXTRAINDENT_DEBUG
  15054. return(LeftIndentSet2)
  15055.  
  15056. EXTRAINDENT_SET:
  15057. LeftIndentSet2=arg(1)
  15058. if ProcessedCmdLine='N' then
  15059. do
  15060. call OptionDebugShow 'EXTRAINDENT', 'Setting default value of extra left indent to "' || LeftIndentSet2 || '"'
  15061. Default4_LeftIndent=LeftIndentSet2
  15062. return(0)
  15063. end
  15064. if LeftIndentSet2=='' then
  15065. LeftIndentCmd=Default4_LeftIndent
  15066. else
  15067. LeftIndentCmd=LeftIndentSet2
  15068. if translate(LeftIndentCmd)='NULL' then
  15069. LeftIndent=''
  15070. else
  15071. call ExecRexxCmd "LeftIndent = " ||LeftIndentCmd
  15072. call EXTRAINDENT_DEBUG
  15073. return
  15074.  
  15075. INDENT_47:
  15076.  
  15077. _DieAsNoTextConditionSupplied:
  15078. CryAndDie('No test condition supplied on "#if" command')
  15079.  
  15080. _PerformSimpleHashIfTest:
  15081. SimpleTest=arg(1)
  15082. if left(SimpleTest,1)<> '[' | right(SimpleTest, 1) <> ']' then
  15083. CryAndDie('Incorrectly bracketed simple #if command.')
  15084. SimpleTest=substr(SimpleTest,2,length(SimpleTest)-2)
  15085. if SimpleTest='' then
  15086. call _DieAsNoTextConditionSupplied
  15087. Parm1=GetSimpleRexxValue(SimpleTest, "SimpleTest")
  15088. parse var SimpleTest FastOperator SimpleTest
  15089. if SimpleTest='' then
  15090. CryAndDie('#if [] has too few parameters (you must put spaces around operator!)')
  15091. Parm3=GetSimpleRexxValue(SimpleTest, "SimpleTest")
  15092. if SimpleTest<> '' then
  15093. CryAndDie('#if [] has too many parameters, expected 3!')
  15094. select
  15095. when FastOperator='==' then
  15096. return(Parm1==Parm3)
  15097. when FastOperator='<>' then
  15098. return(Parm1<>Parm3)
  15099. when FastOperator='=' then
  15100. return(Parm1=Parm3)
  15101. when FastOperator='<' then
  15102. return(Parm1<Parm3)
  15103. when FastOperator='>' then
  15104. return(Parm1>Parm3)
  15105. when FastOperator='<=' then
  15106. return(Parm1<=Parm3)
  15107. when FastOperator='>=' then
  15108. return(Parm1>=Parm3)
  15109. otherwise
  15110. CryAndDie("Unsupported operator of '" || FastOperator || "' used on simple " || HashCmd, '', 'ONLY "==, <>, =, <, >, <=, >=" are supported!')
  15111. end
  15112. CryAndDie('BUG: Did not expect to get here!')
  15113.  
  15114. MatchesIfDebugText:
  15115. MatchIndex=arg(1)
  15116. if MatchIndex<=0 then
  15117. return('')
  15118. else
  15119. return(' (matches #if at ' || IfState.IfAtLine.MatchIndex || ')')
  15120.  
  15121. WantLine:
  15122. if IfState.WantLines.IfNesting='N' then
  15123. return('N')
  15124. else
  15125. do
  15126. if IfState.IfTrue.IfNesting=IfState.InTrue.IfNesting then
  15127. return('Y')
  15128. else
  15129. return('N')
  15130. end
  15131.  
  15132. ProcessHashIfTest:
  15133. if OptionDebugOn='Y' then
  15134. do
  15135. call DBG_CONDITIONAL '#If? at nesting level ' ||IfNesting+1
  15136. call DBGIND 1
  15137. end
  15138. WantTheLines=WantLine()
  15139. if WantTheLines='N' then
  15140. IfResult='N'
  15141. else
  15142. do
  15143. if OptionDebugOn='Y' then
  15144. call DBGIND 1
  15145. parse value PerformReplacementsInCmdsParameters(arg(1))with HashCmd TestCondition
  15146. TestCondition=strip(TestCondition)
  15147. if translate(HashCmd)=CmdHashIf then
  15148. do
  15149. if left(TestCondition,1)<> '[' then
  15150. do
  15151. if TestCondition='' then
  15152. call _DieAsNoTextConditionSupplied
  15153. call ExecRexxCmd 'IfResult = (' || TestCondition || ')'
  15154. end
  15155. else
  15156. do
  15157. IfResult=_PerformSimpleHashIfTest(TestCondition)
  15158. end
  15159. if IfResult then
  15160. IfResult='Y'
  15161. else
  15162. IfResult='N'
  15163. end
  15164. else
  15165. do
  15166. if TestCondition='' then
  15167. CryAndDie(HashCmd|| ' command does not specify the macro name!')
  15168. if pos('CommentBlock  /* ',TestCondition)<>0 then
  15169. IfResult='N'
  15170. else
  15171. IfResult=MacroExists(TestCondition)
  15172. if translate(HashCmd)=CmdHashIfndef then
  15173. IfResult=translate(IfResult, 'YN', 'NY')
  15174. end
  15175. if OptionDebugOn='Y' then
  15176. do
  15177. call DBGIND-1
  15178. if IfResult='N' then
  15179. Tf='FALSE'
  15180. else
  15181. Tf='TRUE'
  15182. if OptionDebugOn='Y' then
  15183. call DBG_CONDITIONAL 'Answer is ' ||Tf
  15184. end
  15185. end
  15186. IfNesting=IfNesting+1
  15187. IfState.WantLines.IfNesting=WantTheLines
  15188. IfState.InTrue.IfNesting='Y'
  15189. IfState.IfTrue.IfNesting=IfResult
  15190. IfState.IfAtLine.IfNesting=CurrentSourceLocation()
  15191. if OptionDebugOn='Y' then
  15192. call DBGIND-1
  15193. return('OK')
  15194.  
  15195. ProcessHashElse:
  15196. if OptionDebugOn='Y' then
  15197. call DBG_CONDITIONAL '#elseif at level #' ||IfNesting||MatchesIfDebugText(IfNesting)
  15198. if IfNesting=0 then
  15199. CryAndDie("Found #elseif without matching #if")
  15200. if IfState.InTrue.IfNesting='N' then
  15201. CryAndDie("Found unexpected #elseif - duplicated #elseif?" ||MatchesIfDebugText(IfNesting))
  15202. if arg(1)<> '' then
  15203. CryAndDie('The #elseif command does not take parameters')
  15204. IfState.InTrue.IfNesting='N'
  15205. return('OK')
  15206.  
  15207. ProcessHashEndif:
  15208. if OptionDebugOn='Y' then
  15209. call DBG_CONDITIONAL 'Endif at level #' ||IfNesting||MatchesIfDebugText(IfNesting)
  15210. if IfNesting=0 then
  15211. CryAndDie("Found #endif without matching #if")
  15212. IfNesting=IfNesting-1
  15213. return('OK')
  15214.  
  15215. HaveNewOutputFile:
  15216. parse arg if!OutFile,if!GenMask,if!Append,if!Mode
  15217. if OutputLevel<>0 then
  15218. call _FileClose CurrentOutFile
  15219. if OptionCgiModeOn='Y' then
  15220. do
  15221. CurrentOutFile=RexStdoutStream
  15222. call DBG 'In CGI mode, will output to "' || CurrentOutFile || '" (standard output)'
  15223. end
  15224. else
  15225. do
  15226. if if!GenMask<> '' then
  15227. CurrentOutFile=GenerateFileName(if!OutFile,if!GenMask)
  15228. else
  15229. do
  15230. CurrentOutFile=if!OutFile
  15231. call MakeDirectoryTree _filespec('drive', CurrentOutFile) || _filespec('path',CurrentOutFile)
  15232. end
  15233. end
  15234. if!OutLine=CurrentOutLine
  15235. CurrentOutLine=0
  15236. do ChkIndex=1 to OutputLevel
  15237. if RexSystemOpSys="UNIX" then
  15238. OutSame=(Output.ChkIndex.File=CurrentOutFile)
  15239. else
  15240. OutSame=(translate(Output.ChkIndex.File)=translate(CurrentOutFile))
  15241. if OutSame then
  15242. do
  15243. if if!Append='Y' then
  15244. call OutputWarningToScreen 'OFO0', 'Appending to currently opened file ("' || CurrentOutFile || '")!'
  15245. else
  15246. do
  15247. WhereOpened=Output.ChkIndex.!Locn
  15248. if WhereOpened='' then
  15249. Extra='Check "/Output" mask for correctness'
  15250. else
  15251. Extra='File opened at ' ||WhereOpened
  15252. CryAndDie('Already have "' || CurrentOutFile || '" open for output!',Extra)
  15253. end
  15254. end
  15255. end
  15256. OutputLevel=OutputLevel+1
  15257. Output.OutputLevel.File=CurrentOutFile
  15258. Output.OutputLevel.Line=if!OutLine
  15259. Output.OutputLevel.!Locn=CurrentSourceLocation('')
  15260. Output.OutputLevel.!PMODE=ProcessingMode
  15261. Output.OutputLevel.!HTAGS=HtmlGeneratorTags
  15262. if ProcessingMode<>if!Mode then
  15263. do
  15264. call DBG 'Processing mode for "' || CurrentOutFile || '" is "' || if!Mode || '" (changed from "' || ProcessingMode || '")'
  15265. ProcessingMode=if!Mode
  15266. end
  15267. if!Hdr='Y'
  15268. if OptionCgiModeOn='N' then
  15269. do
  15270. if FileQueryExists(CurrentOutFile)<> "" then
  15271. do
  15272. if if!Append='Y' then
  15273. do
  15274. call DBG 'Appending to "' || CurrentOutFile || '"'
  15275. if!Hdr='N'
  15276. end
  15277. else
  15278. do
  15279. call DBG 'Deleting "' || CurrentOutFile || '"'
  15280. call MustDeleteFile CurrentOutFile
  15281. end
  15282. end
  15283. end
  15284. call AddOutputFileToDependancyList CurrentOutFile
  15285. HtmlGeneratorTags=OptionHtmlGeneratorTags
  15286. call charout CurrentOutFile, ""
  15287. call _FileClose CurrentOutFile
  15288. call Making,'C'
  15289. call _ExecUserHook 'START'
  15290. if if!Hdr='Y' then
  15291. do
  15292. if Ok2OutputHeader='Y' then
  15293. call OutputHeaderIfWantedOrRequired
  15294. end
  15295. Output.OutputLevel.!SYNRC=OutSyntaxRc
  15296. Output.OutputLevel.!SYNCMD=OutSyntaxCmd
  15297. Output.OutputLevel.!SYNMSG=OutSyntaxMsg
  15298. Output.OutputLevel.!SYNCODE=OutSyntaxCode
  15299. Output.OutputLevel.!SYNELM=OutSyntaxErrLineMask
  15300. call OutputSyntaxCheckingHeaderIfWantedOrRequired
  15301. call _ExecUserHook 'AFTER_HEADERS'
  15302. return
  15303.  
  15304. _BackToPreviousOutput:
  15305. call _ExecUserHook 'END'
  15306. call _FileClose CurrentOutFile
  15307. call DBG 'Closed the Output file = "' || CurrentOutFile || '" (wrote ' || CurrentOutLine || ' line(s))'
  15308. call DoSyntaxCheckingOnFileIfEnabled CurrentOutFile
  15309. if OutputLevel<=1 then
  15310. CryAndDie('No output files on stack!')
  15311. else
  15312. do
  15313. HtmlGeneratorTags=Output.OutputLevel.!HTAGS
  15314. OutSyntaxRc=Output.OutputLevel.!SYNRC
  15315. OutSyntaxCmd=Output.OutputLevel.!SYNCMD
  15316. OutSyntaxMsg=Output.OutputLevel.!SYNMSG
  15317. OutSyntaxCode=Output.OutputLevel.!SYNCODE
  15318. OutSyntaxErrLineMask=Output.OutputLevel.!SYNELM
  15319. CurrentOutLine=Output.OutputLevel.Line
  15320. OutputLevel=OutputLevel-1
  15321. CurrentOutFile=Output.OutputLevel.File
  15322. if ProcessingMode<>Output.OutputLevel.!PMODE then
  15323. do
  15324. ProcessingMode=Output.OutputLevel.!PMODE
  15325. call DBG 'Restoring mode for "' || CurrentOutFile || '" to "' || ProcessingMode || '"'
  15326. end
  15327. call DieIfHoldingOutput
  15328. call OutputHoldPop
  15329. end
  15330. call Making,'R'
  15331. return
  15332.  
  15333. ExtnInfoSet:
  15334. jf!S=arg(1)
  15335. call DBG 'ExtnInfoSet(' || jf!S || ')'
  15336. call DBGIND 1
  15337. if jf!S='' then
  15338. do
  15339. call DBG 'Clearning all configured EXTNINFO'
  15340. drop PPWEXTNINFO.
  15341. end
  15342. else
  15343. do
  15344. parse var jf!S jf!E ':' jf!Parms
  15345. if jf!Parms='' then
  15346. CryAndDie("Invalid EXTNINFO value of:",jf!S)
  15347. if RexSystemOpSys<> "UNIX" then
  15348. jf!E=translate(jf!E)
  15349. do while jf!E<> ''
  15350. parse var jf!E jf!1 ',' jf!E
  15351. call DBG 'Extn Info for .' ||jf!1
  15352. call DBGIND 1
  15353. jf!R=jf!Parms
  15354. do while jf!R<> ''
  15355. parse var jf!R jf!Var '=' jf!R
  15356. jf!Var=strip(jf!Var)
  15357. jf!Val=GetQuotedText(jf!R, "jf!R", ',')
  15358. if jf!Var="PM" then
  15359. do
  15360. if translate(left(jf!Val,3))='LU:' then
  15361. jf!T=substr(jf!Val,4)
  15362. else
  15363. jf!T=jf!Val
  15364. call ValidatePMode jf!T
  15365. end
  15366. call DBG jf!Var|| ' = ' ||jf!Val
  15367. jf!Key='PPWEXTNINFO.PPWEI_' || c2x(jf!Var) || '_' ||c2x(jf!1)
  15368. call value jf!Key,jf!Val
  15369. jf!R=strip(jf!R)
  15370. if left(jf!R,1)=',' then
  15371. jf!R=substr(jf!R,2)
  15372. end
  15373. call DBGIND-1
  15374. end
  15375. end
  15376. call DBGIND-1
  15377. return
  15378.  
  15379. ExtnInfoGet:
  15380. parse arg kf!E,kf!W,kf!Def
  15381. if RexSystemOpSys<> "UNIX" then
  15382. kf!E=translate(kf!E)
  15383. kf!Pre='PPWEXTNINFO.PPWEI_' || c2x(kf!W) || '_'
  15384. kf!Key=kf!Pre||c2x(kf!E)
  15385. if symbol(kf!Key)='VAR' then
  15386. kf!R=value(kf!Key)
  15387. else
  15388. do
  15389. kf!Key=kf!Pre||c2x('*')
  15390. if symbol(kf!Key)='VAR' then
  15391. kf!R=value(kf!Key)
  15392. else
  15393. kf!R=kf!Def
  15394. end
  15395. call DBG 'ExtnInfoGet(EXTN=' || kf!E || ', WANT=' || kf!W || ') => ' ||kf!R
  15396. return(kf!R)
  15397.  
  15398. GetEiOrLu:
  15399. parse arg lf!F,lf!W,lf!LU
  15400. call DBG 'GetEiOrLu(' || lf!F || ')'
  15401. call DBGIND 1
  15402. lf!E=_filespec('E',lf!F)
  15403. OptionSrcExtn="PPWSRC"
  15404. if RexSystemOpSys<> "UNIX" then
  15405. lf!E=translate(lf!E)
  15406. if lf!E=OptionSrcExtn then
  15407. do
  15408. lf!E=_filespec('E', _filespec('W',lf!F))
  15409. call DBG 'The file has the single SRC extension, so process as extension "' || lf!E || '"!'
  15410. end
  15411. lf!R=ExtnInfoGet(lf!E,lf!W)
  15412. if translate(left(lf!R,3))='LU:' then
  15413. do
  15414. if lf!LU<> '' then
  15415. lf!R=lf!LU
  15416. else
  15417. lf!R=substr(lf!R,4)
  15418. end
  15419. call DBG 'Returning: ' ||lf!R
  15420. call DBGIND-1
  15421. return(lf!R)
  15422.  
  15423. StoreOutHeader:
  15424. mf!Spec=arg(1)
  15425. mf!Del=left(mf!Spec,1)
  15426. call DBG '/OutHeader SPEC: ' ||mf!Spec
  15427. parse var mf!Spec (mf!Del) mf!Extn (mf!Del) mf!S (mf!Del) mf!M (mf!Del) mf!E (mf!Del) .
  15428. if RexSystemOpSys<> "UNIX" then
  15429. mf!Extn=translate(mf!Extn)
  15430. mf!Key='OUTHDR_' ||c2x(mf!Extn)
  15431. call value mf!Key,mf!S|| '00'x || mf!M || '00'x||mf!E
  15432. return
  15433.  
  15434. StoreSyntaxCheckCode4Header:
  15435. nf!Spec=arg(1)
  15436. nf!Del=left(nf!Spec,1)
  15437. call DBG '/Syntax SPEC: ' ||nf!Spec
  15438. parse var nf!Spec (nf!Del) nf!Extn (nf!Del) nf!Cmd (nf!Del) nf!Rc (nf!Del) nf!Mask (nf!Del) nf!Lines (nf!Del)
  15439. if RexSystemOpSys<> "UNIX" then
  15440. nf!Extn=translate(nf!Extn)
  15441. nf!Key='OUTHDRSYN_' ||c2x(nf!Extn)
  15442. if nf!Cmd='' then
  15443. drop(nf!Key)
  15444. else
  15445. do
  15446. ReplaceCount=0
  15447. nf!Lines=ReplaceString(nf!Lines,nf!Del, 'FF'x)
  15448. call value nf!Key,nf!Cmd|| '00'x || nf!Rc || '00'x || nf!Mask || '00'x||nf!Lines
  15449. end
  15450. return
  15451.  
  15452. OutputHeaderIfWantedOrRequired:
  15453. of!CmtS=''
  15454. of!CmtM=''
  15455. of!CmtE=''
  15456. of!Extn=_filespec('EXTN',CurrentOutFile)
  15457. if RexSystemOpSys<> "UNIX" then
  15458. of!Extn=translate(of!Extn)
  15459. of!KeyE='OUTHDR_' ||c2x(of!Extn)
  15460. of!KeyM='OUTHDR_' || c2x('*' ||ProcessingMode)
  15461. of!KeyA='OUTHDR_' || c2x('*')
  15462. if symbol(of!KeyE)='VAR' then
  15463. of!UseKey=of!KeyE
  15464. else
  15465. do
  15466. if symbol(of!KeyM)='VAR' then
  15467. of!UseKey=of!KeyM
  15468. else
  15469. do
  15470. if symbol(of!KeyA)='VAR' then
  15471. of!UseKey=of!KeyA
  15472. else
  15473. of!UseKey=''
  15474. end
  15475. end
  15476. if of!UseKey='' then
  15477. call DBG 'No output header definition found'
  15478. else
  15479. do
  15480. call DBG 'Output Header definition was found'
  15481. parse value value(of!UseKey)with of!CmtS '00'x of!CmtM '00'x of!CmtE
  15482. end
  15483. if of!CmtS||of!CmtM||of!CmtE\=='' then
  15484. do
  15485. if left(of!CmtS,1)='@' & of!CmtM||of!CmtE = '' then
  15486. do
  15487. of!Inc=substr(of!CmtS,2)
  15488. call DBG 'Include output header - "' ||of!Inc
  15489. if IncludeLevel=0 then
  15490. GenerateRc=GenerateRc+ProcessInputFile(of!Inc)
  15491. else
  15492. do
  15493. call RecursiveIncludeSave
  15494. GenerateRc=GenerateRc+ProcessInputFile(of!Inc)
  15495. call RecursiveIncludeRestore
  15496. end
  15497. end
  15498. else
  15499. do
  15500. call GenerateOneLine of!CmtS
  15501. call GenerateOneLine of!CmtM|| 'Generator   : PPWIZARD version ' ||PgmVersion
  15502. call GenerateOneLine of!CmtM|| '            : FREE tool for Windows, OS/2, DOS and UNIX by ' || PgmAuthor  || ' (' || PgmAuthorEmail || ')'
  15503. call GenerateOneLine of!CmtM|| '            : ' ||PgmHomePage
  15504. call GenerateOneLine of!CmtM|| "Time        : " ||space(PpwCompTime)
  15505. call GenerateOneLine of!CmtM|| "Input File  : " ||InputFile
  15506. call GenerateOneLine of!CmtM|| "Output File : " ||FileQueryExists(Output.OutputLevel.File)
  15507. call GenerateOneLine of!CmtE
  15508. call GenerateOneLine ''
  15509. end
  15510. end
  15511. return
  15512.  
  15513. OutputSyntaxCheckingHeaderIfWantedOrRequired:
  15514. OutSyntaxCmd=''
  15515. OutSyntaxRc=''
  15516. OutSyntaxMsg=''
  15517. OutSyntaxCode=''
  15518. OutSyntaxErrLineMask=''
  15519. of!Lines=''
  15520. of!KeyE='OUTHDRSYN_' ||c2x(of!Extn)
  15521. of!KeyM='OUTHDRSYN_' || c2x('*' ||ProcessingMode)
  15522. of!KeyA='OUTHDRSYN_' || c2x('*')
  15523. if symbol(of!KeyE)='VAR' then
  15524. of!UseKey=of!KeyE
  15525. else
  15526. do
  15527. if symbol(of!KeyM)='VAR' then
  15528. of!UseKey=of!KeyM
  15529. else
  15530. do
  15531. if symbol(of!KeyA)='VAR' then
  15532. of!UseKey=of!KeyA
  15533. else
  15534. of!UseKey=''
  15535. end
  15536. end
  15537. if of!UseKey='' then
  15538. call DBG 'No output syntax definition found'
  15539. else
  15540. do
  15541. call DBG 'Output syntax checking header code definition was found'
  15542. parse value value(of!UseKey)with OutSyntaxCmd '00'x OutSyntaxRc '00'x OutSyntaxErrLineMask '00'x of!Lines
  15543. end
  15544. if OutSyntaxCmd<> '' then
  15545. do
  15546. if OutSyntaxCmd="*" then
  15547. do
  15548. if ProcessingMode='REXX' then
  15549. do
  15550. of!Lines='if arg(1)="' || SyntaxOkText || '" then exit(' || SyntaxOkRc || ')'
  15551. OutSyntaxRc='*REXX'
  15552. end
  15553. else
  15554. do
  15555. CryAndDie("Don't have an internal syntax handler for current file type")
  15556. end
  15557. end
  15558. if left(OutSyntaxCmd,1)='@' & (OutSyntaxRc || of!Lines) = '' then
  15559. do
  15560. of!Inc=substr(OutSyntaxCmd,2)
  15561. call DBG 'Include output header - "' ||of!Inc
  15562. OutSyntaxRc=''
  15563. OutSyntaxCmd=''
  15564. OutSyntaxMsg=''
  15565. if IncludeLevel=0 then
  15566. GenerateRc=GenerateRc+ProcessInputFile(of!Inc)
  15567. else
  15568. do
  15569. call RecursiveIncludeSave
  15570. GenerateRc=GenerateRc+ProcessInputFile(of!Inc)
  15571. call RecursiveIncludeRestore
  15572. if OutSyntaxCmd='' | OutSyntaxRc = '' then
  15573. CryAndDie('You must set the rexx variables:', ' * OutSyntaxCmd', ' * OutSyntaxRc')
  15574. end
  15575. end
  15576. else
  15577. do
  15578. if left(of!Lines,2)='?:' then
  15579. do
  15580. OutSyntaxCode=d2c(10)||ReplaceString(substr(of!Lines,3), 'FF'x,CodexNewLine)
  15581. end
  15582. else
  15583. do
  15584. do while of!Lines<> ''
  15585. parse var of!Lines of!This 'FF'x of!Lines
  15586. call GenerateOneLine of!This
  15587. end
  15588. call GenerateOneLine ''
  15589. end
  15590. end
  15591. end
  15592. return
  15593.  
  15594. DoSyntaxCheckingOnFileIfEnabled:
  15595. call DBG 'Need to do a syntax check on this file?'
  15596. if OutSyntaxRc='' then
  15597. return
  15598. pf!File=FileQueryExists(arg(1))
  15599. pf!Cmd=ReplaceString(OutSyntaxCmd, '{?}',pf!File)
  15600. if OutSyntaxCode<> '' then
  15601. do
  15602. call OutputWarningToScreen 'SYNS', 'Syntax checking stub "<' || '?SyntaxCheck>" missing in "' || pf!File || '"'
  15603. return
  15604. end
  15605. if OutSyntaxCmd="*" then
  15606. do
  15607. call DBG 'Calling internal validation code'
  15608. if OutSyntaxRc="*REXX" then
  15609. call CheckRexxModuleForSyntaxErrors
  15610. return
  15611. end
  15612. call DBGIND 1
  15613. call DBG 'Calling stub in generated code ("' || pf!File || '")'
  15614. CheckRc='*?*'
  15615. pf!Tmp=RexGetTmpFileName()
  15616. CheckRc=AddressCmd(pf!Cmd||RedirectStdOutAndErr2(pf!Tmp),pf!Tmp)
  15617. if CheckRc<>OutSyntaxRc then
  15618. do
  15619. pf!O=MarksNewLine
  15620. pf!O=pf!O|| "SYNTAX CHECK'S OUTPUT" ||MarksNewLine
  15621. pf!O=pf!O|| '~~~~~~~~~~~~~~~~~~~~~' ||MarksNewLine
  15622. pf!LN=-1
  15623. do while lines(pf!Tmp)<>0
  15624. pf!L=linein(pf!Tmp)
  15625. if pf!L<> '' then
  15626. do
  15627. pf!O=pf!O||pf!L||MarksNewLine
  15628. if pf!LN=-1&OutSyntaxErrLineMask<>0 then
  15629. do
  15630. pf!Num="?"
  15631. pf!M=ReplaceString(OutSyntaxErrLineMask, "{?}", "' pf!Num '")
  15632. interpret "parse var pf!L '" || pf!M || "'"
  15633. if pf!Num<> "" then
  15634. do
  15635. if datatype(pf!Num, 'W')then
  15636. do
  15637. if pf!Num>0 then
  15638. pf!LN=pf!Num
  15639. end
  15640. end
  15641. end
  15642. end
  15643. end
  15644. CloseRc=stream(pf!Tmp, 'c', 'close')
  15645. if pf!LN<>-1 then
  15646. do
  15647. pf!T='SYNTAX ERROR ON LINE #' ||pf!LN
  15648. pf!T=pf!T||MarksNewLine||copies('~',length(pf!T))||MarksNewLine
  15649. pf!FL=0
  15650. pf!Min=pf!LN-8
  15651. pf!Max=pf!Ln+2
  15652. if pf!Min<1 then
  15653. pf!Min=1
  15654. do pf!Fl=pf!Min to pf!Max
  15655. pf!L=FileLineIn(pf!File,pf!Fl)
  15656. if pf!L<> '' |pf!Fl=pf!LN then
  15657. do
  15658. if pf!FL=pf!Ln then
  15659. pf!M='>'
  15660. else
  15661. pf!M=':'
  15662. pf!T=pf!T||pf!FL||pf!M|| ' ' ||pf!L||MarksNewLine
  15663. end
  15664. end
  15665. CloseRc=stream(pf!File, 'c', 'close')
  15666. pf!O=pf!O||MarksNewLine||pf!T
  15667. end
  15668. if left(OutSyntaxMsg,1)<> '-' then
  15669. CryAndDie('Probable Syntax Error detected while checking generated file', 'Got unexpected RC of "' || CheckRc || '" (expected RC of ' || OutSyntaxRc || ')', 'Error checking "' || pf!File || '"',OutSyntaxMsg,pf!O)
  15670. else
  15671. do
  15672. CryAndDie(substr(OutSyntaxMsg,2),pf!O)
  15673. end
  15674. end
  15675. call _SysFileDelete pf!Tmp
  15676. call say ''
  15677. call DBGIND-1
  15678. return
  15679.  
  15680. ProcessHashOutput:
  15681. call DieIfCgiModeOn
  15682. if LineQueued\=='' then
  15683. do
  15684. if OptionDebugOn='Y' then
  15685. do
  15686. call DBG 'Need to flush queued data'
  15687. call DBGIND 3
  15688. end
  15689. call FlushQueuedOutput
  15690. if OptionDebugOn='Y' then
  15691. call DBGIND-3
  15692. end
  15693. qf!Parms=PerformReplacementsInCmdsParameters(arg(1))
  15694. if qf!Parms='' then
  15695. call _BackToPreviousOutput
  15696. else
  15697. do
  15698. qf!NewFile=GetQuotedText(qf!Parms, "qf!Parms")
  15699. qf!Parms=translate(qf!Parms)
  15700. qf!AsIs='N'
  15701. qf!Append='N'
  15702. Ok2OutputHeader='Y'
  15703. qf!Mode=ProcessingMode
  15704. do while qf!Parms<> ''
  15705. ThisParm=GetQuotedText(qf!Parms, "qf!Parms")
  15706. select
  15707. when ThisParm="ASIS" then
  15708. qf!AsIs='Y'
  15709. when ThisParm="NOHEADER" then
  15710. Ok2OutputHeader='N'
  15711. when ThisParm="APPEND" then
  15712. qf!Append='Y'
  15713. when ThisParm="HTML" | ThisParm = "REXX" | ThisParm = "OTHER" then
  15714. qf!Mode=ThisParm
  15715. otherwise
  15716. CryAndDie('The parameter "' || ThisParm || '" is unknown!')
  15717. end
  15718. end
  15719. call OutputHoldPushAndClear
  15720. if qf!AsIs='N' then
  15721. call HaveNewOutputFile qf!NewFile,OptionOutput,qf!Append,qf!Mode
  15722. else
  15723. call HaveNewOutputFile qf!NewFile,,qf!Append,qf!Mode
  15724. end
  15725. return(0)
  15726.  
  15727. _ExecUserHook:
  15728. rf!R=CfgMacro('HOOK_OUTPUT', '')
  15729. if rf!R<> '' then
  15730. do
  15731. call DBG 'Calling #OUTPUT HOOK : ' ||arg(1)
  15732. call DBGIND 1
  15733. rf!R=PerformReplacementsInCmdsParameters(rf!R)
  15734. OutputState=arg(1)
  15735. call ExecRexxCmd rf!R
  15736. call DBGIND-1
  15737. end
  15738. return
  15739.  
  15740. GetQuotedText:
  15741. parse arg sf!Str,sf!Rest,sf!Del,sf!Doing
  15742. sf!Str=strip(sf!Str, 'L')
  15743. sf!Del=' ' ||sf!Del
  15744. if OptionDebugOn='Y' then
  15745. do
  15746. call DBG_QUOTING 'GetQuotedText(): ' ||DebugRightArrow||sf!Str||DebugLeftArrow
  15747. call DBGIND 1
  15748. end
  15749. if sf!Str='' then
  15750. call _ErrorNoQuotedParm
  15751. QuoteChar=left(sf!Str,1)
  15752. if datatype(QuoteChar, 'Alphanumeric')then
  15753. do
  15754. if OptionDebugOn='Y' then
  15755. call DBG_QUOTING 'Text is unquoted'
  15756. DelPos=verify(sf!Str,sf!Del, 'M')
  15757. if DelPos=0 then
  15758. do
  15759. QuotedString=sf!Str
  15760. TheRest=''
  15761. end
  15762. else
  15763. do
  15764. QuotedString=substr(sf!Str,1,DelPos-1)
  15765. TheRest=substr(sf!Str,DelPos)
  15766. end
  15767. end
  15768. else
  15769. do
  15770. if OptionDebugOn='Y' then
  15771. call DBG_QUOTING 'Text is quoted with ' ||DebugRightArrow||QuoteChar||DebugLeftArrow
  15772. SecondQuotePosn=pos(QuoteChar,sf!Str,2)
  15773. if SecondQuotePosn=0 then
  15774. call _ErrorNoEndQuote
  15775. QuotedString=substr(sf!Str,2,SecondQuotePosn-2)
  15776. TheRest=substr(sf!Str,SecondQuotePosn+1)
  15777. end
  15778. if TheRest<> '' then
  15779. do
  15780. if sf!Del<> 'Y' then
  15781. do
  15782. if pos(left(TheRest,1),sf!Del)=0 then
  15783. do
  15784. sf!1='There is no whitespace after the 2nd quote char of "' || QuoteChar || '" (did not expect to find "' || left(TheRest, 1) || '")'
  15785. sf!2='The rest of the line:'
  15786. sf!3=copies(' ',8)||DebugRightArrow||TheRest||DebugLeftArrow
  15787. if sf!Doing<> '' then
  15788. sf!4=''
  15789. else
  15790. sf!4='Doing: ' ||sf!Doing
  15791. CryAndDie(sf!1,sf!2,sf!3,sf!4)
  15792. end
  15793. end
  15794. end
  15795. TheRest=strip(TheRest, 'L')
  15796. if sf!Rest<> '' then
  15797. call _valueS sf!Rest,TheRest
  15798. else
  15799. do
  15800. if TheRest<> '' then
  15801. call DieIfExtraUnexpectedParms TheRest
  15802. end
  15803. if OptionDebugOn='Y' then
  15804. do
  15805. call DBG_QUOTING 'Text is ' ||DebugRightArrow||QuotedString||DebugLeftArrow
  15806. call DBGIND-1
  15807. end
  15808. return(QuotedString)
  15809.  
  15810. GetQuotedRest:
  15811. parse arg sf!Str,sf!Doing
  15812. sf!Str=strip(sf!Str)
  15813. if OptionDebugOn='Y' then
  15814. do
  15815. call DBG_QUOTING 'GetQuotedRest(): ' ||DebugRightArrow||sf!Str||DebugLeftArrow
  15816. call DBGIND 1
  15817. end
  15818. if sf!Str='' then
  15819. call _ErrorNoQuotedParm
  15820. QuoteChar=left(sf!Str,1)
  15821. if datatype(QuoteChar, 'Alphanumeric')then
  15822. do
  15823. QuotedString=sf!Str
  15824. if OptionDebugOn='Y' then
  15825. call DBG_QUOTING 'Text is unquoted'
  15826. end
  15827. else
  15828. do
  15829. if OptionDebugOn='Y' then
  15830. call DBG_QUOTING 'Text is quoted with '||DebugRightArrow||QuoteChar||DebugLeftArrow
  15831. SecondQuotePosn=length(sf!Str)
  15832. if SecondQuotePosn<2|substr(sf!Str,SecondQuotePosn,1)<>QuoteChar then
  15833. call _ErrorNoEndQuote
  15834. QuotedString=substr(sf!Str,2,SecondQuotePosn-2)
  15835. end
  15836. if OptionDebugOn='Y' then
  15837. do
  15838. call DBG_QUOTING 'Text is  ' ||DebugRightArrow||QuotedString||DebugLeftArrow
  15839. call DBGIND-1
  15840. end
  15841. return(QuotedString)
  15842.  
  15843. DieIfExtraUnexpectedParms:
  15844. if arg(1)='' then
  15845. return
  15846. CryAndDie('Unexpected parameter(s) of "' || strip(arg(1)) || '" found!')
  15847.  
  15848. _ErrorNoQuotedParm:
  15849. if sf!Doing<> '' then
  15850. sf!Doing='Doing: ' ||sf!Doing
  15851. CryAndDie('Expect a quoted string, not enough parameters available!',sf!Doing)
  15852.  
  15853. _ErrorNoEndQuote:
  15854. sf!1='Could not find a matching end quote character of "' || QuoteChar || '"!'
  15855. sf!2='Processing:'
  15856. sf!3=copies(' ',8)||DebugRightArrow||sf!Str||DebugLeftArrow
  15857. if sf!Doing<> '' then
  15858. sf!4='Doing: ' ||sf!Doing
  15859. else
  15860. sf!4=''
  15861. CryAndDie(sf!1,sf!2,sf!3,sf!4)
  15862.  
  15863. GetRexxVarValueOrDie:
  15864. grvVar=arg(1)
  15865. if symbol(grvVar)='VAR' then
  15866. return(_valueG(grvVar))
  15867. else
  15868. do
  15869. if symbol(grvVar)='BAD' then
  15870. Reason="contains invalid character(s)"
  15871. else
  15872. Reason="is unknown"
  15873. call DumpVarsIfCompoundVariable grvVar
  15874. CryAndDie('The rexx variable "' || grvVar || '" ' || Reason || '!')
  15875. end
  15876.  
  15877. ProcessRexxVar:
  15878. ResultVar=GetQuotedText(PerformReplacementsInCmdsParameters(arg(1)), "Rest")
  15879. XVarName=''
  15880. ResultVarU=translate(ResultVar)
  15881. if ResultVarU="PUSH" then
  15882. do
  15883. do while Rest<> ''
  15884. ResultVar=GetQuotedText(Rest, "Rest")
  15885. call _StackPush GetRexxVarValueOrDie(ResultVar)
  15886. end
  15887. return(0)
  15888. end
  15889. if ResultVarU="POP" then
  15890. do
  15891. TmpVarCnt=0
  15892. do while Rest<> ''
  15893. ResultVar=GetQuotedText(Rest, "Rest")
  15894. TmpVarCnt=TmpVarCnt+1
  15895. TmpVar.TmpVarCnt=ResultVar
  15896. end
  15897. do while TmpVarCnt<>0
  15898. call _valueS TmpVar.TmpVarCnt,_StackPop()
  15899. TmpVarCnt=TmpVarCnt-1
  15900. end
  15901. return(0)
  15902. end
  15903. parse var Rest FastOperator Rest
  15904. if FastOperator<> '=' then
  15905. do
  15906. FastOperator=translate(FastOperator)
  15907. if left(FastOperator,1)='=' then
  15908. do
  15909. if FastOperator='=X=' then
  15910. do
  15911. XVarName=ResultVar
  15912. ResultVar='XVAR?.X?' ||c2x(translate(XVarName))
  15913. end
  15914. else
  15915. do
  15916. Rest=strip(Rest)
  15917. if symbol(Rest)='VAR' then
  15918. ResultValue=GetRexxVarValueOrDie(Rest)
  15919. else
  15920. ResultValue=GetQuotedRest(Rest)
  15921. select
  15922. when FastOperator='=VALUE=' then
  15923. do
  15924. RestVar=value(ResultValue)
  15925. end
  15926. when FastOperator='=ASIS=' then
  15927. do
  15928. RestVar=AsIs(ResultValue)
  15929. end
  15930. otherwise
  15931. CryAndDie('Unsupported "=?=" operator of "' || FastOperator || '" used on ' ||HashCmd)
  15932. end
  15933. Rest='RestVar'
  15934. end
  15935. FastOperator='='
  15936. end
  15937. end
  15938. select
  15939. when FastOperator='=' then
  15940. do
  15941. Rest=strip(Rest)
  15942. if symbol(Rest)='VAR' then
  15943. ResultValue=GetRexxVarValueOrDie(Rest)
  15944. else
  15945. ResultValue=GetQuotedRest(Rest)
  15946. end
  15947. when FastOperator='PUSH' then
  15948. do
  15949. call DieIfExtraUnexpectedParms Rest
  15950. call _StackPush GetRexxVarValueOrDie(ResultVar)
  15951. return(0)
  15952. end
  15953. when FastOperator='POP' then
  15954. do
  15955. call DieIfExtraUnexpectedParms Rest
  15956. ResultValue=_StackPop()
  15957. end
  15958. otherwise
  15959. do
  15960. AfterOperator=GetSimpleRexxValue(Rest, "Rest")
  15961. if Rest<> '' then
  15962. SourceValue=GetSimpleRexxValue(Rest)
  15963. else
  15964. SourceValue=GetRexxVarValueOrDie(ResultVar)
  15965. if OptionDebugOn='Y' then
  15966. call DBG_REXXVAR 'Evaluating: ' || SourceValue || ' ' || FastOperator || ' ' ||AfterOperator
  15967. select
  15968. when FastOperator='+' then
  15969. ResultValue=SourceValue+AfterOperator
  15970. when FastOperator='-' then
  15971. ResultValue=SourceValue-AfterOperator
  15972. when FastOperator='||' then
  15973. ResultValue=SourceValue||AfterOperator
  15974. when FastOperator='*' then
  15975. ResultValue=SourceValue*AfterOperator
  15976. when FastOperator='/' then
  15977. ResultValue=SourceValue/AfterOperator
  15978. when FastOperator='//' then
  15979. ResultValue=SourceValue//AfterOperator
  15980. when FastOperator='%' then
  15981. ResultValue=SourceValue%AfterOperator
  15982. otherwise
  15983. CryAndDie("Unsupported operator of '" || FastOperator || "' used on " ||HashCmd)
  15984. end
  15985. end
  15986. end
  15987. call _valueS ResultVar,ResultValue
  15988. if OptionDebugOn='Y' then
  15989. do
  15990. call DBGIND 1
  15991. if XVarName='' then
  15992. DbgPrefix=ResultVar
  15993. else
  15994. DbgPrefix='"X" Variable ' ||XVarName
  15995. call DBG_REXXVAR DbgPrefix|| ' = ' ||DebugRightArrow||ResultValue||DebugLeftArrow
  15996. call DBGIND-1
  15997. end
  15998. return(0)
  15999.  
  16000. GetSimpleRexxValue:
  16001. sParm=strip(arg(1), 'L')
  16002. sRestVar=arg(2)
  16003. sQuote=left(sParm,1)
  16004. if sQuote="'" | sQuote = '"' then
  16005. do
  16006. sEndPos=pos(sQuote,sParm,2)
  16007. if sEndPos=0 then
  16008. CryAndDie('Incorrectly quoted rexx literal (could not find ending quote)')
  16009. sValue=substr(sParm,2,sEndPos-2)
  16010. sRest=substr(sParm,sEndPos+1)
  16011. end
  16012. else
  16013. do
  16014. parse var sParm sValue sRest
  16015. if datatype(sValue, 'Number')=0 then
  16016. sValue=GetRexxVarValueOrDie(sValue)
  16017. end
  16018. if sRestVar<> '' then
  16019. call _valueS sRestVar,sRest
  16020. else
  16021. do
  16022. if sRestVar<> '' then
  16023. CryAndDie('Extra unexpected parameters of "' || sRestVar || '" found')
  16024. end
  16025. return(sValue)
  16026.  
  16027. _StackPush:
  16028. StackCnt=StackCnt+1
  16029. Stack.StackCnt.StackData=arg(1)
  16030. Stack.StackCnt.StackPosn=CurrentSourceLocation()
  16031. if OptionDebugOn='Y' then
  16032. call DBG_REXXVAR 'Stack Push(#' || StackCnt || ') = ' ||DebugRightArrow||arg(1)||DebugLeftArrow
  16033. return
  16034.  
  16035. _StackPop:
  16036. if StackCnt<=0 then
  16037. CryAndDie('There is nothing on the stack!')
  16038. spData=Stack.StackCnt.StackData
  16039. if OptionDebugOn='Y' then
  16040. do
  16041. call DBG_REXXVAR 'Stack pop(#' || StackCnt || ') = ' ||DebugRightArrow||spData||DebugLeftArrow
  16042. call DBG_REXXVAR 'matched push() at ' ||Stack.StackCnt.StackPosn
  16043. end
  16044. StackCnt=StackCnt-1
  16045. return(spData)
  16046.  
  16047. MatchesStackPushDebugText:
  16048. MatchIndex=arg(1)
  16049. if MatchIndex<=0 then
  16050. return('')
  16051. else
  16052. return(' (matches "#RexxVar PUSH" at ' || Stack.MatchIndex.StackPosn || ')')
  16053.  
  16054. XVarDefined:call TRACE "OFF"
  16055. parse arg tf!Xv,tf!Wn
  16056. tf!Sa='XVAR?.X?' ||c2x(translate(tf!Xv))
  16057. if tf!Wn<> 'N' then
  16058. do
  16059. if symbol(tf!Sa)<> 'VAR' then
  16060. do
  16061. if tf!Wn='D' then
  16062. CryAndDie('The XVAR "' || tf!Xv || '" does not exist!')
  16063. tf!Sa=''
  16064. end
  16065. end
  16066. if OptionDebugOn='Y' then
  16067. call DBG_EVALUATE 'XVarDefined(' || tf!Xv || ') : ' ||tf!sa
  16068. return(tf!Sa)
  16069.  
  16070. _EnsureVersionY2KSafe:
  16071. TheVer=ReplaceString(translate(arg(1)), '2K', '00')
  16072. if datatype(TheVer, 'Number')=0|(length(TheVer)<>6&length(TheVer)<>8)then
  16073. CryAndDie('The version number "' || TheVer || '" is not valid')
  16074. if TheVer<100 then
  16075. do
  16076. if TheVer>98 then
  16077. TheVer='19' ||TheVer
  16078. else
  16079. TheVer='20' ||TheVer
  16080. end
  16081. return(TheVer)
  16082.  
  16083. ProcessRequireCommon:
  16084. uf!MinVer=_EnsureVersionY2KSafe(GetQuotedText(arg(1), 'uf!Rest'))
  16085. if uf!Rest='' then
  16086. uf!MaxVer='9999.99'
  16087. else
  16088. do
  16089. uf!MaxVer=_EnsureVersionY2KSafe(GetQuotedText(uf!Rest))
  16090. uf!Rest='"' || uf!MaxVer || '"'
  16091. end
  16092. uf!ThisVer=_EnsureVersionY2KSafe(PgmVersion)
  16093. if OptionDebugOn='Y' then
  16094. do
  16095. call DBG 'You require "' || uf!MinVer || '" - ' ||uf!Rest
  16096. call DBG 'You have    "' || uf!ThisVer || '"'
  16097. end
  16098. uf!U='You are using version "' || uf!ThisVer || '"'
  16099. if uf!ThisVer<uf!MinVer then
  16100. CryAndDie('You required at least PPWIZARD version "' || uf!MinVer || '"',uf!U)
  16101. if uf!ThisVer>uf!MaxVer then
  16102. CryAndDie('You need a PPWIZARD version EARLIER than "' || uf!MaxVer || '"',uf!U)
  16103. return(0)
  16104.  
  16105. ProcessRequire:
  16106. return(ProcessRequireCommon(PerformReplacementsInCmdsParameters(arg(1))))
  16107.  
  16108. RexxCtrlC:
  16109. LineCtrlC=SIGL
  16110. TRACE OFF
  16111. call AllFollowingOutputGoesToErrorFile
  16112. call Line1 ''
  16113. call ColorSet 'HIGHLIGHT'
  16114. call Line1 copies('=+',39)
  16115. call ColorSet 'ERROR'
  16116. call CgiStartFatalError
  16117. call Line1 "Come on, you pressed Ctrl+C or Break didn't you!"
  16118. call CgiEndFatalError
  16119. call ColorSet 'HIGHLIGHT'
  16120. call Line1 copies('=+',39)
  16121. call ColorSet
  16122. AbnormalExit(LineCtrlC, "CTRL+C Pressed")
  16123.  
  16124. QuickSourceLine:
  16125. LineNum=arg(1)
  16126. slKey='PPWSL!.' ||LineNum
  16127. if symbol(slKey)='VAR' then
  16128. return(_valueG(slKey))
  16129. SrcLine=sourceline(LineNum)
  16130. call _valueS slKey,SrcLine
  16131. return(SrcLine)
  16132.  
  16133. _FindLastLabel:
  16134. FailedOnLine=arg(1)
  16135. TryLine=FailedOnLine
  16136. do while TryLine>1
  16137. TryLine=TryLine-1
  16138. TheLine=QuickSourceLine(TryLine)
  16139. ColonPos=pos(':',TheLine)
  16140. if ColonPos<>0 then
  16141. do
  16142. MaybeLabel=strip(left(TheLine,ColonPos-1))
  16143. if symbol(MaybeLabel)<> 'BAD' then
  16144. do
  16145. FoundLabelOnLine=TryLine
  16146. return(MaybeLabel|| ':  (line #' || AddCommasToDecimalNumber(TryLine) || ')')
  16147. end
  16148. end
  16149. end
  16150. FoundLabelOnLine=0
  16151. return('')
  16152.  
  16153. GetIncludeStack:
  16154. vf!R=''
  16155. if IncludeLevel>1 then
  16156. do
  16157. do vf!F=1 to IncludeLevel
  16158. if vf!R<> '' then
  16159. vf!R=vf!R|| ' -> '
  16160. vf!R=vf!R||_filespec('n', IncludeFileName.vf!F) || '(' || GetLineNumber4Level(vf!f) || ')'
  16161. end
  16162. end
  16163. return(vf!R)
  16164.  
  16165. SeeAlsoFile:
  16166. wf!W=arg(1)
  16167. wf!T=left('More Info?', wf!W) || ': '
  16168. if ConsoleFile<> '' then
  16169. do
  16170. call Line1 wf!T||ConsoleFile|| ' (console file)'
  16171. wf!T=left('', wf!W) || ': '
  16172. end
  16173. if ConsoleErrorFile<> '' then
  16174. call Line1 wf!T||ConsoleErrorFile|| ' (error file)'
  16175. return
  16176.  
  16177. CommonTrapHandler:
  16178. signal on NOVALUE name SimpleRexxTrapUninitializedVariable
  16179. signal on SYNTAX name SimpleRexxTrapSyntaxError
  16180. FailingLine=arg(1)
  16181. TrapType=arg(2)
  16182. TextDescription=arg(3)
  16183. Text=arg(4)
  16184. CmdBeingEvaluated=arg(5)
  16185. UserBreakPoint=arg(6)
  16186. if TrapType='N' then
  16187. TrapHeading='NoValue Abort!'
  16188. else
  16189. TrapHeading='Syntax Error!'
  16190. HaveCapturedTrapDetails='Y'
  16191. call AllFollowingOutputGoesToErrorFile
  16192. call Line1 ''
  16193. call ColorSet 'HIGHLIGHT'
  16194. call Line1 copies('=+',39)
  16195. call ColorSet 'ERROR'
  16196. call CgiStartFatalError
  16197. call Line1 TrapHeading
  16198. call Line1 copies('~',length(TrapHeading))
  16199. call Line1 substr(TextDescription,1,16)|| ': ' ||Text
  16200. BetterErrorText=Condition('D')
  16201. if BetterErrorText<> '' &BetterErrorText<>Text then
  16202. call Line1 copies(' ',18)||BetterErrorText
  16203. if IncludeLevel<>0 then
  16204. do
  16205. call Line1 'Processing locn : ' ||CurrentSourceLocation()
  16206. wf!S=GetIncludeStack()
  16207. if wf!S<> '' then
  16208. call Line1 'File Stack      : ' ||wf!S
  16209. LastFileLine=strip(LastFileLine)
  16210. LastLine=strip(LastLine)
  16211. call Line1 'Line from file  : ' ||LastFileLine
  16212. if LastLine<>LastFileLine then
  16213. call Line1 'Failing line    : ' ||LastLine
  16214. if LastLineAfterMacroRep<> '' &LastLine<>LastLineAfterMacroRep&LastFileLine<>LastLineAfterMacroRep then
  16215. call Line1 'After Replace   : ' ||LastLineAfterMacroRep
  16216. if MacroBeingExpanded<> '' then
  16217. call Line1 'Expanding Macro : ' || StartsMacroReplacement || MacroBeingExpanded || ' ...' ||EndsMacroReplacement
  16218. end
  16219. else
  16220. do
  16221. if PpwDoing<> '' then
  16222. call Line1 'PPWIZARD was    : ' ||PpwDoing
  16223. end
  16224. if CmdBeingEvaluated<> '' then
  16225. do
  16226. CmdBeingEvaluatedTmp=ReplaceString(CmdBeingEvaluated,DefRexxSpecialSepTag, ";")
  16227. EvPrefix='Evaluating This : '
  16228. ShowThisS=CmdBeingEvaluatedTmp
  16229. if length(ShowThisS)>300 then
  16230. ShowThisS=left(ShowThisS,300)|| ' ...(Too much to show all)'
  16231. ShowThisS=EvPrefix||ShowThisS
  16232. CmdSepL=RexEOL||copies(' ',length(EvPrefix))
  16233. ShowThisL=EvPrefix||ReplaceString(CmdBeingEvaluatedTmp, ";",CmdSepL)
  16234. ShowThisL=ReplaceString(ShowThisL, '0D'x, '')
  16235. call Line1 ShowThisS,ShowThisL
  16236. call Line1 ''
  16237. if TrapType='S' then
  16238. do
  16239. wf!FailedAt='Could not be determined...'
  16240. wf!C=PPWIZARD_REGINA_SYNTAX_CMD('Y')
  16241. if wf!C<> "" & pos('SYNTAX',translate(TrapHeading))<>0 then
  16242. do
  16243. wf!Msk=ReplaceString(PPWIZARD_REGINA_SYNTAX_LINE_MASK(), "{?}", "' wf!Line '")
  16244. Contents=ReplaceString(CmdBeingEvaluated,DefRexxSpecialSepTag,RexEOL)
  16245. wf!TmpRx=RexGetTmpFileName('EV?????.CMD')
  16246. call MustDeleteFile wf!TmpRx
  16247. call lineout wf!TmpRx, "/* Keep OS/2 Happy */"
  16248. call lineout wf!TmpRx, "exit(0);"
  16249. wf!Extra=2
  16250. call charout wf!TmpRx,Contents
  16251. call FileClose wf!TmpRx, 'N'
  16252. wf!Cmd=ReplaceString(wf!C, '{?}',wf!TmpRx)
  16253. wf!TmpO=RexGetTmpFileName()
  16254. wf!CheckRc=AddressCmd(wf!Cmd||RedirectStdOutAndErr2(wf!TmpO),wf!TmpO)
  16255. if wf!CheckRc<>0 then
  16256. do
  16257. wf!ErrText=charin(wf!TmpO,,99999)
  16258. call FileClose wf!TmpO, 'N'
  16259. interpret "parse var wf!ErrText '" || wf!Msk || "'"
  16260. if wf!Line<> '' & DataType(wf!Line, 'W')=1 then
  16261. do
  16262. wf!FailedAt='#' || wf!Line - wf!Extra || ' : ' ||FileLineIn(wf!TmpRx,wf!Line)
  16263. call FileClose wf!TmpRx, 'N'
  16264. end
  16265. end
  16266. call _SysFileDelete wf!TmpRx
  16267. call _SysFileDelete wf!TmpO
  16268. end
  16269. call Line1 'Rexx Invalid at : ' ||wf!FailedAt
  16270. end
  16271. end
  16272. if RexWhich='REGINA' then
  16273. ReginaUname=' (' || uname() || ')'
  16274. else
  16275. ReginaUname=''
  16276. FailingLineText=AddCommasToDecimalNumber(FailingLine)
  16277. call SeeAlsoFile 16
  16278. call Line1 'Operating System: ' ||RexSystemOpSys||ReginaUname
  16279. call Line1 'Rexx Version    : ' ||RexVersionInfo
  16280. if CmdBeingEvaluated='' then
  16281. DumpPpwSrc='Y'
  16282. else
  16283. do
  16284. DumpPpwSrc='N'
  16285. call DumpVarsInExpression CmdBeingEvaluatedTmp,, 'KNOWN VARIABLES', 'Line1'
  16286. end
  16287. if DumpPpwSrc='Y' then
  16288. do
  16289. call Line1 'Failing Module  : ' || PpWizardPgmName || ' (' || PgmVersion || ')'
  16290. call Line1 'Failing Line #  : ' ||FailingLineText
  16291. InRoutine=_FindLastLabel(FailingLine)
  16292. StartAt=FailingLine-7
  16293. if FoundLabelOnLine<>0 then
  16294. do
  16295. if FoundLabelOnLine>StartAt then
  16296. StartAt=FoundLabelOnLine
  16297. else
  16298. do
  16299. if FoundLabelOnLine<>0 then
  16300. do
  16301. if(FailingLine-FoundLabelOnLine)<10 then
  16302. StartAt=FoundLabelOnLine
  16303. else
  16304. call Line1 'After label     : ' ||InRoutine
  16305. end
  16306. end
  16307. end
  16308. call Line1 'SOURCE'
  16309. call Line1 '~~~~~~'
  16310. vlist.0=0
  16311. do ShowLine=StartAt to FailingLine
  16312. FailingSrcLineTxt=strip(QuickSourceLine(ShowLine))
  16313. call Line1 left(AddCommasToDecimalNumber(ShowLine),length(FailingLineText))|| ' : ' ||FailingSrcLineTxt
  16314. call DumpVarsInExpression FailingSrcLineTxt, 'vlist'
  16315. end
  16316. call DumpVarsInExpressionNow 'vlist', 'KNOWN VARIABLES', 'Line1'
  16317. end
  16318. HookText=TrapHeading|| ' at line ' || FailingLineText || '. ' || TextDescription || ': ' ||Text
  16319. call CgiEndFatalError
  16320. call ColorSet 'HIGHLIGHT'
  16321. call Line1 copies('=+',39)
  16322. call ColorSet
  16323. call Line1 ''
  16324. if UserBreakPoint<> '' then
  16325. do
  16326. call RexxTrace HookText,,,'Y'
  16327. end
  16328. AbnormalExit(FailingLine,HookText)
  16329.  
  16330. RexxTrapUninitializedVariable:
  16331. TrappingLine=SIGL
  16332. call CommonTrapHandler TrappingLine, 'N', 'Unknown Variable', condition('D')
  16333.  
  16334. RexxTrapSyntaxError:
  16335. TrappingLine=SIGL
  16336. call CommonTrapHandler TrappingLine, 'S', 'Reason',errortext(Rc)
  16337.  
  16338. SimpleCommonTrapHandler:
  16339. if HaveCapturedTrapDetails='N' then
  16340. do
  16341. FailingLine=arg(1)
  16342. TrapType=arg(2)
  16343. TextDescription=arg(3)
  16344. Text=arg(4)
  16345. if TrapType='N' then
  16346. TrapHeading='NoValue Abort!'
  16347. else
  16348. TrapHeading='Syntax Error!'
  16349. end
  16350. FailingLineText=AddCommasToDecimalNumber(FailingLine)
  16351. say ''
  16352. say copies('*-',39)
  16353. say TrapHeading
  16354. say copies('~',length(TrapHeading))
  16355. if HaveCapturedTrapDetails='Y' then
  16356. say 'Trap within Trap: Original trap details saved and displayed below!'
  16357. say substr(TextDescription,1,16)|| ': ' ||Text
  16358. BetterErrorText=Condition('D')
  16359. if BetterErrorText<> '' &BetterErrorText<>Text then
  16360. call Line1 copies(' ',18)||BetterErrorText
  16361. parse source . . PpWizardPgmName
  16362. parse version VersionOfRexx
  16363. FailingSrcLineTxt=strip(QuickSourceLine(FailingLine))
  16364. say 'Failed at       : ' || PpWizardPgmName || ' (line ' || FailingLineText || ', version ' || PgmVersion || ')'
  16365. say 'Source Code     : ' ||FailingSrcLineTxt
  16366. say 'Rexx Version    : ' ||VersionOfRexx
  16367. call DumpVarsInExpression FailingSrcLineTxt, '', 'KNOWN VARIABLES'
  16368. HookText=TrapHeading|| ' at line ' || FailingLineText || '. ' || TextDescription || ': ' ||Text
  16369. if HaveCapturedTrapDetails='Y' then
  16370. do
  16371. FailingLine=arg(1)
  16372. TrapHeading=arg(2)
  16373. TextDescription=arg(3)
  16374. Text=arg(4)
  16375. say ''
  16376. say 'Reason for secondary trap'
  16377. say '~~~~~~~~~~~~~~~~~~~~~~~~~'
  16378. say substr(TextDescription,1,16)|| ': ' ||Text
  16379. say 'Failed at       : ' || PpWizardPgmName || ' (line ' || FailingLineText || ', version ' || PgmVersion || ')'
  16380. say 'Source Code     : ' ||strip(QuickSourceLine(FailingLine))
  16381. end
  16382. say copies('*-',39)
  16383. call CallErrorHookForSimpleOneLiner HookText
  16384. ExitNowCallingAnyHandlers(FailingLine)
  16385.  
  16386. SimpleRexxTrapUninitializedVariable:
  16387. TrappingLine=SIGL
  16388. call SimpleCommonTrapHandler TrappingLine, 'N', 'Unknown Variable', condition('D')
  16389.  
  16390. SimpleRexxTrapSyntaxError:
  16391. TrappingLine=SIGL
  16392. call SimpleCommonTrapHandler TrappingLine, 'S', 'Reason',errortext(Rc)
  16393.