home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 March / Chip_2002-03_cd1.bin / sharewar / Slunec / app / ppww32.exe / PPWIZARD.REX < prev    next >
OS/2 REXX Batch file  |  2002-01-17  |  370KB  |  14,415 lines

  1. /*
  2.  * Generator   : PPWIZARD version 02.012
  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        : Thursday, 17 Jan 2002 6:27:06pm
  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.017"
  13. SupportedReginaVersions='2.0, 2.2 or 3.0BETA2'
  14. RecommendedReginaVersions='2.2'
  15. PpwStartSec=(time('S') || substr(time('L'),9,3))
  16. TrapHandler=''
  17. RedirMethod=''
  18. call InitCommandLineOptions arg(1)
  19. call InitConsoleOutputVarsPass1
  20. PpwDoing='Initializing'
  21. Dummy=time('Reset')
  22. b2rNewSingleQuote="' || " || '"' || "'" || '" || ' || "'"
  23. b2rAllHexCodes=''
  24. b2rAllAsciiCodes=''
  25. do b2rCharCode=0 to 31
  26. b2rAllHexCodes=b2rAllHexCodes||d2c(b2rCharCode)
  27. end
  28. do b2rCharCode=32 to 126
  29. b2rAllAsciiCodes=b2rAllAsciiCodes||d2c(b2rCharCode)
  30. end
  31. do b2rCharCode=127 to 255
  32. b2rAllHexCodes=b2rAllHexCodes||d2c(b2rCharCode)
  33. end
  34. signal EndBIN2REXPXh
  35.  
  36. _QuoteAscii:
  37. b2rAscii2Quote=arg(1)
  38. if pos("'",b2rAscii2Quote)=0 then
  39. return("'" || b2rAscii2Quote || "'")
  40. else
  41. do
  42. if pos('"',b2rAscii2Quote)=0 then
  43. return('"' || b2rAscii2Quote || '"')
  44. else
  45. do
  46. return("'" || ReplaceString(b2rAscii2Quote, "'", b2rNewSingleQuote) || "'")
  47. end
  48. end
  49.  
  50. _FormatHex:
  51. b2rHexString=arg(1)
  52. b2rLengthHex=length(b2rHexString)
  53. b2rFormattedHex="'"
  54. if b2rLengthHex>7 then
  55. do
  56. b2rLeft1=left(b2rHexString,1)
  57. b2rLeft1Pos=verify(b2rHexString,b2rLeft1)
  58. if b2rLeft1Pos=0 then
  59. return( "copies('" || c2x(b2rLeft1) || "'x, " || b2rLengthHex || ")" )
  60. else
  61. do
  62. if b2rLeft1Pos>7 then
  63. do
  64. b2rFormattedHex="copies('" || c2x(b2rLeft1) || "'x, " || b2rLeft1Pos-1 || ") || '"
  65. b2rHexString=substr(b2rHexString,b2rLeft1Pos)
  66. b2rLengthHex=b2rLengthHex-(b2rLeft1Pos-1)
  67. end
  68. end
  69. end
  70. do b2rCharPosn=1 to b2rLengthHex
  71. if(b2rCharPosn//8)=1 then
  72. do
  73. if b2rCharPosn<>1 then
  74. b2rFormattedHex=b2rFormattedHex|| ' '
  75. end
  76. b2rFormattedHex=b2rFormattedHex||c2x(substr(b2rHexString,b2rCharPosn,1))
  77. end
  78. b2rFormattedHex=b2rFormattedHex|| "'x"
  79. return(b2rFormattedHex)
  80.  
  81. _QuoteAsciiBreakIfRequired:
  82. qabAscii=arg(1)
  83. qabLength=length(qabAscii)
  84. qabReturn=''
  85. do while qabLength>256
  86. qabLeft=left(qabAscii,256)
  87. qabAscii=substr(qabAscii,256+1)
  88. qabLength=qabLength-256
  89. if qabReturn='' then
  90. qabReturn=_QuoteAscii(qabLeft)
  91. else
  92. qabReturn=qabReturn|| " || " ||_QuoteAscii(qabLeft)
  93. end
  94. if qabLength=0 then
  95. return(qabReturn)
  96. else
  97. do
  98. if qabReturn='' then
  99. return(_QuoteAscii(qabAscii))
  100. else
  101. return(qabReturn|| " || " ||_QuoteAscii(qabAscii))
  102. end
  103.  
  104. _FormatHexBreakIfRequired:
  105. fhbHex=arg(1)
  106. fhbLength=length(fhbHex)
  107. fhbReturn=''
  108. do while fhbLength>80
  109. fhbLeft=left(fhbHex,80)
  110. fhbHex=substr(fhbHex,80+1)
  111. fhbLength=fhbLength-80
  112. if fhbReturn='' then
  113. fhbReturn=_FormatHex(fhbLeft)
  114. else
  115. fhbReturn=fhbReturn|| " || " ||_FormatHex(fhbLeft)
  116. end
  117. if fhbLength=0 then
  118. return(fhbReturn)
  119. else
  120. do
  121. if fhbReturn='' then
  122. return(_FormatHex(fhbHex))
  123. else
  124. return(fhbReturn|| " || " ||_FormatHex(fhbHex))
  125. end
  126.  
  127. BIN2REXP:
  128. call BIN2REXP_START
  129. b2rValue=arg(1)
  130. b2rValueLength=length(b2rValue)
  131. if b2rValueLength=0 then
  132. call BIN2REXP_ONEBIT '""'
  133. else
  134. do
  135. do while b2rValue\==''
  136. b2rEndAsciiPos=verify(b2rValue,b2rAllAsciiCodes)
  137. if b2rEndAsciiPos=0 then
  138. do
  139. call BIN2REXP_ONEBIT _QuoteAsciiBreakIfRequired(b2rValue)
  140. b2rValue=''
  141. end
  142. else
  143. do
  144. if b2rEndAsciiPos<>1 then
  145. do
  146. call BIN2REXP_ONEBIT _QuoteAsciiBreakIfRequired(left(b2rValue,b2rEndAsciiPos-1))
  147. b2rValue=substr(b2rValue,b2rEndAsciiPos)
  148. end
  149. else
  150. do
  151. b2rEndBinaryPos=verify(b2rValue,b2rAllHexCodes)
  152. if b2rEndBinaryPos=0 then
  153. do
  154. call BIN2REXP_ONEBIT _FormatHexBreakIfRequired(b2rValue)
  155. b2rValue=''
  156. end
  157. else
  158. do
  159. call BIN2REXP_ONEBIT _FormatHexBreakIfRequired(left(b2rValue,b2rEndBinaryPos-1))
  160. b2rValue=substr(b2rValue,b2rEndBinaryPos)
  161. end
  162. end
  163. end
  164. end
  165. end
  166. call BIN2REXP_END
  167. return
  168.  
  169. EndBIN2REXPXh:
  170. signal EndDUMPVARXh
  171.  
  172. DumpVarsInExpression:
  173. dv_RexxExp=arg(1)
  174. dv_Stem=translate(arg(2))
  175. dv_VarHeading=arg(3)
  176. dv_LineRoutine=arg(4)
  177. if dv_Stem<> '' then
  178. do
  179. dv_AutoDump='N'
  180. dv_StemDot=dv_Stem|| '.'
  181. if symbol(dv_StemDot|| '0') = 'VAR' then
  182. dv_VarCount=value(dv_StemDot|| '0')
  183. else
  184. do
  185. call _DumpVarsLineOutput 'DumpVar: Could not find "' || dv_StemDot || '0' || '"'
  186. return(0)
  187. end
  188. end
  189. else
  190. do
  191. dv_AutoDump='Y'
  192. dv_Stem='DV_VARLIST'
  193. dv_StemDot=dv_Stem|| '.'
  194. dv_VarCount=0
  195. end
  196. if dv_VarCount=0 then
  197. dv_MaxVarLng=0
  198. do while dv_RexxExp<> ''
  199. parse value strip(dv_RexxExp, 'L')with dv_1stChar+1 dv_RexxExp
  200. select
  201. when datatype(dv_1stChar, 'S')then
  202. do
  203. dv_OneVar=dv_1stChar
  204. do while dv_RexxExp<> ''
  205. parse var dv_RexxExp dv_1stChar+1 dv_RexxExp
  206. if datatype(dv_1stChar, 'S')then
  207. dv_OneVar=dv_OneVar||dv_1stChar
  208. else
  209. do
  210. dv_RexxExp=dv_1stChar||dv_RexxExp
  211. leave
  212. end
  213. end
  214. call _RememberDumpedVar dv_OneVar
  215. if pos('.',dv_OneVar)<>0 then
  216. do
  217. do while dv_OneVar<> ''
  218. parse var dv_OneVar dv_ThisBit '.' dv_OneVar
  219. call _RememberDumpedVar dv_ThisBit
  220. end
  221. end
  222. end
  223. when dv_1stChar='"' | dv_1stChar = "'" then
  224. do
  225. dv_EndQuotePos=pos(dv_1stChar,dv_RexxExp)
  226. if dv_EndQuotePos=0 then
  227. dv_RexxExp=''
  228. else
  229. dv_RexxExp=substr(dv_RexxExp,dv_EndQuotePos+1)
  230. end
  231. otherwise
  232. nop
  233. end
  234. end
  235. call value dv_StemDot|| '0',dv_VarCount
  236. if dv_AutoDump='Y' then
  237. call DumpVarsInExpressionNow dv_Stem,dv_VarHeading,dv_LineRoutine
  238. return(dv_VarCount)
  239.  
  240. DumpVarsInExpressionNow:
  241. dv_StemDot=arg(1)|| '.'
  242. dv_VarHeading=arg(2)
  243. dv_LineRoutine=arg(3)
  244. if symbol(dv_StemDot|| '0') = 'VAR' then
  245. dv_VarCount=value(dv_StemDot|| '0')
  246. else
  247. do
  248. call _DumpVarsLineOutput 'DumpVar: could not find "' || dv_StemDot || '0' || '"'
  249. return(0)
  250. end
  251. if dv_VarCount<>0&dv_VarHeading<> '' then
  252. do
  253. call _DumpVarsLineOutput ''
  254. call _DumpVarsLineOutput dv_VarHeading
  255. call _DumpVarsLineOutput copies('~',length(dv_VarHeading))
  256. end
  257. dv_ShowVarLng=dv_MaxVarLng
  258. if dv_MaxVarLng>30 then
  259. dv_ShowVarLng=30
  260. do dv_Index=1 to dv_VarCount
  261. dv_OneVar=value(dv_StemDot||dv_Index)
  262. if length(dv_OneVar)>=dv_ShowVarLng then
  263. ShowVar=dv_OneVar
  264. else
  265. ShowVar=right(dv_OneVar,dv_ShowVarLng)
  266. dv_OneVarValue=value(translate(dv_OneVar))
  267. if datatype(dv_OneVarValue, 'N')=0 then
  268. do
  269. call BIN2REXP dv_OneVarValue
  270. dv_OneVarValue=dv_Value
  271. end
  272. call _DumpVarsLineOutput ShowVar|| ' = ' ||dv_OneVarValue
  273. end
  274. return
  275.  
  276. _RememberDumpedVar:
  277. dv_ThisVar=arg(1)
  278. if symbol(dv_ThisVar)='VAR' then
  279. do
  280. dv_AlreadyHave='N'
  281. dv_ThisVarUpper=translate(dv_ThisVar)
  282. do dv_Index=1 to dv_VarCount
  283. if dv_ThisVarUpper=translate(value(dv_StemDot||dv_Index))then
  284. do
  285. dv_AlreadyHave='Y'
  286. leave
  287. end
  288. end
  289. if dv_AlreadyHave='N' then
  290. do
  291. dv_VarCount=dv_VarCount+1
  292. call value dv_StemDot||dv_VarCount,dv_ThisVar
  293. if length(dv_ThisVar)>dv_MaxVarLng then
  294. dv_MaxVarLng=length(dv_ThisVar)
  295. end
  296. end
  297. return
  298.  
  299. _DumpVarsLineOutput:
  300. if dv_LineRoutine='' then
  301. say arg(1)
  302. else
  303. interpret 'call ' || dv_LineRoutine || ' arg(1)'
  304. return
  305.  
  306. BIN2REXP_START:
  307. dv_Value=''
  308. return
  309.  
  310. BIN2REXP_ONEBIT:
  311. if dv_Value<> '' then
  312. dv_Value=dv_Value|| ' || '
  313. dv_Value=dv_Value||arg(1)
  314. return
  315.  
  316. BIN2REXP_END:
  317. return
  318.  
  319. EndDUMPVARXh:
  320. HaveCapturedTrapDetails='N'
  321. MacroBeingExpanded=''
  322. LastLineAfterMacroRep=''
  323. LastFileLine=''
  324. LastLine=''
  325. ErrorHookCount=0
  326. call RexxHookInit
  327. signal on NOVALUE name SimpleRexxTrapUninitializedVariable
  328. signal on SYNTAX name SimpleRexxTrapSyntaxError
  329. TrapHandler='SIMPLE'
  330. MyBaseHomeDir="http://www.labyrinth.net.au/~dbareis/"
  331. PgmHomePage=MyBaseHomeDir|| "ppwizard.htm"
  332. PgmAuthorHomePage=MyBaseHomeDir|| "index.htm"
  333. PgmAuthor="Dennis Bareis"
  334. PgmAuthorEmail="dbareis@labyrinth.net.au"
  335. ExpressionKilledUs=''
  336. SyntaxOkRc=21924
  337. SyntaxOkText='!CheckSyntax!'
  338. CopyrightDisplayed='N'
  339. CurrentOutFile=''
  340. OutSyntaxMsg=''
  341. OutSyntaxCmd=''
  342. OutSyntaxRc=''
  343. IncludeLevel=0
  344. Warnings=0
  345. LineSourceBeingProcessed='?'
  346. OnExitSleepForOk=0
  347. OnExitSleepForError=2
  348. SleepSwitch='N'
  349. call RemoveColorCodes
  350. call RemoveBeepCode
  351. if translate(strip(arg(1)))='DEBUG' then
  352. call DisplayCopyright
  353. /*
  354. *REXSYSTM.XH Version 01.331 By Dennis Bareis
  355. *http://www.labyrinth.net.au/~dbareis/index.htm(db0@anz.com)
  356. */
  357. trace off
  358. RexSystmRexxPgmName='?'
  359. if '1' == 'F1'x then
  360. RexIsAscii='N'
  361. else
  362. RexIsAscii='Y'
  363. parse version RexVersionInfo
  364. if pos('REGINA',translate(RexVersionInfo))<>0 then
  365. do
  366. RexWhich='REGINA'
  367. parse value translate(RexVersionInfo)with . 'REGINA_' RexVerRegina ' '
  368. RexVerRegina=translate(RexVerRegina, '.', '_')
  369. end
  370. else
  371. do
  372. RexVerRegina=''
  373. if pos('REXX370',translate(RexVersionInfo))<>0 then
  374. do
  375. RexWhich='REXX370'
  376. end
  377. else
  378. do
  379. RexWhich='STANDARD_OS/2'
  380. end
  381. end
  382. parse source RexSystemOpSys .
  383. RexSystemOpSysREAL=RexSystemOpSys
  384. if RexWhich='REGINA' then
  385. do
  386. if RexSystemOpSys="WIN32" then
  387. parse value uname()with RexSystemOpSysREAL .
  388. if RexSystemOpSys="UNIX" then
  389. parse value uname()with RexSystemOpSysREAL .
  390. end
  391. if RexSystemOpSys="BEOS" then
  392. RexSystemOpSys="UNIX"
  393. if RexSystemOpSys="TSO" then
  394. do
  395. call syscalls 'ON'
  396. RexSystemOpSys="UNIX"
  397. end
  398. RexSystmRexxPgmName=RexGetFullSourceName()
  399. if RexIsAscii='N' then
  400. do
  401. RexEOL='15'x
  402. end
  403. else
  404. do
  405. if RexSystemOpSys="UNIX" then
  406. RexEOL='0A'x
  407. else
  408. RexEOL='0D0A'x
  409. end
  410. if arg(2)<> '' then
  411. call RexSystemFailure 'ARG(2) contains unexpected data of ' || arg(2) || '.'
  412. if translate(strip(arg(1)))='DEBUG' then
  413. do
  414. call RexDumpSystemInfo
  415. exit(0)
  416. end
  417. if RexWhich='STANDARD_OS/2' then
  418. do
  419. call RxFuncAdd 'SysSleep',        'RexxUtil', 'SysSleep'
  420. call RxFuncAdd 'SysFileDelete',   'RexxUtil', 'SysFileDelete'
  421. call RxFuncAdd 'SysSearchPath',   'RexxUtil', 'SysSearchPath'
  422. call RxFuncAdd 'SysFileTree',     'RexxUtil', 'SysFileTree'
  423. call RxFuncAdd 'SysTempFileName', 'RexxUtil', 'SysTempFileName'
  424. call SetLocal
  425. RexEnvVarPool='OS2ENVIRONMENT'
  426. RexStdoutStream='STDOUT'
  427. RexStderrStream='STDERR'
  428. RexTmpFileCntr=random(90000)
  429. end
  430. else
  431. do
  432. OPTIONS 'NOEXT_COMMANDS_AS_FUNCS'
  433. numeric digits 11
  434. RexEnvVarPool='SYSTEM'
  435. RexStdoutStream='<stdout>'
  436. RexStderrStream='<stderr>'
  437. end
  438. if RexSystemOpSys<> "UNIX" then
  439. do
  440. RexDirChar='\'
  441. RexOptionChar='/'
  442. end
  443. else
  444. do
  445. RexDirChar='/'
  446. RexOptionChar='-'
  447. end
  448. signal REXSYSTM_1
  449.  
  450. RexDumpSystemInfo:
  451. say 'Program Name  : ' ||RexSystmRexxPgmName
  452. say 'Op System     : ' ||RexSystemOpSys
  453. say 'Rexx Ver      : ' ||RexVersionInfo
  454. say 'Which System  : ' ||RexWhich
  455. if RexWhich='REGINA' then
  456. say 'regina uname(): ' ||uname()
  457. return
  458.  
  459. RexNeedReginaWorkAround:
  460. if RexWhich='STANDARD_OS/2' then
  461. return('N')
  462. else
  463. return('Y')
  464.  
  465. RexGetFullSourceName:
  466. parse source . . TmpRexxSrc
  467. if RexWhich='REGINA' then
  468. TmpRexxSrc=FileQueryExists(strip(TmpRexxSrc))
  469. if RexSystemOpSysREAL="TSO" then
  470. do
  471. TmpRexxSrc=word(TmpRexxSrc,1)
  472. TmpRexxSrc=FileQueryExists(TmpRexxSrc)
  473. end
  474. if TmpRexxSrc='' then
  475. call RexSystemFailure 'Could not determine the name of the rexx program!'
  476. return(TmpRexxSrc)
  477.  
  478. RexGetNameOfTmpDir:call TRACE "OFF"
  479. TmpDir=strip(GetEnv('TMP'))
  480. if TmpDir='' then
  481. TmpDir=strip(GetEnv('TEMP'))
  482. if TmpDir='' then
  483. do
  484. if RexSystemOpSys="UNIX" then
  485. TmpDir='/tmp'
  486. end
  487. if right(TmpDir,1)==RexDirChar then
  488. TmpDir=left(TmpDir,length(TmpDir)-1)
  489. if RexWhich='REXX370' then
  490. do
  491. if TmpDir="SYSTEM" then
  492. TmpDir="TMP"
  493. end
  494. return(TmpDir)
  495.  
  496. RedirectStdOutAndErr2:
  497. if RedirMethod<> '' then
  498. do
  499. select
  500. when RedirMethod="@bash" then
  501. return(' >' || arg(1) || ' 2>&1')
  502. when RedirMethod="@csh" then
  503. return(' >& ' ||arg(1))
  504. otherwise
  505. do
  506. r12Meth=RedirMethod
  507. r12Pos=pos('{?}',r12Meth)
  508. do while r12Pos<>0
  509. r12Meth=left(r12Meth,r12Pos-1)||arg(1)||substr(r12Meth,r12Pos+3)
  510. r12Pos=pos('{?}',r12Meth)
  511. end
  512. end
  513. end
  514. return(' ' ||r12Meth)
  515. end
  516. if RexSystemOpSys="DOS" | RexSystemOpSysREAL = "WIN95" | RexSystemOpSysREAL = "WIN98" | RexSystemOpSysREAL = "WINME" then
  517. do
  518. return(' >' ||arg(1))
  519. end
  520. else
  521. do
  522. return(' >' || arg(1) || ' 2>&1')
  523. end
  524.  
  525. NameOfNulDevice:
  526. if RexSystemOpSys="UNIX" then
  527. return('/dev/null')
  528. else
  529. return('nul')
  530.  
  531. AllCmdOutput2Nul:
  532. return(RedirectStdOutAndErr2(NameOfNulDevice()))
  533.  
  534. AddressCmd:call TRACE "OFF"
  535. SysCmd2Exec=arg(1)
  536. if RexWhich='STANDARD_OS/2' then
  537. SysCmd2Exec='@' ||SysCmd2Exec
  538. call DebugAddressCmdBefore SysCmd2Exec
  539. SysCmd2Exec
  540. SysCmdRc=Rc
  541. FileIndex=2
  542. SysCmdFile=arg(FileIndex)
  543. do while SysCmdFile<> ''
  544. call DebugAddressCmdOutput SysCmdFile, 'H1'
  545. call DebugAddressCmdOutput copies('~', length(SysCmdFile)), 'H2'
  546. if FileQueryExists(SysCmdFile)='' then
  547. call DebugAddressCmdOutput '*File does not exist*',     '!'
  548. else
  549. do
  550. SysCmdLine=0
  551. call FileClose SysCmdFile
  552. do while lines(SysCmdFile)<>0
  553. SysCmdLine=SysCmdLine+1
  554. call DebugAddressCmdOutput linein(SysCmdFile),SysCmdLine
  555. end
  556. call FileClose SysCmdFile
  557. end
  558. FileIndex=FileIndex+1
  559. SysCmdFile=arg(FileIndex)
  560. end
  561. call DebugAddressCmdAfter SysCmdRc
  562. Rc=SysCmdRc
  563. return(SysCmdRc)
  564.  
  565. _filespec:call TRACE "OFF"
  566. fsCmd=translate(arg(1))
  567. select
  568. when fsCmd='D' | fsCmd = 'DRIVE' then
  569. do
  570. if RexSystemOpSys="UNIX" then
  571. return('')
  572. fsPos=pos(':',arg(2))
  573. if fsPos=0 then
  574. return('')
  575. else
  576. return(left(arg(2),fsPos))
  577. end
  578. when fsCmd='P' | fsCmd = 'PATH' then
  579. do
  580. fsStartWith=substr(arg(2),length(_filespec('D',arg(2)))+1)
  581. fsPos=lastpos(RexDirChar,fsStartWith)
  582. if fsPos=0 then
  583. return('')
  584. else
  585. return(left(fsStartWith,fsPos))
  586. end
  587. when fsCmd='N' | fsCmd = 'NAME' then
  588. do
  589. return(substr(arg(2),length(_filespec('L',arg(2)))+1))
  590. end
  591. when fsCmd='L' | fsCmd = 'LOCATION' then
  592. do
  593. return(_filespec('D', arg(2)) || _filespec('P',arg(2)))
  594. end
  595. when fsCmd='E' | fsCmd = 'EXTN' then
  596. do
  597. fsDotPos=lastpos('.',arg(2))
  598. if fsDotPos=0 then
  599. return('')
  600. else
  601. return(substr(arg(2),fsDotPos+1))
  602. end
  603. when fsCmd='W' | fsCmd = 'WITHOUTEXTN' then
  604. do
  605. fsDotPos=lastpos('.',arg(2))
  606. if fsDotPos=0 then
  607. return(arg(2))
  608. else
  609. return(left(arg(2),fsDotPos-1))
  610. end
  611. when fsCmd='B' | fsCmd = 'BASENAME' then
  612. do
  613. return(_filespec('W', _filespec('N',arg(2))))
  614. end
  615. otherwise
  616. call RexSystemFailure 'Unknown _filespec() command of "' || arg(1) || '"'
  617. end
  618. return
  619.  
  620. _SysSleep:call TRACE "OFF"
  621. if RexWhich='STANDARD_OS/2' then
  622. do
  623. call SysSleep arg(1)
  624. return
  625. end
  626. call sleep arg(1)
  627. return
  628.  
  629. _SysFileTree:call TRACE "OFF"
  630. a_Mask=arg(1)
  631. a_Stem=arg(2)
  632. if pos('D',arg(3))<>0 then
  633. a_Type='D'
  634. else
  635. a_Type='F'
  636. if RexWhich='STANDARD_OS/2' then
  637. do
  638. a_P3=a_Type|| 'O'
  639. if pos('S',arg(3))<>0 then
  640. a_P3=a_P3|| 'S'
  641. return(SysFileTree(a_Mask,a_Stem,a_P3))
  642. end
  643. a_TmpFile=RexGetTmpFileName()
  644. if RexSystemOpSys<> "UNIX" then
  645. do
  646. a_Cmd='dir /B '
  647. if pos('S',arg(3))<>0 then
  648. a_Cmd=a_Cmd|| "/S "
  649. if a_Type='F' then
  650. a_Cmd=a_Cmd|| "/A-D "
  651. else
  652. a_Cmd=a_Cmd|| "/AD "
  653. if RexSystemOpSys="DOS" then
  654. a_CmdMask=a_Mask
  655. else
  656. a_CmdMask='"' || a_Mask || '"'
  657. a_Cmd=a_Cmd||a_CmdMask||RedirectStdOutAndErr2(a_TmpFile)
  658. end
  659. else
  660. do
  661. a_Cmd='find ' || _filespec('L', a_Mask) || ' '
  662. if RexSystemOpSysREAL<> "FREEBSD" & RexSystemOpSysREAL <> "Darwin" & RexSystemOpSysREAL <> "TSO" then
  663. a_Cmd=a_Cmd|| '-noleaf '
  664. if pos('S',arg(3))=0 then
  665. do
  666. if RexSystemOpSysREAL<> "FREEBSD" & RexSystemOpSysREAL <> "Darwin" & RexSystemOpSysREAL <> "TSO" then
  667. a_Cmd=a_Cmd|| '-maxdepth 1 '
  668. else
  669. a_Cmd=a_Cmd|| '-prune '
  670. end
  671. if a_Type='F' then
  672. a_Cmd=a_Cmd|| "-type f "
  673. else
  674. a_Cmd=a_Cmd|| "-type d "
  675. stfSName=_filespec('N',a_Mask)
  676. if stfSName<> '' then
  677. a_Cmd=a_Cmd|| '-name "' || stfSName || '"'
  678. a_Cmd=a_Cmd||RedirectStdOutAndErr2(a_TmpFile)
  679. end
  680. Rc=AddressCmd(a_Cmd,a_TmpFile)
  681. LastSlash=lastpos(RexDirChar,a_Mask)
  682. call FileClose a_TmpFile
  683. a_FileCnt=0
  684. do while lines(a_TmpFile)<>0
  685. a_AFile=linein(a_TmpFile)
  686. if a_AFile='' | a_AFile = '.' | a_AFile = '..' then
  687. iterate
  688. if RexSystemOpSys="UNIX" & a_Type = 'D' then
  689. do
  690. if a_AFile=_filespec('L',a_Mask)then
  691. iterate
  692. end
  693. if LastSlash<>0 then
  694. do
  695. if pos(RexDirChar,a_AFile)==0 then
  696. a_AFile=left(a_Mask,LastSlash)||a_AFile
  697. end
  698. if a_Type='F' then
  699. do
  700. a_AFile=FileQueryExists(a_AFile)
  701. if a_AFile='' then
  702. iterate
  703. end
  704. else
  705. do
  706. if RexWhich='REGINA' then
  707. do
  708. if DirQueryExists(a_AFile)='' then
  709. iterate
  710. end
  711. else
  712. do
  713. if pos(' ',a_AFile)<>0 then
  714. iterate
  715. end
  716. end
  717. a_FileCnt=a_FileCnt+1
  718. call _valueS a_Stem|| '.' ||a_FileCnt,strip(a_AFile)
  719. end
  720. call FileClose a_TmpFile
  721. DeleteRc=_SysFileDelete(a_TmpFile)
  722. call _valueS a_Stem|| '.0',a_FileCnt
  723. return(0)
  724.  
  725. _SysFileDelete:call TRACE "OFF"
  726. if RexWhich='STANDARD_OS/2' then
  727. return(SysFileDelete(arg(1)))
  728. b_F=arg(1)
  729. if RexSystemOpSys<> "DOS" then
  730. b_F='"' || b_F || '"'
  731. if RexSystemOpSys="DOS" | RexSystemOpSysREAL = "WIN95" | RexSystemOpSysREAL = "WIN98" | RexSystemOpSysREAL = "WINME" then
  732. return(AddressCmd('if exist ' || b_F || ' del ' ||b_F||AllCmdOutput2Nul()))
  733. else
  734. do
  735. if RexSystemOpSys="UNIX" then
  736. return(AddressCmd('rm -f ' ||b_F||AllCmdOutput2Nul()))
  737. else
  738. return(AddressCmd('del ' ||b_F||AllCmdOutput2Nul()))
  739. end
  740.  
  741. RexGetTmpFileName:call TRACE "OFF"
  742. if arg(1)<> '' then
  743. TmpFileM=arg(1)
  744. else
  745. do
  746. if RexSystemOpSys<> "UNIX" then
  747. TmpFileM='RSTM????.TMP'
  748. else
  749. do
  750. TmpFileM=GetEnv('USER')
  751. if TmpFileM='' then
  752. TmpFileM=GetEnv('user')
  753. if TmpFileM='' then
  754. TmpFileM='?????.rstm'
  755. else
  756. TmpFileM=TmpFileM|| '_?????.rstm'
  757. end
  758. end
  759. TmpFileM=RexGetNameOfTmpDir()||RexDirChar||TmpFileM
  760. if RexWhich='STANDARD_OS/2' then
  761. do
  762. TmpFileF=SysTempFileName(TmpFileM)
  763. if TmpFileF='' then
  764. do
  765. RexTmpFileCntr=RexTmpFileCntr+1
  766. TmpFileF='C_' || right(RexTmpFileCntr, 6, '0') || '.TMP'
  767. end
  768. return(TmpFileF)
  769. end
  770. TmpRandom=right(time('S'),3)||random(99999)
  771. TmpRandomAdd=0
  772. do until FileQueryExists(TmpFileA)=''
  773. TmpRandomS=reverse(d2x(TmpRandom+TmpRandomAdd))
  774. TmpRandomAdd=TmpRandomAdd+1
  775. TmpFileA=TmpFileM
  776. TmpWhich=1
  777. QmPos=pos('?',TmpFileA)
  778. do while QmPos<>0
  779. TmpReplace=substr(TmpRandomS,TmpWhich,1)
  780. TmpWhich=TmpWhich+1
  781. if TmpReplace='' then
  782. TmpWhich=1
  783. else
  784. do
  785. TmpFileA=overlay(TmpReplace,TmpFileA,QmPos)
  786. QmPos=pos('?',TmpFileA)
  787. end
  788. end
  789. end
  790. return(TmpFileA)
  791.  
  792. GetEnv:call TRACE "OFF"
  793. if RexWhich<> 'REXX370' then
  794. rsGetEnv=value(arg(1),,RexEnvVarPool)
  795. else
  796. do
  797. rsGetEnv=''
  798. end
  799. if rsGetEnv=='' & arg(2) = 'Y' then
  800. call RexSystemFailure 'Could not find the environment variable "' || arg(1) || '"'
  801. call DebugGetEnv arg(1),rsGetEnv
  802. return(rsGetEnv)
  803.  
  804. SetEnv:call TRACE "OFF"
  805. if RexWhich<> 'REXX370' then
  806. return(value(arg(1),arg(2),RexEnvVarPool))
  807. else
  808. do
  809. return('')
  810. end
  811.  
  812. _valueS:call TRACE "OFF"
  813. if RexWhich='STANDARD_OS/2' then
  814. return(value(arg(1),arg(2)))
  815. return(value(translate(arg(1)),arg(2)))
  816.  
  817. _valueG:call TRACE "OFF"
  818. if RexWhich='STANDARD_OS/2' then
  819. return(value(arg(1)))
  820. return(value(arg(1)))
  821. /*
  822.  * DB$STUBS - Keep indent (not so easy for comments)
  823.  *            for this bit until finished!
  824.  */
  825.  
  826. DirGetCurrent:
  827.    return( directory() )
  828.  
  829. DirQueryExists:
  830.    if  arg(1) = '' then
  831.        return('')
  832.    select
  833.        when RexWhich =  'REGINA' then
  834.        do
  835.            return( stream(arg(1) || '\.', 'c', 'query exists') )
  836.        end
  837.        when RexWhich =  'STANDARD_OS/2' then
  838.        do
  839.            c_CDir = directory()
  840.            c_NewDir = directory(arg(1))
  841.            call directory c_CDir
  842.            return(c_NewDir)
  843.        end
  844.        when RexWhich =  'REXX370' then
  845.        do
  846.            /* DB$390 - return passed name (BAD! - ppwizard might fail in parts)
  847.             */
  848.            return(arg(1))
  849.        end
  850.        otherwise
  851.        do
  852.            return(arg(1))
  853.        end
  854.    end
  855.  
  856. FileQueryExists:
  857.    if  arg(1) = '' then
  858.        return('')
  859.    if  RexWhich <> 'REXX370' then
  860.        return( stream(arg(1), 'c', 'query exists') )
  861.    else
  862.    do
  863.        /* DB$390 - return passed name (BAD! - ppwizard might fail in parts)
  864.        */
  865.        return(arg(1))
  866.    end
  867.  
  868. FileQueryDateTime:
  869.    if  RexWhich <> 'REXX370' then
  870.        return( stream(arg(1), 'c', 'query datetime') )
  871.    else
  872.    do
  873.        /* DB$390 - Return valid but fixed value
  874.        */
  875.        return('01-01-01 12:00:00')
  876.    end
  877.  
  878. FileQuerySize:
  879.    if  RexWhich <> 'REXX370' then
  880.        return( stream(arg(1), 'c', 'query size') )
  881.    else
  882.    do
  883.        /* DB$390 - Return valid but fixed value
  884.        */
  885.        return('219')
  886.    end
  887.  
  888. FileOpenReadOnly:
  889.    if  RexWhich <> 'REXX370' then
  890.        return( stream(arg(1), 'c', 'open read') )
  891.    else
  892.    do
  893.        /* DB$390 - For now do nothing (so file opens read/write - so what)
  894.        */
  895.        return('')
  896.    end
  897.  
  898. FileClose:
  899.    if  RexWhich <> 'REXX370' then
  900.        return( stream(arg(1), 'c', 'close') )
  901.    else
  902.    do
  903.        /* DB$390 - Worth a try
  904.        */
  905.        call lineout arg(1)
  906.        return('')
  907.    end
  908.  
  909. FileState:
  910.    if  RexWhich <> 'REXX370' then
  911.        return( stream(arg(1), 'State') )
  912.    else
  913.    do
  914.        /* DB$390 - Stream Description
  915.        */
  916.        return('')
  917.    end
  918.  
  919. FileDescription:
  920.    if  RexWhich <> 'REXX370' then
  921.        return( stream(arg(1), 'Description') )
  922.    else
  923.    do
  924.        /* DB$390 - Stream Description
  925.        */
  926.        return('')
  927.    end
  928. /*
  929.    REXSYSTM.XH - a few stream there (need to move stubs there)
  930.    DirMake
  931.    FileCharin    ?
  932.    FileCharout   ?
  933.    FileLinein    ?
  934.    FileLineOut   ?
  935. */
  936.  
  937. REXSYSTM_1:
  938. PpWizardPgmName=RexSystmRexxPgmName
  939. PpWizardOpSysREAL=RexSystemOpSysREAL
  940. PpWizardOpSys=RexSystemOpSys
  941. WizName=translate(_filespec('name',PpWizardPgmName))
  942. TryQuoteListSd="'" || '"'
  943. TryQuoteListDs='"' || "'"
  944. TryQuoteListAny=TryQuoteListDs|| '^~!@#$%&*-+=?/\|`:;._'
  945. NullChar='00'x
  946. TabChar='09'x
  947. CrLf=RexEOL
  948. if RexIsAscii='N' then
  949. do
  950. MarksNewLine='15'x
  951. end
  952. else
  953. do
  954. MarksNewLine='0A'x
  955. TryQuoteListAny=TryQuoteListAny||xrange('DB'x, 'FE'x) || xrange('80'x, 'DA'x)
  956. end
  957. call InitConsoleOutputVarsPass2
  958. if RexSystemOpSys<> "UNIX" then
  959. call SetDebugChars '96,96,25',  'Y'
  960. else
  961. call SetDebugChars '34,-1,165', 'Y'
  962. numeric digits 14
  963. trace off
  964. if RexSystemOpSys="UNIX" then
  965. NewLineChars=MarksNewLine
  966. else
  967. NewLineChars=CrLf
  968. MarksNewLineInHashDefine='<{nl}>'
  969. MarksNewLineInHashDefine2=MarksNewLineInHashDefine||MarksNewLineInHashDefine
  970. Ignore=0
  971. LowerCase="abcdefghijklmnopqrstuvwxyz"
  972. UpperCase="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  973. DecimalDigits="0123456789"
  974. CharsLUN=LowerCase||UpperCase||DecimalDigits
  975. DebugOnStuffOutputted='N'
  976. WantedWarningRc=1
  977. NotEqualInC='!' || '='
  978. EofChar=d2c(26)
  979. RexxCmtStart='/' || '*'
  980. RexxCmtEnd='*' || '/'
  981. TagSvNewLine='<' || '?NewLine>'
  982. LastSystemCmd="none"
  983. LastSystemCmdFull="none"
  984. LastSystemRc=999
  985. signal System_2
  986.  
  987. ProcessSystem:
  988. Rest=PerformReplacementsInCmdsParameters(arg(1))
  989. Log2File=GetQuotedText(Rest, "Rest")
  990. LastSystemCmd=GetQuotedRest(Rest)
  991. select
  992. when RexSystemOpSys="OS/2" then
  993. CmdProc='CMD.EXE /c '
  994. otherwise
  995. CmdProc=''
  996. end
  997. LastSystemCmdFull=CmdProc||LastSystemCmd
  998. DeleteFileAfter='N'
  999. select
  1000. when translate(Log2File)='ASIS' then
  1001. Log2File=''
  1002. when Log2File='-' then
  1003. Log2File=NameOfNulDevice()
  1004. when Log2File='?' then
  1005. do
  1006. Log2File=RexGetTmpFileName()
  1007. DeleteFileAfter='Y'
  1008. end
  1009. otherwise
  1010. nop
  1011. end
  1012. if Log2File<> '' then
  1013. LastSystemCmdFull=LastSystemCmdFull||RedirectStdOutAndErr2(Log2File)
  1014. LastSystemRc=AddressCmd(LastSystemCmdFull,Log2File)
  1015. if DeleteFileAfter='Y' then
  1016. call _SysFileDelete(Log2File)
  1017. return(0)
  1018.  
  1019. System_2:
  1020. signal stack_3
  1021.  
  1022. StackInitForBuild:
  1023. STK_CNT=0
  1024. return
  1025.  
  1026. StackValidation:
  1027. call DBG "Validating the " || STK_CNT || " stack(s)"
  1028. call DBGIND+1
  1029. d_Invalid=0
  1030. do d_S=1 to STK_CNT
  1031. d_ID=STK.d_S
  1032. d_Desc=value(d_ID|| '_DESC')
  1033. call DBG 'Validating: ' ||d_Desc
  1034. d_Lvl=value(d_ID|| '.0')
  1035. call DBGIND+1
  1036. if d_Lvl=0 then
  1037. call DBG 'OK'
  1038. else
  1039. do
  1040. d_Invalid=d_Invalid+1
  1041. call DBG 'There are ' || d_Lvl || ' items still on the stack!'
  1042. d_T='STACK "' || d_Desc || '" has ' || d_Lvl || ' errors'
  1043. call Say ''
  1044. call Say d_T
  1045. call Say copies('~',length(d_T))
  1046. do d_Inv=1 to d_Lvl
  1047. call say 'Push #:' ||d_Inv
  1048. call say 'Locn  :' || value(d_ID || '_LOCN.' ||d_Inv)
  1049. call say 'Doing :' || value(d_ID || '_DOING.' ||d_Inv)
  1050. call say ''
  1051. end
  1052. end
  1053. call DBGIND-1
  1054. end
  1055. if d_Invalid<>0 then
  1056. CryAndDie('There are ' || d_Invalid || ' stacks with errors (details above).')
  1057. call DBGIND-1
  1058. return
  1059.  
  1060. StackPush:call TRACE "OFF"
  1061. parse arg e_Desc,e_What,e_Doing
  1062. e_ID='STK_' ||c2x(e_Desc)
  1063. if symbol(e_ID|| '.0') = 'VAR' then
  1064. e_L=value(e_ID|| '.0')+1
  1065. else
  1066. do
  1067. e_L=1
  1068. STK_CNT=STK_CNT+1
  1069. STK.STK_CNT=e_ID
  1070. call value e_ID|| '_DESC',e_Desc
  1071. end
  1072. call value e_ID|| '.0',e_L
  1073. call value e_ID|| '.' ||e_L,e_What
  1074. call value e_ID|| '_LOCN.' ||e_L,GetInputFileNameAndLine()
  1075. if e_Doing='' then
  1076. e_Doing=GetFileLineBeingProcessed()
  1077. call value e_ID|| '_DOING.' ||e_L,e_Doing
  1078. return
  1079.  
  1080. StackPop:call TRACE "OFF"
  1081. f_ID='STK_' ||c2x(arg(1))
  1082. if symbol(f_ID|| '.0') <> 'VAR' then
  1083. CryAndDie('Can''t pop the non-existant stack "' || arg(1) || '"')
  1084. f_L=value(f_ID|| '.0')
  1085. if f_L<=0 then
  1086. CryAndDie('Nothing to pop on the stack "' || arg(1) || '"')
  1087. call value f_ID|| '.0',f_L-1
  1088. return(value(f_ID|| '.' ||f_L))
  1089.  
  1090. ProcessPush:
  1091. g_R=PerformReplacementsInCmdsParameters(arg(1))
  1092. g_Typ=translate(GetQuotedText(g_R, "g_R"))
  1093. do until g_R=''
  1094. g_I=GetQuotedText(g_R, "g_R")
  1095. select
  1096. when g_Typ='MACRO' then
  1097. do
  1098. call StackPush '#Push MACRO',MacroGet(g_I)
  1099. end
  1100. when g_Typ='REXXVAR' then
  1101. do
  1102. call StackPush '#Push REXXVAR',_valueG(g_I)
  1103. end
  1104. otherwise
  1105. CryAndDie('Unsupported #PUSH type of ' ||g_Typ)
  1106. end
  1107. end
  1108. return(0)
  1109.  
  1110. ProcessPop:
  1111. h_R=PerformReplacementsInCmdsParameters(arg(1))
  1112. h_Typ=translate(GetQuotedText(h_R, "h_R"))
  1113. h_C=0
  1114. do until h_R=''
  1115. h_C=h_C+1
  1116. h_S.h_C=GetQuotedText(h_R, "h_R")
  1117. end
  1118. do h_I=h_C to 1 by-1
  1119. select
  1120. when h_Typ='MACRO' then
  1121. do
  1122. call MacroSet h_S.h_I,StackPop('#Push MACRO'), 'Y'
  1123. end
  1124. when h_Typ='REXXVAR' then
  1125. do
  1126. call _valueS h_S.h_I,StackPop('#Push REXXVAR')
  1127. end
  1128. otherwise
  1129. CryAndDie('Unsupported #POP type of ' ||h_Typ)
  1130. end
  1131. end
  1132. return(0)
  1133.  
  1134. stack_3:
  1135. call InitTransformationCode
  1136. signal Transfrm_4
  1137.  
  1138. InitTransformationCode:
  1139. TransformCode=''
  1140. return
  1141.  
  1142. ProcessTransform:
  1143. HashDefRexx=arg(1)
  1144. if HashDefRexx<> '' then
  1145. do
  1146. HashDefRexx=PerformReplacementsInCmdsParameters(HashDefRexx)
  1147. HashDefRexx=GetQuotedText(HashDefRexx)
  1148. end
  1149. if HashDefRexx<> '' then
  1150. do
  1151. if OptionDebugOn='Y' then
  1152. call DBG 'Start of transformation block "' || HashDefRexx || '"'
  1153. if TransformCode<> '' then
  1154. CryAndDie("Already in tranformation block started at " ||TransformStartLoc)
  1155. TransformStartLoc=CurrentSourceLocation()
  1156. TransformCode=MacroGet(HashDefRexx)
  1157. TransformCode=PerformReplacementsInCmdsParameters(TransformCode)
  1158. end
  1159. else
  1160. do
  1161. if OptionDebugOn='Y' then
  1162. call DBG "End of transformation block"
  1163. if TransformCode='' then
  1164. CryAndDie('We were not in a tranformation block!')
  1165. TransformCode=''
  1166. end
  1167. return(0)
  1168.  
  1169. Transfrm_4:
  1170. ReplaceCount=0
  1171. NextIdUnique=0
  1172. NextIdReplOn='N'
  1173. NextIdMarker='@' || '@'
  1174. NextIdMask='*_'
  1175. NextIdNewCounter=NextIdUnique
  1176. NextIdNew=_GetNextIdPrefix()
  1177. NextIdUsed='N'
  1178. NextIdLocked=''
  1179. signal NextId_5
  1180.  
  1181. ProcessNextId:
  1182. i_P=arg(1)
  1183. if i_P='' then
  1184. call _NextIdInc
  1185. else
  1186. do
  1187. i_P=PerformReplacementsInCmdsParameters(i_P)
  1188. i_Cmd=GetQuotedText(i_P, 'i_P')
  1189. i_CmdU=translate(i_Cmd)
  1190. select
  1191. when i_CmdU='OFF' then
  1192. NextIdReplOn='N'
  1193. when i_CmdU='ON' then
  1194. NextIdReplOn='Y'
  1195. when i_CmdU='LOCK' then
  1196. do
  1197. call _DieIfLocked i_Cmd
  1198. if i_P='' then
  1199. i_P='"?"'
  1200. NextIdLocked=GetQuotedRest(i_P)
  1201. if NextIdLocked='' then
  1202. CryAndDie('You must specify a KEY to lock Next ID incrementing.')
  1203. end
  1204. when i_CmdU='UNLOCK' then
  1205. do
  1206. if NextIdLocked='' then
  1207. CryAndDie('Not locked!')
  1208. if i_P='' then
  1209. i_P='"?"'
  1210. i_Key=GetQuotedRest(i_P)
  1211. if i_Key<>NextIdLocked then
  1212. CryAndDie('Incorrect key used, required "' || NextIdLocked || '"')
  1213. NextIdLocked=''
  1214. end
  1215. when i_CmdU='REPLACE' then
  1216. do
  1217. call _DieIfLocked i_Cmd
  1218. NextIdMarker=GetQuotedRest(i_P)
  1219. if NextIdMarker='' then
  1220. NextIdMarker='@' || '@'
  1221. end
  1222. when i_CmdU='MASK' then
  1223. do
  1224. call _DieIfLocked i_Cmd
  1225. NextIdMask=GetQuotedRest(i_P)
  1226. if NextIdMask='' then
  1227. NextIdMask='*_'
  1228. NextIdNew=_GetNextIdPrefix()
  1229. end
  1230. when i_CmdU='PUSH' then
  1231. do
  1232. i_Info=NextIdReplOn|| '00'x || NextIdMarker || '00'x || NextIdMask || '00'x || NextIdNew || '00'x || NextIdNewCounter || '00'x || NextIdUsed || '00'x||NextIdLocked
  1233. call StackPush "#NextId PUSH",i_Info
  1234. NextIdLocked=''
  1235. NextIdUsed='Y'
  1236. call _NextIdInc
  1237. NextIdReplOn='N'
  1238. end
  1239. when i_CmdU='POP' then
  1240. do
  1241. i_Info=StackPop("#NextId PUSH")
  1242. parse var i_Info NextIdReplOn '00'x NextIdMarker '00'x NextIdMask '00'x NextIdNew '00'x NextIdNewCounter '00'x NextIdUsed '00'x NextIdLocked
  1243. end
  1244. otherwise
  1245. CryAndDie('Unknown #NextID command of "' || i_Cmd || '"')
  1246. end
  1247. end
  1248. if OptionDebugOn='Y' then
  1249. do
  1250. if NextIdReplOn='N' then
  1251. i_T='off'
  1252. else
  1253. i_T='on'
  1254. i_I=NextIdLocked
  1255. if i_I='' then
  1256. i_I='unlocked'
  1257. else
  1258. i_I='locked (KEY = "' || NextIdLocked || '")'
  1259. call DBG '#NextID processing is turned ' ||i_T
  1260. call DBG '#NextID incrementing is ' ||i_I
  1261. call DBG 'If ON, any "' || NextIdMarker || '" strings will be replaced with "' || NextIdNew || '"'
  1262. end
  1263. return(0)
  1264.  
  1265. _NextIdInc:
  1266. call _DieIfLocked 'increment'
  1267. NextIdReplOn='Y'
  1268. if NextIdUsed='Y' then
  1269. do
  1270. NextIdUnique=NextIdUnique+1
  1271. NextIdNewCounter=NextIdUnique
  1272. NextIdNew=_GetNextIdPrefix()
  1273. end
  1274. return
  1275.  
  1276. _DieIfLocked:
  1277. if NextIdLocked<> '' then
  1278. CryAndDie('Operation (' || arg(1) || ') not allowed as #NextId ID is locked, KEY = "' || NextIdLocked || '"')
  1279. return
  1280.  
  1281. _GetNextIdPrefix:
  1282. j_Dec=NextIdNewCounter
  1283. j_Digits=LowerCase
  1284. j_Base=length(j_Digits)
  1285. j_P=''
  1286. do until j_Dec=0
  1287. j_P=substr(j_Digits,(j_Dec//j_Base)+1,1)||j_P
  1288. j_Dec=j_Dec%j_Base
  1289. end
  1290. j_P=ReplaceString(NextIdMask, '*',j_P)
  1291. NextIdUsed='N'
  1292. return(j_P)
  1293.  
  1294. NextId_5:
  1295. call InitINTERCEPTCode
  1296. signal Intercpt_6
  1297.  
  1298. InitINTERCEPTCode:
  1299. InterceptCode=''
  1300. InterceptStartLoc=''
  1301. InterceptOffMarker=''
  1302. return
  1303.  
  1304. ProcessIntercept:
  1305. RexxCode=arg(1)
  1306. if RexxCode<> '' then
  1307. do
  1308. RexxCode=PerformReplacementsInCmdsParameters(RexxCode)
  1309. RexxCode=GetQuotedText(RexxCode)
  1310. end
  1311. if RexxCode<> '' then
  1312. do
  1313. if OptionDebugOn='Y' then
  1314. call DBG 'Start of INTERCPT block "' || RexxCode || '"'
  1315. if InterceptCode<> '' then
  1316. CryAndDie("Already in tranformation block started at " ||InterceptStartLoc)
  1317. InterceptStartLoc=CurrentSourceLocation()
  1318. InterceptOffMarker=arg(2)
  1319. InterceptCode=MacroGet(RexxCode)
  1320. InterceptCode=PerformReplacementsInCmdsParameters(InterceptCode)
  1321. end
  1322. else
  1323. do
  1324. if OptionDebugOn='Y' then
  1325. call DBG "End of INTERCPT block"
  1326. if InterceptCode='' then
  1327. CryAndDie('We were not in a INTERCPT block!')
  1328. InterceptCode=''
  1329. end
  1330. return(0)
  1331.  
  1332. Intercpt_6:
  1333. OutputHoldLvl=0
  1334. call InitOutputHold
  1335. signal OutpHold_7
  1336.  
  1337. InitOutputHold:
  1338. HoldingOutput='N'
  1339. HeldOutput=''
  1340. OutpHoldStartLoc=''
  1341. return
  1342.  
  1343. OutputHoldPushAndClear:
  1344. OutputHoldLvl=OutputHoldLvl+1
  1345. OutHold_.OutputHoldLvl.!HoldingOutput=HoldingOutput
  1346. OutHold_.OutputHoldLvl.!HeldOutput=HeldOutput
  1347. OutHold_.OutputHoldLvl.!OutpHoldStartLoc=OutpHoldStartLoc
  1348. call InitOutputHold
  1349. return
  1350.  
  1351. OutputHoldPop:
  1352. HoldingOutput=OutHold_.OutputHoldLvl.!HoldingOutput
  1353. HeldOutput=OutHold_.OutputHoldLvl.!HeldOutput
  1354. OutpHoldStartLoc=OutHold_.OutputHoldLvl.!OutpHoldStartLoc
  1355. OutputHoldLvl=OutputHoldLvl-1
  1356. return
  1357.  
  1358. DieIfHoldingOutput:
  1359. if HoldingOutput='Y' then
  1360. CryAndDie('Missing #OutputHold (end)', 'Block started at ' ||OutpHoldStartLoc)
  1361. return
  1362.  
  1363. ProcessHashOutputHold:
  1364. OrexxRexx=arg(1)
  1365. if OrexxRexx='' then
  1366. do
  1367. if OptionDebugOn='Y' then
  1368. call DBG 'Start of hold output block'
  1369. if HoldingOutput='Y' then
  1370. CryAndDie("Already in hold output block started at " ||OutpHoldStartLoc)
  1371. call FlushQueuedOutput
  1372. HoldingOutput='Y'
  1373. OutpHoldStartLoc=CurrentSourceLocation()
  1374. end
  1375. else
  1376. do
  1377. if OptionDebugOn='Y' then
  1378. call DBG "End of hold output block - Held " || length(HeldOutput) || ' byte(s)'
  1379. if HoldingOutput='N' then
  1380. CryAndDie('We were not in a hold output block!')
  1381. call FlushQueuedOutput
  1382. OrexxRexx=PerformReplacementsInCmdsParameters(OrexxRexx)
  1383. OrexxRexx=GetQuotedText(OrexxRexx)
  1384. if translate(OrexxRexx)='DROP' then
  1385. HeldOutput=''
  1386. else
  1387. do
  1388. OutputModCode=MacroGet(OrexxRexx)
  1389. OutputModCode=PerformReplacementsInCmdsParameters(OutputModCode)
  1390. call ExecRexxCmd OutputModCode
  1391. end
  1392. if HeldOutput\=='' then
  1393. do
  1394. if OptionDebugOn='Y' then
  1395. call DBG 'Writing ' || length(HeldOutput) || ' byte(s) to output'
  1396. call DirectToOutputFile HeldOutput
  1397. end
  1398. call InitOutputHold
  1399. end
  1400. return(0)
  1401.  
  1402. OutpHold_7:
  1403. signal RexxHook_8
  1404.  
  1405. RexxHookSetBuildingParms:
  1406. parse arg HookBuildParmInput,HookBuildParmOutput,HookBuildParmTemplate
  1407. return
  1408.  
  1409. RexxHookInit:
  1410. RexxHookBefore=''
  1411. RexxHookAfter=''
  1412. RexxHookWarning=''
  1413. RexxHookError=''
  1414. RexxHookGetFileList=''
  1415. call RexxHookSetBuildingParms
  1416. return
  1417.  
  1418. RexxHookSet:
  1419. parse arg ThisCmd,ThisCmdOptions
  1420. parse var ThisCmdOptions rhWhen';'rhCmd
  1421. rhWhen=translate(rhWhen)
  1422. do until rhWhen=''
  1423. parse var rhWhen rhWhen1','rhWhen
  1424. rhDone='N'
  1425. if rhWhen1='' | abbrev("BEFORE",rhWhen1)then
  1426. do
  1427. rhDone='Y'
  1428. RexxHookBefore=rhCmd
  1429. end
  1430. if rhWhen1='' | abbrev("AFTER",rhWhen1)then
  1431. do
  1432. rhDone='Y'
  1433. RexxHookAfter=rhCmd
  1434. end
  1435. if rhWhen1='' | abbrev("WARNING",rhWhen1)then
  1436. do
  1437. rhDone='Y'
  1438. RexxHookWarning=rhCmd
  1439. end
  1440. if rhWhen1='' | abbrev("ERROR",rhWhen1)then
  1441. do
  1442. rhDone='Y'
  1443. RexxHookError=rhCmd
  1444. end
  1445. if rhWhen1='' | abbrev("GETFILELIST",rhWhen1)then
  1446. do
  1447. rhDone='Y'
  1448. RexxHookGetFileList=rhCmd
  1449. end
  1450. if rhDone='N' then
  1451. CryAndDie('The hook type of "' || rhWhen1 || '" is unknown')
  1452. end
  1453. return
  1454.  
  1455. CallHook:
  1456. parse arg CallHook,CallHookOkParmsOk,Parm1,Parm2,Parm3,Parm4
  1457. BuildDetailParms=', HookBuildParmInput, HookBuildParmOutput, HookBuildParmTemplate'
  1458. HookSpecificParms=', Parm1, Parm2, Parm3, Parm4'
  1459. select
  1460. when CallHook="WARNING" then
  1461. HookRexxCmd=RexxHookWarning
  1462. when CallHook="BEFORE" then
  1463. HookRexxCmd=RexxHookBefore
  1464. when CallHook="AFTER" then
  1465. HookRexxCmd=RexxHookAfter
  1466. when CallHook="ERROR" then
  1467. do
  1468. ErrorHookCount=ErrorHookCount+1
  1469. if ErrorHookCount>1 then
  1470. return
  1471. HookRexxCmd=RexxHookError
  1472. end
  1473. when CallHook="GETFILELIST" then
  1474. do
  1475. HookRexxCmd=RexxHookGetFileList
  1476. BuildDetailParms=''
  1477. end
  1478. end
  1479. SrcLineLoc=CurrentSourceLocation('')
  1480. if OptionDebugOn='Y' then
  1481. do
  1482. call DBG 'Calling hook: ' || CallHook || ' - ' ||HookRexxCmd
  1483. call DBGIND 1
  1484. end
  1485. HookCmd='HookRc =  "' || HookRexxCmd || '"("00.050", SrcLineLoc, "' || CallHook || '"' || BuildDetailParms || HookSpecificParms || ')'
  1486. HookRc='?'
  1487. signal ON SYNTAX NAME SyntaxErrorInHook
  1488. Interpret HookCmd
  1489. if OptionDebugOn='Y' then
  1490. call DBG 'Rc = ' ||HookRc
  1491. if abbrev(HookRc, 'OK:')=0 then
  1492. do
  1493. call DumpVarsInExpression HookCmd,, 'HOOK VARIABLES', 'Line1'
  1494. CryAndDie('Hook Command Failed: ' || HookCmd, "Hook's Return Code : " ||HookRc)
  1495. end
  1496. OkParms=substr(HookRc,4)
  1497. if OkParms<> '' & CallHookOkParmsOk <> 'Y' then
  1498. CryAndDie('OK parameters not allowed on "' || CallHook || '" hooks.')
  1499. if OptionDebugOn='Y' then
  1500. call DBGIND-1
  1501. return(OkParms)
  1502.  
  1503. SyntaxErrorInHook:
  1504. CryAndDie('Hook Cmd Failed: ' ||HookCmd)
  1505.  
  1506. RexxHook_8:
  1507. WarningSpecs=''
  1508. signal Warning_9
  1509.  
  1510. OutputWarningToScreen:
  1511. WarningPrefix=strip( 'WARNING ' ||strip(arg(1)))
  1512. WarningTextP=arg(2)
  1513. if IncludeLevel=0 then
  1514. LineText=''
  1515. else
  1516. LineText='(@' || AddCommasToDecimalNumber(IncludeLineNumber) || ')'
  1517. WarningTextUn=WarningPrefix|| ': ' ||WarningTextP
  1518. WarningText=LineText||WarningTextUn
  1519. WarningTextU=translate(WarningText)
  1520. IgnoreList=WarningSpecs
  1521. do while IgnoreList<> ''
  1522. parse var IgnoreList IgnoreThis (PathDelimiterChar) IgnoreList
  1523. IgnoreThis1=left(IgnoreThis,1)
  1524. IgnoreThisR=substr(IgnoreThis,2)
  1525. if IgnoreThis1<> '-' & IgnoreThis1 <> '+' & IgnoreThis1 <> '!' then
  1526. do
  1527. IgnoreThis1='-'
  1528. IgnoreThisR=IgnoreThis
  1529. IgnoreThis=IgnoreThis1||IgnoreThisR
  1530. end
  1531. if IgnoreThisR='' then
  1532. iterate
  1533. if IgnoreThisR='*' |pos(IgnoreThisR,WarningTextU)<>0 then
  1534. do
  1535. if OptionDebugOn='Y' then
  1536. call DBG 'Warning matched the spec => ' ||IgnoreThis
  1537. select
  1538. when IgnoreThis1='!' then
  1539. do
  1540. if OptionDebugOn='Y' then
  1541. call DBG 'Normal Warning => ' ||WarningText
  1542. leave
  1543. end
  1544. when IgnoreThis1='+' then
  1545. do
  1546. CryAndDie(WarningTextUn,, 'This warning was promoted to a fatal error by "' || IgnoreThis || '"')
  1547. end
  1548. when IgnoreThis1='-' then
  1549. do
  1550. if OptionDebugOn='Y' then
  1551. call DBG 'Ignoring Warning => ' ||WarningText
  1552. return
  1553. end
  1554. end
  1555. end
  1556. end
  1557. if RexxHookWarning<> '' then
  1558. do
  1559. WarnHookRc=translate(CallHook("WARNING", 'Y',WarningTextP))
  1560. if WarnHookRc='IGNORE+' then
  1561. Warnings=Warnings+1
  1562. if WarnHookRc='IGNORE' | WarnHookRc = 'IGNORE+' then
  1563. do
  1564. if OptionDebugOn='Y' then
  1565. call DBG "HOOK said to drop warning: " ||WarningTextP
  1566. return
  1567. end
  1568. if WarnHookRc<> '' then
  1569. CryAndDie('Unknown warning hook return code of: ' ||WarnHookRc)
  1570. end
  1571. call Line1 copies("  ", IncludeLevel) || WarningColor || '   ' ||WarningText||Reset
  1572. Warnings=Warnings+1
  1573. return
  1574.  
  1575. WarnAboutDepreciatedFeature:
  1576. call OutputWarningToScreen 'DEP0', 'Replace OBSOLETE Feature ASAP -> ' ||arg(1)
  1577. return
  1578.  
  1579. ProcessHashWarning:
  1580. Rest=PerformReplacementsInCmdsParameters(arg(1))
  1581. WarningCde=GetQuotedText(Rest, "Rest")
  1582. WarningMsg=GetQuotedRest(Rest)
  1583. call OutputWarningToScreen WarningCde,WarningMsg
  1584. return(0)
  1585.  
  1586. WARNINGS_DEBUG:
  1587. if OptionDebugOn='Y' then
  1588. call OptionDebugShow 'WARNINGS', 'Ignoring any warnings containing "' || WarningSpecs || '"'
  1589. return
  1590.  
  1591. WARNINGS_SET:
  1592. Tags=arg(1)
  1593. if ProcessedCmdLine='N' then
  1594. do
  1595. call OptionDebugShow 'WARNINGS', 'Setting default ignore warnings to "' || Tags || '"'
  1596. Default4_WarningSpecs=Tags
  1597. return(0)
  1598. end
  1599. if Tags=='' then
  1600. Tags=Default4_WarningSpecs
  1601. if translate(Tags)=='NULL' then
  1602. Tags=''
  1603. WarningSpecs=Tags
  1604. call WARNINGS_DEBUG
  1605. return
  1606.  
  1607. WARNINGS_GET:
  1608. call WARNINGS_DEBUG
  1609. return(WarningSpecs)
  1610.  
  1611. Warning_9:
  1612. signal Tabs_10
  1613.  
  1614. TABS_DEBUG:
  1615. if OptionDebugOn='Y' then
  1616. call OptionDebugShow 'TABS', 'TABS is set to "' || OptionTabsString || '" (' || TabsMode || ')'
  1617. return
  1618.  
  1619. TABS_SET:
  1620. OptionTabsString=translate(arg(1))
  1621. if ProcessedCmdLine='N' then
  1622. do
  1623. call OptionDebugShow 'TABS', 'Setting default TABS to "' || OptionTabsString || '"'
  1624. DefaultTabsString=OptionTabsString
  1625. return(0)
  1626. end
  1627. if OptionTabsString=='' then
  1628. OptionTabsString=DefaultTabsString
  1629. WidthOfTab=0
  1630. OptionTabs=left(OptionTabsString,1)
  1631. select
  1632. when datatype(OptionTabsString, 'W')then
  1633. do
  1634. OptionTabs='E'
  1635. WidthOfTab=OptionTabsString
  1636. TabsMode='expanding tabs, fixed tab stop every ' || WidthOfTab || ' characters'
  1637. end
  1638. when OptionTabsString='WARNINGS' then
  1639. TabsMode='display warnings'
  1640. when OptionTabsString='IGNORE' then
  1641. TabsMode='ignore tabs, leave in place'
  1642. when OptionTabsString='TOSPACES' then
  1643. TabsMode='converting each tab to one space'
  1644. otherwise
  1645. CryAndDie('Invalid TABS option of "' || OptionTabsString || '"')
  1646. end
  1647. call TABS_DEBUG
  1648. return
  1649.  
  1650. TABS_GET:
  1651. call TABS_DEBUG
  1652. return(OptionTabsString)
  1653.  
  1654. Tabs_10:
  1655. SrTypePre=d2c(254)||d2c(174)
  1656. SrTypeSuf=d2c(175)
  1657. call SrInit
  1658. signal SR_TYPE_11
  1659.  
  1660. SrInit:
  1661. SrCaseIns=SrTypePre|| 'CI' ||SrTypeSuf
  1662. SrCaseIns_P=length(SrCaseIns)+1
  1663. SrFixed=SrTypePre|| 'FiX' ||SrTypeSuf
  1664. SrFixed_P=length(SrFixed)+1
  1665. return
  1666.  
  1667. CompareReplaceFixed:call TRACE "OFF"
  1668.  
  1669. CompareReplaceFixed2:
  1670. sr_FromOrig=arg(1)
  1671. sr_SSpec=arg(2)
  1672. sr_CaseInSens='N'
  1673. sr_From=sr_FromOrig
  1674. sr_From_L=length(sr_From)
  1675. if arg(3, 'E')=1 then
  1676. sr_NoMatch=sr_From
  1677. else
  1678. sr_NoMatch=0
  1679. do while sr_SSpec<> ''
  1680. parse var sr_SSpec sr_CmdChar +1 sr_SSpec
  1681. select
  1682. when sr_CmdChar='@' then
  1683. do
  1684. parse var sr_SSpec sr_Operator ',' sr_Posn '=' +1 sr_Delim +1 sr_CompWith (sr_Delim) sr_SSpec
  1685. sr_Length=length(sr_CompWith)
  1686. if datatype(sr_Posn, 'W')=0 then
  1687. CryAndDie("CompareReplaceFixed()", "The position must be a whole number, '" || sr_Posn || "' is invalid")
  1688. if sr_Posn<0 then
  1689. do
  1690. sr_Posn=sr_From_L+sr_Posn+1
  1691. if sr_Posn<1 then
  1692. return(sr_NoMatch)
  1693. end
  1694. if sr_CaseInSens='N' then
  1695. sr_bit=substr(sr_From,sr_Posn,sr_Length)
  1696. else
  1697. sr_bit=translate(substr(sr_From,sr_Posn,sr_Length))
  1698. select
  1699. when sr_Operator='=' then
  1700. srCompRc=sr_bit=sr_CompWith
  1701. when sr_Operator='<>' then
  1702. srCompRc=sr_bit<>sr_CompWith
  1703. when sr_Operator='==' then
  1704. srCompRc=sr_bit==sr_CompWith
  1705. when sr_Operator='\==' then
  1706. srCompRc=sr_bit\==sr_CompWith
  1707. when sr_Operator='<' then
  1708. srCompRc=sr_bit<sr_CompWith
  1709. when sr_Operator='>' then
  1710. srCompRc=sr_bit>sr_CompWith
  1711. when sr_Operator='<=' then
  1712. srCompRc=sr_bit<=sr_CompWith
  1713. when sr_Operator='>=' then
  1714. srCompRc=sr_bit>=sr_CompWith
  1715. otherwise
  1716. CryAndDie("CompareReplaceFixed()", "Unsupported operator of '" || sr_Operator || "' used", '', 'ONLY "=, <>, ==, \==, <, >, <=, >=" are supported!')
  1717. end
  1718. if srCompRc=0 then
  1719. return(sr_NoMatch)
  1720. end
  1721. when sr_CmdChar='!' then
  1722. do
  1723. parse var sr_SSpec sr_CmdChar2 +1 sr_SSpec
  1724. select
  1725. when sr_CmdChar2='B' | sr_CmdChar2 = 'L' | sr_CmdChar2 = 'T' then
  1726. do
  1727. sr_From=strip(sr_From,sr_CmdChar2)
  1728. sr_From_L=length(sr_From)
  1729. end
  1730. when sr_CmdChar2='I' then
  1731. do
  1732. sr_From=space(sr_From)
  1733. sr_From_L=length(sr_From)
  1734. end
  1735. when sr_CmdChar2='S' then
  1736. sr_CaseInSens='N'
  1737. when sr_CmdChar2='i' then
  1738. sr_CaseInSens='Y'
  1739. otherwise
  1740. CryAndDie("CompareReplaceFixed()", 'Invalid "!" command of "' || sr_CmdChar2 || '"')
  1741. end
  1742. end
  1743. when sr_CmdChar='?' then
  1744. do
  1745. parse var sr_SSpec sr_Operator +1 sr_Delim +1 sr_LookFor (sr_Delim) sr_SSpec
  1746. if sr_CaseInSens='N' then
  1747. sr_Pos=pos(sr_LookFor,sr_From)
  1748. else
  1749. sr_Pos=pos(sr_LookFor,translate(sr_From))
  1750. if sr_Operator='=' then
  1751. do
  1752. if sr_Pos=0 then
  1753. return(sr_NoMatch)
  1754. end
  1755. else
  1756. do
  1757. if sr_Pos<>0 then
  1758. return(sr_NoMatch)
  1759. end
  1760. end
  1761. otherwise
  1762. CryAndDie("CompareReplaceFixed()", 'Invalid compare command of "' || sr_CmdChar || '"')
  1763. end
  1764. end
  1765. if arg(3, 'O')=1 then
  1766. return(1)
  1767. sr_RSpec=arg(3)
  1768. ReplaceCount=ReplaceCount+1
  1769. sr_From=sr_FromOrig
  1770. sr_From_L=length(sr_From)
  1771. sr_output=''
  1772. do forever
  1773. parse var sr_RSpec sr_Before '@' sr_RSpec
  1774. sr_Output = sr_Output || sr_Before
  1775. if sr_RSpec=='' then
  1776. return(sr_Output)
  1777. parse var sr_RSpec sr_CmdChar +1 sr_RSpec
  1778. select
  1779. when sr_CmdChar='$' then
  1780. do
  1781. parse var sr_RSpec sr_Posn ',' sr_Length ';' sr_RSpec
  1782. if sr_Posn<0 then
  1783. do
  1784. sr_Posn=sr_From_L+sr_Posn+1
  1785. if sr_Posn<1 then
  1786. return(sr_From)
  1787. end
  1788. if sr_Length='*' then
  1789. sr_Output=sr_Output||substr(sr_From,sr_Posn)
  1790. else
  1791. sr_Output=sr_Output||substr(sr_From,sr_Posn,sr_Length)
  1792. end
  1793. when sr_CmdChar='=' then
  1794. do
  1795. parse var sr_RSpec sr_Delim +1 sr_Exec (sr_Delim) sr_RSpec
  1796. CompareString=sr_From
  1797. call ExecRexxCmd('sr_Output = sr_Output || ' ||sr_Exec)
  1798. end
  1799. when sr_CmdChar='@' then
  1800. sr_Output=sr_Output|| '@'
  1801. otherwise
  1802. CryAndDie("CompareReplaceFixed()", 'Invalid replace command of "' || sr_CmdChar || '"')
  1803. end
  1804. end
  1805.  
  1806. SR_TYPE_11:
  1807. SpellDelChars=d2c(9)|| ',.=:;<>&-%()!/~' || '?#${}[]"'
  1808. SpellDictFileCount=0
  1809. SpellDelChangeCount=0
  1810. SpellingPrompts='N'
  1811. SpellShowEachError='N'
  1812. SpellingAddFile=''
  1813. SpellWordCount=0
  1814. SpellMistakeCount=0
  1815. SpellingAddCount=0
  1816. BadlySpellWordCount=0
  1817. CheckSpelling='N';
  1818. signal SPELLING_12
  1819.  
  1820. PrepareSpellingForThisBuild:
  1821. if OptionCompleteAddToToDepFile='Y' then
  1822. do
  1823. do DictIndex=1 to SpellDictFileCount
  1824. call AddInputFileToDependancyList SpellDictFile.DictIndex,SpellDictTime.DictIndex
  1825. end
  1826. end
  1827. Drop ?BADWORDEB.
  1828. return
  1829.  
  1830. LoadSpellingDictionary:
  1831. DictFileS=arg(1)
  1832. call DBG_SPELLING 'User wants the dictionary "' || DictFileS || '"'
  1833. DictFile=FindFile(DictFileS)
  1834. if DictFile='' then
  1835. CryAndDie('The dictionary file "' || DictFileS || '" does not exist!')
  1836. call DBG_SPELLING 'Loading "' || DictFile || '"'
  1837. SpellDictFileCount=SpellDictFileCount+1
  1838. SpellDictFile.SpellDictFileCount=DictFile
  1839. SpellDictTime.SpellDictFileCount=GetFileDateTimeButDontWarnOnError(DictFile)
  1840. call FileClose DictFile
  1841. do while lines(DictFile)<>0
  1842. ThisWord=translate(strip(linein(DictFile)))
  1843. if ThisWord='' then
  1844. iterate
  1845. if left(ThisWord,1)=';' then
  1846. iterate
  1847. if left(ThisWord,1)<> '$' then
  1848. do
  1849. SpellWordCount=SpellWordCount+1
  1850. call _valueS '?SPELLDICT.?' || c2x(ThisWord), ''
  1851. end
  1852. else
  1853. do
  1854. parse var ThisWord DictCmd Rest
  1855. select
  1856. when DictCmd='$MISTAKE' then
  1857. do
  1858. parse var Rest SpeltWrong SpeltCorrectly .
  1859. SpellMistakeCount=SpellMistakeCount+1
  1860. call _valueS '?SPELLERR.?' ||c2x(SpeltWrong),SpeltCorrectly
  1861. end
  1862. when DictCmd='$DELIMITERS' then
  1863. do
  1864. call DBG_SPELLING 'Dictionary is changing spelling delimiters'
  1865. SpellDelChangeCount=SpellDelChangeCount+1
  1866. if SpellDelChangeCount>1 then
  1867. call OutputWarningToScreen 'SPL9', 'Spell check delimiters already modified!'
  1868. call ExecRexxCmd "SpellDelChars = " ||strip(Rest)
  1869. end
  1870. otherwise
  1871. do
  1872. SpellWordCount=SpellWordCount+1
  1873. call _valueS '?SPELLDICT.?' || c2x(ThisWord), ''
  1874. end
  1875. end
  1876. end
  1877. end
  1878. call FileClose DictFile
  1879. call DBG_SPELLING 'Now have ' || AddCommasToDecimalNumber(SpellWordCount) || ' word(s) in dictionary and ' || AddCommasToDecimalNumber(SpellMistakeCount) || ' common mistakes noted!'
  1880. CheckSpelling='Y';
  1881. return
  1882.  
  1883. SpellCheckOneLine:
  1884. SpellLine=space(arg(1))
  1885. if 1=1 then
  1886. do
  1887. RightBit=SpellLine
  1888. SpellLine=''
  1889. StartPos=pos('<',RightBit)
  1890. do while StartPos<>0
  1891. EndPos=pos('>',RightBit,StartPos+1)
  1892. if EndPos=0 then
  1893. EndPos=StartPos
  1894. SpellLine=SpellLine||left(RightBit,StartPos-1)|| ' '
  1895. RightBit=substr(RightBit,EndPos+1)
  1896. StartPos=pos('<',RightBit)
  1897. end
  1898. SpellLine=SpellLine||RightBit
  1899. if SpellLine='' then
  1900. return
  1901. end
  1902. SpellLine=translate(translate(SpellLine), '', SpellDelChars, ' ')
  1903. do WordIndex=1 to words(SpellLine)
  1904. ThisWord=Word(SpellLine,WordIndex)
  1905. if left(ThisWord,1)="'" then
  1906. ThisWord=substr(ThisWord,2)
  1907. if right(ThisWord,1)="'" then
  1908. ThisWord=left(ThisWord,length(ThisWord)-1)
  1909. if length(ThisWord)>100 then
  1910. do
  1911. if OptionDebugOn='Y' then
  1912. call DBG_SPELLING 'Word too big to safely handle "' || ThisWord || '"'
  1913. iterate
  1914. end
  1915. ThisWordC2X=c2x(ThisWord)
  1916. if SpellMistakeCount<>0 then
  1917. do
  1918. MistakeId='?SPELLERR.?' ||ThisWordC2X
  1919. if symbol(MistakeId)='VAR' then
  1920. do
  1921. if SpellShowEachError='Y' then
  1922. ShowThisError='Y'
  1923. else
  1924. do
  1925. DuplicatedId='?BADWORDEB.?' ||ThisWordC2X
  1926. if symbol(DuplicatedId)='VAR' then
  1927. ShowThisError='N'
  1928. else
  1929. do
  1930. ShowThisError='Y'
  1931. call _valueS DuplicatedId, ''
  1932. end
  1933. end
  1934. if ShowThisError='Y' then
  1935. do
  1936. CorrectWord=_valueG(MistakeId)
  1937. if CorrectWord='' then
  1938. call OutputWarningToScreen 'SPL0', 'Common Mistake: ' ||ThisWord
  1939. else
  1940. call OutputWarningToScreen 'SPL0', 'Common Mistake: ' || ThisWord || ' (use "' || CorrectWord || '" instead)'
  1941. end
  1942. iterate
  1943. end
  1944. end
  1945. if SpellWordCount=0&SpellingPrompts='N' then
  1946. iterate
  1947. ValidId='?SPELLDICT.?' ||ThisWordC2X
  1948. if symbol(ValidId)<> 'VAR' then
  1949. do
  1950. if datatype(ThisWord)<> 'NUM' then
  1951. do
  1952. WordWarningId=''
  1953. WordWarningMsg=''
  1954. if SpellingPrompts<> 'N' then
  1955. do
  1956. DuplicatedId='?BADWORDPI.?' ||ThisWordC2X
  1957. if symbol(DuplicatedId)='VAR' then
  1958. do
  1959. BadIndex=_valueG(DuplicatedId)
  1960. if BadIndex<> '' then
  1961. do
  1962. WordWarningId='SPL1'
  1963. WordWarningMsg='Added "' || ThisWord || '" to "' || SpellingAddFile || '"'
  1964. SpellingAddOccurs.BadIndex=SpellingAddOccurs.BadIndex+1
  1965. end
  1966. end
  1967. else
  1968. do
  1969. DuplicatedIdValue=''
  1970. if SpellingAddFile<> '' & SpellingPrompts <> 'N' then
  1971. do
  1972. if SpellingPrompts='OK' then
  1973. UserResp='Y'
  1974. else
  1975. do
  1976. do until UserResp='Y' | UserResp = 'N' | UserResp = 'Q' | UserResp = 'A'
  1977. call charout,ThisWord|| ' <- OK (Yes/yes All/No/Quit asking)?'
  1978. UserResp=translate(left(linein(),1))
  1979. end
  1980. end
  1981. if UserResp='A' then
  1982. do
  1983. SpellingPrompts='OK'
  1984. UserResp='Y'
  1985. end
  1986. if UserResp='Y' then
  1987. do
  1988. SpellingAddCount=SpellingAddCount+1
  1989. DuplicatedIdValue=SpellingAddCount
  1990. SpellingAddWord.SpellingAddCount=ThisWord
  1991. SpellingAddOccurs.SpellingAddCount=1
  1992. if SpellingPrompts='OK' then
  1993. do
  1994. WordWarningId='SPL1'
  1995. WordWarningMsg='Added "' || ThisWord || '" to "' || SpellingAddFile || '"'
  1996. end
  1997. end
  1998. else
  1999. do
  2000. if UserResp='Q' then
  2001. SpellingPrompts='N'
  2002. end
  2003. end
  2004. BadlySpellWordCount=BadlySpellWordCount+1
  2005. call _valueS DuplicatedId,DuplicatedIdValue
  2006. end
  2007. end
  2008. if SpellShowEachError='Y' then
  2009. ShowThisError='Y'
  2010. else
  2011. do
  2012. DuplicatedId='?BADWORDEB.?' ||ThisWordC2X
  2013. if symbol(DuplicatedId)='VAR' then
  2014. ShowThisError='N'
  2015. else
  2016. do
  2017. ShowThisError='Y'
  2018. call _valueS DuplicatedId, ''
  2019. end
  2020. end
  2021. if ShowThisError='Y' then
  2022. do
  2023. if WordWarningId='' then
  2024. do
  2025. WordWarningId='SPL1'
  2026. WordWarningMsg='Spelling? : ' ||ThisWord
  2027. end
  2028. call OutputWarningToScreen WordWarningId,WordWarningMsg
  2029. end
  2030. end
  2031. end
  2032. end
  2033. return
  2034.  
  2035. OutputAnySpellingAdditions:
  2036. if SpellingAddCount=0 then
  2037. return
  2038. call DBG_SPELLING 'Adding spelling words to file "' || SpellingAddFile || '"'
  2039. call DBGIND 1
  2040. if MacroExists("PPWIZARD_DONT_SORT_ADD_WORDS") = 'N' then
  2041. do
  2042. call DBG_SPELLING 'Sorting ' || SpellingAddCount || ' "bad" word(s) by number of occurences!'
  2043. SpellingAddWord.0=SpellingAddCount
  2044. SpellingAddOccurs.0=SpellingAddCount
  2045. SrtM=1
  2046. SrtCount=SpellingAddOccurs.0
  2047. do while(9*SrtM+4)<SrtCount
  2048. SrtM=SrtM*3+1
  2049. end
  2050. do while SrtM>0
  2051. SrtK=SrtCount-SrtM
  2052. do SrtJ=1 to SrtK
  2053. SrtIndex1=SrtJ
  2054. do while SrtIndex1>0
  2055. SrtIndex2=SrtIndex1+SrtM
  2056. SrtGreater=SpellingAddOccurs.SrtIndex1>SpellingAddOccurs.SrtIndex2
  2057. if SrtGreater then
  2058. do
  2059. SrtTemp=SpellingAddOccurs.SrtIndex1;SpellingAddOccurs.SrtIndex1=SpellingAddOccurs.SrtIndex2;SpellingAddOccurs.SrtIndex2=SrtTemp;SrtTemp=SpellingAddWord.SrtIndex1;SpellingAddWord.SrtIndex1=SpellingAddWord.SrtIndex2;SpellingAddWord.SrtIndex2=SrtTemp
  2060. end
  2061. else
  2062. leave
  2063. SrtIndex1=SrtIndex1-SrtM
  2064. end
  2065. end
  2066. SrtM=SrtM%3
  2067. end
  2068. call ArrayReverse "SpellingAddWord"
  2069. call ArrayReverse "SpellingAddOccurs"
  2070. end
  2071. call FileClose SpellingAddFile
  2072. if QueryExists(SpellingAddFile)<> "" then
  2073. do
  2074. call DBG_SPELLING 'Deleting existing "' || SpellingAddFile || '"'
  2075. call MustDeleteFile SpellingAddFile
  2076. end
  2077. call DBG_SPELLING 'Writing words to file'
  2078. call DBGIND 1
  2079. do WordIndex=1 to SpellingAddCount
  2080. call lineout SpellingAddFile,SpellingAddWord.WordIndex
  2081. if OptionDebugOn='Y' then
  2082. call DBG_SPELLING 'The word "' || SpellingAddWord.WordIndex || '" occured ' || SpellingAddOccurs.WordIndex || ' time(s).'
  2083. end
  2084. call DBGIND-1
  2085. call DieIfIoErrorOccurred SpellingAddFile
  2086. call FileClose SpellingAddFile
  2087. call OutputInformationToScreen AddCommasToDecimalNumber(SpellingAddCount)|| ' word(s) added to "' || SpellingAddFile || '"'
  2088. call DBGIND-1
  2089. return
  2090.  
  2091. SPELLING_12:
  2092. OptionDebugOn='N'
  2093. OptionMaxCol=500
  2094. if RexWhich='REGINA' then
  2095. do
  2096. if pos('0.0',RexVerRegina)<>0 then
  2097. OptionDebugTime='L'
  2098. else
  2099. OptionDebugTime='S'
  2100. end
  2101. else
  2102. do
  2103. OptionDebugTime='S'
  2104. end
  2105. call DBGINDInit
  2106. signal Debug_13
  2107.  
  2108. DebugInc:call TRACE "OFF"
  2109. call DBGIND 1
  2110. return
  2111.  
  2112. DebugDec:call TRACE "OFF"
  2113. call DBGIND-1
  2114. return
  2115.  
  2116. DebugOn:call TRACE "OFF"
  2117. call _DebugOnOff 'Y'
  2118. return
  2119.  
  2120. DebugOff:call TRACE "OFF"
  2121. call _DebugOnOff 'N'
  2122. return
  2123.  
  2124. _DebugOnOff:
  2125. if DebugSwitchUsed='Y' then
  2126. call DBG 'Command ignored as "/debug" used'
  2127. else
  2128. do
  2129. OptionDebugOn=arg(1)
  2130. call DebugStateChanged
  2131. end
  2132. return
  2133.  
  2134. DebugIndent:call TRACE "OFF"
  2135.  
  2136. DBGIND:
  2137. DebugIndent=DebugIndent+(arg(1)*2)
  2138. if DebugIndent<0 then
  2139. DebugIndent=0
  2140. return
  2141.  
  2142. Debug:call TRACE "OFF"
  2143.  
  2144. DBG:
  2145. if OptionDebugOn='N' then
  2146. return
  2147.  
  2148. DBG2:
  2149. call _DBG1 _DebugPrefix()|| '         >' ||translate(arg(1),DebugNewline,MarksNewLine)
  2150. return
  2151.  
  2152. _DebugPrefix:
  2153. if OptionDebugTime='N' then
  2154. return(copies("  ",IncludeLevel+DebugIndent))
  2155. else
  2156. do
  2157. if OptionDebugTime='L' then
  2158. return( '[' || left(time('L'),11)               || ']' || copies("  ",IncludeLevel+DebugIndent))
  2159. else
  2160. return( '[' || (time('S') || substr(time('L'), 9, 3)) - PpwStartSec || ']' || copies("  ",IncludeLevel+DebugIndent))
  2161. end
  2162.  
  2163. YorN2OnorOff:
  2164. if arg(1)='Y' then
  2165. return('ON')
  2166. else
  2167. return('OFF')
  2168.  
  2169. DebugShowCurrentLineWithLineNumber:
  2170. if OptionDebugOn='Y' then
  2171. do
  2172. FmtLineNum=IncludeLineNumber
  2173. if length(FmtLineNum)<4 then
  2174. FmtLineNum=right(FmtLineNum,4, '0')
  2175. if arg(2)<> '' then
  2176. FmtLineNum=copies(arg(2),length(FmtLineNum))
  2177. if IncludeMemHandle='' then
  2178. FmtLineNum='{' || DebugCurrentFileNumber || '}' ||FmtLineNum
  2179. else
  2180. FmtLineNum='[' || DebugCurrentFileNumber || ']' ||FmtLineNum
  2181. select
  2182. when AsIsModeOn='Y' & AutoTagOn = 'Y' then
  2183. DebugSym='> '
  2184. when AsIsModeOn='Y' then
  2185. DebugSym='} '
  2186. when AutoTagOn='Y' then
  2187. DebugSym=') '
  2188. otherwise
  2189. DebugSym=': '
  2190. end
  2191. if arg(1)=='' then
  2192. call _DBG1 _DebugPrefix()||FmtLineNum||DebugSym
  2193. else
  2194. call _DBG1 _DebugPrefix()||FmtLineNum||DebugSym||DebugRightArrow||translate(arg(1),DebugNewline,MarksNewLine)||DebugLeftArrow
  2195. end
  2196. return
  2197.  
  2198. DebugShowLineDropped:
  2199. if OptionDebugOn='Y' then
  2200. do
  2201. call _DBG1 _DebugPrefix()||left(arg(1),length(FmtLineNum), ' ') || '-'
  2202. end
  2203. return
  2204.  
  2205. DebugGetEnv:
  2206. if OptionDebugOn='Y' then
  2207. call DBG 'GetEnv(): "' || arg(1) || '" = ' ||DebugRightArrow||arg(2)||DebugLeftArrow
  2208. return
  2209.  
  2210. DebugWarning:
  2211. if OptionDebugOn='N' then
  2212. return
  2213. DbgWarning='!!! ' || arg(1) || ' !!!'
  2214. DbgLine=copies('!',length(DbgWarning))
  2215. call DBG2 ''
  2216. call DBG2 left('!!!![ DEBUG WARNING ]', length(DbgWarning), '!')
  2217. call DBG2 DbgWarning
  2218. call DBG2 left('', length(DbgWarning), '!')
  2219. call DBG2 ''
  2220. return
  2221.  
  2222. DebugOutputVariableInfo:
  2223. if OptionDebugOn='Y' then
  2224. call DBG2 '? ' ||translate(arg(1),DebugNewline,MarksNewLine)
  2225. return
  2226.  
  2227. DBGINDInit:
  2228. DebugIndent=0
  2229. return
  2230.  
  2231. DebugGetOpSysText:
  2232. if PpWizardOpSys=PpWizardOpSysREAL then
  2233. return(PpWizardOpSys)
  2234. else
  2235. return(PpWizardOpSys|| ' ("' || PpWizardOpSysREAL || '")')
  2236.  
  2237. DebugStateChanged:
  2238. if OptionDebugOn='Y' then
  2239. do
  2240. call DisplayCopyright
  2241. if DebugOnStuffOutputted='N' then
  2242. do
  2243. SourceTime=FileQueryDateTime(PpWizardPgmName)
  2244. call DBG 'Debug Header'
  2245. call DBG '~~~~~~~~~~~~'
  2246. call DBGIND 1
  2247. call DBG 'Started@: "' || PpwCompTime        || '"'
  2248. call DBG 'Program : "' || PpWizardPgmName    || '" (' || SourceTime || ')'
  2249. call DBG 'OptionE : "' || OptionsEnvironment || '"'
  2250. call DBG 'OptionC : "' || OptionsCmdLine     || '"'
  2251. call DBG 'Src Type: "' || ProcessingMode     || '"'
  2252. call DBG 'OpSystem: "' ||DebugGetOpSysText()
  2253. call DBG 'Rexx Ver: "' || RexVersionInfo     || '"'
  2254. call DBG 'Mode    : "' || RexWhich           || '"'
  2255. if RexWhich='REGINA' then
  2256. call DBG 'uname() : "' || uname()        || '"'
  2257. if OptionFilterIn<> '' then
  2258. call DBG 'Filter I: ' || FunctionFilterIn || '(' || InputInterfaceVer || ')'
  2259. if OptionFilterOut<> '' then
  2260. call DBG 'Filter O: "' || OptionFilterOut   || '" (interface version ' || OutputInterfaceVer || ')'
  2261. call _DBG1 ''
  2262. DebugOnStuffOutputted='Y'
  2263. call DBGIND-1
  2264. end
  2265. end
  2266. call SetEnv "PPWIZARD_DEBUG",OptionDebugOn
  2267. return
  2268.  
  2269. ProcessHashDebug:
  2270. if DebugSwitchUsed='Y' then
  2271. call DBG 'Command ignored as "/debug" used'
  2272. else
  2273. do
  2274. ReturnRc=SetOnorOffVariable(arg(1), 'OptionDebugOn')
  2275. call DebugStateChanged
  2276. end
  2277. return(0)
  2278.  
  2279. DebugShowAsMuchEnvironmentDetailAsPossible:
  2280. if OptionDebugOn='N' then
  2281. return
  2282. call DBG 'Dumping Environmental Info'
  2283. TmpSetFile=RexGetTmpFileName()
  2284. RedirBit=RedirectStdOutAndErr2(TmpSetFile)
  2285. call _EnvAddCmd 'set'
  2286. if RexSystemOpSys<> "UNIX" then
  2287. do
  2288. select
  2289. when RexSystemOpSys="OS/2"  then VerCmd = 'VER /R'
  2290. otherwise VerCmd='VER'
  2291. end
  2292. call _EnvAddCmd VerCmd
  2293. end
  2294. if RexSystemOpSys<> "UNIX" then
  2295. call _SysFileDelete TmpSetFile
  2296. return
  2297.  
  2298. _EnvAddCmd:
  2299. call AddressCmd arg(1)||RedirBit,TmpSetFile
  2300. if RexSystemOpSys="UNIX" then
  2301. call _SysFileDelete TmpSetFile
  2302. return
  2303.  
  2304. _DBG1:
  2305. k_Line=arg(1)
  2306. if OptionMaxCol=0 then
  2307. call Line1 k_Line
  2308. else
  2309. do
  2310. if length(k_Line)<=OptionMaxCol then
  2311. call Line1 k_Line
  2312. else
  2313. call Line1 left(k_Line,OptionMaxCol)|| ' <-[' || OptionMaxCol || ']'
  2314. end
  2315. return
  2316.  
  2317. _SetDebugChar:
  2318. l_Var=arg(1)
  2319. l_CurValVar=arg(2)
  2320. parse value strip(value(l_Var)) with l_Val ',' l_Rest
  2321. call value l_Var,l_Rest
  2322. if l_Val=-1 then
  2323. l_NewVal=''
  2324. else
  2325. do
  2326. l_Val=strip(l_Val)
  2327. if l_Val='' then
  2328. l_NewVal=value(l_CurValVar)
  2329. else
  2330. do
  2331. if datatype(l_Val, 'W')then
  2332. l_NewVal=d2c(l_Val)
  2333. else
  2334. l_NewVal=l_Val
  2335. end
  2336. end
  2337. return(l_NewVal)
  2338.  
  2339. SetDebugChars:
  2340. m_Chars=arg(1)
  2341. m_MakDef=arg(2)
  2342. if m_Chars='' then
  2343. do
  2344. DebugLeftArrow=_DebugLeftArrow
  2345. DebugRightArrow=_DebugRightArrow
  2346. DebugNewline=_DebugNewline
  2347. end
  2348. else
  2349. do
  2350. DebugRightArrow=_SetDebugChar('m_Chars', 'DebugRightArrow')
  2351. DebugLeftArrow=_SetDebugChar('m_Chars', 'DebugLeftArrow' )
  2352. DebugNewline=_SetDebugChar('m_Chars', 'DebugNewline' )
  2353. end
  2354. if m_MakDef='Y' then
  2355. do
  2356. _DebugLeftArrow=DebugLeftArrow
  2357. _DebugRightArrow=DebugRightArrow
  2358. _DebugNewline=DebugNewline
  2359. end
  2360. call DBG 'New debug characters are "LEFT=' || DebugRightArrow || ', RIGHT=' || DebugLeftArrow || ', NL=' || DebugNewline || '"'
  2361. return
  2362.  
  2363. Debug_13:
  2364. AllBitsOff='000000'x
  2365. AllBitsOn='FFFFFF'x
  2366. UserBitsOn='000003'x
  2367. AllBitsOnExceptUser=bitxor(AllBitsOn,UserBitsOn)
  2368. DebugLevel=AllBitsOnExceptUser
  2369. DebugLevelCnt=0
  2370. SeeLevelAll=_SaveDebugLevel("ALL",           "FFFFFF")
  2371. DummyUser1=_SaveDebugLevel("USER1",         "000001")
  2372. DummyUser2=_SaveDebugLevel("USER2",         "000002")
  2373. SeeLevelConditional=_SaveDebugLevel("CONDITIONAL",   "000004")
  2374. SeeFoundVar=_SaveDebugLevel("FOUNDVAR",      "000008")
  2375. SeeFoundVarParms=_SaveDebugLevel("FOUNDVARPARMS", "000010")
  2376. SeeFoundStdVar=_SaveDebugLevel("FOUNDSTDVAR",   "000020")
  2377. SeeAfterReplace=_SaveDebugLevel("AFTERREPLACE",  "000040")
  2378. SeeOptions=_SaveDebugLevel("OPTIONS",       "000080")
  2379. SeeOpSys=_SaveDebugLevel("OPSYS",         "000100")
  2380. SeeDefining=_SaveDebugLevel("DEFINING",      "000200")
  2381. SeeDefaultOrMacroValue=_SaveDebugLevel("MACROVALORDEF", "000400")
  2382. SeeAsIs=_SaveDebugLevel("ASIS",          "000800")
  2383. SeeAutoTag=_SaveDebugLevel("AUTOTAG",       "001000")
  2384. SeeRexxVar=_SaveDebugLevel("REXXVAR",       "002000")
  2385. SeeRexxTrace=_SaveDebugLevel("REXXTRACE",     "004000")
  2386. SeeInterpret=_SaveDebugLevel("INTERPRET",     "008000")
  2387. SeeEvaluate=_SaveDebugLevel("EVALUATE",      "010000")
  2388. SeeImport=_SaveDebugLevel("IMPORT",        "020000")
  2389. SeeSpelling=_SaveDebugLevel("SPELLING",      "040000")
  2390. SeeQuoting=_SaveDebugLevel("QUOTING",       "080000")
  2391. SeeImport=bitand(SeeImport,SeeDefaultOrMacroValue)
  2392. signal DebugOpt_14
  2393.  
  2394. IsDebugOn:call TRACE "OFF"
  2395. ido1=arg(1)
  2396. if ido1='' then
  2397. return(OptionDebugOn)
  2398. else
  2399. do
  2400. if OptionDebugOn='N' then
  2401. return(0)
  2402. else
  2403. do
  2404. idoUBits=bitand(DebugLevel,UserBitsOn)
  2405. idoUBits=bitand(idoUBits,x2c(right(ido1,6, '0')))
  2406. return(c2d(idoUBits))
  2407. end
  2408. end
  2409.  
  2410. DebugAddressCmdBefore:
  2411. if OptionDebugOn='Y' then
  2412. do
  2413. if bitand(DebugLevel,SeeOpSys)==SeeOpSys then
  2414. do
  2415. call DBGIND 1
  2416. call DBG 'Executing: ' ||arg(1)
  2417. call DBGIND-1
  2418. end
  2419. end
  2420. return
  2421.  
  2422. DebugAddressCmdOutput:
  2423. if OptionDebugOn='Y' then
  2424. do
  2425. if bitand(DebugLevel,SeeOpSys)==SeeOpSys then
  2426. do
  2427. call DBGIND 2
  2428. DbgLineNumber=arg(2)
  2429. if datatype(DbgLineNumber, 'W')=0 then
  2430. call DBG '> ' ||arg(1)
  2431. else
  2432. do
  2433. if DbgLineNumber<999 then
  2434. DbgLineNumber=right(DbgLineNumber,3, '0')
  2435. call DBG '> ' || DbgLineNumber || ': ' ||arg(1)
  2436. end
  2437. call DBGIND-2
  2438. end
  2439. end
  2440. return
  2441.  
  2442. DebugAddressCmdAfter:
  2443. if OptionDebugOn='Y' then
  2444. do
  2445. if bitand(DebugLevel,SeeOpSys)==SeeOpSys then
  2446. do
  2447. call DBGIND 2
  2448. call DBG '  Rc = ' ||arg(1)
  2449. call DBGIND-2
  2450. end
  2451. end
  2452. return
  2453.  
  2454. DebugOutputAfterReplacement:
  2455. if OptionDebugOn='N' then
  2456. return
  2457. if bitand(DebugLevel,SeeAfterReplace)==SeeAfterReplace then
  2458. call DBG2 arg(2)||DebugRightArrow||translate(arg(1),DebugNewline,MarksNewLine)||DebugLeftArrow
  2459. return
  2460.  
  2461. DBG_DEFINING:
  2462. if bitand(DebugLevel,SeeDefining)==SeeDefining then
  2463. call DBG arg(1)
  2464. return
  2465.  
  2466. DBG_ASIS:
  2467. if bitand(DebugLevel,SeeAsIs)==SeeAsIs then
  2468. call DBG arg(1)
  2469. return
  2470.  
  2471. DBG_REXXVAR:
  2472. if bitand(DebugLevel,SeeRexxVar)==SeeRexxVar then
  2473. call DBG arg(1)
  2474. return
  2475.  
  2476. DBG_INTERPRET:
  2477. if bitand(DebugLevel,SeeInterpret)==SeeInterpret then
  2478. call DBG arg(1)
  2479. return
  2480.  
  2481. DBG_EVALUATE:
  2482. if bitand(DebugLevel,SeeEvaluate)==SeeEvaluate then
  2483. call DBG arg(1)
  2484. return
  2485.  
  2486. DBG_SPELLING:
  2487. if bitand(DebugLevel,SeeSpelling)==SeeSpelling then
  2488. call DBG arg(1)
  2489. return
  2490.  
  2491. DBG_QUOTING:
  2492. if bitand(DebugLevel,SeeQuoting)==SeeQuoting then
  2493. call DBG arg(1)
  2494. return
  2495.  
  2496. DBG_IMPORT:
  2497. if bitand(DebugLevel,SeeImport)==SeeImport then
  2498. call DBG arg(1)
  2499. return
  2500.  
  2501. DBG_AUTOTAG:
  2502. if bitand(DebugLevel,SeeAutoTag)==SeeAutoTag then
  2503. call DBG arg(1)
  2504. return
  2505.  
  2506. DBG_MACROVALORDEF:
  2507. if bitand(DebugLevel,SeeDefaultOrMacroValue)==SeeDefaultOrMacroValue then
  2508. call DBG arg(1)
  2509. return
  2510.  
  2511. DBG_OPTIONS:
  2512. if bitand(DebugLevel,SeeOptions)==SeeOptions then
  2513. call DBG arg(1)
  2514. return
  2515.  
  2516. DBG_CONDITIONAL:
  2517. if bitand(DebugLevel,SeeLevelConditional)==SeeLevelConditional then
  2518. call DBG arg(1)
  2519. return
  2520.  
  2521. DebugOutputVariableInfo_FOUNDSTDVAR:
  2522. if bitand(DebugLevel,SeeFoundStdVar)==SeeFoundStdVar then
  2523. call DebugOutputVariableInfo arg(1)
  2524. return
  2525.  
  2526. DebugOutputVariableInfo_FOUNDVAR:
  2527. if bitand(DebugLevel,SeeFoundVar)==SeeFoundVar then
  2528. call DebugOutputVariableInfo arg(1)
  2529. return
  2530.  
  2531. DebugOutputVariableInfo_FOUNDVARPARMS:
  2532. if bitand(DebugLevel,SeeFoundVarParms)==SeeFoundVarParms then
  2533. call DebugOutputVariableInfo arg(1)
  2534. return
  2535.  
  2536. DebugOutputVariableInfo_FOUNDSTDVAR:
  2537. if bitand(DebugLevel,SeeFoundVar)==SeeFoundVar then
  2538. call DebugOutputVariableInfo arg(1)
  2539. return
  2540.  
  2541. _SaveDebugLevel:
  2542. DebugLevelCnt=DebugLevelCnt+1
  2543. DebugLevelNme.DebugLevelCnt=translate(arg(1))
  2544. DebugLevelVal.DebugLevelCnt=arg(2)
  2545. return(x2c(arg(2)))
  2546.  
  2547. GetDebugLevel:
  2548. WantedName=translate(arg(1))
  2549. do DbgIndex=1 to DebugLevelCnt
  2550. if WantedName=DebugLevelNme.DbgIndex then
  2551. return(DebugLevelVal.DbgIndex)
  2552. end
  2553. return('')
  2554.  
  2555. _WorkOutDebugLevelText:
  2556. DbgLvlTxt="ALL"
  2557. do DbgIndex=1 to DebugLevelCnt
  2558. if bitand(DebugLevel,x2c(DebugLevelVal.DbgIndex))=AllBitsOff then
  2559. DbgLvlTxt=DbgLvlTxt|| ',-' ||DebugLevelNme.DbgIndex
  2560. end
  2561. return(DbgLvlTxt)
  2562.  
  2563. DEBUGLEVEL_DEBUG:
  2564. if OptionDebugOn='Y' then
  2565. call OptionDebugShow 'DEBUGLEVEL', 'Debug level (when on) is ' ||_WorkOutDebugLevelText()
  2566. return
  2567.  
  2568. DEBUGLEVEL_GET:
  2569. call DEBUGLEVEL_DEBUG
  2570. return(_WorkOutDebugLevelText())
  2571.  
  2572. DEBUGLEVEL_SET:
  2573. DebugCmdsIn=arg(1)
  2574. DebugCmds=DebugCmdsIn
  2575. do while DebugCmds<> ''
  2576. parse var DebugCmds OneDebugOpt','DebugCmds
  2577. OptionAction=left(OneDebugOpt,1)
  2578. if OptionAction='+' then
  2579. OneDebugOpt=substr(OneDebugOpt,2)
  2580. else
  2581. do
  2582. if OptionAction='-' then
  2583. OneDebugOpt=substr(OneDebugOpt,2)
  2584. else
  2585. OptionAction='+'
  2586. end
  2587. OptionBinary=x2c(GetDebugLevel(OneDebugOpt))
  2588. if OptionBinary='' then
  2589. CryAndDie('Invalid debug option of "' || OneDebugOpt || '"')
  2590. if OptionAction='+' then
  2591. DebugLevel=bitor(DebugLevel,OptionBinary)
  2592. else
  2593. DebugLevel=bitxor(DebugLevel,OptionBinary)
  2594. end
  2595. if ProcessedCmdLine='N' then
  2596. do
  2597. call OptionDebugShow 'DEBUGLEVEL', 'Setting default value of debug level to "' || _WorkOutDebugLevelText() || '"'
  2598. Default4_DebugLevel=DebugLevel
  2599. return(0)
  2600. end
  2601. if DebugCmdsIn='' then
  2602. DebugLevel=Default4_DebugLevel
  2603. call DEBUGLEVEL_DEBUG
  2604. return
  2605.  
  2606. DebugOpt_14:
  2607. OptionCgiModeOn='N'
  2608. CgiOutputFile=''
  2609. CgiFatalError='N'
  2610. signal CGI_15
  2611.  
  2612. InitConsoleOutputVarsPass1:
  2613. ConsoleFile=''
  2614. OutputToConsoleLog='N'
  2615. OutputToErrorLog='N'
  2616. ConsoleErrorFile='PPWIZARD.ERR'
  2617. TruncateDefaultErrorFile='Y'
  2618. return
  2619.  
  2620. InitConsoleOutputVarsPass2:
  2621. call UserIsSpecifyingConsoleFileName GetEnv("PPWIZARD_CONSOLEFILE")
  2622. call UserIsSpecifyingErrorFileName GetEnv("PPWIZARD_ERRORFILE")
  2623. if ConsoleErrorFile='' then
  2624. ConsoleErrorFile='PPWIZARD.ERR'
  2625. return
  2626.  
  2627. UserIsSpecifyingErrorFileName:
  2628. ConsoleErrorFile=arg(1)
  2629. if ConsoleErrorFile<> '' then
  2630. do
  2631. if left(ConsoleErrorFile,1)='+' then
  2632. do
  2633. ConsoleErrorFile=substr(ConsoleErrorFile,2)
  2634. TruncateDefaultErrorFile='N'
  2635. end
  2636. else
  2637. do
  2638. TruncateDefaultErrorFile='Y'
  2639. end
  2640. end
  2641. return
  2642.  
  2643. UserIsSpecifyingConsoleFileName:
  2644. n_ConFile=arg(1)
  2645. if ConsoleFile<> '' then
  2646. do
  2647. call FileClose ConsoleFile
  2648. ConsoleFile=''
  2649. end
  2650. if n_ConFile<> '' then
  2651. do
  2652. if left(n_ConFile,1)='+' then
  2653. do
  2654. n_ConFile=substr(n_ConFile,2)
  2655. end
  2656. else
  2657. do
  2658. call MustDeleteFile n_ConFile
  2659. end
  2660. end
  2661. if n_ConFile='' then
  2662. OutputToConsoleLog='N'
  2663. else
  2664. do
  2665. call MakeDirectoryTree _filespec('Location',n_ConFile)
  2666. OutputToConsoleLog='y'
  2667. ConsoleFile=n_ConFile
  2668. end
  2669. return
  2670.  
  2671. AllFollowingOutputGoesToErrorFile:
  2672. if ConsoleErrorFile='' then
  2673. return
  2674. if TruncateDefaultErrorFile='Y' then
  2675. do
  2676. TruncateDefaultErrorFile='N'
  2677. call MustDeleteFile ConsoleErrorFile
  2678. end
  2679. call MakeDirectoryTree _filespec('Location',ConsoleErrorFile)
  2680. TheTime=NiceDateTime()
  2681. if symbol('InputFileFull') <> 'VAR' then
  2682. TheFile=''
  2683. else
  2684. TheFile=InputFileFull
  2685. OutputToErrorLog='Y'
  2686. call Say2ErrorFile ''
  2687. call Say2ErrorFile ''
  2688. call Say2ErrorFile copies('*+',38)
  2689. if TheFile<> '' then
  2690. call Say2ErrorFile copies(' ',(78-length(TheFile))%2)||TheFile
  2691. call Say2ErrorFile copies(' ',(78-length(TheTime))%2)||TheTime
  2692. call Say2ErrorFile copies('*+',38)
  2693. call Say2ErrorFile ''
  2694. return
  2695.  
  2696. Say2ErrorFile:
  2697. if OutputToErrorLog='Y' then
  2698. do
  2699. o_L=arg(1)
  2700. do until o_L==''
  2701. parse var o_L o_Nxt (MarksNewLine) o_L
  2702. call lineout ConsoleErrorFile,o_Nxt
  2703. end
  2704. end
  2705. return
  2706.  
  2707. Char1ToErrorFile:
  2708. if OutputToErrorLog='Y' then
  2709. call charout ConsoleErrorFile,arg(1)
  2710. return
  2711.  
  2712. AddConsoleHdr:
  2713. OutputToConsoleLog='N' 
  2714. TheTime=NiceDateTime()
  2715. OutputToConsoleLog='Y' 
  2716. call _Lne2CFle ''
  2717. call _Lne2CFle ''
  2718. call _Lne2CFle copies('*+',38)
  2719. call _Lne2CFle copies(' ',(78-length(TheTime))%2)||TheTime
  2720. call _Lne2CFle copies('*+',38)
  2721. call _Lne2CFle ''
  2722. return
  2723.  
  2724. _Lne2CFle:
  2725. if OutputToConsoleLog<> 'N' then
  2726. do
  2727. p_L=arg(1)
  2728. do until p_L==''
  2729. parse var p_L p_Nxt (MarksNewLine) p_L
  2730. call lineout ConsoleFile,p_Nxt
  2731. end
  2732. end
  2733. return
  2734.  
  2735. _Chr2CFle:
  2736. if OutputToConsoleLog<> 'N' then
  2737. call charout ConsoleFile,arg(1)
  2738. return
  2739.  
  2740. Say:call TRACE "OFF"
  2741.  
  2742. Line1:
  2743. parse arg Lne1S,Lne1L
  2744. if Lne1L='' then
  2745. Lne1L=Lne1S
  2746. if OptionCgiModeOn='N' then
  2747. do
  2748. say Lne1S
  2749. if OutputToErrorLog='Y' then
  2750. call Say2ErrorFile Lne1L
  2751. if OutputToConsoleLog<> 'N' then
  2752. do
  2753. if OutputToConsoleLog='y' then
  2754. call AddConsoleHdr
  2755. call _Lne2CFle Lne1L
  2756. end
  2757. end
  2758. else
  2759. do
  2760. if CgiOutputFile<> '' then
  2761. call lineout CgiOutputFile,Lne1S
  2762. if CgiFatalError='Y' then
  2763. say _MustSeeAsIsInHtmlViewer(Lne1S)
  2764. end
  2765. return
  2766.  
  2767. Chars:call TRACE "OFF"
  2768.  
  2769. Char1:
  2770. TheChar1=arg(1)
  2771. if OptionCgiModeOn='N' then
  2772. do
  2773. call charout,TheChar1
  2774. if OutputToErrorLog='Y' then
  2775. call Char1ToErrorFile TheChar1
  2776. if OutputToConsoleLog<> 'N' then
  2777. do
  2778. if OutputToConsoleLog='y' then
  2779. call AddConsoleHdr
  2780. call _Chr2CFle TheChar1
  2781. end
  2782. end
  2783. else
  2784. do
  2785. if CgiOutputFile<> '' then
  2786. call charout CgiOutputFile,TheChar1
  2787. if CgiFatalError='Y' then
  2788. call charout,_MustSeeAsIsInHtmlViewer(TheChar1)
  2789. end
  2790. return
  2791.  
  2792. DieIfCgiModeOn:
  2793. if OptionCgiModeOn='Y' then
  2794. call CryAndDie "This feature is not allowed in CGI mode"
  2795. return
  2796.  
  2797. TurnCgiModeOn:
  2798. OptionCgiModeOn='Y'
  2799. CgiOutputFile=ThisCmdOptions
  2800. if pos('?',CgiOutputFile)<>0 then
  2801. do
  2802. PartSecond=time('Long')
  2803. parse var PartSecond .'.'PartSecond
  2804. RandomBit=right(time('Seconds'), 5, '0')
  2805. RandomBit=RandomBit||left(strip(PartSecond),3)
  2806. RandomBit=RandomBit|| '.' || right( date('Days'), 3, '0')
  2807. CgiOutputFile=ReplaceString(CgiOutputFile, '?',RandomBit)
  2808. end
  2809. if CgiOutputFile<> '' then
  2810. do
  2811. if FileQueryExists(CgiOutputFile)<> '' then
  2812. do
  2813. call FileClose CgiOutputFile
  2814. DeleteRc=_SysFileDelete(CgiOutputFile)
  2815. if DeleteRc<>0 then
  2816. call DBG 'Could not delete "' || CgiOutputFile || '" (Rc = ' || DeleteRc || ')'
  2817. end
  2818. end
  2819. call RemoveColorCodes
  2820. call RemoveBeepCode
  2821. return
  2822.  
  2823. CloseCgiFileIfOpen:
  2824. if OutputToConsoleLog<> 'N' then
  2825. do
  2826. call FileClose ConsoleFile
  2827. OutputToConsoleLog='N'
  2828. end
  2829. if OutputToErrorLog='Y' then
  2830. do
  2831. call FileClose ConsoleErrorFile
  2832. OutputToErrorLog='N'
  2833. end
  2834. if CgiOutputFile<> '' then
  2835. call FileClose CgiOutputFile
  2836. return
  2837.  
  2838. CgiStartFatalError:
  2839. if OptionCgiModeOn='N' then
  2840. return
  2841. CgiDoVar='CGI_FATAL_MY_MESSAGE_ONLY'
  2842. if MacroExists(CgiDoVar)='Y' then
  2843. do
  2844. CgiErrorCodes=CfgMacro(CgiDoVar, '')
  2845. if CgiErrorCodes='' then
  2846. call DBG 'We do not want any error indication in user output'
  2847. else
  2848. call DBG 'Displaying user message only (no error details)'
  2849. say CgiErrorCodes
  2850. return
  2851. end
  2852. call DBG 'Will show user error output as "' || CgiDoVar || '" was not defined'
  2853. CgiErrDefault='<P><HR><FONT SIZE=+1 COLOR=RED><CENTER><H1>FATAL ERROR</H1></CENTER><P><PRE>'
  2854. CgiErrorCodes=CfgMacro("CGI_FATAL_HEADER",CgiErrDefault)
  2855. say CgiErrorCodes
  2856. CgiErrDefault='</PRE><HR></FONT>'
  2857. CgiErrorCodes=CfgMacro("CGI_FATAL_TRAILER",CgiErrDefault)
  2858. CgiFatalError='Y'
  2859. return
  2860.  
  2861. CgiEndFatalError:
  2862. if OptionCgiModeOn='N' then
  2863. return
  2864. if CgiFatalError='N' then
  2865. return
  2866. say CgiErrorCodes
  2867. CgiFatalError='N'
  2868. return
  2869.  
  2870. _MustSeeAsIsInHtmlViewer:
  2871. BrowserOk=ReplaceString(arg(1), "<",          "<")
  2872. BrowserOk=ReplaceString(BrowserOk, ">",          ">")
  2873. return(BrowserOk)
  2874.  
  2875. CGI_15:
  2876. signal EndLineCrLfXH
  2877.  
  2878. CrLfClose:
  2879. _CrlfBuffer=''
  2880. return(FileClose(arg(1)))
  2881.  
  2882. CrLfOpen:
  2883. call CrLfClose arg(1)
  2884. _CrLfEOL=CrLf
  2885. _CrLfEOLLng=length(_CrLfEOL)
  2886. if arg(2)<> '' then
  2887. do
  2888. if chars(arg(1))<>0 then
  2889. do
  2890. _CrLf2Read=arg(2)
  2891. if _CrLf2Read<5000 then
  2892. _CrLf2Read=5000
  2893. _CrlfBuffer=charin(arg(1),,_CrLf2Read)
  2894. if pos(_CrLfEOL,_CrlfBuffer)=0 then
  2895. do
  2896. if pos(MarksNewLine,_CrlfBuffer)<>0 then
  2897. do
  2898. _CrLfEOL=MarksNewLine
  2899. _CrLfEOLLng=1
  2900. end
  2901. end
  2902. end
  2903. end
  2904. return(0)
  2905.  
  2906. CrLfLines:
  2907. if _CrlfBuffer<> '' then
  2908. return(1)
  2909. else
  2910. do
  2911. if chars(arg(1))=0 then
  2912. return(0)
  2913. else
  2914. return(1)
  2915. end
  2916.  
  2917. CrLfLineIn:
  2918. _CrLfPos=pos(_CrLfEOL,_CrlfBuffer)
  2919. do while _CrLfPos=0
  2920. if chars(arg(1))=0 then
  2921. leave
  2922. _CrlfBuffer=_CrlfBuffer||charin(arg(1),,5000)
  2923. _CrLfPos=pos(_CrLfEOL,_CrlfBuffer)
  2924. end
  2925. if _CrLfPos=0 then
  2926. do
  2927. _CrLfReturn=_CrlfBuffer
  2928. _CrlfBuffer=''
  2929. end
  2930. else
  2931. do
  2932. _CrLfReturn=left(_CrlfBuffer,_CrLfPos-1)
  2933. _CrlfBuffer=substr(_CrlfBuffer,_CrLfPos+_CrLfEOLLng)
  2934. end
  2935. return(_CrLfReturn)
  2936.  
  2937. EndLineCrLfXH:
  2938. ReplaceCount=0
  2939. CiSelfRef="{*}"
  2940. signal EndREPLSTR
  2941.  
  2942. ReplaceString:call TRACE "OFF"
  2943. parse arg rs?TheString,rs?ChangeFrom
  2944. rs?FoundPosn=pos(rs?ChangeFrom,rs?TheString)
  2945. if rs?FoundPosn=0 then
  2946. return(rs?TheString)
  2947. rs?ChangeTo=arg(3)
  2948. rs?ChangeFromLength=length(rs?ChangeFrom)
  2949. rs?LeftPart=''
  2950. do until rs?FoundPosn=0
  2951. rs?LeftPart=rs?LeftPart||left(rs?TheString,rs?FoundPosn-1)||rs?ChangeTo
  2952. rs?TheString=substr(rs?TheString,rs?FoundPosn+rs?ChangeFromLength)
  2953. ReplaceCount=ReplaceCount+1
  2954. rs?FoundPosn=pos(rs?ChangeFrom,rs?TheString)
  2955. end
  2956. return(rs?LeftPart||rs?TheString)
  2957.  
  2958. ReplaceStringCi:call TRACE "OFF"
  2959. rsi?TheString=arg(1)
  2960. rsi?TheStringU=translate(rsi?TheString)
  2961. rsi?ChangeFrom=translate(arg(2))
  2962. rsi?FoundPosn=pos(rsi?ChangeFrom,rsi?TheStringU)
  2963. if rsi?FoundPosn=0 then
  2964. return(rsi?TheString)
  2965. rsi?ChangeTo=arg(3)
  2966. if pos(CiSelfRef,rsi?ChangeTo)=0 then
  2967. rsi?Ref='N'
  2968. else
  2969. rsi?Ref='Y'
  2970. rsi?ChangeFromLength=length(rsi?ChangeFrom)
  2971. rsi?LeftPart=''
  2972. do until rsi?FoundPosn=0
  2973. if rsi?Ref='N' then
  2974. rsi?SubWith=rsi?ChangeTo
  2975. else
  2976. do
  2977. rsi?SaveCount=ReplaceCount
  2978. rsi?SubWith=ReplaceString(rsi?ChangeTo,CiSelfRef,substr(rsi?TheString,rsi?FoundPosn,rsi?ChangeFromLength))
  2979. ReplaceCount=rsi?SaveCount
  2980. end
  2981. rsi?LeftPart=rsi?LeftPart||left(rsi?TheString,rsi?FoundPosn-1)||rsi?SubWith
  2982. rsi?TheString=substr(rsi?TheString,rsi?FoundPosn+rsi?ChangeFromLength)
  2983. rsi?TheStringU=substr(rsi?TheStringU,rsi?FoundPosn+rsi?ChangeFromLength)
  2984. ReplaceCount=ReplaceCount+1
  2985. rsi?FoundPosn=pos(rsi?ChangeFrom,rsi?TheStringU)
  2986. end
  2987. return(rsi?LeftPart||rsi?TheString)
  2988.  
  2989. EndREPLSTR:
  2990. ReplaceCount=0
  2991. signal EndBULK_C2S
  2992.  
  2993. BulkChar2String:call TRACE "OFF"
  2994. parse arg brRightBit,brArray
  2995. brModifyThese=value(brArray)
  2996. brPos=verify(brRightBit,brModifyThese, 'M')
  2997. if brPos=0 then
  2998. return(brRightBit)
  2999. brLeftBit=''
  3000. brArray=brArray|| '.'
  3001. do until brPos=0
  3002. brLeftBit=brLeftBit||left(brRightBit,brPos-1)||value(brArray||pos(substr(brRightBit,brPos,1),brModifyThese))
  3003. brRightBit=substr(brRightBit,brPos+1)
  3004. ReplaceCount=ReplaceCount+1
  3005. brPos=verify(brRightBit,brModifyThese, 'M')
  3006. end
  3007. return(brLeftBit||brRightBit)
  3008.  
  3009. BulkChangePrepare:call TRACE "OFF"
  3010. parse arg brArray,brChar,brString
  3011. if brChar=='' then
  3012. call value brArray, ''
  3013. else
  3014. do
  3015. brValue=value(brArray)||BrChar
  3016. call value brArray,brValue
  3017. call value brArray|| '.' ||length(brValue),brString
  3018. end
  3019. return
  3020.  
  3021. EndBULK_C2S:
  3022. _C.0='00000000'x
  3023. _C.1='77073096'x
  3024. _C.2='EE0E612C'x
  3025. _C.3='990951BA'x
  3026. _C.4='076DC419'x
  3027. _C.5='706AF48F'x
  3028. _C.6='E963A535'x
  3029. _C.7='9E6495A3'x
  3030. _C.8='0EDB8832'x
  3031. _C.9='79DCB8A4'x
  3032. _C.10='E0D5E91E'x
  3033. _C.11='97D2D988'x
  3034. _C.12='09B64C2B'x
  3035. _C.13='7EB17CBD'x
  3036. _C.14='E7B82D07'x
  3037. _C.15='90BF1D91'x
  3038. _C.16='1DB71064'x
  3039. _C.17='6AB020F2'x
  3040. _C.18='F3B97148'x
  3041. _C.19='84BE41DE'x
  3042. _C.20='1ADAD47D'x
  3043. _C.21='6DDDE4EB'x
  3044. _C.22='F4D4B551'x
  3045. _C.23='83D385C7'x
  3046. _C.24='136C9856'x
  3047. _C.25='646BA8C0'x
  3048. _C.26='FD62F97A'x
  3049. _C.27='8A65C9EC'x
  3050. _C.28='14015C4F'x
  3051. _C.29='63066CD9'x
  3052. _C.30='FA0F3D63'x
  3053. _C.31='8D080DF5'x
  3054. _C.32='3B6E20C8'x
  3055. _C.33='4C69105E'x
  3056. _C.34='D56041E4'x
  3057. _C.35='A2677172'x
  3058. _C.36='3C03E4D1'x
  3059. _C.37='4B04D447'x
  3060. _C.38='D20D85FD'x
  3061. _C.39='A50AB56B'x
  3062. _C.40='35B5A8FA'x
  3063. _C.41='42B2986C'x
  3064. _C.42='DBBBC9D6'x
  3065. _C.43='ACBCF940'x
  3066. _C.44='32D86CE3'x
  3067. _C.45='45DF5C75'x
  3068. _C.46='DCD60DCF'x
  3069. _C.47='ABD13D59'x
  3070. _C.48='26D930AC'x
  3071. _C.49='51DE003A'x
  3072. _C.50='C8D75180'x
  3073. _C.51='BFD06116'x
  3074. _C.52='21B4F4B5'x
  3075. _C.53='56B3C423'x
  3076. _C.54='CFBA9599'x
  3077. _C.55='B8BDA50F'x
  3078. _C.56='2802B89E'x
  3079. _C.57='5F058808'x
  3080. _C.58='C60CD9B2'x
  3081. _C.59='B10BE924'x
  3082. _C.60='2F6F7C87'x
  3083. _C.61='58684C11'x
  3084. _C.62='C1611DAB'x
  3085. _C.63='B6662D3D'x
  3086. _C.64='76DC4190'x
  3087. _C.65='01DB7106'x
  3088. _C.66='98D220BC'x
  3089. _C.67='EFD5102A'x
  3090. _C.68='71B18589'x
  3091. _C.69='06B6B51F'x
  3092. _C.70='9FBFE4A5'x
  3093. _C.71='E8B8D433'x
  3094. _C.72='7807C9A2'x
  3095. _C.73='0F00F934'x
  3096. _C.74='9609A88E'x
  3097. _C.75='E10E9818'x
  3098. _C.76='7F6A0DBB'x
  3099. _C.77='086D3D2D'x
  3100. _C.78='91646C97'x
  3101. _C.79='E6635C01'x
  3102. _C.80='6B6B51F4'x
  3103. _C.81='1C6C6162'x
  3104. _C.82='856530D8'x
  3105. _C.83='F262004E'x
  3106. _C.84='6C0695ED'x
  3107. _C.85='1B01A57B'x
  3108. _C.86='8208F4C1'x
  3109. _C.87='F50FC457'x
  3110. _C.88='65B0D9C6'x
  3111. _C.89='12B7E950'x
  3112. _C.90='8BBEB8EA'x
  3113. _C.91='FCB9887C'x
  3114. _C.92='62DD1DDF'x
  3115. _C.93='15DA2D49'x
  3116. _C.94='8CD37CF3'x
  3117. _C.95='FBD44C65'x
  3118. _C.96='4DB26158'x
  3119. _C.97='3AB551CE'x
  3120. _C.98='A3BC0074'x
  3121. _C.99='D4BB30E2'x
  3122. _C.100='4ADFA541'x
  3123. _C.101='3DD895D7'x
  3124. _C.102='A4D1C46D'x
  3125. _C.103='D3D6F4FB'x
  3126. _C.104='4369E96A'x
  3127. _C.105='346ED9FC'x
  3128. _C.106='AD678846'x
  3129. _C.107='DA60B8D0'x
  3130. _C.108='44042D73'x
  3131. _C.109='33031DE5'x
  3132. _C.110='AA0A4C5F'x
  3133. _C.111='DD0D7CC9'x
  3134. _C.112='5005713C'x
  3135. _C.113='270241AA'x
  3136. _C.114='BE0B1010'x
  3137. _C.115='C90C2086'x
  3138. _C.116='5768B525'x
  3139. _C.117='206F85B3'x
  3140. _C.118='B966D409'x
  3141. _C.119='CE61E49F'x
  3142. _C.120='5EDEF90E'x
  3143. _C.121='29D9C998'x
  3144. _C.122='B0D09822'x
  3145. _C.123='C7D7A8B4'x
  3146. _C.124='59B33D17'x
  3147. _C.125='2EB40D81'x
  3148. _C.126='B7BD5C3B'x
  3149. _C.127='C0BA6CAD'x
  3150. _C.128='EDB88320'x
  3151. _C.129='9ABFB3B6'x
  3152. _C.130='03B6E20C'x
  3153. _C.131='74B1D29A'x
  3154. _C.132='EAD54739'x
  3155. _C.133='9DD277AF'x
  3156. _C.134='04DB2615'x
  3157. _C.135='73DC1683'x
  3158. _C.136='E3630B12'x
  3159. _C.137='94643B84'x
  3160. _C.138='0D6D6A3E'x
  3161. _C.139='7A6A5AA8'x
  3162. _C.140='E40ECF0B'x
  3163. _C.141='9309FF9D'x
  3164. _C.142='0A00AE27'x
  3165. _C.143='7D079EB1'x
  3166. _C.144='F00F9344'x
  3167. _C.145='8708A3D2'x
  3168. _C.146='1E01F268'x
  3169. _C.147='6906C2FE'x
  3170. _C.148='F762575D'x
  3171. _C.149='806567CB'x
  3172. _C.150='196C3671'x
  3173. _C.151='6E6B06E7'x
  3174. _C.152='FED41B76'x
  3175. _C.153='89D32BE0'x
  3176. _C.154='10DA7A5A'x
  3177. _C.155='67DD4ACC'x
  3178. _C.156='F9B9DF6F'x
  3179. _C.157='8EBEEFF9'x
  3180. _C.158='17B7BE43'x
  3181. _C.159='60B08ED5'x
  3182. _C.160='D6D6A3E8'x
  3183. _C.161='A1D1937E'x
  3184. _C.162='38D8C2C4'x
  3185. _C.163='4FDFF252'x
  3186. _C.164='D1BB67F1'x
  3187. _C.165='A6BC5767'x
  3188. _C.166='3FB506DD'x
  3189. _C.167='48B2364B'x
  3190. _C.168='D80D2BDA'x
  3191. _C.169='AF0A1B4C'x
  3192. _C.170='36034AF6'x
  3193. _C.171='41047A60'x
  3194. _C.172='DF60EFC3'x
  3195. _C.173='A867DF55'x
  3196. _C.174='316E8EEF'x
  3197. _C.175='4669BE79'x
  3198. _C.176='CB61B38C'x
  3199. _C.177='BC66831A'x
  3200. _C.178='256FD2A0'x
  3201. _C.179='5268E236'x
  3202. _C.180='CC0C7795'x
  3203. _C.181='BB0B4703'x
  3204. _C.182='220216B9'x
  3205. _C.183='5505262F'x
  3206. _C.184='C5BA3BBE'x
  3207. _C.185='B2BD0B28'x
  3208. _C.186='2BB45A92'x
  3209. _C.187='5CB36A04'x
  3210. _C.188='C2D7FFA7'x
  3211. _C.189='B5D0CF31'x
  3212. _C.190='2CD99E8B'x
  3213. _C.191='5BDEAE1D'x
  3214. _C.192='9B64C2B0'x
  3215. _C.193='EC63F226'x
  3216. _C.194='756AA39C'x
  3217. _C.195='026D930A'x
  3218. _C.196='9C0906A9'x
  3219. _C.197='EB0E363F'x
  3220. _C.198='72076785'x
  3221. _C.199='05005713'x
  3222. _C.200='95BF4A82'x
  3223. _C.201='E2B87A14'x
  3224. _C.202='7BB12BAE'x
  3225. _C.203='0CB61B38'x
  3226. _C.204='92D28E9B'x
  3227. _C.205='E5D5BE0D'x
  3228. _C.206='7CDCEFB7'x
  3229. _C.207='0BDBDF21'x
  3230. _C.208='86D3D2D4'x
  3231. _C.209='F1D4E242'x
  3232. _C.210='68DDB3F8'x
  3233. _C.211='1FDA836E'x
  3234. _C.212='81BE16CD'x
  3235. _C.213='F6B9265B'x
  3236. _C.214='6FB077E1'x
  3237. _C.215='18B74777'x
  3238. _C.216='88085AE6'x
  3239. _C.217='FF0F6A70'x
  3240. _C.218='66063BCA'x
  3241. _C.219='11010B5C'x
  3242. _C.220='8F659EFF'x
  3243. _C.221='F862AE69'x
  3244. _C.222='616BFFD3'x
  3245. _C.223='166CCF45'x
  3246. _C.224='A00AE278'x
  3247. _C.225='D70DD2EE'x
  3248. _C.226='4E048354'x
  3249. _C.227='3903B3C2'x
  3250. _C.228='A7672661'x
  3251. _C.229='D06016F7'x
  3252. _C.230='4969474D'x
  3253. _C.231='3E6E77DB'x
  3254. _C.232='AED16A4A'x
  3255. _C.233='D9D65ADC'x
  3256. _C.234='40DF0B66'x
  3257. _C.235='37D83BF0'x
  3258. _C.236='A9BCAE53'x
  3259. _C.237='DEBB9EC5'x
  3260. _C.238='47B2CF7F'x
  3261. _C.239='30B5FFE9'x
  3262. _C.240='BDBDF21C'x
  3263. _C.241='CABAC28A'x
  3264. _C.242='53B39330'x
  3265. _C.243='24B4A3A6'x
  3266. _C.244='BAD03605'x
  3267. _C.245='CDD70693'x
  3268. _C.246='54DE5729'x
  3269. _C.247='23D967BF'x
  3270. _C.248='B3667A2E'x
  3271. _C.249='C4614AB8'x
  3272. _C.250='5D681B02'x
  3273. _C.251='2A6F2B94'x
  3274. _C.252='B40BBE37'x
  3275. _C.253='C30C8EA1'x
  3276. _C.254='5A05DF1B'x
  3277. _C.255='2D02EF8D'x
  3278. signal CRC32REX_16
  3279.  
  3280. Crc32PrePostConditioning:call TRACE "OFF"
  3281. if arg(1)='' then
  3282. return('FFFFFFFF'x)
  3283. else
  3284. return(bitxor(arg(1), 'FFFFFFFF'x))
  3285.  
  3286. UpdateCrc32:call TRACE "OFF"
  3287. q_Crc=arg(1)
  3288. q_Buffer=arg(2)
  3289. q_BufferLng=length(q_Buffer)
  3290. do while q_BufferLng<>0
  3291. if q_BufferLng<=2000 then
  3292. do
  3293. q_UseSize=q_BufferLng
  3294. q_PerfBuffer=q_Buffer
  3295. end
  3296. else
  3297. do
  3298. q_UseSize=2000
  3299. q_PerfBuffer=left(q_Buffer,q_UseSize)
  3300. q_Buffer=substr(q_Buffer,q_UseSize+1)
  3301. end
  3302. q_BufferLng=q_BufferLng-q_UseSize
  3303. do q_ThisByte=1 to q_UseSize
  3304. q_ArrayEl=c2d(right(bitand(bitxor(q_Crc, '000000'x || substr(q_PerfBuffer, q_ThisByte, 1)), '000000FF'x),1))
  3305. q_Crc=Bitxor(bitand('00'x || left(q_Crc, 3), '00FFFFFF'x),_C.q_ArrayEl)
  3306. end
  3307. end
  3308. return(q_Crc)
  3309.  
  3310. Crc32InDisplayableForm:call TRACE "OFF"
  3311. return(c2x(arg(1)))
  3312.  
  3313. CRC32REX_16:
  3314. signal EndBASEDATEXh
  3315.  
  3316. BaseDate:procedure;call TRACE "OFF"
  3317. TheDate=translate(arg(1), ' ', '/-')
  3318. if TheDate='' then
  3319. TheDate=date('Sorted')
  3320. parse var TheDate Year MM DD
  3321. if length(Year)>=8 then
  3322. do
  3323. DD=substr(Year,7,2)
  3324. MM=substr(Year,5,2)
  3325. Year=left(Year,4)
  3326. end
  3327. DaysInMonth='31  28  31  30  31  30  31  31  30  31  30  31'
  3328. if datatype(Year, 'WholeNumber')<>1 then
  3329. return(-10)
  3330. if datatype(MM, 'WholeNumber')<>1 then
  3331. return(-20)
  3332. if datatype(DD, 'WholeNumber')<>1 then
  3333. return(-30)
  3334. if MM<0|MM>12 then
  3335. return(-21)
  3336. DaysThisMonth=word(DaysInMonth,MM)
  3337. if MM=2 then
  3338. DaysThisMonth=DaysThisMonth+1
  3339. if DD<0|DD>DaysThisMonth then
  3340. return(-31)
  3341. if length(strip(Year))=2 then
  3342. do
  3343. if Year>=80 then
  3344. Year='19' ||Year
  3345. else
  3346. Year='20' ||Year
  3347. end
  3348. y=Year;m=MM;d=DD
  3349. z=y+(m-14)%12
  3350. f=word('306 337 0 31 61 92 122 153 184 214 245 275',m)
  3351. b=d+f+365*z+z%4-z%100+z%400-307
  3352. return(b)
  3353.  
  3354. BD2DATE:procedure;call TRACE "OFF"
  3355. parse arg rd,Format,Delimiter
  3356. z=rd+307
  3357. h=100*z-25
  3358. a=h%3652425
  3359. b=a-a%4
  3360. year=(100*b+h)%36525
  3361. c=b+z-365*year-year%4
  3362. month=(5*c+456)%153
  3363. day=c-word('0 31 61 92 122 153 184 214 245 275 306 337',month-2)
  3364. if month>12 then
  3365. do
  3366. year=year+1
  3367. month=month-12
  3368. end
  3369. yyyy=right(year,4, '0')
  3370. mm=right(month,2, '0')
  3371. dd=right(day,2, '0')
  3372. return(yyyy||Delimiter||mm||Delimiter||dd)
  3373.  
  3374. EndBASEDATEXh:
  3375. signal PREFIX_17
  3376.  
  3377. HASHPREFIX_DEBUG:
  3378. if OptionDebugOn='Y' then
  3379. call OptionDebugShow 'HASHPREFIX', 'Hash prefix is now "' || HashPrefix || '" (' || HashPrefix || 'define etc)'
  3380. return
  3381.  
  3382. HASHPREFIX_GET:
  3383. call HASHPREFIX_DEBUG
  3384. return(HashPrefix)
  3385.  
  3386. HASHPREFIX_SET:
  3387. HashPrefix=arg(1)
  3388. if ProcessedCmdLine='N' then
  3389. do
  3390. call OptionDebugShow 'HASHPREFIX', 'Setting default value of hash Prefix to "' || HashPrefix || '"'
  3391. Default4_HashPrefix=HashPrefix
  3392. return(0)
  3393. end
  3394. if HashPrefix=='' then
  3395. HashPrefix=Default4_HashPrefix
  3396. AfterPrefix=translate(HashPrefix, '',LowerCase)
  3397. if AfterPrefix<>HashPrefix then
  3398. CryAndDie('A hash prefix should not include lower case characters!')
  3399. HashPrefixLng=length(HashPrefix)
  3400. call HASHPREFIX_DEBUG
  3401. CmdHashAsIs=HashPrefix|| 'ASIS'
  3402. CmdHashAutoTag=HashPrefix|| 'AUTOTAG'
  3403. CmdHashAutoTagClear=HashPrefix|| 'AUTOTAGCLEAR'
  3404. CmdHashAutoTagState=HashPrefix|| 'AUTOTAGSTATE'
  3405. CmdHashLoopBreak=HashPrefix|| 'BREAK'
  3406. CmdHashLoopContinue=HashPrefix|| 'CONTINUE'
  3407. CmdHashDebug=HashPrefix|| 'DEBUG'
  3408. CmdHashDefine=HashPrefix|| 'DEFINE'
  3409. CmdHashDefinePlus=HashPrefix|| 'DEFINE+'
  3410. CmdHashDefineIfReq=HashPrefix|| 'DEFINE?'
  3411. CmdHashDefineRexx=HashPrefix|| 'DEFINEREXX'
  3412. CmdHashDefineRexxPlus=HashPrefix|| 'DEFINEREXX+'
  3413. CmdHashDependsOn=HashPrefix|| 'DEPENDSON'
  3414. CmdHashElseifL=HashPrefix|| 'ELSEIF'
  3415. CmdHashEndifL=HashPrefix|| 'ENDIF'
  3416. CmdHashEof=HashPrefix|| 'EOF'
  3417. CmdHashErrorL=HashPrefix|| 'ERROR'
  3418. CmdHashEvaluateL=HashPrefix|| 'EVALUATE'
  3419. CmdHashEvaluatePlusL=HashPrefix|| 'EVALUATE+'
  3420. CmdHashIf=HashPrefix|| 'IF'
  3421. CmdHashIfdef=HashPrefix|| 'IFDEF'
  3422. CmdHashIfndef=HashPrefix|| 'IFNDEF'
  3423. CmdHashImport=HashPrefix|| 'IMPORT'
  3424. CmdHashInclude=HashPrefix|| 'INCLUDE'
  3425. CmdHashInfo=HashPrefix|| 'INFO'
  3426. CmdHashIntercept=HashPrefix|| 'INTERCEPT'
  3427. CmdHashMacroSpace=HashPrefix|| 'MACROSPACE'
  3428. CmdHashNextId=HashPrefix|| 'NEXTID'
  3429. CmdHashOnExit=HashPrefix|| 'ONEXIT'
  3430. CmdHashOption=HashPrefix|| 'OPTION'
  3431. CmdHashOutput=HashPrefix|| 'OUTPUT'
  3432. CmdHashOutputHold=HashPrefix|| 'OUTPUTHOLD'
  3433. CmdHashPush=HashPrefix|| 'PUSH'
  3434. CmdHashPop=HashPrefix|| 'POP'
  3435. CmdHashRequire=HashPrefix|| 'REQUIRE'
  3436. CmdHashSystem=HashPrefix|| 'SYSTEM'
  3437. CmdHashTransform=HashPrefix|| 'TRANSFORM'
  3438. CmdHashRexxVar=HashPrefix|| 'REXXVAR'
  3439. CmdHashUndefL=HashPrefix|| 'UNDEF'
  3440. CmdHashWarningL=HashPrefix|| 'WARNING'
  3441. CmdHashLoopS=HashPrefix|| '{'
  3442. CmdHashLoopE=HashPrefix|| '}'
  3443. CmdHash1Line=HashPrefix|| '('
  3444. CmdHash1LineEnd=HashPrefix|| ')'
  3445. CmdHashOneLine=HashPrefix|| 'ONELINE'
  3446. CmdHashEvaluateS=HashPrefix|| 'E'
  3447. CmdHashEvaluatePlusS=HashPrefix|| 'E+'
  3448. CmdHashUndefS=HashPrefix|| 'U'
  3449. CmdHashElseifS=HashPrefix|| 'ELSE'
  3450. CmdHashEndifS=HashPrefix|| 'END'
  3451. CmdHashErrorS=HashPrefix|| '!'
  3452. CmdHashWarningS=HashPrefix|| 'W'
  3453. return
  3454.  
  3455. PREFIX_17:
  3456. signal LineCmt_18
  3457.  
  3458. LINECOMMENT_DEBUG:
  3459. if OptionDebugOn='Y' then
  3460. do
  3461. if LineComment<>NullChar then
  3462. call OptionDebugShow 'LINECOMMENT', 'Lines starting with "' || LineComment || '" are comments ("' || InLineComment || '" for inline comments)'
  3463. else
  3464. call OptionDebugShow 'LINECOMMENT', 'Comment removal has been turned off'
  3465. end
  3466. return
  3467.  
  3468. LINECOMMENT_GET:
  3469. call LINECOMMENT_DEBUG
  3470. return(LineCommentSet2)
  3471.  
  3472. LINECOMMENT_SET:
  3473. LineComment=arg(1)
  3474. LineCommentSet2=LineComment
  3475. if ProcessedCmdLine='N' then
  3476. do
  3477. call OptionDebugShow 'LINECOMMENT', 'Setting default value of line comment to "' || LineComment || '"'
  3478. Default4_LineComment=LineComment
  3479. return(0)
  3480. end
  3481. if LineComment=='' then
  3482. LineComment=Default4_LineComment
  3483. if translate(LineComment)='NULL' then
  3484. LineComment=NullChar
  3485. else
  3486. do
  3487. if length(LineComment)<>1 then
  3488. CryAndDie('A comment char should be one character long')
  3489. end
  3490. InLineComment=LineComment||LineComment
  3491. call LINECOMMENT_DEBUG
  3492. return
  3493.  
  3494. LineCmt_18:
  3495. signal WhiteSpc_19
  3496.  
  3497. _WsFmt:
  3498. dbgExtra=''
  3499. do CharIndex=1 to length(ExtraWhiteSpace)
  3500. if CharIndex<>1 then
  3501. dbgExtra=dbgExtra|| ', '
  3502. dbgExtra=dbgExtra||c2x(substr(ExtraWhiteSpace,CharIndex,1))
  3503. end
  3504. return(dbgExtra)
  3505.  
  3506. WHITESPACE_DEBUG:
  3507. if OptionDebugOn='Y' then
  3508. do
  3509. if ExtraWhiteSpace=='' then
  3510. call OptionDebugShow 'WHITESPACE', 'No extra whitespace characters defined'
  3511. else
  3512. call OptionDebugShow 'WHITESPACE', 'Extra whitespace characters are hexadecimal ' ||_WsFmt()
  3513. end
  3514. return
  3515.  
  3516. WHITESPACE_GET:
  3517. call WHITESPACE_DEBUG
  3518. return(ExtraWhiteSpace)
  3519.  
  3520. WHITESPACE_SET:
  3521. ExtraWhiteSpace=arg(1)
  3522. if ProcessedCmdLine='N' then
  3523. do
  3524. Default4_ExtraWhiteSpace=ExtraWhiteSpace
  3525. if ExtraWhiteSpace=='' then
  3526. call OptionDebugShow 'WHITESPACE', 'Setting default to no extra whitespace'
  3527. else
  3528. call OptionDebugShow 'WHITESPACE', 'Setting default to extra whitespace characters are hexadecimal ' ||_WsFmt()
  3529. return(0)
  3530. end
  3531. if ExtraWhiteSpace=='NULL' then
  3532. ExtraWhiteSpace=Default4_ExtraWhiteSpace
  3533. call WHITESPACE_DEBUG
  3534. return
  3535.  
  3536. WhiteSpc_19:
  3537. signal LineCont_20
  3538.  
  3539. LINECONTINUATION_DEBUG:
  3540. if OptionDebugOn='Y' then
  3541. do
  3542. if LineContChar=NullChar then
  3543. call OptionDebugShow 'LINECONTINUATION', 'Line continuation handling has been turned off'
  3544. else
  3545. do
  3546. call OptionDebugShow 'LINECONTINUATION', 'The line continuation marker is now "' || LineContChar || '"'
  3547. if symbol('CodexNewLine') = 'VAR' then
  3548. DbgText='"' || CodexNewLine || '"'
  3549. else
  3550. DbgText="'X' code for newline"
  3551. call DBGIND 1
  3552. call DBG '"' || LineContAddNewLine   || '" = Join with    ' ||DbgText
  3553. call DBG '"' || LineContWithoutSpace || '" = Join without space'
  3554. call DBG '"' || LineContWithSpace    || '" = Join with    space'
  3555. call DBG '"' || LineContDefault      || '" = Join with    space'
  3556. call DBGIND-1
  3557. end
  3558. end
  3559. return
  3560.  
  3561. LINECONTINUATION_GET:
  3562. call LINECONTINUATION_DEBUG
  3563. return(LineContCharList)
  3564.  
  3565. LINECONTINUATION_SET:
  3566. LineContParm=arg(1)
  3567. LineContParmSet2=LineContParm
  3568. if ProcessedCmdLine='N' then
  3569. do
  3570. call OptionDebugShow 'LINECONTINUATION', 'Setting default value of line continuation chars to "' || LineContParm || '"'
  3571. Default4_LineContParm=LineContParm
  3572. LineContCharList=LineContParm
  3573. return(0)
  3574. end
  3575. if LineContParm=='' then
  3576. LineContParm=Default4_LineContParm
  3577. if translate(LineContParm)='NULL' then
  3578. LineContParm=NullChar
  3579. else
  3580. do
  3581. if length(LineContParm)<>1&length(LineContParm)<>5 then
  3582. CryAndDie('Invalid line continuation spec of "' || LineContParm || '"')
  3583. end
  3584. LineContCharList=overlay(LineContParm,LineContCharList)
  3585. LineContChar=substr(LineContCharList,1,1)
  3586. LineContAddNewLine=substr(LineContCharList,2,1)||LineContChar
  3587. LineContAddNewLineObs=d2c(25)||LineContChar
  3588. LineContWithoutSpace=substr(LineContCharList,3,1)||LineContChar
  3589. LineContWithSpace=substr(LineContCharList,4,1)||LineContChar
  3590. LineContDefault=substr(LineContCharList,5,1)||LineContChar
  3591. call LINECONTINUATION_DEBUG
  3592. return
  3593.  
  3594. LineCont_20:
  3595. AsIsCount=0
  3596. AsIsUsing=''
  3597. signal AsIs_21
  3598.  
  3599. AsIsPrepare:call TRACE "OFF"
  3600. AsIsParms=space(arg(1))
  3601. AsIsUsing=AsIsParms
  3602. AsIsCount=0
  3603. AsIsIndex=0
  3604. AsIsCollecting=''
  3605. call DBG_ASIS 'AsIsPrepare(): Cleared memory. Processing "' || AsIsUsing || '"'
  3606. call DBGIND 1
  3607. aiOptCnt=0
  3608. do while AsIsParms<> ''
  3609. call _SetUpAsIsTagging translate(GetQuotedText(AsIsParms, "AsIsParms"))
  3610. end
  3611. if AsIsCount<>0 then
  3612. do
  3613. if aiOptCnt=0 then
  3614. aiMsg='none'
  3615. else
  3616. do
  3617. if aiOptCnt=AsIsCount then
  3618. aiMsg='all'
  3619. else
  3620. aiMsg=aiOptCnt
  3621. end
  3622. call DBG_ASIS 'Have ' || AsIsCount || ' "as is" tags (' || aiMsg || ' optimised)'
  3623. end
  3624. call DBGIND-1
  3625. return(AsIsCount)
  3626.  
  3627. ExpandAsIsTags:
  3628. if AsIsModeOn='N' then
  3629. return(arg(1))
  3630.  
  3631. AsIs:call TRACE "OFF"
  3632. if AsIsCount=0 then
  3633. return(arg(1))
  3634. EaiString=arg(1)
  3635. AsIsCnt=ReplaceCount
  3636. do Tag=1 to AsIsIndex
  3637. if AsIsBef.Tag=='' then
  3638. EaiString=BulkChar2String(EaiString,AsIsAft.Tag)
  3639. else
  3640. do
  3641. if left(AsIsBef.Tag,2)<>SrTypePre then
  3642. EaiString=ReplaceString(EaiString,AsIsBef.Tag,AsIsAft.Tag)
  3643. else
  3644. do
  3645. select
  3646. when abbrev(AsIsBef.Tag,SrCaseIns)then
  3647. EaiString=ReplaceStringCI(EaiString,substr(AsIsBef.Tag,SrCaseIns_P),AsIsAft.Tag)
  3648. when abbrev(AsIsBef.Tag,SrFixed)then
  3649. EaiString=CompareReplaceFixed2(EaiString,substr(AsIsBef.Tag,SrFixed_P),AsIsAft.Tag)
  3650. otherwise
  3651. EaiString=ReplaceString(EaiString,AsIsBef.Tag,AsIsAft.Tag)
  3652. end
  3653. end
  3654. end
  3655. end
  3656. if OptionDebugOn='Y' then
  3657. do
  3658. if AsIsCnt<>ReplaceCount then
  3659. call DebugOutputAfterReplacement EaiString, 'ASIS'
  3660. end
  3661. return(EaiString)
  3662.  
  3663. ProcessAsIs:
  3664. HashCmdParms=PerformReplacementsInCmdsParameters(arg(1))
  3665. AsIsCmd=translate(GetQuotedText(HashCmdParms, "AsIsParms"))
  3666. if AsIsCmd='SETUP' then
  3667. do
  3668. AsIsPrepCache='?'
  3669. call SetupNamedAsIsStorage GetQuotedText(AsIsParms)
  3670. return(0)
  3671. end
  3672. call SetOnorOffVariable AsIsCmd, 'AsIsModeOn'
  3673. if AsIsModeOn='N' then
  3674. do
  3675. AsIsCount=0
  3676. if AsIsParms<> '' then
  3677. CryAndDie('Did not expect more than the "OFF" parameter')
  3678. call OptionsPop
  3679. end
  3680. else
  3681. do
  3682. call OptionsPush
  3683. call OptionOnOrOff_SET "KEEPINDENT",      "KeepIndent",      "ON"
  3684. call OptionOnOrOff_SET "LEAVEBLANKLINES", "LeaveBlankLines", "ON"
  3685. call LINECOMMENT_SET "NULL"
  3686. call LINECONTINUATION_SET "NULL"
  3687. call AsIsPrepare AsIsParms
  3688. end
  3689. if OptionDebugOn='Y' then
  3690. do
  3691. if AsIsCount=0 then
  3692. call DBG_ASIS 'AsIs mode is ' || YorN2OnorOff(AsIsModeOn) || '.  No tags prepared.'
  3693. else
  3694. call DBG_ASIS 'AsIs mode is ' || YorN2OnorOff(AsIsModeOn) || '.  Have ' || AsIsCount || ' tags from "' || AsIsUsing || '"'
  3695. end
  3696. return(0)
  3697.  
  3698. SetupNamedAsIsStorage:
  3699. AsIsNameU=translate(arg(1))
  3700. AsIsName='AI_' ||c2x(AsIsNameU)
  3701. AsIsAltCnt=arg(2)
  3702. AsIsCounter=0
  3703. if AsIsAltCnt='' then
  3704. do
  3705. TagFrom=AutoTagFirst
  3706. TagTo=AutoTagLast
  3707. end
  3708. else
  3709. do
  3710. TagFrom=1
  3711. TagTo=AsIsAltCnt
  3712. end
  3713. do Tag=TagFrom to TagTo
  3714. AsIsCounter=AsIsCounter+1
  3715. if AsIsAltCnt='' then
  3716. do
  3717. AsIsBef.AsIsCounter.AsIsName=AutoTagOnB.Tag
  3718. AsIsAft.AsIsCounter.AsIsName=AutoTagOnA.Tag
  3719. end
  3720. else
  3721. do
  3722. AsIsBef.AsIsCounter.AsIsName=ImportB.Tag
  3723. AsIsAft.AsIsCounter.AsIsName=ImportA.Tag
  3724. end
  3725. end
  3726. call _valueS AsIsName,AsIsCounter
  3727. if AsIsAltCnt='' then
  3728. call ClearAutoTags 'N'
  3729. call DBG_ASIS 'Captured ' || AsIsCounter || ' tags as "' || AsIsNameU || '"'
  3730. return
  3731.  
  3732. _SetUpAsIsTagging:
  3733. AsIsNameU=translate(arg(1))
  3734. AsIsName='AI_' ||c2x(AsIsNameU)
  3735. call DBG_ASIS 'Getting tags from storage named "' || AsIsNameU || '"'
  3736. call DBGIND 1
  3737. if symbol(AsIsName)<> 'VAR' then
  3738. CryAndDie('#AsIs "SETUP" has not been run for "' || AsIsNameU || '"')
  3739. AsIsCopyCount=_valueG(AsIsName)
  3740. do Index=1 to AsIsCopyCount
  3741. ThisBefore=AsIsBef.Index.AsIsName
  3742. ThisAfter=AsIsAft.Index.AsIsName
  3743. AsIsCount=AsIsCount+1
  3744. call DBG_ASIS 'AsIs #' || AsIsCount || ': From=' || DebugRightArrow || ThisBefore || DebugLeftArrow || ',  To=' ||DebugRightArrow||ThisAfter||DebugLeftArrow
  3745. if length(ThisBefore)<>1 then
  3746. do
  3747. AsIsCollecting=''
  3748. AsIsIndex=AsIsIndex+1
  3749. AsIsBef.AsIsIndex=ThisBefore
  3750. AsIsAft.AsIsIndex=ThisAfter
  3751. end
  3752. else
  3753. do
  3754. if AsIsCollecting=='' then
  3755. do
  3756. AsIsCollecting='OptAsIs' ||AsIsIndex
  3757. call _valueS AsIsCollecting, ''
  3758. AsIsIndex=AsIsIndex+1
  3759. AsIsBef.AsIsIndex=''
  3760. AsIsAft.AsIsIndex=AsIsCollecting
  3761. end
  3762. aiOptCnt=aiOptCnt+1
  3763. aiOptList=_valueG(AsIsCollecting)||ThisBefore
  3764. aiIndex=length(aiOptList)
  3765. call _valueS AsIsCollecting,aiOptList
  3766. call _valueS AsIsCollecting|| '.' ||aiIndex,ThisAfter
  3767. end
  3768. end
  3769. call DBG_ASIS 'Copied ' || AsIsCopyCount || ' tags'
  3770. call DBGIND-1
  3771. return
  3772.  
  3773. AsIs_21:
  3774. AtChangeType=''
  3775. AtChangeTypeDesc="CASESENSITIVE"
  3776. signal AutoTag_22
  3777.  
  3778. ShowAutoTagStateWhenDebugOn:
  3779. if OptionDebugOn='Y' then
  3780. do
  3781. if AutoTagName='' then
  3782. DbgText1=''
  3783. else
  3784. DbgText1=' (named "' || AutoTagName || '")'
  3785. call DBG_AUTOTAG 'AutoTagging is ' || YorN2OnorOff(AutoTagOn) || '.  Have ' || ((AutoTagLast - AutoTagFirst) + 1) || ' tags available in state #' ||AutoTagStateCnt||DbgText1
  3786. if arg(1)='Y' then
  3787. do
  3788. call DBGIND 1
  3789. do Tag=AutoTagFirst to AutoTagLast
  3790. call DBG_AUTOTAG 'AutoTag #' || Tag || ': From=' || DebugRightArrow || AutoTagOnB.Tag || DebugLeftArrow || ',  To=' ||DebugRightArrow||AutoTagOnA.Tag||DebugLeftArrow
  3791. end
  3792. call DBGIND-1
  3793. end
  3794. end
  3795. return
  3796.  
  3797. CompletelyInitializeAutoTagState:
  3798. AutoTagOn='N'
  3799. call ClearAutoTags 'Y'
  3800. return
  3801.  
  3802. ClearAutoTags:
  3803. if arg(1)='N' then
  3804. do
  3805. if AutoTagStateCnt=0 then
  3806. AutoTagLast=0
  3807. else
  3808. AutoTagLast=AutoTagState.AutoTagStateCnt.Last
  3809. end
  3810. else
  3811. do
  3812. AutoTagLast=0
  3813. AutoTagStateCnt=0
  3814. AutoTagFirst=1
  3815. AutoTagName=''
  3816. end
  3817. if OptionDebugOn='Y' then
  3818. do
  3819. if AutoTagStateCnt=0 then
  3820. call DBG_AUTOTAG 'Cleared ALL autotags (no state information saved - State #0).'
  3821. else
  3822. call ShowAutoTagStateWhenDebugOn
  3823. end
  3824. return
  3825.  
  3826. AutoTag:call TRACE "OFF"
  3827. EatString=arg(1)
  3828. if AutoTagFirst>AutoTagLast then
  3829. return(EatString)
  3830. AtCnt=ReplaceCount
  3831. do Tag=AutoTagFirst to AutoTagLast
  3832. if left(AutoTagOnB.Tag,2)<>SrTypePre then
  3833. EatString=ReplaceString(EatString,AutoTagOnB.Tag,AutoTagOnA.Tag)
  3834. else
  3835. do
  3836. select
  3837. when abbrev(AutoTagOnB.Tag,SrCaseIns)then
  3838. EatString=ReplaceStringCI(EatString,substr(AutoTagOnB.Tag,SrCaseIns_P),AutoTagOnA.Tag)
  3839. when abbrev(AutoTagOnB.Tag,SrFixed)then
  3840. EatString=CompareReplaceFixed2(EatString,substr(AutoTagOnB.Tag,SrFixed_P),AutoTagOnA.Tag)
  3841. otherwise
  3842. EatString=ReplaceString(EatString,AutoTagOnB.Tag,AutoTagOnA.Tag)
  3843. end
  3844. end
  3845. end
  3846. if OptionDebugOn='Y' then
  3847. do
  3848. if AtCnt<>ReplaceCount then
  3849. call DebugOutputAfterReplacement EatString, 'ATAG'
  3850. end
  3851. return(EatString)
  3852.  
  3853. ProcessAutoTagClear:
  3854. if arg(1)='' then
  3855. AtClearAll='N'
  3856. else
  3857. do
  3858. AtParm=GetQuotedText(arg(1))
  3859. if translate(AtParm)<> 'ALL' then
  3860. CryAndDie('Invalid parameter of "' || AtParm || '" specified!')
  3861. AtClearAll='Y'
  3862. end
  3863. call ClearAutoTags AtClearAll
  3864. return(0)
  3865.  
  3866. _GetStateIndexForNameOrDie:
  3867. gsiName=arg(1)
  3868. do NameIndex=1 to AutoTagStateCnt
  3869. if gsiName=AutoTagState.NameIndex.Name then
  3870. return(NameIndex)
  3871. end
  3872. CryAndDie('There is no state known as "' || gsiName(1) || '"')
  3873.  
  3874. MatchesAutoTagStateIncDebugText:
  3875. MatchIndex=arg(1)
  3876. if MatchIndex<=0 then
  3877. return('')
  3878. else
  3879. return(' (matches "#AutoTagState +" at ' || AutoTagState.MatchIndex.AtLine || ')')
  3880.  
  3881. ProcessAutoTagState:
  3882. Rest=strip(arg(1))
  3883. Ats1stParm=left(Rest,1)
  3884. if Ats1stParm='+' | Ats1stParm = '-' then
  3885. Rest=substr(Rest,2)
  3886. else
  3887. Ats1stParm=GetQuotedText(arg(1), "Rest")
  3888. select
  3889. when Ats1stParm='+' then
  3890. do
  3891. AutoTagStateCnt=AutoTagStateCnt+1
  3892. AutoTagState.AutoTagStateCnt.First=AutoTagFirst
  3893. AutoTagState.AutoTagStateCnt.Last=AutoTagLast
  3894. AutoTagState.AutoTagStateCnt.Name=AutoTagName
  3895. AutoTagState.AutoTagStateCnt.AtOnOff=AutoTagOn
  3896. AutoTagState.AutoTagStateCnt.AtLine=CurrentSourceLocation()
  3897. BeforeFirst=AutoTagFirst
  3898. BeforeLast=AutoTagLast
  3899. AutoTagFirst=AutoTagLast+1
  3900. AutoTagName=''
  3901. do while Rest<> ''
  3902. StateAlias=translate(GetQuotedText(Rest, "Rest"))
  3903. if StateAlias="REMEMBER" then
  3904. do
  3905. CopyFrom=BeforeFirst
  3906. Copyto=BeforeLast
  3907. end
  3908. else
  3909. do
  3910. NameIndex=_GetStateIndexForNameOrDie(StateAlias)
  3911. CopyFrom=AutoTagState.NameIndex.First
  3912. Copyto=AutoTagState.NameIndex.Last
  3913. end
  3914. do AddTagIndex=CopyFrom to CopyTo
  3915. call _AddAutoTag AutoTagOnB.AddTagIndex,AutoTagOnA.AddTagIndex
  3916. end
  3917. end
  3918. if OptionDebugOn='Y' then
  3919. call DBG_AUTOTAG 'Remembering current #AutoTag state, now in state #' ||AutoTagStateCnt
  3920. end
  3921. when Ats1stParm='-' then
  3922. do
  3923. if AutoTagStateCnt<=0 then
  3924. CryAndDie('No #autotag states memorised!')
  3925. if OptionDebugOn='Y' then
  3926. call DBG_AUTOTAG 'This restore matches the setup at ' ||AutoTagState.AutoTagStateCnt.AtLine
  3927. BeforeFirst=AutoTagFirst
  3928. BeforeLast=AutoTagLast
  3929. AutoTagFirst=AutoTagState.AutoTagStateCnt.First
  3930. AutoTagLast=AutoTagState.AutoTagStateCnt.Last
  3931. AutoTagOn=AutoTagState.AutoTagStateCnt.AtOnOff
  3932. AutoTagName=AutoTagState.AutoTagStateCnt.Name
  3933. AutoTagStateCnt=AutoTagStateCnt-1
  3934. if Rest='' then
  3935. Remember='N'
  3936. else
  3937. do
  3938. Rest=translate(GetQuotedText(Rest, "Rest"))
  3939. if Rest="REMEMBER" then
  3940. Remember='Y'
  3941. else
  3942. CryAndDie('Invalid parameter of "' || Rest || '" specified (expected "REMEMBER")')
  3943. end
  3944. if Rest='' then
  3945. DbgWord='dropping'
  3946. else
  3947. do
  3948. Rest=translate(GetQuotedText(Rest))
  3949. if Rest<> "REMEMBER" then
  3950. CryAndDie('Invalid parameter of "' || Rest || '" specified (expected "REMEMBER")')
  3951. DbgWord='remembering'
  3952. AutoTagLast=AutoTagFirst-1
  3953. do AddTagIndex=BeforeFirst to BeforeLast
  3954. call _AddAutoTag AutoTagOnB.AddTagIndex,AutoTagOnA.AddTagIndex
  3955. end
  3956. end
  3957. if OptionDebugOn='Y' then
  3958. call DBG_AUTOTAG 'Restoring #AutoTag state #' || AutoTagStateCnt || ', we are ' || DbgWord || ' any new tags you may have defined'
  3959. end
  3960. otherwise
  3961. AutoTagName=translate(Ats1stParm)
  3962. if Rest<> '' then
  3963. call DieIfExtraUnexpectedParms Rest
  3964. if OptionDebugOn='Y' then
  3965. call DBG_AUTOTAG 'This state is now named "' || AutoTagName || '"'
  3966. end
  3967. call ShowAutoTagStateWhenDebugOn AutoTagOn
  3968. return(0)
  3969.  
  3970. _AddAutoTag:
  3971. TheTagB=arg(1)
  3972. TheTagA=arg(2)
  3973. ThePosn=arg(3)
  3974. if ThePosn='' then
  3975. ThePosn='999999'
  3976. ThePosn=(ThePosn+AutoTagFirst)-1
  3977. if ThePosn>AutoTagLast then
  3978. do
  3979. AutoTagLast=AutoTagLast+1
  3980. SlotIndex=AutoTagLast
  3981. end
  3982. else
  3983. do
  3984. ToIndex=AutoTagLast+2
  3985. do MoveIndex=ThePosn to AutoTagLast
  3986. ToIndex=ToIndex-1
  3987. FromIndex=ToIndex-1
  3988. AutoTagOnB.ToIndex=AutoTagOnB.FromIndex
  3989. AutoTagOnA.ToIndex=AutoTagOnA.FromIndex
  3990. end
  3991. SlotIndex=ThePosn
  3992. AutoTagLast=AutoTagLast+1
  3993. end
  3994. AutoTagOnB.SlotIndex=TheTagB
  3995. AutoTagOnA.SlotIndex=TheTagA
  3996. return
  3997.  
  3998. _DeleteAutoTag:
  3999. TheTagB=arg(1)
  4000. do Tag=AutoTagFirst to AutoTagLast
  4001. if TheTagB=AutoTagOnB.Tag then
  4002. do
  4003. AutoTagLast=AutoTagLast-1
  4004. do ToIndex=Tag to AutoTagLast
  4005. FromIndex=ToIndex+1
  4006. AutoTagOnB.ToIndex=AutoTagOnB.FromIndex
  4007. AutoTagOnA.ToIndex=AutoTagOnA.FromIndex
  4008. end
  4009. return('Y')
  4010. end
  4011. end
  4012. if OptionDebugOn='Y' then
  4013. call DBG_AUTOTAG 'No need to delete the tag (it does not exist)'
  4014. return('N')
  4015.  
  4016. ProcessAutoTag:
  4017. AtBefore=GetQuotedText(arg(1), "Rest")
  4018. if AtBefore='' then
  4019. CryAndDie("You did not supply text to be replaced (can't replace empty string)!")
  4020. AtDumpList='N'
  4021. OnOrOff=IsStringOnOrOffCmd(AtBefore)
  4022. if OnOrOff<> '' & Rest = '' then
  4023. do
  4024. AutoTagOn=OnOrOff
  4025. if AutoTagOn='Y' then
  4026. AtDumpList='Y'
  4027. end
  4028. else
  4029. do
  4030. AtBefore_NoCT=AtBefore
  4031. AtBefore=AtChangeType||AtBefore
  4032. if Rest='' then
  4033. call _DeleteAutoTag AtBefore
  4034. else
  4035. do
  4036. AtAfter=ReplaceString(GetQuotedText(Rest, "Rest"),AutoTagSelf,AtBefore_NoCT)
  4037. if ReplacementsAllowed='Y' then
  4038. do
  4039. do while pos(StartsMacroReplacement,AtAfter)<>0
  4040. BeforeCount=ReplaceCount
  4041. AtAfterR=_ReplaceAllHashDefinedVariables(AtAfter)
  4042. if pos(MarksNewLine,AtAfterR)<>0 then
  4043. leave
  4044. AtAfter=AtAfterR
  4045. if OptionDebugOn='Y' then
  4046. do
  4047. if BeforeCount<>ReplaceCount then
  4048. call DebugOutputAfterReplacement AtAfter, 'VP2O'
  4049. end
  4050. end
  4051. if pos(StartsStdSymbolReplacement,AtAfter)<>0 then
  4052. do
  4053. if pos(MarksNewLine,AtAfter)=0 then
  4054. do
  4055. BeforeCount=ReplaceCount
  4056. AtAfterR=ReplaceStandardDefinitions(AtAfter)
  4057. if BeforeCount<>ReplaceCount then
  4058. do
  4059. if pos(MarksNewLine,AtAfterR)=0 then
  4060. do
  4061. AtAfter=AtAfterR
  4062. if OptionDebugOn='Y' then
  4063. call DebugOutputAfterReplacement AtAfter, 'SP2O'
  4064. end
  4065. end
  4066. end
  4067. end
  4068. end
  4069. AtSlot=''
  4070. if Rest<> '' then
  4071. do
  4072. SlotSpec=word(rest,1)
  4073. Rest=subword(rest,2)
  4074. if left(SlotSpec,1)<> '#' then
  4075. CryAndDie('Invalid slot specification of "' || SlotSpec || '" supplied, must begin with a "#"!')
  4076. AtSlot=substr(SlotSpec,2)
  4077. end
  4078. if OptionDebugOn='Y' then
  4079. call DBG_AUTOTAG 'Assigning ' || DebugRightArrow || AtBefore_NoCT || DebugLeftArrow || ' = ' || DebugRightArrow || AtAfter || DebugLeftArrow || ' (TYPE=' || AtChangeTypeDesc || ')'
  4080. call _AddAutoTag AtBefore,AtAfter,AtSlot
  4081. end
  4082. end
  4083. call ShowAutoTagStateWhenDebugOn AtDumpList
  4084. if Rest<> '' then
  4085. CryAndDie('Too many parameters!')
  4086. return(0)
  4087.  
  4088. ATCHANGETYPE_DEBUG:
  4089. if OptionDebugOn='Y' then
  4090. call OptionDebugShow 'ATCHANGETYPE', 'AutoTag change type is "' || AtChangeTypeDesc || '"'
  4091. return
  4092.  
  4093. ATCHANGETYPE_GET:
  4094. call ATCHANGETYPE_DEBUG
  4095. return(AtChangeTypeDesc)
  4096.  
  4097. ATCHANGETYPE_SET:
  4098. AtChangeTypeDesc=translate(arg(1))
  4099. if ProcessedCmdLine='N' then
  4100. do
  4101. call OptionDebugShow 'ATCHANGETYPE', 'Setting default change type to "' || AtChangeTypeDesc || '"'
  4102. Default4_ATCHANGETYPEDESC=AtChangeTypeDesc
  4103. return(0)
  4104. end
  4105. if AtChangeTypeDesc=='' then
  4106. AtChangeTypeDesc=Default4_ATCHANGETYPEDESC
  4107. SelectOn=translate(AtChangeTypeDesc)
  4108. select
  4109. when SelectOn="CASESENSITIVE" then
  4110. AtChangeType=''
  4111. when SelectOn="CASEINSENSITIVE" then
  4112. AtChangeType=SrCaseIns
  4113. when SelectOn="FIXED" then
  4114. AtChangeType=SrFixed
  4115. otherwise
  4116. CryAndDie('Unknown ATCHANGETYPE option of "' || AtChangeTypeDesc || '"')
  4117. end
  4118. call ATCHANGETYPE_DEBUG
  4119. return
  4120.  
  4121. AutoTag_22:
  4122. OptionCount=0
  4123. LongestPpwOptionLng=0
  4124. call _OptionsAdd "ALLOWPACK"
  4125. call _OptionsAdd "ALLOWSPELL"
  4126. call _OptionsAdd "CSREPLACEMENT"
  4127. call _OptionsAdd "DEFINEMACROREPLACE"
  4128. call _OptionsAdd "KEEPINDENT"
  4129. call _OptionsAdd "LEAVEBLANKLINES"
  4130. call _OptionsAdd "REPLACE"
  4131. call _OptionsAdd "ATCHANGETYPE"
  4132. call _OptionsAdd "DEBUGLEVEL"
  4133. call _OptionsAdd "EXTRAINDENT"
  4134. call _OptionsAdd "EXPANDX"
  4135. call _OptionsAdd "HASHPREFIX"
  4136. call _OptionsAdd "LINECOMMENT"
  4137. call _OptionsAdd "LINECONTINUATION"
  4138. call _OptionsAdd "MACROPARMTAGS"
  4139. call _OptionsAdd "PARMVAL"
  4140. call _OptionsAdd "REPLACEMENTTAGS"
  4141. call _OptionsAdd "TABS"
  4142. call _OptionsAdd "WARNINGS"
  4143. call _OptionsAdd "WHITESPACE"
  4144. signal OPTION_23
  4145.  
  4146. _OptionsAdd:
  4147. OptionCount=OptionCount+1
  4148. OptionList.OptionCount=arg(1)
  4149. ThisLng=length(arg(1))
  4150. if ThisLng>LongestPpwOptionLng then
  4151. LongestPpwOptionLng=ThisLng
  4152. return
  4153.  
  4154. SetUpPpwizardOptionDefaults:
  4155. if RexIsAscii='N' then
  4156. DefWhite=''
  4157. else
  4158. do
  4159. if RexSystemOpSys<> "UNIX" then
  4160. DefWhite=d2c(26)||d2c(27)
  4161. else
  4162. DefWhite=d2c(13)||d2c(26)||d2c(27)
  4163. end
  4164. ProcessedCmdLine='N'
  4165. call DBG_OPTIONS 'Setting PPWIZARD defaults (may be overriden with ' || OptChar || 'option switch)'
  4166. call DBGIND 1
  4167. call OptionOnOrOff_SET "ALLOWPACK",          "AllowPack",           "ON"
  4168. call OptionOnOrOff_SET "ALLOWSPELL",         "AllowSpell",          "ON"
  4169. call ATCHANGETYPE_SET "CASESENSITIVE"
  4170. call OptionOnOrOff_SET "CSREPLACEMENT",      "CsReplacement",       "OFF"
  4171. call DEBUGLEVEL_SET 'ALL,-USER1,-USER2'
  4172. call OptionOnOrOff_SET "DEFINEMACROREPLACE", "DefineMacroReplace",  "OFF"
  4173. call EXPANDX_SET 'LATE'
  4174. call EXTRAINDENT_SET 'NULL'
  4175. call HASHPREFIX_SET '#'
  4176. call OptionOnOrOff_SET "KEEPINDENT",         "KeepIndent",          "OFF"
  4177. call OptionOnOrOff_SET "LEAVEBLANKLINES",    "LeaveBlankLines",     "OFF"
  4178. call LINECOMMENT_SET ';'
  4179. call LINECONTINUATION_SET '\%-+ '
  4180. call MACROPARMTAGS_SET '{}$'
  4181. call OptionOnOrOff_SET "REPLACE",            "ReplacementsAllowed", "ON"
  4182. call PARMVAL_SET "SOME"
  4183. call REPLACEMENTTAGS_SET '<>$?[]'
  4184. call TABS_SET 'Warnings'
  4185. call WARNINGS_SET ''
  4186. call WHITESPACE_SET DefWhite
  4187. call DBGIND-1
  4188. return
  4189.  
  4190. SetUpOptionsForThisBuild:
  4191. ProcessedCmdLine='Y'
  4192. call DBG_OPTIONS 'Initializing #options for this build of ' ||CurrentOutFile
  4193. call DBGIND 1
  4194. call OptionOnOrOff_SET "ALLOWPACK",          "AllowPack",           ""
  4195. call OptionOnOrOff_SET "ALLOWSPELL",         "AllowSpell",          ""
  4196. call ATCHANGETYPE_SET ''
  4197. call OptionOnOrOff_SET "CSREPLACEMENT",      "CsReplacement",       ""
  4198. call DEBUGLEVEL_SET ''
  4199. call OptionOnOrOff_SET "DEFINEMACROREPLACE", "DefineMacroReplace",  ""
  4200. call EXPANDX_SET ''
  4201. call EXTRAINDENT_SET ''
  4202. call HASHPREFIX_SET ''
  4203. call OptionOnOrOff_SET "KEEPINDENT",         "KeepIndent",          ""
  4204. call OptionOnOrOff_SET "LEAVEBLANKLINES",    "LeaveBlankLines",     ""
  4205. call LINECOMMENT_SET ''
  4206. call LINECONTINUATION_SET ''
  4207. call MACROPARMTAGS_SET ''
  4208. call OptionOnOrOff_SET "REPLACE",            "ReplacementsAllowed", ""
  4209. call PARMVAL_SET ''
  4210. call REPLACEMENTTAGS_SET ''
  4211. call TABS_SET ''
  4212. call WARNINGS_SET ''
  4213. call WHITESPACE_SET 'NULL'
  4214. call DBGIND-1
  4215. return
  4216.  
  4217. MatchesOptionStackPushDebugText:
  4218. MatchIndex=arg(1)
  4219. if MatchIndex<=0 then
  4220. return('')
  4221. else
  4222. return(' (matches "#option PUSH" at ' || OptPush.MatchIndex || ')')
  4223.  
  4224. OptionsPush:
  4225. OptionStackCnt=OptionStackCnt+1
  4226. OptPush.OptionStackCnt=CurrentSourceLocation()
  4227. PushName='OptPush' ||OptionStackCnt
  4228. if OptionDebugOn='Y' then
  4229. call DBG_OPTIONS 'Saving current options on stack as #' ||OptionStackCnt
  4230. call DBGIND 1
  4231. do OptionIndex=1 to OptionCount
  4232. call _valueS PushName|| '.' ||OptionIndex,OptionGetValue(OptionList.OptionIndex)
  4233. end
  4234. call DBGIND-1
  4235. return
  4236.  
  4237. OptionsPop:
  4238. if OptionStackCnt<=0 then
  4239. CryAndDie('There are no options on the stack to pop!')
  4240. if OptionDebugOn='Y' then
  4241. call DBG_OPTIONS 'Restoring current options from #' || OptionStackCnt || ' (pushed at ' || OptPush.OptionStackCnt || ')'
  4242. call DBGIND 1
  4243. PushName='OptPush' ||OptionStackCnt
  4244. do OptionIndex=1 to OptionCount
  4245. call OptionSetValue OptionList.OptionIndex,_valueG(PushName|| '.' ||OptionIndex)
  4246. end
  4247. call DBGIND-1
  4248. OptionStackCnt=OptionStackCnt-1
  4249. return
  4250.  
  4251. ProcessOption:
  4252. Options=arg(1)
  4253. if ProcessedCmdLine='Y' then
  4254. Options=PerformReplacementsInCmdsParameters(Options)
  4255. if Options='' then
  4256. CryAndDie('No options specified!')
  4257. do while Options<> ''
  4258. parse var Options Word1' 'RestOptions
  4259. Word1=translate(word1)
  4260. select
  4261. when Word1="PUSH" | Word1 = "+" then
  4262. do
  4263. Options=RestOptions
  4264. call OptionsPush
  4265. end
  4266. when Word1="POP" | Word1 = "-" then
  4267. do
  4268. Options=RestOptions
  4269. call OptionsPop
  4270. end
  4271. otherwise
  4272. do
  4273. if pos('=',Options)=0 then
  4274. CryAndDie('Could not find an "=" sign in "' || Options || '"')
  4275. parse var Options ThisOption'='Options
  4276. ThisOption=translate(strip(ThisOption))
  4277. ThisValue=GetQuotedText(Options, "Options")
  4278. call OptionSetValue ThisOption,ThisValue
  4279. end
  4280. end
  4281. end
  4282. return(0)
  4283.  
  4284. OptionDebugShow:
  4285. if OptionDebugOn='Y' then
  4286. call DBG_OPTIONS left(arg(1),LongestPpwOptionLng)|| ': ' ||arg(2)
  4287. return
  4288.  
  4289. OptionOnOrOff_DEBUG:
  4290. if OptionDebugOn='Y' then
  4291. call OptionDebugShow arg(1), 'Currently set to ' ||YorN2OnorOff(_valueG(arg(2)))
  4292. return
  4293.  
  4294. OptionOnOrOff_SET:
  4295. parse arg OptionName,OnOffVar2Set,OnOffValue
  4296. if ProcessedCmdLine='N' then
  4297. do
  4298. call OptionDebugShow OptionName, 'Setting default to "' || OnOffValue || '"'
  4299. call _valueS "Default4_" ||OnOffVar2Set,OnOffValue
  4300. return(0)
  4301. end
  4302. if OnOffValue=='' then
  4303. OnOffValue=_valueG("Default4_" ||OnOffVar2Set)
  4304. OnOrOff=IsStringOnOrOffCmd(OnOffValue)
  4305. if OnOrOff='' then
  4306. CryAndDie('Tried to set "' || OnOffVar2Set || '" to an invalid value of "' || OnOffValue || '"')
  4307. call _valueS OnOffVar2Set,OnOrOff
  4308. call OptionOnOrOff_DEBUG OptionName,OnOffVar2Set
  4309. return(0)
  4310.  
  4311. OptionOnOrOff_GET:
  4312. parse arg OptionName,OnOffVar2Get
  4313. VarState=YorN2OnorOff(_valueG(OnOffVar2Get))
  4314. call OptionOnOrOff_DEBUG OptionName,OnOffVar2Get
  4315. return(VarState)
  4316.  
  4317. OptionSetValue:
  4318. parse arg sOption,sValue
  4319. select
  4320. when sOption="ALLOWPACK" then
  4321. call OptionOnOrOff_SET "ALLOWPACK", "AllowPack",sValue
  4322. when sOption="ALLOWSPELL" then
  4323. call OptionOnOrOff_SET "ALLOWSPELL", "AllowSpell",sValue
  4324. when sOption="ATCHANGETYPE" then
  4325. call ATCHANGETYPE_SET sValue,sOption
  4326. when sOption="CSREPLACEMENT" then
  4327. call OptionOnOrOff_SET "CSREPLACEMENT", "CsReplacement",sValue
  4328. when sOption="DEBUGLEVEL" then
  4329. call DEBUGLEVEL_SET sValue,sOption
  4330. when sOption="DEFINEMACROREPLACE" then
  4331. call OptionOnOrOff_SET "DEFINEMACROREPLACE", "DefineMacroReplace",sValue
  4332. when sOption="EXPANDX" then
  4333. call EXPANDX_SET sValue,sOption
  4334. when sOption="EXTRAINDENT" then
  4335. call EXTRAINDENT_SET sValue,sOption
  4336. when sOption="HASHPREFIX" then
  4337. call HASHPREFIX_SET sValue,sOption
  4338. when sOption="KEEPINDENT" then
  4339. call OptionOnOrOff_SET "KEEPINDENT", "KeepIndent",sValue
  4340. when sOption="LEAVEBLANKLINES" then
  4341. call OptionOnOrOff_SET "LEAVEBLANKLINES", "LeaveBlankLines",sValue
  4342. when sOption="LINECOMMENT" then
  4343. call LINECOMMENT_SET sValue,sOption
  4344. when sOption="LINECONTINUATION" then
  4345. call LINECONTINUATION_SET sValue,sOption
  4346. when sOption="MACROPARMTAGS" then
  4347. call MACROPARMTAGS_SET sValue,sOption
  4348. when sOption="PARMVAL" then
  4349. call PARMVAL_SET sValue,sOption
  4350. when sOption="REPLACE" then
  4351. call OptionOnOrOff_SET "REPLACE", "ReplacementsAllowed",sValue
  4352. when sOption="REPLACEMENTTAGS" then
  4353. call REPLACEMENTTAGS_SET sValue,sOption
  4354. when sOption="TABS" then
  4355. call TABS_SET sValue,sOption
  4356. when sOption="WARNINGS" then
  4357. call WARNINGS_SET sValue,sOption
  4358. when sOption="WHITESPACE" then
  4359. call WHITESPACE_SET sValue,sOption
  4360. otherwise
  4361. CryAndDie("Can't set '" || sOption || "' as this option is unknown")
  4362. end
  4363. return
  4364.  
  4365. OptionGetValue:
  4366. parse arg gOption
  4367. select
  4368. when gOption="ALLOWPACK" then
  4369. return(OptionOnOrOff_GET("ALLOWPACK", "AllowPack"))
  4370. when gOption="ALLOWSPELL" then
  4371. return(OptionOnOrOff_GET("ALLOWSPELL", "AllowSpell"))
  4372. when gOption="ATCHANGETYPE" then
  4373. return(ATCHANGETYPE_GET(gOption))
  4374. when gOption="CSREPLACEMENT" then
  4375. return(OptionOnOrOff_GET("CSREPLACEMENT", "CsReplacement"))
  4376. when gOption="DEBUGLEVEL" then
  4377. return(DEBUGLEVEL_GET(gOption))
  4378. when gOption="DEFINEMACROREPLACE" then
  4379. return(OptionOnOrOff_GET("DEFINEMACROREPLACE", "DefineMacroReplace"))
  4380. when gOption="EXPANDX" then
  4381. return(EXPANDX_GET(gOption))
  4382. when gOption="EXTRAINDENT" then
  4383. return(EXTRAINDENT_GET(gOption))
  4384. when gOption="HASHPREFIX" then
  4385. return(HASHPREFIX_GET(gOption))
  4386. when gOption="KEEPINDENT" then
  4387. return(OptionOnOrOff_GET("KEEPINDENT", "KeepIndent"))
  4388. when gOption="LEAVEBLANKLINES" then
  4389. return(OptionOnOrOff_GET("LEAVEBLANKLINES", "LeaveBlankLines"))
  4390. when gOption="LINECOMMENT" then
  4391. return(LINECOMMENT_GET(gOption))
  4392. when gOption="LINECONTINUATION" then
  4393. return(LINECONTINUATION_GET(gOption))
  4394. when gOption="MACROPARMTAGS" then
  4395. return(MACROPARMTAGS_GET(gOption))
  4396. when gOption="PARMVAL" then
  4397. return(PARMVAL_GET(gOption))
  4398. when gOption="REPLACE" then
  4399. return(OptionOnOrOff_GET("REPLACE", "ReplacementsAllowed"))
  4400. when gOption="REPLACEMENTTAGS" then
  4401. return(REPLACEMENTTAGS_GET(gOption))
  4402. when gOption="TABS" then
  4403. return(TABS_GET(gOption))
  4404. when gOption="WARNINGS" then
  4405. return(WARNINGS_GET(gOption))
  4406. when gOption="WHITESPACE" then
  4407. return(WHITESPACE_GET(gOption))
  4408. otherwise
  4409. CryAndDie("Can't get '" || gOption || "' as this option is unknown")
  4410. end
  4411. return
  4412.  
  4413. OPTION_23:
  4414. DefRexxSpecialSepTag='<' || '?xRexxEos>'
  4415. call SetDollarTraceState 'N'
  4416. call InitializeDefineRexx
  4417. signal Def_Rexx_24
  4418.  
  4419. SetDollarTraceState:
  4420. DefRexxDolTrace=arg(1)
  4421. return
  4422.  
  4423. MakeSafeInSQuotes:
  4424. r_Str=arg(1)
  4425. r_Str=ReplaceString(r_Str, "'", "''")
  4426. r_L1M=left(StartsMacroReplacement,1)
  4427. r_Str=ReplaceString(r_Str,r_L1M, "' || '" || r_L1M || "' || '")
  4428. r_L1P=left(StartsMacroParm,1)
  4429. r_Str=ReplaceString(r_Str,r_L1P, "' || '" || r_L1P || "' || '")
  4430. return(r_Str)
  4431.  
  4432. InitializeDefineRexx:
  4433. DefRexxVar=''
  4434. DefRexxAddType=''
  4435. DefRexxCode=''
  4436. DefRexxStartLoc=''
  4437. DefRexxPack='Y'
  4438. DefRexxTraceNext='N'
  4439. DefRexxLineCnt=0
  4440. DefRexxTraceAll=DefRexxDolTrace
  4441. DefRexxNumTrace=0
  4442. DefRexxTraceAllowed='Y'
  4443. return
  4444.  
  4445. ProcessDefineRexx:
  4446. if arg(1)='' then
  4447. do
  4448. if DefRexxVar='' then
  4449. CryAndDie("Not currently defining rexx code!", 'To execute you need to specify a parameter of ""')
  4450. if DefRexxNumTrace<>0 then
  4451. do
  4452. if OptionDebugOn='Y' then
  4453. do
  4454. if DefRexxVar<> '?JustExec?';then
  4455. EndCmt='@Finished@ (Executing rexx from macro "' || DefRexxVar || '")'
  4456. else
  4457. EndCmt="@Finished@"
  4458. call DefRexxAddLine "call RexxTrace '" || EndCmt || "','?'"
  4459. DefRexxNumTrace=DefRexxNumTrace+1
  4460. end
  4461. call DBG_DEFINING DefRexxNumTrace|| ' $trace statements inserted'
  4462. end
  4463. if DefineMacroReplace='Y' then
  4464. DefRexxCode=PerformReplacementsInCmdsParameters(DefRexxCode)
  4465. if DefRexxVar<> '?JustExec?';then
  4466. do
  4467. call AddHashDefine DefRexxVar,DefRexxCode,DefRexxAddType
  4468. end
  4469. else
  4470. do
  4471. if OptionDebugOn='Y' then
  4472. call DBG_DEFINING 'Rexx code will be immediately executed but not saved'
  4473. DefRexxCode=PerformReplacementsInCmdsParameters(DefRexxCode)
  4474. call ExecRexxCmd DefRexxCode
  4475. end
  4476. call InitializeDefineRexx
  4477. end
  4478. else
  4479. do
  4480. if DefRexxVar<> '' then
  4481. CryAndDie("Already in rexx code block started at " ||DefRexxStartLoc)
  4482. call InitializeDefineRexx
  4483. DefRexxStartLoc=CurrentSourceLocation()
  4484. DefRexxAddType=arg(2)
  4485. DefRexxVar=GetQuotedText(PerformReplacementsInCmdsParameters(arg(1)), "Rest")
  4486. if DefRexxVar='' then
  4487. DefRexxVar='?JustExec?';
  4488. if Rest<> '' then
  4489. do
  4490. Rest=translate(Rest)
  4491. do until Rest=''
  4492. DefSpec=GetQuotedText(Rest, "Rest")
  4493. select
  4494. when DefSpec='NOPACK' then
  4495. DefRexxPack='N'
  4496. when DefSpec='$TRACE' then
  4497. DefRexxTraceAll='Y'
  4498. when DefSpec='$TRACE_OFF' then
  4499. DefRexxTraceAll='N'
  4500. otherwise
  4501. CryAndDie('Invalid option of "' || DefSpec || '" used')
  4502. end
  4503. end
  4504. end
  4505. if OptionDebugOn='Y' then
  4506. do
  4507. if DefRexxPack='Y' then
  4508. call DBG_DEFINING "AllowPack option is currently " ||YorN2OnorOff(AllowPack)
  4509. if DefRexxTraceAll='Y' then
  4510. call DBG_DEFINING '$Trace statements for each line are being inserted!'
  4511. else
  4512. call DBG_DEFINING '$Trace statements for each line are NOT being inserted!'
  4513. if DefRexxVar<> '?JustExec?';then
  4514. StrCmt='@Starting@ (Executing rexx from macro "' || DefRexxVar || '")'
  4515. else
  4516. StrCmt="@Starting@"
  4517. call DefRexxAddLine "call RexxTrace '" || StrCmt || "','?'"
  4518. DefRexxNumTrace=DefRexxNumTrace+1
  4519. end
  4520. end
  4521. return(0)
  4522.  
  4523. AddDefineRexxLine:
  4524. NewRexxLine=strip(arg(1))
  4525. DefRexxLineCnt=DefRexxLineCnt+1
  4526. if right(NewRexxLine,2)=RexxCmtEnd then
  4527. do
  4528. StartCmtPos=lastpos(RexxCmtStart,NewRexxLine)
  4529. if StartCmtPos<>0 then
  4530. do
  4531. if StartCmtPos=0 then
  4532. NewRexxLine=''
  4533. else
  4534. NewRexxLine=strip(left(NewRexxLine,StartCmtPos-1), 'T')
  4535. end
  4536. end
  4537. do while right(NewRexxLine,1)=';'
  4538. NewRexxLine=strip(left(NewRexxLine,length(NewRexxLine)-1), 'T')
  4539. end
  4540. if NewRexxLine='' then
  4541. return
  4542. UnpackedLine=space(NewRexxLine)
  4543. if DefRexxPack='Y' then
  4544. do
  4545. if AllowPack='Y' then
  4546. NewRexxLine=CompressRexxLine(NewRexxLine)
  4547. end
  4548. DropLine='N'
  4549. if translate(word(NewRexxLine,1))="$TRACE" then
  4550. do
  4551. Rest=translate(subword(NewRexxLine,2))
  4552. select
  4553. when Rest="ON" then
  4554. do
  4555. DefRexxTraceAllowed='Y'
  4556. DropLine='Y'
  4557. end
  4558. when Rest="OFF" then
  4559. do
  4560. DefRexxTraceAllowed='N'
  4561. DropLine='Y'
  4562. end
  4563. otherwise
  4564. do
  4565. DropLine='Y'
  4566. if OptionDebugOn='Y' then
  4567. do
  4568. UserTraceCmt=subword(NewRexxLine,2)
  4569. if UserTraceCmt='' then
  4570. DefRexxTraceNext="Y"
  4571. else
  4572. do
  4573. call DBG_DEFINING '$tracing comment: ' ||UserTraceCmt
  4574. DefRexxTraceNext="N"
  4575. UserTraceCmt=MakeSafeInSQuotes(UserTraceCmt)
  4576. NewRexxLine="call RexxTrace '" || UserTraceCmt || "','?'"
  4577. call DefRexxAddLine NewRexxLine
  4578. DefRexxNumTrace=DefRexxNumTrace+1
  4579. end
  4580. end
  4581. end
  4582. end
  4583. end
  4584. if DropLine='Y' then
  4585. DropLine='N'
  4586. else
  4587. do
  4588. if DefRexxTraceNext="Y" then
  4589. TraceThis='Y'
  4590. else
  4591. do
  4592. if DefRexxTraceAll='N' then
  4593. TraceThis='N'
  4594. else
  4595. do
  4596. if pos('/' || translate(NewRexxLine) || '/', "/THEN/DO/ELSE/")=0 then
  4597. TraceThis='Y'
  4598. else
  4599. TraceThis='N'
  4600. end
  4601. end
  4602. if TraceThis='Y' then
  4603. do
  4604. DefRexxTraceNext="N"
  4605. if OptionDebugOn='Y' then
  4606. do
  4607. if DefRexxTraceAllowed='Y' then
  4608. do
  4609. call DBG_DEFINING '$tracing: ' ||UnpackedLine
  4610. TraceThis=MakeSafeInSQuotes(UnpackedLine)
  4611. NewRexxLine="call RexxTrace '@" || DefRexxLineCnt || " -> " || TraceThis || "',,'Y'" ||DefRexxSpecialSepTag||NewRexxLine
  4612. DefRexxNumTrace=DefRexxNumTrace+1
  4613. end
  4614. end
  4615. end
  4616. call DefRexxAddLine NewRexxLine
  4617. end
  4618. return
  4619.  
  4620. DefRexxAddLine:
  4621. if DefRexxCode='' then
  4622. DefRexxCode=arg(1)
  4623. else
  4624. DefRexxCode=DefRexxCode||DefRexxSpecialSepTag||arg(1)
  4625. return
  4626.  
  4627. Def_Rexx_24:
  4628. NameOfOs2ReginaRexxInterpreter=""
  4629. signal Rexx_25
  4630.  
  4631. _GetNameOfMacroSpaceExe:
  4632. if Symbol('MacroSpaceExe') <> 'VAR' then
  4633. do
  4634. MacroSpaceExeBase='MacroSpc.EXE'
  4635. MacroSpaceExe=_filespec('drive', PpWizardPgmName) || _filespec('Path',PpWizardPgmName)||MacroSpaceExeBase
  4636. if QueryExists(MacroSpaceExe)='' then
  4637. do
  4638. MacroSpaceExe=FindFileInPath(MacroSpaceExeBase, '*PATH')
  4639. if MacroSpaceExe="" then
  4640. MacroSpaceExe=FindFileInPath(MacroSpaceExeBase, '*DPATH')
  4641. end
  4642. call DBG 'Macro Space Pgm: ' ||MacroSpaceExe
  4643. end
  4644. return(MacroSpaceExe)
  4645.  
  4646. _GetNameOfOs2ReginaExe:
  4647. if Symbol('Os2ReginaExe') <> 'VAR' then
  4648. do
  4649. Os2ReginaExeBase='ROS2REXX.EXE'
  4650. Os2ReginaExe=_filespec('drive', PpWizardPgmName) || _filespec('Path',PpWizardPgmName)||Os2ReginaExeBase
  4651. if QueryExists(Os2ReginaExe)='' then
  4652. do
  4653. Os2ReginaExe=FindFileInPath(Os2ReginaExeBase, '*PATH')
  4654. end
  4655. end
  4656. return(Os2ReginaExe)
  4657.  
  4658. DoMacroSpaceOperation:
  4659. parse arg MsCommand,MsFile,MsFunction,MsQuiet
  4660. CallersLine=SIGL
  4661. call DBG 'Trying to macrospace "' || MsCommand || '" "' || MsFile || '" alias (' || MsFunction || ')'
  4662. TmpFile=RexGetTmpFileName()
  4663. CheckPgm=_GetNameOfMacroSpaceExe()
  4664. if CheckPgm='' then
  4665. do
  4666. if MsQuiet="QUIET" then
  4667. return
  4668. else
  4669. CryAndDie("Can't perform macro space command as " || MacroSpaceExeBase || ' is unavailable.')
  4670. end
  4671. FailMsg='MACRO SPACE COMMAND FAILED'
  4672. call AddressCmd CheckPgm|| ' ' || MsCommand || ' ' || MsFile || ' ' || MsFunction || ' >' || TmpFile || ' 2>&1'
  4673. if MsQuiet="QUIET" then
  4674. return
  4675. else
  4676. signal CheckMacroSpaceRc
  4677.  
  4678. CheckRexxModuleForSyntaxErrors:
  4679. call DBG 'CheckRexxModuleForSyntaxErrors()'
  4680. if RexWhich='REGINA' then
  4681. do
  4682. call CallStubInGeneratedCodeToCheckSyntax
  4683. return
  4684. end
  4685. CallersLine=SIGL
  4686. TmpFile=RexGetTmpFileName()
  4687. CheckPgm=_GetNameOfMacroSpaceExe()
  4688. if CheckPgm='' then
  4689. do
  4690. call DBG "Can't use normal validation method on the rexx syntax - " || MacroSpaceExeBase || ' file not found!'
  4691. call CallStubInGeneratedCodeToCheckSyntax
  4692. return
  4693. end
  4694. FailMsg='INVALID SYNTAX'
  4695. call AddressCmd CheckPgm|| ' CheckSyntax ' || Output.1.File || ' >' || NameOfNulDevice() || ' 2>' ||TmpFile
  4696.  
  4697. CheckMacroSpaceRc:
  4698. CheckRc=Rc
  4699. if CheckRc=0 then
  4700. do
  4701. DosDelRc=_SysFileDelete(TmpFile)
  4702. call UseOs2ReginaToDoubleCheckSyntax
  4703. return
  4704. end
  4705. call Line1 ''
  4706. call Char1 ErrorColor
  4707. call Line1 FailMsg
  4708. call Line1 copies('~',length(FailMsg))
  4709. do while lines(TmpFile)<>0
  4710. call Line1 linein(TmpFile)
  4711. end
  4712. call Char1 Reset|| ''
  4713. call FileClose TmpFile
  4714. DosDelRc=_SysFileDelete(TmpFile)
  4715. AbnormalExit(CallersLine, "Syntax Error in generated rexx code")
  4716.  
  4717. CallStubInGeneratedCodeToCheckSyntax:
  4718. CheckingFile=Output.1.File
  4719. call DBGIND 1
  4720. call DBG 'Calling stub in generated code'
  4721. signal ON SYNTAX NAME SyntaxErrorInGeneratedCode
  4722. CheckRc='*?*'
  4723. interpret 'CheckRc =  "' || CheckingFile || '"("' || SyntaxOkText || '")'
  4724. if CheckRc<>SyntaxOkRc then
  4725. CryAndDie('Probably Syntax Error, got unexpected RC of "' || CheckRc || '"')
  4726. call DBGIND-1
  4727. return
  4728.  
  4729. SyntaxErrorInGeneratedCode:
  4730. CryAndDie('Faulty syntax in generated "' || CheckingFile || '"!')
  4731.  
  4732. UseOs2ReginaToDoubleCheckSyntax:
  4733. if RexWhich='REGINA' then
  4734. return
  4735. if NameOfOs2ReginaRexxInterpreter='-' then
  4736. return
  4737. call DBG 'OS/2 rexx already passed code, can we double check using OS/2 regina?'
  4738. UseExe=NameOfOs2ReginaRexxInterpreter
  4739. if UseExe='' then
  4740. UseExe=_GetNameOfOs2ReginaExe()
  4741. if UseExe='' then
  4742. return
  4743. CheckingFile=Output.1.File
  4744. call DBGIND 1
  4745. call DBG 'Checking using "' || UseExe || '"'
  4746. call AddressCmd UseExe|| ' ' || CheckingFile || ' ' ||SyntaxOkText
  4747. if Rc<>SyntaxOkRc&Rc<>255 then
  4748. CryAndDie('Probably syntax error in "' || Output.1.File || '"', 'Got unexpected RC of "' || Rc || '" from ' ||UseExe)
  4749. call DBGIND-1
  4750. return
  4751.  
  4752. Rexx_25:
  4753. InfiniteLoopDetected='N'
  4754. InfiniteLoopWhen=0
  4755. InfiniteIncludeLoopWhen=0
  4756. RexxSkipCounter=0
  4757. ArePositionalChars='"' || "'="
  4758. MarksPhpXml='<' || '?'
  4759. signal Define_26
  4760.  
  4761. InitCondNlCount:
  4762. CondNlCount=0
  4763. return
  4764.  
  4765. _RXQuote:
  4766. parse arg t_Right,t_Quote,t_OpQuote
  4767. t_Break=t_Quote|| '||,' ||DefRexxSpecialSepTag||t_Quote
  4768. t_DQuote=t_Quote||t_Quote
  4769. t_Left=''
  4770. do while length(t_Right)>100
  4771. if t_Left=='' then
  4772. t_Left=ReplaceString(left(t_Right,100),t_Quote,t_DQuote)
  4773. else
  4774. t_Left=t_Left||t_Break||ReplaceString(left(t_Right,100),t_Quote,t_DQuote)
  4775. t_Right=substr(t_Right,100+1)
  4776. end
  4777. return(t_Left||ReplaceString(t_Right,t_Quote,t_DQuote))
  4778.  
  4779. _MacroBitNotFoundText:
  4780. if CsReplacement='N' then
  4781. return('')
  4782. else
  4783. return('Macro names & parameters are case sensitive (check case)')
  4784.  
  4785. InitializeHashDefinesForThisCompile:
  4786. call DBG_DEFINING 'Initializing all #defines, got ' || OptionDefineCount || ' /define definitions to load up.'
  4787. drop MACRO?.
  4788. call AddHashDefine '_PPWIZARD_', ''
  4789. if OptionDefineCount<>0 then
  4790. do
  4791. do Index=1 to OptionDefineCount
  4792. call AddHashDefine OptionDefine.Index.Var,OptionDefine.Index.Cont
  4793. end
  4794. end
  4795. call _GetUserOptionsViaDefineSwitch
  4796. return
  4797.  
  4798. _GetUserOptionsViaDefineSwitch:
  4799. call DBG_MACROVALORDEF 'Getting some lesser options (not worth specific commands)'
  4800. call DBGIND 1
  4801. if RexSystemOpSys="UNIX" then
  4802. PathDelimiterChar=':'
  4803. else
  4804. PathDelimiterChar=';'
  4805. PathDelimiterChar=CfgMacro("PATH_DELIMITER_CHAR",PathDelimiterChar)
  4806. if length(PathDelimiterChar)<>1 then
  4807. CryAndDie("Invalid path delimiter (expected 1 only character)")
  4808. RexxLocalVar=CfgMacro("REXX_MAKE_LOCAL_VAR", '@' || '@')
  4809. InfiniteLoopWhen=CfgMacro("INFINITE_MACRO_LOOP_WHEN",20)
  4810. InfiniteIncludeLoopWhen=CfgMacro("INFINITE_INCLUDE_LOOP_WHEN",20)
  4811. call DBGIND-1
  4812. return
  4813.  
  4814. PARMVAL_DEBUG:
  4815. if OptionDebugOn='Y' then
  4816. do
  4817. if OptionParmVal="S" then
  4818. u_D="SOME"
  4819. else
  4820. u_D=YorN2OnorOff(OptionParmVal)
  4821. call OptionDebugShow 'PARMVAL', 'Currently set to "' || u_D || '"'
  4822. end
  4823. return
  4824.  
  4825. PARMVAL_SET:
  4826. v_Value=translate(arg(1))
  4827. if ProcessedCmdLine='N' then
  4828. do
  4829. call OptionDebugShow 'PARMVAL', 'Setting default to "' || v_Value || '"'
  4830. DefaultParmVal=v_Value
  4831. return(0)
  4832. end
  4833. if v_Value=='' then
  4834. v_Value=DefaultParmVal
  4835. if v_Value="SOME" then
  4836. OptionParmVal="S"
  4837. else
  4838. do
  4839. OptionParmVal=IsStringOnOrOffCmd(v_Value)
  4840. if OptionParmVal='' then
  4841. CryAndDie('Invalid PARMVAL option of "' || v_Value || '"')
  4842. end
  4843. call PARMVAL_DEBUG
  4844. return
  4845.  
  4846. PARMVAL_GET:
  4847. call PARMVAL_DEBUG
  4848. if OptionParmVal="S" then
  4849. w_Value="SOME"
  4850. else
  4851. w_Value=YorN2OnorOff(OptionParmVal)
  4852. return(w_Value)
  4853.  
  4854. REPLACEMENTTAGS_DEBUG:
  4855. if OptionDebugOn='Y' then
  4856. call OptionDebugShow 'REPLACEMENTTAGS', 'Replace tags now look like "' || StartsMacroReplacement || 'MacroVar' || EndsMacroReplacement || '" and "' || StartsStdSymbolReplacement || 'StandardMacroVar' || EndsMacroReplacement || '", Indirection like "' || MacroIndLeft || 'symbol' || MacroIndRight || '"'
  4857. return
  4858.  
  4859. REPLACEMENTTAGS_SET:
  4860. Tags=arg(1)
  4861. if ProcessedCmdLine='N' then
  4862. do
  4863. call OptionDebugShow 'REPLACEMENTTAGS', 'Setting default value of replacement tags to "' || Tags || '"'
  4864. Default4_ReplacementTags=Tags
  4865. return(0)
  4866. end
  4867. if Tags=='' then
  4868. Tags=Default4_ReplacementTags
  4869. w_L=length(Tags)
  4870. if w_L<>4&w_L<>6 then
  4871. CryAndDie('Tried to set invalid replace tags of "' || Tags || '"')
  4872. StartsMacroReplacement=substr(Tags,1,1)||substr(Tags,3,1)
  4873. StdSymbolReplacementChar=substr(Tags,4,1)
  4874. StartsStdSymbolReplacement=substr(Tags,1,1)||StdSymbolReplacementChar
  4875. EndsMacroReplacement=substr(Tags,2,1)
  4876. if w_L=6 then
  4877. do
  4878. MacroIndLeft=substr(Tags,5,1)
  4879. MacroIndRight=substr(Tags,6,1)
  4880. end
  4881. EndsVar=' ' ||EndsMacroReplacement
  4882. StartsStdSymbolReplacement_x=StartsStdSymbolReplacement|| 'x'
  4883. CodexNewLine=StartsStdSymbolReplacement|| "NewLine" ||EndsMacroReplacement
  4884. if RexIsAscii='N' then
  4885. do
  4886. CodexHexNewLine=StartsStdSymbolReplacement_x|| "15" ||EndsMacroReplacement
  4887. CodexHexSpace=StartsStdSymbolReplacement_x|| "40" ||EndsMacroReplacement
  4888. CodexHexHash=StartsStdSymbolReplacement_x|| "7B" ||EndsMacroReplacement
  4889. CodexHexDollar=StartsStdSymbolReplacement_x|| "5B" ||EndsMacroReplacement
  4890. CodexHexQuestionMark=StartsStdSymbolReplacement_x|| "1A" ||EndsMacroReplacement
  4891. CodexHexLessThan=StartsStdSymbolReplacement_x|| "4C" ||EndsMacroReplacement
  4892. CodexSemiColon=StartsStdSymbolReplacement_x|| "5E" ||EndsMacroReplacement
  4893. end
  4894. else
  4895. do
  4896. CodexHexNewLine=StartsStdSymbolReplacement_x|| "0A" ||EndsMacroReplacement
  4897. CodexHexSpace=StartsStdSymbolReplacement_x|| "20" ||EndsMacroReplacement
  4898. CodexHexHash=StartsStdSymbolReplacement_x|| "23" ||EndsMacroReplacement
  4899. CodexHexDollar=StartsStdSymbolReplacement_x|| "24" ||EndsMacroReplacement
  4900. CodexHexQuestionMark=StartsStdSymbolReplacement_x|| "3F" ||EndsMacroReplacement
  4901. CodexHexLessThan=StartsStdSymbolReplacement_x|| "3C" ||EndsMacroReplacement
  4902. CodexSemiColon=StartsStdSymbolReplacement_x|| "3B" ||EndsMacroReplacement
  4903. end
  4904. call REPLACEMENTTAGS_DEBUG
  4905. return
  4906.  
  4907. REPLACEMENTTAGS_GET:
  4908. call REPLACEMENTTAGS_DEBUG
  4909. return(substr(StartsMacroReplacement,1,1)||EndsMacroReplacement||substr(StartsMacroReplacement,2,1)||substr(StartsStdSymbolReplacement,2,1)||MacroIndLeft||MacroIndRight)
  4910.  
  4911. MACROPARMTAGS_DEBUG:
  4912. if OptionDebugOn='Y' then
  4913. call OptionDebugShow 'MACROPARMTAGS', 'Macro parameters now look like "' || StartsMacroParm || 'MacroParameter' || EndsMacroParm || '"'
  4914. return
  4915.  
  4916. MACROPARMTAGS_SET:
  4917. Tags=arg(1)
  4918. if ProcessedCmdLine='N' then
  4919. do
  4920. call OptionDebugShow 'MACROPARMTAGS', 'Setting default value of macro parameter tags to "' || Tags || '"'
  4921. Default4_MacroParameterTags=Tags
  4922. return(0)
  4923. end
  4924. if Tags=='' then
  4925. Tags=Default4_MacroParameterTags
  4926. if length(Tags)<>3 then
  4927. CryAndDie('Tried to set invalid macro parameter tags of "' || Tags || '"')
  4928. StartsMacroParm=substr(Tags,1,1)||substr(Tags,3,1)
  4929. EndsMacroParm=substr(Tags,2,1)
  4930. HidesMacroParm=substr(Tags,1,1)|| '_' ||substr(Tags,3,1)
  4931. AutoTagSelf=StartsMacroParm|| 'AT' ||EndsMacroParm
  4932. call MACROPARMTAGS_DEBUG
  4933. return
  4934.  
  4935. MACROPARMTAGS_GET:
  4936. call MACROPARMTAGS_DEBUG
  4937. return(substr(StartsMacroParm,1,1)||EndsMacroParm||substr(StartsMacroParm,2,1))
  4938.  
  4939. ProcessDefine:
  4940. Rest=arg(1)
  4941. if DefineMacroReplace='Y' then
  4942. Rest=PerformReplacementsInCmdsParameters(Rest)
  4943. if pos(MarksNewLineInHashDefine,Rest)<>0 then
  4944. do
  4945. Rest=ReplaceString(arg(1),MarksNewLineInHashDefine2,MarksNewLine)
  4946. Rest=ReplaceString(Rest,MarksNewLineInHashDefine,MarksNewLine)
  4947. end
  4948. parse var Rest HashDefineV HashDefineC
  4949. return(AddHashDefine(HashDefineV,strip(HashDefineC),arg(2)))
  4950.  
  4951. ProcessEvaluate:
  4952. Rest=PerformReplacementsInCmdsParameters(arg(1))
  4953. HashDefineAnswerName=GetQuotedText(Rest, "Rest")
  4954. if Rest='' then
  4955. CryAndDie('Evaluate what command?')
  4956. CmdToEvaluate=GetQuotedRest(Rest)
  4957. HashDefineRc=0
  4958. if HashDefineAnswerName='' then
  4959. call ExecRexxCmd CmdToEvaluate
  4960. else
  4961. do
  4962. CmdToEvaluate='EvaluateAnswer = ' ||CmdToEvaluate
  4963. call ExecRexxCmd CmdToEvaluate
  4964. HashDefineRc=AddHashDefine(HashDefineAnswerName,EvaluateAnswer,arg(2))
  4965. end
  4966. return(HashDefineRc)
  4967.  
  4968. MacroExists:
  4969. if verify(arg(1),EndsVar, 'M') <> 0 then CryAndDie('The macro name "' || arg(1) || '" is invalid (Any of "' || EndsVar || '" are invalid)')
  4970. s_MacName=arg(1)
  4971. s_MacNameO=s_MacName
  4972. s_RbPos=pos(MacroIndRight,s_MacName)
  4973. if s_RbPos<>0 then
  4974. do
  4975. if OptionDebugOn='Y' then
  4976. do
  4977. call DBG_DEFINING '[indirection]: ' ||DebugRightArrow||s_MacName||DebugLeftArrow
  4978. call DBGIND 1
  4979. end
  4980. do while s_RbPos<>0
  4981. s_LbPos=lastpos(MacroIndLeft,s_MacName,s_RbPos)
  4982. if s_LbPos=0 then
  4983. CryAndDie('Could not find a matching "' || MacroIndLeft || '" character for "' || MacroIndRight || '"', 'The invalid macro is:', '  ' ||s_MacName)
  4984. s_L=left(s_MacName,s_LbPos-1)
  4985. s_M=substr(s_MacName,s_LbPos+1,s_RbPos-s_LbPos-1)
  4986. s_R=substr(s_MacName,s_RbPos+1)
  4987. if OptionDebugOn='Y' then
  4988. do
  4989. call DBG_DEFINING 'Looking for: ' ||s_M
  4990. call DBGIND 1
  4991. end
  4992. s_RepType=''
  4993. if symbol(s_M)='VAR' then
  4994. do
  4995. s_RepType='REXX'
  4996. s_RepWith=value(s_M)
  4997. end
  4998. else
  4999. do
  5000. if CsReplacement='N' then
  5001. s_SavedAs='MACRO?.M?'||c2x(translate(s_M))
  5002. else
  5003. s_SavedAs='MACRO?.M?'||c2x(s_M)
  5004. if symbol(s_SavedAs)='VAR' then
  5005. do
  5006. s_RepType='PPWIZARD'
  5007. s_RepWith=value(s_SavedAs)
  5008. end
  5009. end
  5010. if OptionDebugOn='Y' then
  5011. do
  5012. if s_RepType='' then
  5013. call DBG_DEFINING 'No such REXX or PPWIZARD symbol!'
  5014. else
  5015. call DBG_DEFINING s_RepType|| ' symbol contained: ' ||s_RepWith
  5016. call DBGIND-1
  5017. end
  5018. if s_RepType='' then
  5019. do
  5020. if s_MacName=s_MacNameO then
  5021. s_Show=s_MacName
  5022. else
  5023. s_Show=s_MacName|| ' <= "' ||s_MacNameO
  5024. CryAndDie("Could not find a REXX variable or PPWIZARD macro matching:", '  ' || s_M, 'In the macro reference:', '  ' ||s_Show)
  5025. end
  5026. s_MacName=s_L||s_RepWith||s_R
  5027. if OptionDebugOn='Y' then
  5028. call DBG_DEFINING 'New macro reference is "' ||DebugRightArrow||s_MacName||DebugLeftArrow
  5029. s_RbPos=pos(MacroIndRight,s_MacName)
  5030. end
  5031. if OptionDebugOn='Y' then
  5032. call DBGIND-1
  5033. end
  5034. if pos(MacroIndLeft,s_MacName)<>0 then
  5035. CryAndDie('Could not find a matching "' || MacroIndRight || '" character for "' || MacroIndLeft || '"', 'The invalid macro is:', '  ' ||s_MacName)
  5036. x_Dummy=s_MacName
  5037. if CsReplacement='N' then
  5038. x_As='MACRO?.M?'||c2x(translate(s_MacName))
  5039. else
  5040. x_As='MACRO?.M?'||c2x(s_MacName)
  5041. if symbol(x_As)='VAR' then
  5042. return('Y')
  5043. else
  5044. return('N')
  5045.  
  5046. HandleUndefCommand:
  5047. y_Ud=PerformReplacementsInCmdsParameters(arg(1))
  5048. if verify(y_Ud,EndsVar, 'M') <> 0 then CryAndDie('The macro name "' || y_Ud || '" is invalid (Any of "' || EndsVar || '" are invalid)')
  5049. s_MacName=y_Ud
  5050. s_MacNameO=s_MacName
  5051. s_RbPos=pos(MacroIndRight,s_MacName)
  5052. if s_RbPos<>0 then
  5053. do
  5054. if OptionDebugOn='Y' then
  5055. do
  5056. call DBG_DEFINING '[indirection]: ' ||DebugRightArrow||s_MacName||DebugLeftArrow
  5057. call DBGIND 1
  5058. end
  5059. do while s_RbPos<>0
  5060. s_LbPos=lastpos(MacroIndLeft,s_MacName,s_RbPos)
  5061. if s_LbPos=0 then
  5062. CryAndDie('Could not find a matching "' || MacroIndLeft || '" character for "' || MacroIndRight || '"', 'The invalid macro is:', '  ' ||s_MacName)
  5063. s_L=left(s_MacName,s_LbPos-1)
  5064. s_M=substr(s_MacName,s_LbPos+1,s_RbPos-s_LbPos-1)
  5065. s_R=substr(s_MacName,s_RbPos+1)
  5066. if OptionDebugOn='Y' then
  5067. do
  5068. call DBG_DEFINING 'Looking for: ' ||s_M
  5069. call DBGIND 1
  5070. end
  5071. s_RepType=''
  5072. if symbol(s_M)='VAR' then
  5073. do
  5074. s_RepType='REXX'
  5075. s_RepWith=value(s_M)
  5076. end
  5077. else
  5078. do
  5079. if CsReplacement='N' then
  5080. s_SavedAs='MACRO?.M?'||c2x(translate(s_M))
  5081. else
  5082. s_SavedAs='MACRO?.M?'||c2x(s_M)
  5083. if symbol(s_SavedAs)='VAR' then
  5084. do
  5085. s_RepType='PPWIZARD'
  5086. s_RepWith=value(s_SavedAs)
  5087. end
  5088. end
  5089. if OptionDebugOn='Y' then
  5090. do
  5091. if s_RepType='' then
  5092. call DBG_DEFINING 'No such REXX or PPWIZARD symbol!'
  5093. else
  5094. call DBG_DEFINING s_RepType|| ' symbol contained: ' ||s_RepWith
  5095. call DBGIND-1
  5096. end
  5097. if s_RepType='' then
  5098. do
  5099. if s_MacName=s_MacNameO then
  5100. s_Show=s_MacName
  5101. else
  5102. s_Show=s_MacName|| ' <= "' ||s_MacNameO
  5103. CryAndDie("Could not find a REXX variable or PPWIZARD macro matching:", '  ' || s_M, 'In the macro reference:', '  ' ||s_Show)
  5104. end
  5105. s_MacName=s_L||s_RepWith||s_R
  5106. if OptionDebugOn='Y' then
  5107. call DBG_DEFINING 'New macro reference is "' ||DebugRightArrow||s_MacName||DebugLeftArrow
  5108. s_RbPos=pos(MacroIndRight,s_MacName)
  5109. end
  5110. if OptionDebugOn='Y' then
  5111. call DBGIND-1
  5112. end
  5113. if pos(MacroIndLeft,s_MacName)<>0 then
  5114. CryAndDie('Could not find a matching "' || MacroIndRight || '" character for "' || MacroIndLeft || '"', 'The invalid macro is:', '  ' ||s_MacName)
  5115. y_Dummy=s_MacName
  5116. if CsReplacement='N' then
  5117. SavedAs='MACRO?.M?'||c2x(translate(s_MacName))
  5118. else
  5119. SavedAs='MACRO?.M?'||c2x(s_MacName)
  5120. if symbol(SavedAs)='VAR' then
  5121. drop(SavedAs)
  5122. return(0)
  5123.  
  5124. MacroSet:call TRACE "OFF"
  5125.  
  5126. AddHashDefine:
  5127. parse arg HashDefineU,HashDefineC,DefineMode
  5128. if OptionDebugOn='Y' then
  5129. do
  5130. call DBG_DEFINING 'Defining "' || HashDefineU || '" <- ' ||DebugRightArrow||HashDefineC||DebugLeftArrow
  5131. call DBGIND 1
  5132. end
  5133. if verify(HashDefineU,EndsVar, 'M') <> 0 then CryAndDie('The macro name "' || HashDefineU || '" is invalid (Any of "' || EndsVar || '" are invalid)')
  5134. s_MacName=HashDefineU
  5135. s_MacNameO=s_MacName
  5136. s_RbPos=pos(MacroIndRight,s_MacName)
  5137. if s_RbPos<>0 then
  5138. do
  5139. if OptionDebugOn='Y' then
  5140. do
  5141. call DBG_DEFINING '[indirection]: ' ||DebugRightArrow||s_MacName||DebugLeftArrow
  5142. call DBGIND 1
  5143. end
  5144. do while s_RbPos<>0
  5145. s_LbPos=lastpos(MacroIndLeft,s_MacName,s_RbPos)
  5146. if s_LbPos=0 then
  5147. CryAndDie('Could not find a matching "' || MacroIndLeft || '" character for "' || MacroIndRight || '"', 'The invalid macro is:', '  ' ||s_MacName)
  5148. s_L=left(s_MacName,s_LbPos-1)
  5149. s_M=substr(s_MacName,s_LbPos+1,s_RbPos-s_LbPos-1)
  5150. s_R=substr(s_MacName,s_RbPos+1)
  5151. if OptionDebugOn='Y' then
  5152. do
  5153. call DBG_DEFINING 'Looking for: ' ||s_M
  5154. call DBGIND 1
  5155. end
  5156. s_RepType=''
  5157. if symbol(s_M)='VAR' then
  5158. do
  5159. s_RepType='REXX'
  5160. s_RepWith=value(s_M)
  5161. end
  5162. else
  5163. do
  5164. if CsReplacement='N' then
  5165. s_SavedAs='MACRO?.M?'||c2x(translate(s_M))
  5166. else
  5167. s_SavedAs='MACRO?.M?'||c2x(s_M)
  5168. if symbol(s_SavedAs)='VAR' then
  5169. do
  5170. s_RepType='PPWIZARD'
  5171. s_RepWith=value(s_SavedAs)
  5172. end
  5173. end
  5174. if OptionDebugOn='Y' then
  5175. do
  5176. if s_RepType='' then
  5177. call DBG_DEFINING 'No such REXX or PPWIZARD symbol!'
  5178. else
  5179. call DBG_DEFINING s_RepType|| ' symbol contained: ' ||s_RepWith
  5180. call DBGIND-1
  5181. end
  5182. if s_RepType='' then
  5183. do
  5184. if s_MacName=s_MacNameO then
  5185. s_Show=s_MacName
  5186. else
  5187. s_Show=s_MacName|| ' <= "' ||s_MacNameO
  5188. CryAndDie("Could not find a REXX variable or PPWIZARD macro matching:", '  ' || s_M, 'In the macro reference:', '  ' ||s_Show)
  5189. end
  5190. s_MacName=s_L||s_RepWith||s_R
  5191. if OptionDebugOn='Y' then
  5192. call DBG_DEFINING 'New macro reference is "' ||DebugRightArrow||s_MacName||DebugLeftArrow
  5193. s_RbPos=pos(MacroIndRight,s_MacName)
  5194. end
  5195. if OptionDebugOn='Y' then
  5196. call DBGIND-1
  5197. end
  5198. if pos(MacroIndLeft,s_MacName)<>0 then
  5199. CryAndDie('Could not find a matching "' || MacroIndRight || '" character for "' || MacroIndLeft || '"', 'The invalid macro is:', '  ' ||s_MacName)
  5200. y_Dummy=s_MacName
  5201. if CsReplacement='N' then
  5202. SavedAs='MACRO?.M?'||c2x(translate(s_MacName))
  5203. else
  5204. SavedAs='MACRO?.M?'||c2x(s_MacName)
  5205. if symbol(SavedAs)='VAR' then
  5206. do
  5207. select
  5208. when DefineMode='Y' then
  5209. do
  5210. if OptionDebugOn='Y' then
  5211. call DBG_DEFINING 'User said OK to redefine so no warning'
  5212. end
  5213. when DefineMode='' then
  5214. do
  5215. call OutputWarningToScreen 'R000', 'Redefine of "' || HashDefineU || '".'
  5216. end
  5217. when DefineMode='?' then
  5218. do
  5219. if OptionDebugOn='Y' then
  5220. do
  5221. call DBG_DEFINING 'Macro already defined, conditional definition aborted!'
  5222. call DBGIND-1
  5223. end
  5224. return(0)
  5225. end
  5226. otherwise
  5227. CryAndDie('Unknown define mode of "' || DefineMode || '"')
  5228. end
  5229. end
  5230. call _valueS SavedAs,HashDefineC
  5231. if OptionDebugOn='Y' then
  5232. call DBGIND-1
  5233. return(0)
  5234.  
  5235. PerformReplacementsInCmdsParameters:
  5236. cpParms=ReplaceHashAndStandardDefines(arg(1), "PRM")
  5237. if ExpandXCmd='Y' then
  5238. do
  5239. if pos(StartsStdSymbolReplacement_x,cpParms)<>0 then
  5240. cpParms=ReplaceTheXCodesWeKnowExist(cpParms)
  5241. end
  5242. if pos(MarksNewLine,cpParms)<>0 then
  5243. do
  5244. Line1='The commands parameters expanded a macro that generated multiple lines!'
  5245. Line2='The parameters are now:'
  5246. Line3=copies(' ',8)||translate(cpParms,DebugNewline,MarksNewLine)
  5247. CryAndDie(Line1,Line2,Line3)
  5248. end
  5249. return(cpParms)
  5250.  
  5251. ReplaceMacros:call TRACE "OFF"
  5252. signal _ReplaceMacros
  5253.  
  5254. ReplaceHashAndStandardDefines:
  5255. if ReplacementsAllowed='N' then
  5256. return(arg(1))
  5257.  
  5258. _ReplaceMacros:
  5259. parse arg HashDefineString,HashDefPrefix,HashDefRecord
  5260. ReplLoop=0
  5261. do while pos(StartsMacroReplacement,HashDefineString)<>0
  5262. BeforeCount=ReplaceCount
  5263. HashDefineString=_ReplaceAllHashDefinedVariables(HashDefineString)
  5264. if HashDefRecord='Y' then
  5265. LastLineAfterMacroRep=HashDefineString
  5266. if OptionDebugOn='Y' then
  5267. do
  5268. if BeforeCount<>ReplaceCount then
  5269. do
  5270. if HashDefPrefix='' then
  5271. call DebugOutputAfterReplacement HashDefineString, 'VCMD'
  5272. else
  5273. call DebugOutputAfterReplacement HashDefineString, 'V' ||HashDefPrefix
  5274. end
  5275. end
  5276. if pos(MarksNewLine,HashDefineString)<>0 then
  5277. leave
  5278. if ReplLoop>=InfiniteLoopWhen then
  5279. do
  5280. if InfiniteLoopWhen<>0 then
  5281. do
  5282. InfiniteLoopDetected='Y'
  5283. if ReplLoop=InfiniteLoopWhen then
  5284. do
  5285. OptionDebugOn='Y'
  5286. call DBG 'Infinite loop detected, debug forced on for a few loops'
  5287. call DBGIND 1
  5288. call DBG InfiniteLoopWhen|| ' loops detected, possible actions:'
  5289. call DBGIND 1
  5290. call DBG 'Have have you forgotten to use "#option DefineMacroReplace=ON" somewhere?'
  5291. call DBG 'Use "/define:INFINITE_MACRO_LOOP_WHEN=0"    to turn off detection'
  5292. call DBG 'Use "/define:INFINITE_MACRO_LOOP_WHEN=1000" to increase detection threshold'
  5293. call DBGIND-2
  5294. say ''
  5295. call DebugStateChanged
  5296. end
  5297. say ''
  5298. if ReplLoop>InfiniteLoopWhen+50 then
  5299. CryAndDie("Infinite loop detected (debug turned on above), current line now:", "",HashDefineString)
  5300. end
  5301. end
  5302. ReplLoop=ReplLoop+1
  5303. end
  5304. if InfiniteLoopDetected='Y' then
  5305. CryAndDie("Increase your loop detection value from " || InfiniteLoopWhen || ' with "/define:INFINITE_MACRO_LOOP_WHEN=Value"', "Increase to at least " || ReplLoop || '!')
  5306. if pos(StartsStdSymbolReplacement,HashDefineString)<>0 then
  5307. do
  5308. BeforeCount=ReplaceCount
  5309. HashDefineString=ReplaceStandardDefinitions(HashDefineString)
  5310. if HashDefRecord='Y' then
  5311. LastLineAfterMacroRep=HashDefineString
  5312. if OptionDebugOn='Y' then
  5313. do
  5314. if BeforeCount<>ReplaceCount then
  5315. do
  5316. if HashDefPrefix='' then
  5317. call DebugOutputAfterReplacement HashDefineString, 'SCMD'
  5318. else
  5319. call DebugOutputAfterReplacement HashDefineString, 'S' ||HashDefPrefix
  5320. end
  5321. end
  5322. end
  5323. return(HashDefineString)
  5324.  
  5325. _UnknownStandardSymbol:
  5326. call CryAndDie 'The standard symbol "' || StartsStdSymbolReplacement || SymbolName || EndsMacroReplacement || '" is unknown!'
  5327.  
  5328. ReplaceStandardDefinitions:
  5329. RightBit=arg(1)
  5330. if pos(MarksNewLine,RightBit)<>0 then
  5331. return(RightBit)
  5332. LeftBit=''
  5333. StartPos=pos(StartsStdSymbolReplacement,RightBit)
  5334. do while StartPos<>0
  5335. if StartsStdSymbolReplacement==MarksPhpXml then
  5336. do
  5337. Left4=substr(RightBit,StartPos+2,3)
  5338. if Left4='xml' then
  5339. do
  5340. LeftBit=LeftBit|| '<' ||CodexHexQuestionMark
  5341. RightBit=substr(RightBit,3)
  5342. StartPos=pos(StartsStdSymbolReplacement,RightBit)
  5343. iterate
  5344. end
  5345. if Left4='php' then
  5346. do
  5347. StartPos=pos(StartsStdSymbolReplacement,RightBit,StartPos+2)
  5348. iterate
  5349. end
  5350. if left(Left4,1)=' ' then
  5351. do
  5352. StartPos=pos(StartsStdSymbolReplacement,RightBit,StartPos+2)
  5353. iterate
  5354. end
  5355. end
  5356. EndPos=pos(EndsMacroReplacement,RightBit,StartPos+1)
  5357. if EndPos=0 then
  5358. CryAndDie('Could not find the "' || EndsMacroReplacement || '" end of variable started at: ' ||substr(RightBit,StartPos))
  5359. LeftBit=LeftBit||left(RightBit,StartPos-1)
  5360. SymbolNameC=substr(RightBit,StartPos+2,(EndPos-StartPos)-2)
  5361. RightBit=substr(RightBit,EndPos+1)
  5362. if left(SymbolNameC,1)='x' then
  5363. do
  5364. ReplaceCount=ReplaceCount-1
  5365. SymbolValue=StartsStdSymbolReplacement||SymbolNameC||EndsMacroReplacement
  5366. end
  5367. else
  5368. do
  5369. if OptionDebugOn='Y' then
  5370. call DebugOutputVariableInfo_FOUNDSTDVAR 'Found : ' ||StartsStdSymbolReplacement||SymbolNameC||EndsMacroReplacement
  5371. SymbolName=translate(SymbolNameC)
  5372. Left1=left(SymbolName,1)
  5373. if Left1='=' then
  5374. DdCodes=''
  5375. else
  5376. do
  5377. SpcPos=pos(' ',SymbolName)
  5378. if SpcPos=0 then
  5379. DdCodes=''
  5380. else
  5381. do
  5382. DdCodes=substr(SymbolName,SpcPos+1)
  5383. SymbolName=left(SymbolName,SpcPos-1)
  5384. end
  5385. end
  5386. select
  5387. when Left1='?' then
  5388. do
  5389. SymbolName=substr(SymbolName,2)
  5390. if symbol(SymbolName)<> 'VAR' then
  5391. do
  5392. call DumpVarsIfCompoundVariable SymbolName
  5393. call CryAndDie 'The rexx variable "' || SymbolName || '" is unknown!'
  5394. end
  5395. SymbolValue=_valueG(SymbolName)
  5396. end
  5397. when Left1='I' then
  5398. do
  5399. select
  5400. when SymbolName="INPUTFILE" then
  5401. SymbolValue=InputFileFull
  5402. when SymbolName="INPUTCOMPONENT" then
  5403. SymbolValue=IncludeFileName
  5404. when SymbolName="INPUTCOMPONENTLINE" then
  5405. SymbolValue=IncludeLineNumber
  5406. when SymbolName="INCLUDELEVEL" then
  5407. SymbolValue=IncludeLevel
  5408. otherwise
  5409. call _UnknownStandardSymbol
  5410. end
  5411. end
  5412. when Left1='S' then
  5413. do
  5414. select
  5415. when SymbolName="SPACE" then
  5416. SymbolValue=CodexHexSpace
  5417. when SymbolName="SEMICOLON" then
  5418. SymbolValue=CodexSemiColon
  5419. otherwise
  5420. call _UnknownStandardSymbol
  5421. end
  5422. end
  5423. when Left1='O' then
  5424. do
  5425. select
  5426. when SymbolName="OUTPUTLINE" then
  5427. SymbolValue=CurrentOutLine+1
  5428. when SymbolName="OUTPUTLEVEL" then
  5429. SymbolValue=OutputLevel
  5430. when SymbolName="OPSYS" then
  5431. SymbolValue=PpWizardOpSys
  5432. when SymbolName="OPSYSSPECIFIC" then
  5433. SymbolValue=PpWizardOpSysREAL
  5434. when SymbolName="OUTPUTFILE" then
  5435. do
  5436. call FileClose CurrentOutFile
  5437. SymbolValue=QueryExists(CurrentOutFile)
  5438. if SymbolValue='' then
  5439. CryAndDie('Could not obtain file name information for the "' || StartsStdSymbolReplacement || 'OutputFile>" variable!')
  5440. end
  5441. otherwise
  5442. call _UnknownStandardSymbol
  5443. end
  5444. end
  5445. when Left1='P' then
  5446. do
  5447. select
  5448. when SymbolName='PROCESSINGMODE' then
  5449. SymbolValue=ProcessingMode
  5450. when SymbolName='PROTECTFROMPPWSTART' then
  5451. SymbolValue=MarksNewLine||HashPrefix||ProtectFromPpwS||MarksNewLine
  5452. when SymbolName='PROTECTFROMPPWEND' then
  5453. SymbolValue=MarksNewLine||ProtectFromPpwE||MarksNewLine
  5454. when SymbolName='PPWIZARDAUTHORHOMEPAGE' then
  5455. SymbolValue=PgmAuthorHomePage
  5456. when SymbolName='PPWIZARDAUTHOR' then
  5457. SymbolValue=PgmAuthor
  5458. when SymbolName='PPWIZARDAUTHOREMAIL' then
  5459. SymbolValue=PgmAuthorEmail
  5460. when SymbolName='PPWIZARDPGM' then
  5461. SymbolValue=PpWizardPgmName
  5462. when SymbolName='PPWIZARDHOMEPAGE' then
  5463. SymbolValue=PgmHomePage
  5464. when SymbolName='PPWIZARDGENERATORMETATAGS' then
  5465. SymbolValue=PgmDefaultHtmlMetaTags
  5466. when SymbolName='PPWIZARDAUTHORBASEWEBDIR' then
  5467. SymbolValue=MyBaseHomeDir
  5468. otherwise
  5469. call _UnknownStandardSymbol
  5470. end
  5471. end
  5472. when Left1='D' then
  5473. do
  5474. select
  5475. when SymbolName='DEBUGON' then
  5476. SymbolValue=OptionDebugOn
  5477. when SymbolName='DOLLAR' then
  5478. SymbolValue=CodexHexDollar
  5479. when SymbolName='DIRSLASH' then
  5480. SymbolValue=RexDirChar
  5481. otherwise
  5482. call _UnknownStandardSymbol
  5483. end
  5484. end
  5485. when SymbolName='NEWLINE' then
  5486. SymbolValue=CodexHexNewLine
  5487. when SymbolName='NEWLINE?' then
  5488. do
  5489. CondNlCount=CondNlCount+1
  5490. SymbolValue="{?WaNtNl?}"
  5491. end
  5492. when SymbolName='/' then
  5493. SymbolValue=OptionXSlash
  5494. when SymbolName='COMPILETIME' then
  5495. do
  5496. z_Fmt=CfgMacro("PPWIZARD_FORMAT_COMPILETIME", '%c')
  5497. SymbolValue=FormatTime(z_Fmt,PpwCompTs, "PPWIZARD")
  5498. end
  5499. when SymbolName='CMDLINETOTAL' then
  5500. SymbolValue=CmdLineTotal
  5501. when SymbolName='VERSION' then
  5502. SymbolValue=PgmVersion
  5503. when SymbolName='HASH' then
  5504. SymbolValue=CodexHexHash
  5505. when SymbolName='HASHPREFIX' then
  5506. SymbolValue=HashPrefix
  5507. when SymbolName='RESTARTLINE' then
  5508. SymbolValue=MarksNewLine
  5509. when SymbolName='TOTALOUTPUTLINES' then
  5510. SymbolValue=GeneratedLines+1
  5511. when SymbolName='NEWESTFILEDATETIME' then
  5512. SymbolValue=NewestSourcefile
  5513. when SymbolName='LESSTHAN' then
  5514. SymbolValue=CodexHexLessThan
  5515. when SymbolName='QUESTIONMARK' then
  5516. SymbolValue=CodexHexQuestionMark
  5517. when SymbolName='BASEDIR' then
  5518. SymbolValue=BaseDir4CurrentInputFile
  5519. when SymbolName='UNIQUE' then
  5520. do
  5521. PPwizardUnique=PPwizardUnique+1
  5522. SymbolValue=PPwizardUnique
  5523. end
  5524. when SymbolName='TEMPLATEDATAFILE' then
  5525. SymbolValue=TemplateDataFile
  5526. when SymbolName='CGISTART' then
  5527. SymbolValue='Content-type: text/html' ||CodexHexNewLine||CodexHexNewLine
  5528. when SymbolName='REXXSKIP' then
  5529. do
  5530. RexxSkipCounter=RexxSkipCounter+1
  5531. RexxLbl=_filespec("WITHOUTEXTN", _filespec("NAME", IncludeFileName)) || '_' ||RexxSkipCounter
  5532. SymbolValue=MarksNewLine||HashPrefix|| 'RexxVar "RexxSkipLbl" = "' || RexxLbl || '"' ||MarksNewLine
  5533. SymbolValue=SymbolValue|| 'signal ' || RexxLbl || ';' ||MarksNewLine
  5534. SymbolValue=SymbolValue||MarksNewLine||HashPrefix|| 'RexxVar "RexxSkipLbl" PUSH' ||MarksNewLine
  5535. end
  5536. when SymbolName='REXXSKIPTO' then
  5537. do
  5538. SymbolValue=MarksNewLine||HashPrefix|| 'RexxVar "RexxSkipLbl" POP' ||MarksNewLine
  5539. SymbolValue=SymbolValue||RexxSkipLbl|| ':' ||MarksNewLine
  5540. end
  5541. when Left1='=' then
  5542. do
  5543. if OptionDebugOn='Y' then
  5544. call DBGIND 1
  5545. call ExecRexxCmd 'SymbolValue = ' ||substr(SymbolNameC,2)
  5546. if OptionDebugOn='Y' then
  5547. call DBGIND-1
  5548. end
  5549. otherwise
  5550. call _UnknownStandardSymbol
  5551. end
  5552. if DdCodes<> '' then
  5553. do
  5554. do until DdCodes=''
  5555. parse var DdCodes DdCode DdCodes
  5556. if OptionDebugOn='Y' then
  5557. do
  5558. call DebugOutputVariableInfo_FOUNDSTDVAR '$$Bef : ' ||SymbolValue
  5559. call DebugOutputVariableInfo_FOUNDSTDVAR '$$Cmd : ' ||DdCode
  5560. end
  5561. select
  5562.  
  5563. when DdCode='$$DSQ' then
  5564. do
  5565. QChar=QuoteIt(SymbolValue,TryQuoteListDs)
  5566. SymbolValue=QChar||SymbolValue||QChar
  5567. end
  5568.  
  5569. when DdCode='$$SDQ' then
  5570. do
  5571. QChar=QuoteIt(SymbolValue,TryQuoteListSd)
  5572. SymbolValue=QChar||SymbolValue||QChar
  5573. end
  5574.  
  5575. when DdCode='$$AQ' then
  5576. do
  5577. QChar=QuoteIt(SymbolValue,TryQuoteListAny)
  5578. SymbolValue=QChar||SymbolValue||QChar
  5579. end
  5580.  
  5581. when DdCode='$$UPPER' then
  5582. SymbolValue=translate(SymbolValue)
  5583.  
  5584. when DdCode='$$LOWER' then
  5585. SymbolValue=ToLowerCase(SymbolValue)
  5586.  
  5587. when DdCode='$$ADDCOMMA' then
  5588. SymbolValue=AddCommasToDecimalNumber(SymbolValue)
  5589.  
  5590. when DdCode='$$HTMLQ' then
  5591. SymbolValue=ReplaceString(SymbolValue, '"', '"')
  5592.  
  5593. when DdCode='$$SQX2' then
  5594. SymbolValue=ReplaceString(SymbolValue, "'" , "''")
  5595.  
  5596. when DdCode="$$RX'" then
  5597. SymbolValue=_RXQuote(SymbolValue, "'")
  5598.  
  5599. when DdCode='$$RX"' then
  5600. SymbolValue=_RXQuote(SymbolValue, '"')
  5601.  
  5602. when DdCode='$$SPCPLUS' then
  5603. do
  5604. if SymbolValue\=='' then
  5605. SymbolValue=' ' ||SymbolValue
  5606. end
  5607.  
  5608. when DdCode='$$RXEXEC' then
  5609. do
  5610. RxExec=''
  5611. call ExecRexxCmd SymbolValue
  5612. SymbolValue=RxExec
  5613. end
  5614.  
  5615. otherwise
  5616. do
  5617. UserRexx=CfgMacro("REXX_" || DdCode, '')
  5618. if UserRexx='' then
  5619. CryAndDie('The $$ replacement command of "' || DdCode || '" is unknown!')
  5620. TheMacro=""
  5621. TheName=SymbolName
  5622. TheValue=SymbolValue
  5623. call ExecRexxCmd UserRexx
  5624. if OptionDebugOn='Y' then
  5625. do
  5626. if SymbolValue=TheValue then
  5627. do
  5628. call DBGIND 1
  5629. call DebugOutputVariableInfo_FOUNDVARPARMS 'The user rexx code did not modify the "TheValue" variable'
  5630. call DBGIND-1
  5631. end
  5632. end
  5633. SymbolValue=TheValue
  5634. end
  5635. end
  5636. end
  5637. end
  5638. if OptionDebugOn='Y' then
  5639. call DebugOutputVariableInfo_FOUNDSTDVAR 'Value : ' ||DebugRightArrow||SymbolValue||DebugLeftArrow
  5640. end
  5641. LeftBit=LeftBit||SymbolValue
  5642. ReplaceCount=ReplaceCount+1
  5643. if pos(MarksNewLine,SymbolValue)<>0 then
  5644. leave
  5645. StartPos=pos(StartsStdSymbolReplacement,RightBit)
  5646. end
  5647. return(LeftBit||RightBit)
  5648.  
  5649. GetDefineContents:
  5650. if verify(arg(1),EndsVar, 'M') <> 0 then CryAndDie('The macro name "' || arg(1) || '" is invalid (Any of "' || EndsVar || '" are invalid)')
  5651. s_MacName=arg(1)
  5652. s_MacNameO=s_MacName
  5653. s_RbPos=pos(MacroIndRight,s_MacName)
  5654. if s_RbPos<>0 then
  5655. do
  5656. if OptionDebugOn='Y' then
  5657. do
  5658. call DBG_DEFINING '[indirection]: ' ||DebugRightArrow||s_MacName||DebugLeftArrow
  5659. call DBGIND 1
  5660. end
  5661. do while s_RbPos<>0
  5662. s_LbPos=lastpos(MacroIndLeft,s_MacName,s_RbPos)
  5663. if s_LbPos=0 then
  5664. CryAndDie('Could not find a matching "' || MacroIndLeft || '" character for "' || MacroIndRight || '"', 'The invalid macro is:', '  ' ||s_MacName)
  5665. s_L=left(s_MacName,s_LbPos-1)
  5666. s_M=substr(s_MacName,s_LbPos+1,s_RbPos-s_LbPos-1)
  5667. s_R=substr(s_MacName,s_RbPos+1)
  5668. if OptionDebugOn='Y' then
  5669. do
  5670. call DBG_DEFINING 'Looking for: ' ||s_M
  5671. call DBGIND 1
  5672. end
  5673. s_RepType=''
  5674. if symbol(s_M)='VAR' then
  5675. do
  5676. s_RepType='REXX'
  5677. s_RepWith=value(s_M)
  5678. end
  5679. else
  5680. do
  5681. if CsReplacement='N' then
  5682. s_SavedAs='MACRO?.M?'||c2x(translate(s_M))
  5683. else
  5684. s_SavedAs='MACRO?.M?'||c2x(s_M)
  5685. if symbol(s_SavedAs)='VAR' then
  5686. do
  5687. s_RepType='PPWIZARD'
  5688. s_RepWith=value(s_SavedAs)
  5689. end
  5690. end
  5691. if OptionDebugOn='Y' then
  5692. do
  5693. if s_RepType='' then
  5694. call DBG_DEFINING 'No such REXX or PPWIZARD symbol!'
  5695. else
  5696. call DBG_DEFINING s_RepType|| ' symbol contained: ' ||s_RepWith
  5697. call DBGIND-1
  5698. end
  5699. if s_RepType='' then
  5700. do
  5701. if s_MacName=s_MacNameO then
  5702. s_Show=s_MacName
  5703. else
  5704. s_Show=s_MacName|| ' <= "' ||s_MacNameO
  5705. CryAndDie("Could not find a REXX variable or PPWIZARD macro matching:", '  ' || s_M, 'In the macro reference:', '  ' ||s_Show)
  5706. end
  5707. s_MacName=s_L||s_RepWith||s_R
  5708. if OptionDebugOn='Y' then
  5709. call DBG_DEFINING 'New macro reference is "' ||DebugRightArrow||s_MacName||DebugLeftArrow
  5710. s_RbPos=pos(MacroIndRight,s_MacName)
  5711. end
  5712. if OptionDebugOn='Y' then
  5713. call DBGIND-1
  5714. end
  5715. if pos(MacroIndLeft,s_MacName)<>0 then
  5716. CryAndDie('Could not find a matching "' || MacroIndRight || '" character for "' || MacroIndLeft || '"', 'The invalid macro is:', '  ' ||s_MacName)
  5717. ba_MN=s_MacName
  5718. if CsReplacement='N' then
  5719. ba_SA='MACRO?.M?'||c2x(translate(s_MacName))
  5720. else
  5721. ba_SA='MACRO?.M?'||c2x(s_MacName)
  5722. if symbol(ba_SA)='VAR' then
  5723. return(_valueG(ba_SA))
  5724. if arg(1)=ba_MN then
  5725. ba_New=''
  5726. else
  5727. ba_New=' ("' || ba_MN || '")'
  5728. CryAndDie('Macro named "' || arg(1) || '"' || ba_New || ' does not exist!',_MacroBitNotFoundText())
  5729.  
  5730. _SpecialPrm:
  5731. call DebugOutputVariableInfo_FOUNDVARPARMS "This is a special variable, it's value is: " ||arg(1)
  5732. return
  5733.  
  5734. _DieInvPrm:
  5735. 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())
  5736. return
  5737.  
  5738. ReplaceDefinitionsParameters:
  5739. do ParmIndex=1 to ParmCount
  5740. ParmUsed.ParmIndex='N'
  5741. end
  5742. bb_DieIfNotUsed='N'
  5743. bb_ValPointless='N'
  5744. DefaultCnt=0
  5745. ParmLeftBit=''
  5746. ParmRightBit=VariableCont
  5747. ParmPos=pos(StartsMacroParm,ParmRightBit)
  5748. do while ParmPos<>0
  5749. ParmLeftBit=ParmLeftBit||left(ParmRightBit,ParmPos-1)
  5750. ParmRightBit=substr(ParmRightBit,ParmPos+2)
  5751. EqualPos=pos('=',ParmRightBit)
  5752. MaybeEndPos=pos(EndsMacroParm,ParmRightBit)
  5753. if MaybeEndPos=0 then
  5754. CryAndDie('Incorrect use of macro parameter, no matching "' || EndsMacroParm || '" for "' || StartsMacroParm || '"')
  5755. if EqualPos<>0&EqualPos<MaybeEndPos then
  5756. do
  5757. if CsReplacement='N' then
  5758. ThisParmName=translate(strip(left(ParmRightBit,EqualPos-1)))
  5759. else
  5760. ThisParmName=strip(left(ParmRightBit,EqualPos-1))
  5761. ParmRightBit=substr(ParmRightBit,EqualPos+1)
  5762. ParmDefault=GetQuotedText(ParmRightBit, "ParmRightBit",EndsMacroParm)
  5763. HaveDefault='Y'
  5764. CurlyPos=pos(EndsMacroParm,ParmRightBit)
  5765. if CurlyPos=0 then
  5766. CryAndDie("Expected to find '" || EndsMacroParm || "' " || 'after the parameter default of "' || ParmDefault || '"!')
  5767. ParmCmds=left(ParmRightBit,CurlyPos-1)
  5768. ParmRightBit=substr(ParmRightBit,CurlyPos+1)
  5769. FoundIndex=0
  5770. do DefaultIndex=1 to DefaultCnt
  5771. if ThisParmName=PrmDefaultName.DefaultIndex then
  5772. do
  5773. FoundIndex=DefaultIndex
  5774. leave
  5775. end
  5776. end
  5777. if FoundIndex=0 then
  5778. do
  5779. DefaultCnt=DefaultCnt+1
  5780. FoundIndex=DefaultCnt
  5781. end
  5782. PrmDefaultName.FoundIndex=ThisParmName
  5783. PrmDefaultValue.FoundIndex=ParmDefault
  5784. end
  5785. else
  5786. do
  5787. HaveDefault='N'
  5788. if CsReplacement='N' then
  5789. ThisParmName=translate(strip(left(ParmRightBit,MaybeEndPos-1)))
  5790. else
  5791. ThisParmName=strip(left(ParmRightBit,MaybeEndPos-1))
  5792. SpcPos=pos(' ',ThisParmName)
  5793. if SpcPos=0 then
  5794. ParmCmds=''
  5795. else
  5796. do
  5797. ParmCmds=substr(ThisParmName,SpcPos+1)
  5798. ThisParmName=left(ThisParmName,SpcPos-1)
  5799. end
  5800. ParmRightBit=substr(ParmRightBit,MaybeEndPos+1)
  5801. end
  5802. if OptionDebugOn='Y' then
  5803. call DebugOutputVariableInfo_FOUNDVARPARMS 'Parm : ' ||ThisParmName
  5804. FndVarIndex=0
  5805. do ParmIndex=1 to ParmCount
  5806. if ParmName.ParmIndex<> '' then
  5807. do
  5808. if ThisParmName=ParmName.ParmIndex then
  5809. do
  5810. ParmUsed.ParmIndex='Y'
  5811. FndVarIndex=ParmIndex
  5812. end
  5813. end
  5814. end
  5815. if FndVarIndex<>0 then
  5816. ReplaceParmWith=ParmValue.FndVarIndex
  5817. else
  5818. do
  5819. if HaveDefault='Y' then
  5820. ReplaceParmWith=ParmDefault
  5821. else
  5822. do
  5823. if OptionDebugOn='Y' then
  5824. do
  5825. call DBGIND 1
  5826. call DebugOutputVariableInfo_FOUNDVARPARMS 'Parameter not supplied. No default given. Default value stored?'
  5827. end
  5828. do DefaultIndex=1 to DefaultCnt
  5829. if ThisParmName=PrmDefaultName.DefaultIndex then
  5830. do
  5831. ReplaceParmWith=PrmDefaultValue.DefaultIndex
  5832. HaveDefault='Y'
  5833. leave
  5834. end
  5835. end
  5836. if OptionDebugOn='Y' then
  5837. do
  5838. if HaveDefault='N' then
  5839. Ans='Oops - not user defined!'
  5840. else
  5841. Ans='Lucky!'
  5842. call DebugOutputVariableInfo_FOUNDVARPARMS Ans
  5843. call DBGIND-1
  5844. end
  5845. if HaveDefault='N' then
  5846. do
  5847. bb_ReginaBugWorkAround='N'
  5848. select
  5849. when ThisParmName='?' then
  5850. do
  5851. bb_ValPointless='Y'
  5852. bb_ReginaBugWorkAround='Y'
  5853. if OptionDebugOn='Y' then
  5854. call _SpecialPrm 'is all unused parms'
  5855. ReplaceParmWith=''
  5856. do ParmIndex=1 to ParmCount
  5857. if ParmName.ParmIndex<> '' then
  5858. do
  5859. if ParmUsed.ParmIndex='N' then
  5860. do
  5861. if ReplaceParmWith=='' then
  5862. LSPC=''
  5863. else
  5864. LSPC=' '
  5865. if ParmValueT.ParmIndex='NV' then
  5866. ReplaceParmWith=ReplaceParmWith||LSPC||ParmNameC.ParmIndex
  5867. else
  5868. do
  5869. if ParmCmds='' then
  5870. do
  5871. QChar=QuoteIt(ParmValue.ParmIndex,TryQuoteListAny)
  5872. ReplaceParmWith=ReplaceParmWith||LSPC||ParmNameC.ParmIndex|| '=' ||QChar||ParmValue.ParmIndex||QChar
  5873. end
  5874. else
  5875. do
  5876. ReplaceParmWith=ReplaceParmWith||LSPC||StartsMacroParm||ParmNameC.ParmIndex|| ' ' ||ParmCmds||EndsMacroParm
  5877. end
  5878. end
  5879. end
  5880. end
  5881. end
  5882. ParmCmds=''
  5883. end
  5884. when ThisParmName='??' then
  5885. do
  5886. bb_ValPointless='Y'
  5887. bb_ReginaBugWorkAround='Y'
  5888. if OptionDebugOn='Y' then
  5889. call _SpecialPrm 'all parms as rexx array'
  5890. RepWith=''
  5891. ArrayCnt=0
  5892. do ParmIndex=1 to ParmCount
  5893. if ParmName.ParmIndex<> '' then
  5894. do
  5895. MpTmp=ParmValue.ParmIndex
  5896. if length(MpTmp)<=200 then
  5897. do
  5898. MpRepVW=QuoteAsRexxLit(MpTmp)
  5899. end
  5900. else
  5901. do
  5902. MpRepVW='MpTmpV'
  5903. MpTmpF='Y'
  5904. do while length(MpTmp)>200
  5905. RepWith=RepWith|| 'MpTmpV='
  5906. if MpTmpF='Y' then
  5907. MpTmpF='N'
  5908. else
  5909. RepWith=RepWith|| 'MpTmpV||'
  5910. RepWith=RepWith||QuoteAsRexxLit(left(MpTmp,200))||DefRexxSpecialSepTag
  5911. MpTmp=substr(MpTmp,200+1)
  5912. end
  5913. if MpTmp\=='' then
  5914. RepWith=RepWith|| 'MpTmpV=MpTmpV||' ||QuoteAsRexxLit(MpTmp)||DefRexxSpecialSepTag
  5915. end
  5916. ArrayCnt=ArrayCnt+1
  5917. RepWith=RepWith|| 'MP.' || ArrayCnt || ".MPNAME  = " ||QuoteAsRexxLit(ParmNameC.ParmIndex)||DefRexxSpecialSepTag
  5918. RepWith=RepWith|| 'MP.' || ArrayCnt || ".MPVALUE = " ||MpRepVW||DefRexxSpecialSepTag
  5919. RepWith=RepWith|| 'MP.' || ArrayCnt || ".MPUSED  = '" || ParmUsed.ParmIndex                   || "'" ||DefRexxSpecialSepTag
  5920. RepWith=RepWith|| 'MP.' || ArrayCnt || ".MPTYPE  = '" || ParmValueT.ParmIndex                 || "'" ||DefRexxSpecialSepTag
  5921. end
  5922. end
  5923. ReplaceParmWith=RepWith|| 'MP.0 = ' ||ArrayCnt||DefRexxSpecialSepTag
  5924. ParmCmds=''
  5925. end
  5926. when translate(ThisParmName)='?MACNAME' then
  5927. do
  5928. bb_ReginaBugWorkAround='Y'
  5929. if OptionDebugOn='Y' then
  5930. call _SpecialPrm 'name of macro being expanded'
  5931. ReplaceParmWith=VariableName
  5932. end
  5933. when translate(ThisParmName)='?RESETUSED' then
  5934. do
  5935. bb_ReginaBugWorkAround='Y'
  5936. if OptionDebugOn='Y' then
  5937. call _SpecialPrm 'All parms now marked unused'
  5938. do ParmIndex=1 to ParmCount
  5939. ParmUsed.ParmIndex='N'
  5940. end
  5941. bb_ValPointless='Y'
  5942. ReplaceParmWith=''
  5943. ParmCmds=''
  5944. end
  5945. when ThisParmName='!' then
  5946. do
  5947. bb_DieIfNotUsed="Y"
  5948. bb_ReginaBugWorkAround='Y'
  5949. if OptionDebugOn='Y' then
  5950. call _SpecialPrm 'Empty - It is a parameter validation command'
  5951. ReplaceParmWith=''
  5952. ParmCmds=''
  5953. end
  5954. otherwise
  5955. do
  5956. if bb_ReginaBugWorkAround='N' then
  5957. call _DieInvPrm
  5958. end
  5959. end
  5960. end
  5961. end
  5962. end
  5963. if ParmCmds<> '' then
  5964. do
  5965. ParmCmds=translate(strip(ParmCmds))
  5966. do until ParmCmds=''
  5967. parse var ParmCmds ParmCmd ParmCmds
  5968. if OptionDebugOn='Y' then
  5969. do
  5970. call DBGIND 1
  5971. call DebugOutputVariableInfo_FOUNDVARPARMS '$Bef: ' ||ReplaceParmWith
  5972. call DebugOutputVariableInfo_FOUNDVARPARMS '$Cmd: ' ||ParmCmd
  5973. call DBGIND-1
  5974. end
  5975. select
  5976. when ParmCmd='$$PASSAQ' then
  5977. do
  5978. QChar=QuoteIt(ReplaceParmWith,TryQuoteListAny)
  5979. ReplaceParmWith=ThisParmName|| '=' ||QChar||ReplaceParmWith||QChar
  5980. end
  5981. when ParmCmd='$$PASSDSQ' then
  5982. do
  5983. QChar=QuoteIt(ReplaceParmWith,TryQuoteListDs)
  5984. ReplaceParmWith=ThisParmName|| '=' ||QChar||ReplaceParmWith||QChar
  5985. end
  5986. when ParmCmd='$$IGNORE' then
  5987. ReplaceParmWith=''
  5988.  
  5989. when ParmCmd='$$DSQ' then
  5990. do
  5991. QChar=QuoteIt(ReplaceParmWith,TryQuoteListDs)
  5992. ReplaceParmWith=QChar||ReplaceParmWith||QChar
  5993. end
  5994.  
  5995. when ParmCmd='$$SDQ' then
  5996. do
  5997. QChar=QuoteIt(ReplaceParmWith,TryQuoteListSd)
  5998. ReplaceParmWith=QChar||ReplaceParmWith||QChar
  5999. end
  6000.  
  6001. when ParmCmd='$$AQ' then
  6002. do
  6003. QChar=QuoteIt(ReplaceParmWith,TryQuoteListAny)
  6004. ReplaceParmWith=QChar||ReplaceParmWith||QChar
  6005. end
  6006.  
  6007. when ParmCmd='$$UPPER' then
  6008. ReplaceParmWith=translate(ReplaceParmWith)
  6009.  
  6010. when ParmCmd='$$LOWER' then
  6011. ReplaceParmWith=ToLowerCase(ReplaceParmWith)
  6012.  
  6013. when ParmCmd='$$ADDCOMMA' then
  6014. ReplaceParmWith=AddCommasToDecimalNumber(ReplaceParmWith)
  6015.  
  6016. when ParmCmd='$$HTMLQ' then
  6017. ReplaceParmWith=ReplaceString(ReplaceParmWith, '"', '"')
  6018.  
  6019. when ParmCmd='$$SQX2' then
  6020. ReplaceParmWith=ReplaceString(ReplaceParmWith, "'" , "''")
  6021.  
  6022. when ParmCmd="$$RX'" then
  6023. ReplaceParmWith=_RXQuote(ReplaceParmWith, "'")
  6024.  
  6025. when ParmCmd='$$RX"' then
  6026. ReplaceParmWith=_RXQuote(ReplaceParmWith, '"')
  6027.  
  6028. when ParmCmd='$$SPCPLUS' then
  6029. do
  6030. if ReplaceParmWith\=='' then
  6031. ReplaceParmWith=' ' ||ReplaceParmWith
  6032. end
  6033.  
  6034. when ParmCmd='$$RXEXEC' then
  6035. do
  6036. RxExec=''
  6037. call ExecRexxCmd ReplaceParmWith
  6038. ReplaceParmWith=RxExec
  6039. end
  6040.  
  6041. otherwise
  6042. do
  6043. UserRexx=CfgMacro("REXX_" || ParmCmd, '')
  6044. if UserRexx='' then
  6045. CryAndDie('The $$ replacement command of "' || ParmCmd || '" is unknown!')
  6046. TheMacro=VariableName
  6047. TheName=ThisParmName
  6048. TheValue=ReplaceParmWith
  6049. call ExecRexxCmd UserRexx
  6050. if OptionDebugOn='Y' then
  6051. do
  6052. if ReplaceParmWith=TheValue then
  6053. do
  6054. call DBGIND 1
  6055. call DebugOutputVariableInfo_FOUNDVARPARMS 'The user rexx code did not modify the "TheValue" variable'
  6056. call DBGIND-1
  6057. end
  6058. end
  6059. ReplaceParmWith=TheValue
  6060. end
  6061. end
  6062. end
  6063. end
  6064. if OptionDebugOn='Y' then
  6065. do
  6066. call DBGIND 1
  6067. call DebugOutputVariableInfo_FOUNDVARPARMS 'Use : ' ||ReplaceParmWith
  6068. call DBGIND-1
  6069. end
  6070. ParmRightBit=ReplaceParmWith||ParmRightBit
  6071. ParmPos=pos(StartsMacroParm,ParmRightBit)
  6072. end
  6073. ParmLeftBit=ParmLeftBit||ParmRightBit
  6074. if bb_ValPointless='N' then
  6075. do
  6076. if OptionParmVal<> "S" then
  6077. do
  6078. bb_DieIfNotUsed=OptionParmVal
  6079. end
  6080. if bb_DieIfNotUsed='Y' | OptionDebugOn = 'Y' then
  6081. do
  6082. bb_UnUsed=''
  6083. do ParmIndex=1 to ParmCount
  6084. if ParmUsed.ParmIndex='N' then
  6085. do
  6086. 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).'
  6087. if bb_UnUsed='' then
  6088. bb_UnUsed=ParmName.ParmIndex
  6089. else
  6090. bb_UnUsed=bb_UnUsed|| ', ' ||ParmName.ParmIndex
  6091. end
  6092. end
  6093. if bb_DieIfNotUsed='Y' then
  6094. do
  6095. if bb_UnUsed<> '' then
  6096. do
  6097. bb_UnUsed='    ' ||bb_UnUsed
  6098. if DefaultCnt=0 then
  6099. bb_Def='No macro parameters used default values'
  6100. else
  6101. do
  6102. bb_Def=''
  6103. do DefaultIndex=1 to DefaultCnt
  6104. if bb_Def='' then
  6105. bb_Def=PrmDefaultName.DefaultIndex
  6106. else
  6107. bb_Def=bb_Def|| ', ' ||PrmDefaultName.DefaultIndex
  6108. end
  6109. end
  6110. bb_Def='    ' ||bb_Def
  6111. CryAndDie('The "' || VariableName || '" macro was supplied parameters it', 'does not require! These are:', bb_UnUsed, '', 'These macro parameters used default values:',bb_Def)
  6112. end
  6113. end
  6114. end
  6115. end
  6116. if pos('{',ParmLeftBit)<>0 then
  6117. do
  6118. if pos(StartsMacroParm,ParmLeftBit)<>0 then
  6119. CryAndDie('Not all "' || VariableName || '" parameters replaced!')
  6120. ParmLeftBit=ReplaceString(ParmLeftBit,HidesMacroParm,StartsMacroParm)
  6121. end
  6122. return(ParmLeftBit)
  6123.  
  6124. _ReplaceAllHashDefinedVariables:
  6125. RightBit=arg(1)
  6126. LeftBit=''
  6127. ChangesMade='N'
  6128. VarPos=pos(StartsMacroReplacement,RightBit)
  6129. do while VarPos<>0
  6130. LeftBit=LeftBit||left(RightBit,VarPos-1)
  6131. RightBit=substr(RightBit,VarPos+2)
  6132. DelPos=verify(RightBit,EndsVar, 'M')
  6133. if DelPos=0 then
  6134. CryAndDie("Can't find the end of the macro reference at " ||DebugRightArrow||StartsMacroReplacement||RightBit||DebugLeftArrow)
  6135. VariableName=left(RightBit,DelPos-1)
  6136. MacroBeingExpanded=VariableName
  6137. RightBit=strip(substr(RightBit,DelPos), 'L')
  6138. if OptionDebugOn='Y' then
  6139. do
  6140. call DebugOutputVariableInfo_FOUNDVAR 'Found : ' || StartsMacroReplacement || VariableName || ' ...' ||EndsMacroReplacement
  6141. call DBGIND 1
  6142. end
  6143. DefnAsIs='N'
  6144. VariableCont=GetDefineContents(VariableName)
  6145. if OptionDebugOn='Y' then
  6146. do
  6147. call DebugOutputVariableInfo_FOUNDVAR 'Value : ' ||DebugRightArrow||VariableCont||DebugLeftArrow
  6148. call DBGIND 1
  6149. end
  6150. ParmCount=0
  6151. DDCmdCount=0
  6152. PositionalParmCount=0
  6153. EndParmDelimiters=EndsMacroReplacement|| '= '
  6154. Left1=left(RightBit,1)
  6155. do while Left1<>EndsMacroReplacement
  6156. if pos(Left1,ArePositionalChars)<>0 then
  6157. do
  6158. PositionalParmCount=PositionalParmCount+1
  6159. ThisParmNameC='#' ||PositionalParmCount
  6160. if CsReplacement='N' then
  6161. ThisParmName=translate(ThisParmNameC)
  6162. else
  6163. ThisParmName=ThisParmNameC
  6164. ThisParmValType='V'
  6165. if Left1='=' then
  6166. ThisParmVal=GetQuotedText(substr(RightBit,2), "RightBit",EndsMacroReplacement)
  6167. else
  6168. ThisParmVal=GetQuotedText(RightBit, "RightBit",EndsMacroReplacement)
  6169. end
  6170. else
  6171. do
  6172. DelPos=verify(RightBit,EndParmDelimiters, 'M')
  6173. if DelPos=0 then
  6174. CryAndDie('Macro reference incorrectly formatted, missing "' || EndsMacroReplacement || '"?')
  6175. ThisParmNameC=strip(left(RightBit,DelPos-1))
  6176. if CsReplacement='N' then
  6177. ThisParmName=translate(ThisParmNameC)
  6178. else
  6179. ThisParmName=ThisParmNameC
  6180. DelChar=substr(RightBit,DelPos,1)
  6181. if DelChar='=' then
  6182. do
  6183. ThisParmVal=GetQuotedText(substr(RightBit,DelPos+1), "RightBit",EndsMacroReplacement)
  6184. ThisParmValType='V'
  6185. end
  6186. else
  6187. do
  6188. RightBit=strip(substr(RightBit,DelPos), 'L')
  6189. if left(ThisParmName,2)<> '$$' then
  6190. do
  6191. ThisParmVal=ThisParmName
  6192. ThisParmValType='NV'
  6193. end
  6194. else
  6195. do
  6196. if OptionDebugOn='Y' then
  6197. call DebugOutputVariableInfo_FOUNDVARPARMS '$$Cmd: ' ||ThisParmName
  6198. select
  6199. when ThisParmName='$$ASIS' then
  6200. DefnAsIs='Y'
  6201. otherwise
  6202. do
  6203. DDCmdCount=DDCmdCount+1
  6204. DDCmd.DDCmdCount=ThisParmName
  6205. end
  6206. end
  6207. Left1=left(RightBit,1)
  6208. iterate
  6209. end
  6210. end
  6211. end
  6212. do ChkIndex=1 to ParmCount
  6213. if ThisParmName=ParmName.ChkIndex then
  6214. CryAndDie('The macro parameter "' || ThisParmName || '" was specified more than once!')
  6215. end
  6216. ParmCount=ParmCount+1
  6217. ParmName.ParmCount=ThisParmName
  6218. ParmNameC.ParmCount=ThisParmNameC
  6219. ParmValue.ParmCount=ThisParmVal
  6220. ParmValueT.ParmCount=ThisParmValType
  6221. Left1=left(RightBit,1)
  6222. end
  6223. if DefnAsIs='Y' then
  6224. do
  6225. if ParmCount<>0 then
  6226. CryAndDie('You wanted "' || VariableName || '" subsituted ASIS but then specified parameters!')
  6227. end
  6228. else
  6229. do
  6230. if ParmCount<>0 then
  6231. VariableCont=ReplaceDefinitionsParameters()
  6232. else
  6233. do
  6234. if pos(StartsMacroParm,VariableCont)<>0 then
  6235. VariableCont=ReplaceDefinitionsParameters()
  6236. else
  6237. VariableCont=ReplaceString(VariableCont,HidesMacroParm,StartsMacroParm)
  6238. end
  6239. end
  6240. if DDCmdCount<>0 then
  6241. do
  6242. do ddIndex=1 to DDCmdCount
  6243. ThisDdCmd=DDCmd.ddIndex
  6244. select
  6245.  
  6246. when ThisDdCmd='$$DSQ' then
  6247. do
  6248. QChar=QuoteIt(VariableCont,TryQuoteListDs)
  6249. VariableCont=QChar||VariableCont||QChar
  6250. end
  6251.  
  6252. when ThisDdCmd='$$SDQ' then
  6253. do
  6254. QChar=QuoteIt(VariableCont,TryQuoteListSd)
  6255. VariableCont=QChar||VariableCont||QChar
  6256. end
  6257.  
  6258. when ThisDdCmd='$$AQ' then
  6259. do
  6260. QChar=QuoteIt(VariableCont,TryQuoteListAny)
  6261. VariableCont=QChar||VariableCont||QChar
  6262. end
  6263.  
  6264. when ThisDdCmd='$$UPPER' then
  6265. VariableCont=translate(VariableCont)
  6266.  
  6267. when ThisDdCmd='$$LOWER' then
  6268. VariableCont=ToLowerCase(VariableCont)
  6269.  
  6270. when ThisDdCmd='$$ADDCOMMA' then
  6271. VariableCont=AddCommasToDecimalNumber(VariableCont)
  6272.  
  6273. when ThisDdCmd='$$HTMLQ' then
  6274. VariableCont=ReplaceString(VariableCont, '"', '"')
  6275.  
  6276. when ThisDdCmd='$$SQX2' then
  6277. VariableCont=ReplaceString(VariableCont, "'" , "''")
  6278.  
  6279. when ThisDdCmd="$$RX'" then
  6280. VariableCont=_RXQuote(VariableCont, "'")
  6281.  
  6282. when ThisDdCmd='$$RX"' then
  6283. VariableCont=_RXQuote(VariableCont, '"')
  6284.  
  6285. when ThisDdCmd='$$SPCPLUS' then
  6286. do
  6287. if VariableCont\=='' then
  6288. VariableCont=' ' ||VariableCont
  6289. end
  6290.  
  6291. when ThisDdCmd='$$RXEXEC' then
  6292. do
  6293. RxExec=''
  6294. call ExecRexxCmd VariableCont
  6295. VariableCont=RxExec
  6296. end
  6297.  
  6298. otherwise
  6299. do
  6300. UserRexx=CfgMacro("REXX_" || ThisDdCmd, '')
  6301. if UserRexx='' then
  6302. CryAndDie('The $$ replacement command of "' || ThisDdCmd || '" is unknown!')
  6303. TheMacro=""
  6304. TheName=VariableName
  6305. TheValue=VariableCont
  6306. call ExecRexxCmd UserRexx
  6307. if OptionDebugOn='Y' then
  6308. do
  6309. if VariableCont=TheValue then
  6310. do
  6311. call DBGIND 1
  6312. call DebugOutputVariableInfo_FOUNDVARPARMS 'The user rexx code did not modify the "TheValue" variable'
  6313. call DBGIND-1
  6314. end
  6315. end
  6316. VariableCont=TheValue
  6317. end
  6318. end
  6319. end
  6320. end
  6321. if OptionDebugOn='Y' then
  6322. call DBGIND-2
  6323. RightBit=substr(RightBit,2)
  6324. LeftBit=LeftBit||VariableCont
  6325. ReplaceCount=ReplaceCount+1
  6326. if pos(MarksNewLine,LeftBit)<>0 then
  6327. leave
  6328. VarPos=pos(StartsMacroReplacement,RightBit)
  6329. end
  6330. MacroBeingExpanded=''
  6331. TheString=LeftBit||RightBit
  6332. return(TheString)
  6333.  
  6334. CfgMacro:
  6335. DefVar=arg(1)
  6336. if MacroExists(DefVar)='N' then
  6337. do
  6338. DefValue=arg(2)
  6339. DefDbgWrd='not'
  6340. end
  6341. else
  6342. do
  6343. DefValue=GetDefineContents(DefVar)
  6344. DefDbgWrd='was'
  6345. end
  6346. if OptionDebugOn='Y' then
  6347. call DBG_MACROVALORDEF 'Option(Macro) "' || DefVar || '" ' || DefDbgWrd || ' found. Using ' ||DebugRightArrow||DefValue||DebugLeftArrow
  6348. return(DefValue)
  6349.  
  6350. Define_26:
  6351. RexxTokens='|=+-/%*<>\,;:()&'
  6352. signal LineOut_27
  6353.  
  6354. GenerateOneLine:
  6355. if CondNlCount=0 then
  6356. call GenerateOneLineAsIs arg(1)
  6357. else
  6358. do
  6359. if OptionDebugOn='Y' then
  6360. call DBG 'Looking for Conditional newline codes'
  6361. BefCodeCount=ReplaceCount
  6362. Line2Gen=ReplaceString(arg(1), "{?WaNtNl?}",MarksNewLine)
  6363. if BefCodeCount<>ReplaceCount then
  6364. do
  6365. if OptionDebugOn='Y' then
  6366. call DBG 'Found ' ReplaceCount - BefCodeCount || ' conditional newline codes'
  6367. CondNlCount=CondNlCount-(ReplaceCount-BefCodeCount)
  6368. do until BefCodeCount=ReplaceCount
  6369. BefCodeCount=ReplaceCount
  6370. Line2Gen=ReplaceString(Line2Gen,MarksNewLine||MarksNewLine,MarksNewLine)
  6371. end
  6372. if Line2Gen\=='' then
  6373. do
  6374. if left(Line2Gen,1)=MarksNewLine then
  6375. Line2Gen=substr(Line2Gen,2)
  6376. if Line2Gen\=='' then
  6377. do
  6378. if right(Line2Gen,1)=MarksNewLine then
  6379. Line2Gen=left(Line2Gen,length(Line2Gen)-1)
  6380. end
  6381. end
  6382. end
  6383. do until Line2Gen==''
  6384. parse var Line2Gen This1 (MarksNewLine) Line2Gen
  6385. call GenerateOneLineAsIs This1
  6386. end
  6387. end
  6388. return
  6389.  
  6390. GenerateOneLineAsIs:
  6391. Line2Gen2=arg(1)
  6392. if CheckSpelling='Y';then
  6393. do
  6394. if AllowSpell='Y' & Line2Gen2 <> '' then
  6395. call SpellCheckOneLine Line2Gen2
  6396. end
  6397. if OptionFilterOut='' then
  6398. do
  6399. if HoldingOutput='N' then
  6400. call DirectToOutputFile Line2Gen2||NewLineChars
  6401. else
  6402. HeldOutput=HeldOutput||Line2Gen2||NewLineChars
  6403. GeneratedLines=GeneratedLines+1
  6404. CurrentOutLine=CurrentOutLine+1
  6405. end
  6406. else
  6407. do
  6408. FilterRc=HtmlFilterOut("O",Line2Gen2,CurrentOutFile,CurrentOutLine,GeneratedLines,NewLineChars)
  6409. if Left(FilterRc,3)<> "OK:" then
  6410. CryAndDie(FilterRc)
  6411. else
  6412. do
  6413. NumWritten=substr(FilterRc,4)
  6414. GeneratedLines=GeneratedLines+NumWritten
  6415. CurrentOutLine=CurrentOutLine+NumWritten
  6416. end
  6417. end
  6418. return
  6419.  
  6420. DirectToOutputFile:
  6421. if 0=charout(CurrentOutFile,arg(1))then
  6422. return
  6423. IoReason=FileDescription(CurrentOutFile)
  6424. CryAndDie('Write to "' || CurrentOutFile || '" failed (' || IoReason || ')!')
  6425.  
  6426. OutputRexxLine:
  6427. RexxLine=arg(1)
  6428. if right(RexxLine,1)=';' then
  6429. RexxLine=left(RexxLine,length(RexxLine)-1)
  6430. if OptionPack='Y' & KeepIndent = 'N' then
  6431. do
  6432. if AllowPack='Y' then
  6433. RexxLine=CompressRexxLine(RexxLine)
  6434. else
  6435. do
  6436. if OptionDebugOn='Y' then
  6437. call DBG 'Not allowed to pack this line'
  6438. end
  6439. end
  6440. ElPos=pos(':',RexxLine)
  6441. if ElPos<>0 then
  6442. do
  6443. PossLabel=strip(left(RexxLine,ElPos-1))
  6444. if datatype(PossLabel, 'S')=1 then
  6445. call GenerateOneLine ''
  6446. end
  6447. if pos(NotEqualInC,RexxLine)<>0 then
  6448. call OutputInformationToScreen '"' || NotEqualInC || '" found.  Did you mean to use "<>" or "\="?'
  6449. call GenerateOneLine RexxLine
  6450. return
  6451.  
  6452. CompressRexxLine:
  6453. RexxLine=arg(1)
  6454. Spos=lastpos("'",RexxLine)
  6455. Dpos=lastpos('"',RexxLine)
  6456. EndPos=max(Spos,Dpos)
  6457. if EndPos=0 then
  6458. return(_CompressRexx(RexxLine))
  6459. else
  6460. do
  6461. Spos=pos("'",RexxLine)
  6462. Dpos=pos('"',RexxLine)
  6463. StartPos=min(Spos,Dpos)
  6464. if StartPos=0 then
  6465. StartPos=max(Spos,Dpos)
  6466. LeftBit=left(RexxLine,StartPos-1)
  6467. RightBit=substr(RexxLine,EndPos+1)
  6468. if right(LeftBit,1, "*") == ' ' then
  6469. LeftSpace=' '
  6470. else
  6471. LeftSpace=''
  6472. if left(RightBit,1, "*") == ' ' then
  6473. RightSpace=' '
  6474. else
  6475. RightSpace=''
  6476. LeftBit=_CompressRexx(LeftBit)
  6477. RightBit=_CompressRexx(RightBit)
  6478. if LeftSpace==' ' then
  6479. do
  6480. if right(LeftBit,1)='=' then
  6481. LeftSpace=''
  6482. end
  6483. LeftBit=_CompressRexx(LeftBit)
  6484. RightBit=_CompressRexx(RightBit)
  6485. return(LeftBit||LeftSpace||substr(RexxLine,StartPos,(EndPos-StartPos)+1)||RightSpace||RightBit)
  6486. end
  6487.  
  6488. _CompressRexx:
  6489. ToCompress=space(arg(1))
  6490. Compressed=''
  6491. TokenPos=verify(ToCompress,RexxTokens, 'M')
  6492. do while TokenPos<>0
  6493. Compressed=Compressed||strip(left(ToCompress,TokenPos-1), 'T')||substr(ToCompress,TokenPos,1)
  6494. ToCompress=strip(substr(ToCompress,TokenPos+1), 'L')
  6495. TokenPos=verify(ToCompress,RexxTokens, 'M')
  6496. end
  6497. return(Compressed||ToCompress)
  6498.  
  6499. LineOut_27:
  6500. call InitializeOneLine
  6501. signal OneLine_28
  6502.  
  6503. InitializeOneLine:
  6504. OneLineLevel=0
  6505. OneLineBuffer=''
  6506. OneLineGCount=0
  6507. return
  6508.  
  6509. InitializeOneLine4ThisLevel:
  6510. OneLineSeperator.OneLineLevel=''
  6511. OneLineStartLoc.OneLineLevel=''
  6512. OneLineStopper.OneLineLevel=''
  6513. OneLineNonPpwCnt.OneLineLevel=0
  6514. OneLineCount.OneLineLevel=0
  6515. return
  6516.  
  6517. AddToOneLine:
  6518. _OneLineBit=arg(1)
  6519. _Word1=word(_OneLineBit,1)
  6520. if translate(_Word1)=CmdHash1Line then
  6521. do
  6522. if OneLineBuffer\=='' then
  6523. do
  6524. OneLineBuffer=OneLineBuffer||OneLineSeperator.OneLineLevel
  6525. end
  6526. call ProcessOneLine subword(_OneLineBit,2),CmdHash1LineEnd
  6527. return('')
  6528. end
  6529. if strip(_OneLineBit)<>OneLineStopper.OneLineLevel then
  6530. do
  6531. OneLineCount.OneLineLevel=OneLineCount.OneLineLevel+1
  6532. OneLineGCount=OneLineGCount+1
  6533. if OneLineGCount=1 then
  6534. do
  6535. if translate(left(_Word1,length(CmdHashDefine)))=CmdHashDefine then
  6536. do
  6537. PpwCmdDivider2=MarksNewLineInHashDefine
  6538. OneLineBuffer=OneLineBuffer||_OneLineBit|| ' '
  6539. end
  6540. else
  6541. do
  6542. PpwCmdDivider2=MarksNewLine
  6543. OneLineNonPpwCnt.OneLineLevel=OneLineNonPpwCnt.OneLineLevel+1
  6544. OneLineBuffer=OneLineBuffer||_OneLineBit
  6545. end
  6546. end
  6547. else
  6548. do
  6549. if left(_Word1,HashPrefixLng)<>HashPrefix then
  6550. do
  6551. if OneLineNonPpwCnt.OneLineLevel=0 then
  6552. OneLineBuffer=OneLineBuffer||_OneLineBit
  6553. else
  6554. OneLineBuffer=OneLineBuffer||OneLineSeperator.OneLineLevel||_OneLineBit
  6555. OneLineNonPpwCnt.OneLineLevel=OneLineNonPpwCnt.OneLineLevel+1
  6556. end
  6557. else
  6558. do
  6559. parse var _OneLineBit _ppwCmd _ppwCmdParm
  6560. _OneLineBit=_ppwCmd|| ' ' ||strip(_ppwCmdParm)
  6561. OneLineBuffer=OneLineBuffer||PpwCmdDivider2||_OneLineBit||PpwCmdDivider2
  6562. end
  6563. end
  6564. return('')
  6565. end
  6566. if OptionDebugOn='Y' then
  6567. call DBG 'End of #( block - ' || OneLineCount.OneLineLevel || ' line(s)'
  6568. OneLineLevel=OneLineLevel-1
  6569. call StackPop "PPWIZARD's #( Command"
  6570. if OneLineLevel<>0 then
  6571. return('')
  6572. else
  6573. do
  6574. _OneLineBit=OneLineBuffer
  6575. call InitializeOneLine
  6576. return(_OneLineBit)
  6577. end
  6578.  
  6579. ProcessOneLine:
  6580. OneLineLevel=OneLineLevel+1
  6581. call StackPush "PPWIZARD's #( Command",,"#( command - level " ||OneLineLevel
  6582. call InitializeOneLine4ThisLevel
  6583. OneLineStartLoc.OneLineLevel=CurrentSourceLocation()
  6584. Rest=PerformReplacementsInCmdsParameters(arg(1))
  6585. if Rest='' then
  6586. OneLineSeperator.OneLineLevel=' '
  6587. else
  6588. do
  6589. OneLineSeperator.OneLineLevel=GetQuotedText(Rest, "Rest")
  6590. end
  6591. if Rest<> '' then
  6592. OneLineStopper.OneLineLevel=GetQuotedText(Rest)
  6593. else
  6594. do
  6595. OneLineStopper.OneLineLevel=arg(2)
  6596. if OneLineStopper.OneLineLevel='' then
  6597. OneLineStopper.OneLineLevel=HashPrefix|| 'OneLineEnd'
  6598. end
  6599. if OptionDebugOn='Y' then
  6600. do
  6601. call DBG 'Line separator      = ' ||DebugRightArrow||OneLineSeperator.OneLineLevel||DebugLeftArrow
  6602. call DBG 'End of block marker = ' || DebugRightArrow || OneLineStopper.OneLineLevel   || DebugLeftArrow || ' (case sensitive!)'
  6603. end
  6604. return(0)
  6605.  
  6606. OneLine_28:
  6607. UserHashCmds=''
  6608. signal CMDNFND_29
  6609.  
  6610. LookForUnknownCmdHandler:
  6611. UserHashCmds=CfgMacro("UNKNOWN_HASH_COMMANDS", '')
  6612. return
  6613.  
  6614. ProcessUnknownHashCommand:
  6615. parse arg HashCmd,HashParms
  6616. CmdGenerates=''
  6617. call ExecRexxCmd UserHashCmds
  6618. if CmdGenerates\=='' then
  6619. do
  6620. if IncludeMemBufferNextLine=='' then
  6621. IncludeMemBufferNextLine=CmdGenerates
  6622. else
  6623. IncludeMemBufferNextLine=CmdGenerates||MarksNewLine||IncludeMemBufferNextLine
  6624. end
  6625. return(0)
  6626.  
  6627. CMDNFND_29:
  6628. OptChar='/'
  6629. CmdLineQL='"' || "'~`!#$%^=(["
  6630. CmdLineQR='"' || "'~`!#$%^=)]"
  6631. signal CmdLine_30
  6632.  
  6633. InitCommandLineOptions:
  6634. OptChar1='/'
  6635. OptChar2='-'
  6636. OptionsCmdLine=strip(arg(1))
  6637. OptionDebugOn='N'
  6638. OptionMaxCol=500
  6639. DepDelPrev='N'
  6640. OptionBaseDirectory=''
  6641. InputMasksAllowed='Y'
  6642. OptionPrjExtn='DEF_*'
  6643. CgiOutputFile=''
  6644. OptionCgiModeOn='N'
  6645. ProcessingMode=''
  6646. call MakingText "HTML"
  6647. call MakingText "OTHER"
  6648. call MakingText "REXX"
  6649. call MakingText "COPY"
  6650. PpwOnOK=''
  6651. PpwOnERROR=''
  6652. OptionUncUsed='N'
  6653. OptionValidation=''
  6654. OptionValidationRc=''
  6655. OptionOutput=''
  6656. OptionDependsOn=''
  6657. OptionWantInfoMsgs='Y'
  6658. OptionHashIncludeCnt=0
  6659. OptionIncludePathCnt=0
  6660. OptionTemplate=''
  6661. OptionQuietDependsOn='N'
  6662. OptionSummary='Y'
  6663. OptionPack='N'
  6664. OptionTranslateFileNames='N'
  6665. OptionFilterIn=''
  6666. OptionFilterOut=''
  6667. OptionDefineCount=0
  6668. OptionKeepRexxCmts='N'
  6669. OptionCompleteAddToToDepFile='Y'
  6670. OptionAtEndCommand=''
  6671. OptionAtEndCommandOkTest=''
  6672. HaveGeneratorTags='N'
  6673. OptionHtmlGeneratorTags=''
  6674. OptionNoDepFileOnWarnings='Y'
  6675. OptionHideCmdS=''
  6676. OptionHideCmdE=''
  6677. OptionHideCmdS_L=0
  6678. OptionHideCmdE_L=0
  6679. Option0FilesPerMaskOk='N'
  6680. Option0FilesTotalOk='N'
  6681. Option0FilesTotalAfterExcludeOk='N'
  6682. OptionXSlash=''
  6683. OptionDeleteOnError='Y'
  6684. bc_Line=copies('*+',20)
  6685. call StoreOutHeader "|VBS|'" || bc_Line || "|' |'" || bc_Line || "|"
  6686. return
  6687.  
  6688. QuickCheckForDebugSwitch:
  6689. OptionsEnvironment=GetEnv('PPWIZARD_OPTIONS')
  6690. UpperTheCmdLine=translate(OptionsEnvironment|| ' ' ||OptionsCmdLine)
  6691. if pos(OptChar1|| 'DEBUG ', UpperTheCmdLine || ' ') <> 0 | pos(OptChar2 || 'DEBUG ', UpperTheCmdLine || ' ')<>0 then
  6692. do
  6693. OptionDebugOn='Y'
  6694. OptionWantInfoMsgs='Y'
  6695. call DebugStateChanged
  6696. end
  6697. return
  6698.  
  6699. ProcessCommandLine:
  6700. call SetUpPpwizardOptionDefaults
  6701. call InitializeCharCodes
  6702. PpwDoing='Starting to processing parameters (from command line + Environment)'
  6703. call DBG PpwDoing
  6704. InputMaskCount=0
  6705. DebugSwitchUsed='N'
  6706. OptionWantCopyright='Y'
  6707. CmdLineTotal=''
  6708. PpwClDep=''
  6709. call ProcessCommandLineBit "environment",OptionsEnvironment
  6710. PpwDefaultProject=FindProjectFile('ppwizard')
  6711. if PpwDefaultProject<> '' then
  6712. call ProcessCommandLineBit PpwDefaultProject,OptChar|| 'LIST:' || ReplaceString(PpwDefaultProject, ' ', '{x20}')
  6713. call ProcessCommandLineBit "command line",OptionsCmdLine
  6714. call DBG 'Finished Processing : ' ||CmdLineTotal
  6715. PpwDoing=''
  6716. return
  6717.  
  6718. AddToSwitchList:
  6719. bd_ForDep=arg(1)
  6720. bd_ThisParm=ReplaceString(ThisParm, ' ', '{x20}')
  6721. if CmdLineTotal='' then
  6722. CmdLineTotal=bd_ThisParm
  6723. else
  6724. CmdLineTotal=CmdLineTotal|| ' ' ||bd_ThisParm
  6725. if bd_ForDep='Y' then
  6726. do
  6727. if PpwClDep='' then
  6728. PpwClDep=bd_ThisParm
  6729. else
  6730. PpwClDep=PpwClDep|| ' ' ||bd_ThisParm
  6731. end
  6732. return
  6733.  
  6734. ProcessCommandLineBit:
  6735. parse arg be_What,be_CmdLine
  6736. call DBGIND 1
  6737. call DBG 'Processing switches - ' ||be_What
  6738. call DBGIND 1
  6739. do while be_CmdLine<> ''
  6740. be_CmdLine=strip(be_CmdLine)
  6741. be_QPos=pos(left(be_CmdLine,1),CmdLineQL)
  6742. if be_QPos<>0 then
  6743. do
  6744. be_SQ=substr(CmdLineQL,be_QPos,1)
  6745. be_EQ=substr(CmdLineQR,be_QPos,1)
  6746. call DBG 'Item quoted. Left Quote = ' || be_SQ || ', Looking for end quote of ' ||be_EQ
  6747. be_Start=be_CmdLine
  6748. be_CmdLine=substr(be_CmdLine,2)
  6749. be_QPos=pos(be_EQ,be_CmdLine)
  6750. if be_QPos=0 then
  6751. UserSyntaxError('Could not find the ending quote of ' || be_EQ || ' at ==> ' ||be_Start)
  6752. ThisParm=left(be_CmdLine,be_QPos-1)
  6753. be_CmdLine=substr(be_CmdLine,be_QPos+1)
  6754. if be_CmdLine<> '' then
  6755. do
  6756. if left(be_CmdLine,1)\==' ' then
  6757. UserSyntaxError('Invalid quoted parameter (space must follow quoted item) at ==> ' ||be_Start)
  6758. end
  6759. end
  6760. else
  6761. do
  6762. parse var be_CmdLine ThisParm be_CmdLine
  6763. end
  6764. ParmType=left(ThisParm,1)
  6765. select
  6766. when ParmType=OptChar1|ParmType=OptChar2 then
  6767. do
  6768. ThisParmT='Switch'
  6769. OptChar=ParmType
  6770. end
  6771. when ParmType='@' then
  6772. ThisParmT='Project'
  6773. when ParmType=';' then
  6774. ThisParmT='Commented out'
  6775. otherwise
  6776. do
  6777. ThisParmT='FileMask'
  6778. ParmType=''
  6779. end
  6780. end
  6781. call DBG ThisParmT|| ' <- "' || ThisParm || '"'
  6782. if ParmType=';' then
  6783. iterate
  6784. call DBGIND 1
  6785. ThisParm=ReplaceCurlyHexCodes(ThisParm)
  6786. PpwDoing='Processing command line: ' ||ThisParm
  6787. if ParmType='@' then
  6788. do
  6789. PrjFile=substr(ThisParm,2)
  6790. PrjFileF=FindProjectFile(PrjFile)
  6791. if PrjFileF='' then
  6792. CryAndDie('The specified project "' || PrjFile || '" does not exist')
  6793. ThisParm=OptChar|| 'LIST:' || ReplaceString(PrjFileF, ' ', '{x20}')
  6794. be_CmdLine=ThisParm|| ' ' ||be_CmdLine
  6795. call DBGIND-1
  6796. iterate
  6797. end
  6798. if ParmType='' then
  6799. do
  6800. if InputMasksAllowed='N' then
  6801. CryAndDie('Sorry but no more input masks can be accepted', 'Input mask "' || ThisParm || '" specified in:', '    ' ||be_What)
  6802. call AddToSwitchList 'N'
  6803. be_FM=MakeAbsolute(ThisParm)
  6804. be_FF='?' ||RexDirChar
  6805. if left(be_FM,2)=be_FF then
  6806. do
  6807. be_Find=substr(be_FM,3)
  6808. be_FM=FindFile(be_Find)
  6809. if be_FM='' then
  6810. CryAndDie('Could not locate the file "' || be_Find || '"!')
  6811. end
  6812. be_Marker='{ENDBASE}'
  6813. if pos(be_Marker,be_FM)<>0 then
  6814. do
  6815. parse var be_FM be_BD (be_Marker) be_FM
  6816. be_FM=be_BD||be_FM
  6817. call DBG 'Without base dir marker = "' || be_FM || '"'
  6818. if left(be_BD,1)='+' then
  6819. be_BD=substr(be_BD,2)
  6820. end
  6821. else
  6822. do
  6823. if OptionBaseDirectory<> '' then
  6824. do
  6825. be_BD=OptionBaseDirectory
  6826. end
  6827. else
  6828. do
  6829. if left(be_FM,1)='+' then
  6830. be_BD=substr(be_FM,2)
  6831. else
  6832. be_BD=be_FM
  6833. be_BD=_filespec('Location',be_BD)
  6834. end
  6835. end
  6836. call ValidateBaseDirUse be_BD,be_FM, 'Y'
  6837. be_PM=ProcessingMode
  6838. be_OM=OptionOutput
  6839. be_DM=OptionDependsOn
  6840. InputMaskCount=InputMaskCount+1
  6841. InputMaskBDir.InputMaskCount=be_BD
  6842. InputMaskPMode.InputMaskCount=be_PM
  6843. InputMaskOutMask.InputMaskCount=be_OM
  6844. InputMaskDepMask.InputMaskCount=be_DM
  6845. InputMask0FilesOk.InputMaskCount=Option0FilesPerMaskOk
  6846. be_U="<Unknown at this time>"
  6847. if be_PM='' then
  6848. be_PM=be_U
  6849. if be_OM='' then
  6850. be_OM=be_U
  6851. if be_DM='' then
  6852. be_DM=be_U
  6853. call DBG 'Base Directory  = "' || be_BD || '"'
  6854. call DBG 'Processing Mode = "' || be_PM || '"'
  6855. call DBG 'Output Mask     = "' || be_OM || '"'
  6856. call DBG 'Depends On Mask = "' || be_DM || '"'
  6857. call DBG '0 Files OK      = ' ||Option0FilesPerMaskOk
  6858. InputMask.InputMaskCount=be_FM
  6859. call DBGIND-1
  6860. iterate
  6861. end
  6862. ParmPos=verify(ThisParm, ':=', 'M')
  6863. if ParmPos=0 then
  6864. do
  6865. ThisCmd=ThisParm
  6866. ThisCmdOptions=''
  6867. end
  6868. else
  6869. do
  6870. ThisCmd=left(ThisParm,ParmPos-1)
  6871. ThisCmdOptions=substr(ThisParm,ParmPos+1)
  6872. end
  6873. ThisCmd=translate(substr(ThisCmd,2))
  6874. RecordSwitch='Y'
  6875. IsDepSwitch='Y'
  6876. select
  6877. when ThisCmd='PACK' then
  6878. OptionPack=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  6879. when ThisCmd='DELETEPREV' then
  6880. DepDelPrev=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  6881. when ThisCmd='CRLF' then
  6882. do
  6883. if SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y') = 'Y' then
  6884. NewLineChars=CrLf
  6885. else
  6886. NewLineChars=MarksNewLine
  6887. end
  6888. when ThisCmd='COPY' then
  6889. call PModeSwitch ThisCmd,ThisCmdOptions
  6890. when ThisCmd='OTHER' then
  6891. call PModeSwitch ThisCmd,ThisCmdOptions
  6892. when ThisCmd='HTML' then
  6893. call PModeSwitch ThisCmd,ThisCmdOptions
  6894. when ThisCmd='REXX' then
  6895. call PModeSwitch ThisCmd,ThisCmdOptions
  6896. when ThisCmd='OUTPUT' then
  6897. OptionOutput=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  6898. when ThisCmd='DEPENDSON' then
  6899. do
  6900. OptionDependsOn=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  6901. if left(OptionDependsOn,1)<> '-' then
  6902. OptionQuietDependsOn='N'
  6903. else
  6904. do
  6905. OptionQuietDependsOn='Y'
  6906. OptionDependsOn=substr(OptionDependsOn,2)
  6907. end
  6908. end
  6909. when ThisCmd='DEPENDSONCOMPLETE' then
  6910. OptionCompleteAddToToDepFile=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  6911. when ThisCmd='0OK' then
  6912. do
  6913. if ThisCmdOptions='' then
  6914. ThisCmdOptions='YES,YES,YES'
  6915. parse var ThisCmdOptions be_P1 ',' be_P2 ',' be_P3
  6916. if be_P1<> '' then
  6917. Option0FilesPerMaskOk=SwitchWantsYesOrNo(ThisCmd,be_P1, 'Y')
  6918. if be_P2<> '' then
  6919. Option0FilesTotalOk=SwitchWantsYesOrNo(ThisCmd,be_P2, 'Y')
  6920. if be_P3<> '' then
  6921. Option0FilesTotalAfterExcludeOk=SwitchWantsYesOrNo(ThisCmd,be_P3, 'Y')
  6922. end
  6923. when ThisCmd='TEMPLATE' then
  6924. OptionTemplate=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  6925. when ThisCmd='COLOR' | ThisCmd = 'COLOUR' then
  6926. do
  6927. WantColor=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  6928. if WantColor='N' then
  6929. call RemoveColorCodes
  6930. else
  6931. do
  6932. call NotAvailableUnderNtYet ThisCmd
  6933. call SetColorCodes
  6934. end
  6935. end
  6936. when ThisCmd='BEEP' then
  6937. do
  6938. WantBeep=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  6939. if WantBeep='N' then
  6940. call RemoveBeepCode
  6941. else
  6942. call SetBeepCode
  6943. end
  6944. when ThisCmd='WARNINGSRC' then
  6945. do
  6946. if ThisCmdOptions='' then
  6947. WantedWarningRc=1
  6948. else
  6949. do
  6950. WantedWarningRc=GetQuotedText(ThisCmdOptions)
  6951. if datatype(WantedWarningRc, 'W')=0 then
  6952. CryAndDie('Invalid warning return code of "' || WantedWarningRc || '" supplied!')
  6953. end
  6954. end
  6955. when ThisCmd='OUTHEADER' then
  6956. call StoreOutHeader GetQuotedText(ThisCmdOptions)
  6957. when ThisCmd='SYNTAX' then
  6958. call StoreSyntaxCheckCode4Header GetQuotedText(ThisCmdOptions)
  6959. when ThisCmd='FILENAMES' then
  6960. do
  6961. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  6962. OptionTranslateFileNames=translate(strip(ThisCmdOptions))
  6963. if OptionTranslateFileNames<> "LOWER" & OptionTranslateFileNames <> "UPPER" then
  6964. UserSyntaxError('Expected "UPPER" or "LOWER" on the "' || TheCmd || '" command, not "' || ThisCmdOptions || '"!')
  6965. end
  6966. when ThisCmd='DEFINE' then
  6967. do
  6968. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  6969. parse var ThisCmdOptions DefineVar'='DefineContents
  6970. OptionDefineCount=OptionDefineCount+1
  6971. OptionDefine.OptionDefineCount.Var=DefineVar
  6972. OptionDefine.OptionDefineCount.Cont=strip(DefineContents)
  6973. end
  6974. when ThisCmd='OPTION' then
  6975. do
  6976. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  6977. call ProcessOption ThisCmdOptions
  6978. end
  6979. when ThisCmd='REQUIRE' then
  6980. do
  6981. be_P=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  6982. call ProcessRequireCommon translate(be_P, ' ', ',')
  6983. end
  6984. when ThisCmd='FILTERINPUT' then
  6985. do
  6986. call NotAvailableUnderNtYet ThisCmd
  6987. OptionFilterIn=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  6988. call DoMacroSpaceOperation "ADD", OptionFilterIn, "HtmlFilterIn"
  6989. end
  6990. when ThisCmd='FILTEROUTPUT' then
  6991. do
  6992. call NotAvailableUnderNtYet ThisCmd
  6993. OptionFilterOut=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  6994. call DoMacroSpaceOperation "ADD", OptionFilterOut, "HtmlFilterOut"
  6995. end
  6996. when ThisCmd='SPELLSHOWALL' then
  6997. SpellShowEachError=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  6998. when ThisCmd='SPELLCHECK' then
  6999. do
  7000. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7001. call LoadSpellingDictionary ThisCmdOptions
  7002. end
  7003. when ThisCmd='SPELLADDWORD' then
  7004. do
  7005. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7006. SpellingAddFile=ThisCmdOptions
  7007. if left(SpellingAddFile,1)<> '-' then
  7008. SpellingPrompts='Y'
  7009. else
  7010. do
  7011. SpellingPrompts='OK'
  7012. SpellingAddFile=substr(SpellingAddFile,2)
  7013. end
  7014. end
  7015. when ThisCmd='**/' then
  7016. OptionKeepRexxCmts=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7017. when ThisCmd='INFO' then
  7018. OptionWantInfoMsgs=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7019. when ThisCmd='#INCLUDE' | ThisCmd = 'INCLUDE' then
  7020. do
  7021. if ThisCmdOptions='' then
  7022. OptionHashIncludeCnt=0
  7023. else
  7024. do
  7025. OptionHashIncludeCnt=OptionHashIncludeCnt+1
  7026. OptionHashInclude.OptionHashIncludeCnt=ThisCmdOptions
  7027. end
  7028. call DBG OptionHashIncludeCnt|| ' /#Include items stored'
  7029. end
  7030. when ThisCmd='BASEDIR' then
  7031. do
  7032. OptionBaseDirectory=MakeAbsolute(ThisCmdOptions)
  7033. call DBG "BASEDIR: " ||OptionBaseDirectory
  7034. end
  7035. when ThisCmd='INCLUDEPATH' then
  7036. do
  7037. if ThisCmdOptions='' then
  7038. OptionIncludePathCnt=0
  7039. else
  7040. do
  7041. OptionIncludePathCnt=OptionIncludePathCnt+1
  7042. OptionIncludePath.OptionIncludePathCnt=ThisCmdOptions
  7043. end
  7044. end
  7045. when ThisCmd='CGI' then
  7046. call TurnCgiModeOn ThisCmdOptions
  7047. when ThisCmd='HTMLGENERATOR' then
  7048. do
  7049. HaveGeneratorTags='Y'
  7050. OptionHtmlGeneratorTags=ThisCmdOptions
  7051. end
  7052. when ThisCmd='EXCLUDE' then
  7053. do
  7054. IsDepSwitch='N'
  7055. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7056. ExcludeList.0=0
  7057. TmpMask=ThisCmdOptions
  7058. call DBG 'Looking for files matching "' || TmpMask || '"'
  7059. if left(TmpMask,1)<> '+' then
  7060. FollowDirs='N'
  7061. else
  7062. do
  7063. FollowDirs='Y'
  7064. TmpMask=substr(TmpMask,2)
  7065. end
  7066. call GetListOfFiles TmpMask, 'ExcludeList',FollowDirs
  7067. call DBGIND 1
  7068. call DBG 'Found ' || ExcludeList.0 || ' files(s) to exclude'
  7069. call DBGIND 1
  7070. do InputIndex=1 to ExcludeList.0
  7071. TheFile=ExcludeList.InputIndex
  7072. call DBG TheFile
  7073. call _valueS "_EXCLUDE_._EXF_" || c2x(TheFile), 'you used "' || OptChar || ThisCmd || ':' || ThisCmdOptions || '"'
  7074. end
  7075. call DBGIND-2
  7076. end
  7077. when ThisCmd='INC2CACHE' then
  7078. IncludeIntoMemory=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7079. when ThisCmd='$TRACE' then
  7080. call SetDollarTraceState SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7081. when ThisCmd='DEBUGTIME' then
  7082. OptionDebugTime=left(SwitchOptionsValidateAgainstList(ThisCmd,ThisCmdOptions, "N,NO,L,LONG,S,SHORT"),1)
  7083. when ThisCmd='DEBUGCHARS' then
  7084. call SetDebugChars ThisCmdOptions
  7085. when ThisCmd='HOOK' then
  7086. call RexxHookSet ThisCmd,ThisCmdOptions
  7087. when ThisCmd='REGSYNTAX' then
  7088. do
  7089. if RexWhich='REGINA' then
  7090. call DBG "/RegSyntax has no effect under Regina!"
  7091. NameOfOs2ReginaRexxInterpreter=ThisCmdOptions
  7092. end
  7093. when ThisCmd='REDIRMETHOD' then
  7094. RedirMethod=ThisCmdOptions
  7095. when ThisCmd='DEBUG' then
  7096. do
  7097. call RemoveBeepCode
  7098. call RemoveColorCodes
  7099. call SwitchMustNotHaveOptions ThisCmd,ThisCmdOptions
  7100. DebugSwitchUsed='Y'
  7101. OptionDebugOn='Y'
  7102. OptionWantInfoMsgs='Y'
  7103. call DebugStateChanged
  7104. end
  7105. when ThisCmd='COPYRIGHT' then
  7106. OptionWantCopyright=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7107. when ThisCmd='XSLASH' then
  7108. do
  7109. YesOrNo=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7110. if YesOrNo='N' then
  7111. OptionXSlash=''
  7112. else
  7113. OptionXSlash=' /'
  7114. end
  7115. when ThisCmd='GETENV' then
  7116. do
  7117. FromEnv=GetEnv(ThisCmdOptions)
  7118. if FromEnv='' then
  7119. CryAndDie('The environment variable "' || ThisCmdOptions || '" does not exist.')
  7120. call DBG 'Contained: ' ||FromEnv
  7121. be_CmdLine=FromEnv|| ' ' ||be_CmdLine
  7122. end
  7123. when ThisCmd='INPUT' then
  7124. be_CmdLine='"' || SwitchMustHaveOptions(ThisCmd, ThisCmdOptions) || '" ' ||be_CmdLine
  7125. when ThisCmd='LIST' then
  7126. do
  7127. RecordSwitch='N'
  7128. ListFile=QueryExists(ThisCmdOptions)
  7129. if ListFile='' then
  7130. CryAndDie('The list file "' || ThisCmdOptions || '" does not exist')
  7131. call DBG 'Processing: "' || ListFile || '"'
  7132. call DBGIND 1
  7133. call FileClose ListFile
  7134. LCmt=';' || ';'
  7135. LineNum=0
  7136. SpecList=''
  7137. do while lines(ListFile)<>0
  7138. OneSpec=strip(linein(ListFile))
  7139. CmtPos=lastpos(LCmt,OneSpec)
  7140. LineNum=LineNum+1
  7141. if CmtPos<>0 then
  7142. OneSpec=strip(left(OneSpec,CmtPos-1), 'T')
  7143. if OneSpec='' | left(OneSpec, 1) = ';' then
  7144. iterate
  7145. OneSpec=ReplaceString(OneSpec, ' ', '{' || 'x20}')
  7146. call DBG 'Line #' || LineNum || ': ' ||OneSpec
  7147. SpecList=SpecList|| ' ' ||OneSpec
  7148. end
  7149. call DBGIND-1
  7150. be_CmdLine=strip(SpecList)|| ' ' ||be_CmdLine
  7151. call DieIfIoErrorOccurred ListFile
  7152. call FileClose ListFile
  7153. end
  7154. when ThisCmd='DEPENDSONWARNINGS' then
  7155. OptionNoDepFileOnWarnings=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7156. when ThisCmd='@EXTN' then
  7157. OptionPrjExtn=ThisCmdOptions
  7158. when ThisCmd='CONSOLEFILE' then
  7159. call UserIsSpecifyingConsoleFileName ThisCmdOptions
  7160. when ThisCmd='ERRORFILE' then
  7161. call UserIsSpecifyingErrorFileName ThisCmdOptions
  7162. when ThisCmd='DEBUGCOLS' then
  7163. do
  7164. TheValue=SwitchMustHaveOptions(ThisCmd,ThisCmdOptions)
  7165. OptValid='N'
  7166. if datatype(TheValue, 'W')=1 then
  7167. do
  7168. if TheValue>=0 then
  7169. OptValid='Y'
  7170. end
  7171. if OptValid='N' then
  7172. UserSyntaxError('Invalid /DebugCols value of "' || TheValue || '" supplied!')
  7173. OptionMaxCol=TheValue
  7174. end
  7175. when ThisCmd='DROPFILES' then
  7176. do
  7177. call DBG 'Dropping all stored input file masks'
  7178. InputMaskCount=0
  7179. call SwitchMustNotHaveOptions ThisCmd,ThisCmdOptions
  7180. end
  7181. when ThisCmd='ONOK' then
  7182. PpwOnOK=ThisCmdOptions
  7183. when ThisCmd='ONERROR' then
  7184. do
  7185. PpwOnERROR=ThisCmdOptions
  7186. if SleepSwitch='N' then
  7187. OnExitSleepForError=0
  7188. end
  7189. when ThisCmd='HIDECMD' then
  7190. do
  7191. if translate(ThisCmdOptions)='HTML[]' then
  7192. ThisCmdOptions='<!--[{?}]-->'
  7193. parse var ThisCmdOptions OptionHideCmdS '{?}' OptionHideCmdE
  7194. OptionHideCmdS_L=length(OptionHideCmdS)
  7195. OptionHideCmdE_L=length(OptionHideCmdE)
  7196. if OptionHideCmdS_L=0|OptionHideCmdE_L=0 then
  7197. CryAndDie('Your hide template must include "{?}" to indicate where the', 'command would be and must not start or end the template')
  7198. end
  7199. when ThisCmd='EXEC' then
  7200. do
  7201. call SplitOffRcTest
  7202. call RunExecOrValidateCmd ThisCmd,ExecRcTest,ExecCmd
  7203. end
  7204. when ThisCmd='VALIDATE' then
  7205. do
  7206. call SplitOffRcTest
  7207. OptionValidationRc=ExecRcTest
  7208. OptionValidation=ExecCmd
  7209. end
  7210. when ThisCmd='SLEEP' then
  7211. do
  7212. SleepSwitch='Y'
  7213. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7214. parse var ThisCmdOptions OnExitSleepForOK ',' OnExitSleepForError
  7215. if OnExitSleepForError='' then
  7216. OnExitSleepForError=2
  7217. end
  7218. when ThisCmd='DELETEONERROR' then
  7219. OptionDeleteOnError=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7220. when ThisCmd='MAKING' then
  7221. do
  7222. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7223. parse var ThisCmdOptions '/' be_M '/' be_T
  7224. call MakingText be_M,be_T
  7225. end
  7226. when ThisCmd='UNC' then
  7227. OptionUncUsed=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  7228. when ThisCmd='?' then
  7229. UserSyntaxError('?')
  7230. otherwise
  7231. UserSyntaxError('Unknown switch of "' || OptChar || ThisCmd || '" specified')
  7232. end
  7233. call DBGIND-1
  7234. if RecordSwitch='Y' then
  7235. call AddToSwitchList IsDepSwitch
  7236. end
  7237. call DBGIND-3
  7238. return
  7239.  
  7240. UserSyntaxError:
  7241. call AllFollowingOutputGoesToErrorFile
  7242. call CgiStartFatalError
  7243. call DisplayCopyright
  7244. if arg(1)='?' then
  7245. Title='SYNTAX'
  7246. else
  7247. do
  7248. call Line1 ErrorColor|| "SYNTAX ERROR"
  7249. call Line1 "~~~~~~~~~~~~"
  7250. call Line1 '    ' ||arg(1)
  7251. Title='CORRECT SYNTAX'
  7252. end
  7253. call CgiEndFatalError
  7254. call Line1 ''
  7255. call Line1 Title
  7256. call Line1 copies('~',length(Title))
  7257. call Line1 '    ' || WizName || ' InputMask1 [-Option1 InputMask2 /Option2 ...]'
  7258. call Line1 ''
  7259. call Line1 'SOME COMMON OPTIONS'
  7260. call Line1 '~~~~~~~~~~~~~~~~~~~'
  7261. call Line1 OptChar|| 'Output:Mask     = Call output what?  Place it where? (example "out\*.html")'
  7262. call Line1 OptChar|| 'Rexx ' || OptChar || 'Other     = Not HTML mode (rexx preprocessor or "OTHER")'
  7263. call Line1 OptChar|| 'DependsOn:Mask  = Generate/Check dependencies (makefile type functionality)'
  7264. call Line1 OptChar|| 'Debug           = Show debug information (diagnose problems or learning)'
  7265. call Line1 ''
  7266. call Line1 "Please see PPWIZARD's documentation for more details (and more options)." ||Beep||Beep||Reset
  7267. if arg(1)<> '?' then
  7268. AbnormalExit(MyLineNumber(), "Invalid Command Line - " ||arg(1))
  7269. else
  7270. do
  7271. parse version ThisRexxVer
  7272. call Line1 ''
  7273. call Line1 'ENVIRONMENTAL INFORMATION'
  7274. call Line1 '~~~~~~~~~~~~~~~~~~~~~~~~~'
  7275. call Line1 'Rexx Version  : ' ||ThisRexxVer
  7276. call Line1 'Operating Syst: ' ||DebugGetOpSysText()
  7277. call Line1 'PPWIZARD      : ' ||PgmVersion
  7278. call Line1 '              : "' || PpWizardPgmName || '"'
  7279. AbnormalExit(MyLineNumber(), "User just wanted version number information")
  7280. end
  7281.  
  7282. SwitchMustHaveOptions:
  7283. parse arg TheCmd,TheOptions
  7284. if TheOptions='' then
  7285. UserSyntaxError('You must supply parameters on the "' || OptChar || TheCmd || '" switch!')
  7286. return(TheOptions)
  7287.  
  7288. SwitchMustNotHaveOptions:
  7289. parse arg TheCmd,TheOptions,Value2Set
  7290. if TheOptions<> '' then
  7291. UserSyntaxError('No parameters are expected for the "' || OptChar || TheCmd || '" switch!')
  7292. return(Value2Set)
  7293.  
  7294. SwitchOptionsValidateAgainstList:
  7295. TheCmd=arg(1)
  7296. TheOption=translate(arg(2))
  7297. ValidList=',' || translate(arg(3)) || ','
  7298. if pos(',' || TheOption || ',',ValidList)<>0 then
  7299. return(TheOption)
  7300. UserSyntaxError('An invalid parameter of "' || TheOption || '" was specified on the "' || OptChar || TheCmd || '" switch!')
  7301.  
  7302. SwitchWantsYesOrNo:
  7303. TheCmd=arg(1)
  7304. TheOption=translate(arg(2))
  7305. Default=arg(3)
  7306. if TheOption='' then
  7307. return(Default)
  7308. else
  7309. return(left(SwitchOptionsValidateAgainstList(TheCmd,TheOption, "Y,N,YES,NO"),1))
  7310.  
  7311. NotAvailableUnderNtYet:
  7312. TheCmd=arg(1)
  7313. if RexWhich='REGINA' then
  7314. UserSyntaxError('"' || OptChar || TheCmd || '" can not be performed under Windows (or regina).... Yet...')
  7315. return
  7316.  
  7317. FindProjectFile:
  7318. bf_PrjFile=arg(1)
  7319. if pos('.',bf_PrjFile)=0 then
  7320. bf_PrjFile=bf_PrjFile|| '.ppw'
  7321. if OptionDebugOn='Y' then
  7322. do
  7323. call DBGIND 1
  7324. call DBG 'Looking for the project file "' || bf_PrjFile || '"'
  7325. call DBGIND 1
  7326. end
  7327. bf_Full=FindFile(bf_PrjFile)
  7328. if OptionDebugOn='Y' then
  7329. do
  7330. call DBGIND 1
  7331. if bf_Full='' then
  7332. call DBG 'Project file not found.'
  7333. else
  7334. call DBG 'Found project file "' || bf_Full || '"'
  7335. call DBGIND-3
  7336. end
  7337. return(bf_Full)
  7338.  
  7339. SplitOffRcTest:
  7340. call SwitchMustHaveOptions ThisCmd,ThisCmdOptions
  7341. if left(ThisCmdOptions,1)='{' then
  7342. parse var ThisCmdOptions '{' ExecRcTest '}' ExecCmd
  7343. else
  7344. do
  7345. ExecCmd=ThisCmdOptions
  7346. ExecRcTest=''
  7347. end
  7348. return
  7349.  
  7350. RunExecOrValidateCmd:
  7351. parse arg bg_Switch,bg_CmdRc,bg_Cmd
  7352. if OptionDebugOn='Y' then
  7353. call DBG 'Performing ' || OptChar || bg_Switch || ' command'
  7354. bg_Exec=ReplaceString(bg_Cmd, "{?}",CurrentOutFile)
  7355. if left(bg_Exec,1)<> '!' then
  7356. bg_Redirect='Y'
  7357. else
  7358. do
  7359. bg_Redirect='N'
  7360. bg_Exec=substr(bg_Exec,2)
  7361. end
  7362. if bg_Redirect='N' then
  7363. do
  7364. call AddressCmd bg_Exec
  7365. CmdRc=Rc
  7366. end
  7367. else
  7368. do
  7369. TmpFile=RexGetTmpFileName()
  7370. call AddressCmd bg_Exec||RedirectStdOutAndErr2(TmpFile),TmpFile
  7371. CmdRc=Rc
  7372. call _SysFileDelete TmpFile
  7373. end
  7374. if bg_CmdRc<> '' then
  7375. do
  7376. call DBGIND 1
  7377. bg_ExecOk=0
  7378. bg_ExecThis='bg_ExecOk = ' || '(' || bg_CmdRc || ')'
  7379. if ProcessedCmdLine='Y' then
  7380. call ExecRexxCmd bg_ExecThis
  7381. else
  7382. do
  7383. call DBG 'Interpreting: ' ||bg_ExecThis
  7384. interpret bg_ExecThis
  7385. end
  7386. call DBGIND-1
  7387. if\bg_ExecOk then
  7388. CryAndDie('User command failed (CmdRc was ' || CmdRc || '):', '     ' || bg_Exec, 'Test was:', '     ' ||bg_CmdRc)
  7389. end
  7390. return
  7391.  
  7392. MakeAbsolute:
  7393. bh_Path=arg(1)
  7394. if left(bh_Path,1)<> '+' then
  7395. bh_Plus=''
  7396. else
  7397. do
  7398. bh_Path=substr(bh_Path,2)
  7399. bh_Plus='+'
  7400. end
  7401. bh_File=bh_Path
  7402. if left(bh_File,1)='.' |pos(RexDirChar,bh_File)=0 then
  7403. do
  7404. DotSlash='.' ||RexDirChar
  7405. DotDotSlash='.' ||DotSlash
  7406. maDir=GetCurrentDirectory()
  7407. if OptionDebugOn='Y' then
  7408. do
  7409. call DBG 'Converting relative "' || bh_File || '"'
  7410. call DBGIND 1
  7411. end
  7412. if pos(RexDirChar,bh_File)<>0 then
  7413. do
  7414. do forever
  7415. select
  7416. when left(bh_File,2)==DotSlash then
  7417. do
  7418. bh_File=substr(bh_File,3)
  7419. end
  7420. when left(bh_File,3)==DotDotSlash then
  7421. do
  7422. LastChar=right(maDir,1)
  7423. SlashPos=lastpos(RexDirChar,maDir)
  7424. if SlashPos=0|LastChar=RexDirChar|LastChar=':' then
  7425. CryAndDie('The spec "' || bh_Path || '" can not be converted to absolute', 'from the current directory "' || GetCurrentDirectory() || '"')
  7426. maDir=left(maDir,SlashPos-1)
  7427. bh_File=substr(bh_File,4)
  7428. end
  7429. otherwise
  7430. leave
  7431. end
  7432. end
  7433. end
  7434. if right(maDir,1)=RexDirChar then
  7435. bh_File=maDir||bh_File
  7436. else
  7437. bh_File=maDir||RexDirChar||bh_File
  7438. if OptionDebugOn='Y' then
  7439. do
  7440. call DBG 'To Absolute "' || bh_File || '"'
  7441. call DBGIND-1
  7442. end
  7443. end
  7444. return(bh_Plus||bh_File)
  7445.  
  7446. ValidateBaseDirUse:
  7447. parse arg bi_BD,bi_FM,bi_MayHavePlus
  7448. call DBG 'Validating base directory "' || bi_BD || '" against "' || bi_FM || '"'
  7449. if bi_MayHavePlus='Y' then
  7450. do
  7451. if left(bi_FM,1)='+' then
  7452. bi_FM=substr(bi_FM,2)
  7453. end
  7454. if RexSystemOpSys="UNIX" then
  7455. do
  7456. bi_BdU=bi_BD
  7457. bi_FmU=bi_FM
  7458. end
  7459. else
  7460. do
  7461. bi_BdU=translate(bi_BD)
  7462. bi_FmU=translate(bi_FM)
  7463. end
  7464. if bi_BdU\==left(bi_FmU,length(bi_BdU))then
  7465. CryAndDie('The file mask       "' || bi_FmU ||  '"', 'does not begin with "' || bi_BdU || '"')
  7466. return
  7467.  
  7468. PModeSwitch:
  7469. parse arg bj_PM,bj_Prm
  7470. call SwitchMustNotHaveOptions bj_PM,bj_Prm
  7471. ProcessingMode=bj_PM
  7472. return
  7473.  
  7474. MakingText:
  7475. parse arg bk_M,bk_T
  7476. if bk_T='' then
  7477. do
  7478. if translate(bk_M)='COPY' then
  7479. bk_T='Coping: "{IS}" -> "{OL}"'
  7480. else
  7481. bk_T='Making ({PM}) - {OL}'
  7482. end
  7483. call value 'PPWMAKING_' ||bk_M,bk_T
  7484. call DBG '/Making Text for ' || bk_M || ' mode is: ' ||bk_T
  7485. return
  7486.  
  7487. CmdLine_30:
  7488. DependsOnFmtVer="FORMAT 00.157"
  7489. call ClearCollectedDependancyInfo
  7490. call ClearDependancyTimeStampCache
  7491. signal DEPENDON_31
  7492.  
  7493. _CheckedLineout:
  7494. bl_File=arg(1)
  7495. bl_Line=arg(2)
  7496. if 0<>lineout(bl_File,bl_Line)then
  7497. CryAndDie('Write to "' || bl_File || '" failed!')
  7498. return
  7499.  
  7500. NeedToRemake:
  7501. DepFile4=arg(1)
  7502. if OptionDependsOn='' then
  7503. do
  7504. call DBG 'No Dependancy file to check - Need to make'
  7505. DepFileName=''
  7506. return("Y")
  7507. end
  7508. DepFileName=GenerateFileName(DepFile4,OptionDependsOn)
  7509. if _NeedToRemakeCheckDependencies()='N' then
  7510. do
  7511. if OptionQuietDependsOn='N' then
  7512. call Line1 ''
  7513. return('N')
  7514. end
  7515. if DepDelPrev='Y' then
  7516. do
  7517. call DBG 'Delete all output dependancy files (made last build)'
  7518. call DBGIND 1
  7519. call FileOpenReadOnly DepFileName
  7520. do while lines(DepFileName)<>0
  7521. bm_Line=linein(DepFileName)
  7522. if bm_Line='' then
  7523. iterate
  7524. parse var bm_Line bm_Type bm_Line
  7525. if bm_Type='output' then
  7526. do
  7527. bm_LastTime=GetQuotedText(bm_Line, "bm_Line")
  7528. call MustDeleteFile bm_LastTime
  7529. end
  7530. end
  7531. call FileClose DepFileName
  7532. call DBGIND-1
  7533. end
  7534. call MustDeleteFile DepFileName
  7535. return('Y')
  7536.  
  7537. ClearCollectedDependancyInfo:
  7538. DepTmpCnt=0
  7539. DepInCnt=0
  7540. DepOutCnt=0
  7541. return
  7542.  
  7543. ClearDependancyTimeStampCache:
  7544. TimeStampCount=0
  7545. return
  7546.  
  7547. GetFileDateTimeButDontWarnOnError:
  7548. tsFile=arg(1)
  7549. if QueryExists(tsFile)=='' then
  7550. Ts=-1
  7551. else
  7552. Ts=GetFileTimeStamp(tsFile)
  7553. return(Ts)
  7554.  
  7555. _ShowDependancyCheckProgress:
  7556. if OptionQuietDependsOn='N' then
  7557. call Line1 '  ?> ' ||arg(1)
  7558. else
  7559. call DBG arg(1)
  7560. return
  7561.  
  7562. _NeedToRemakeCheckDependencies:
  7563. TitleText='Checking Dependencies - "' || _filespec('name', CurrentOutFile) || '"'
  7564. if OptionQuietDependsOn='Y' then
  7565. call DBG TitleText
  7566. else
  7567. do
  7568. call Line1 TitleColor||TitleText
  7569. call Line1 copies('~',length(TitleText))||Reset
  7570. end
  7571. if QueryExists(DepFileName)='' then
  7572. do
  7573. call _ShowDependancyCheckProgress DepFileName|| ' does not exist.'
  7574. return('Y')
  7575. end
  7576. call FileClose DepFileName
  7577. OpenRc=FileOpenReadOnly(DepFileName)
  7578. DependLine=linein(DepFileName)
  7579. if DependLine<>DependsOnFmtVer then
  7580. do
  7581. call _ShowDependancyCheckProgress 'Dependency formatting is not at current level'
  7582. call FileClose DepFileName
  7583. return('Y')
  7584. end
  7585. ReMake='N'
  7586. DepLineNum=1
  7587. do while lines(DepFileName)<>0
  7588. DependLine=linein(DepFileName)
  7589. DepLineNum=DepLineNum+1
  7590. if DependLine='' then
  7591. iterate
  7592. call DBG 'Line #' || DepLineNum || ': ' ||DependLine
  7593. call DBGIND 1
  7594. parse var DependLine DepType DependLine
  7595. WhatStamped=GetQuotedText(DependLine, "DependLine")
  7596. LineStamp=GetQuotedRest(DependLine)
  7597. call _ShowDependancyCheckProgress 'Checking: "' || WhatStamped || '"'
  7598. DependantTime=GetDependsStamp("WhatStamped")
  7599. if DependantTime=-1 then
  7600. do
  7601. call _ShowDependancyCheckProgress "Can't locate the dependant file (" || DepType || ")!"
  7602. ReMake='Y'
  7603. call DBGIND-1
  7604. leave
  7605. end
  7606. if DependantTime<>LineStamp then
  7607. do
  7608. call _ShowDependancyCheckProgress "The " || DepType || " dependancy stamp differs from last make."
  7609. ReMake='Y'
  7610. call DBGIND-1
  7611. leave
  7612. end
  7613. call DBGIND-1
  7614. end
  7615. call FileClose DepFileName
  7616. if ReMake='N' then
  7617. call _ShowDependancyCheckProgress 'No need to remake...'
  7618. return(ReMake)
  7619.  
  7620. IsTempFile:
  7621. bn_File=translate(arg(1))
  7622. do bn_I=1 to DepTmpCnt
  7623. if bn_File=DepTmp.bn_I then
  7624. return(bn_I)
  7625. end
  7626. return(0)
  7627.  
  7628. AddTempFileToDependancyList:call TRACE "OFF"
  7629. bo_TFile=arg(1)
  7630. if RexSystemOpSys<> "UNIX" then
  7631. bo_TFile=translate(bo_TFile)
  7632. if IsTempFile(bo_TFile)<>0 then
  7633. return('N')
  7634. DepTmpCnt=DepTmpCnt+1
  7635. DepTmp.DepTmpCnt=bo_TFile
  7636. return('Y')
  7637.  
  7638. AddInputFileToDependancyList:call TRACE "OFF"
  7639. parse arg bp_IFile,bp_TS
  7640. if RexSystemOpSys<> "UNIX" then
  7641. bp_IFile=translate(bp_IFile)
  7642. if IsTempFile(bp_IFile)<>0 then
  7643. return('N')
  7644. if bp_TS='' then
  7645. bp_TS=GetDependsStamp("bp_IFile")
  7646. do bp_I=1 to DepInCnt
  7647. if bp_IFile=DepIn.bp_I then
  7648. return('N')
  7649. end
  7650. DepInCnt=DepInCnt+1
  7651. DepIn.DepInCnt=bp_IFile
  7652. DepInTs.DepInCnt=bp_TS
  7653. return('Y')
  7654.  
  7655. AddOutputFileToDependancyList:call TRACE "OFF"
  7656. bq_OFile=arg(1)
  7657. if RexSystemOpSys<> "UNIX" then
  7658. bq_OFile=translate(bq_OFile)
  7659. if IsTempFile(bq_OFile)<>0 then
  7660. return('N')
  7661. do bq_I=1 to DepOutCnt
  7662. if bq_OFile=DepOut.bq_I then
  7663. return('N')
  7664. end
  7665. DepOutCnt=DepOutCnt+1
  7666. DepOut.DepOutCnt=bq_OFile
  7667. return('Y')
  7668.  
  7669. DeletingOnError:
  7670. if symbol('DepOutCnt') <> 'VAR' then
  7671. return
  7672. if OptionDeleteOnError='N' then
  7673. return
  7674. call DBG 'Deleting any files we created for this build'
  7675. call DBGIND 1
  7676. do br_I=1 to DepOutCnt
  7677. br_File=DepOut.br_I
  7678. call FileClose br_File
  7679. if QueryExists(br_File)<> "" then
  7680. do
  7681. DeleteRc=_SysFileDelete(br_File)
  7682. if QueryExists(br_File)<> "" then
  7683. call DBG 'Could not delete "' || br_File || '"'
  7684. end
  7685. end
  7686. call DBGIND-1
  7687. return
  7688.  
  7689. _OutputDepWhatToFile:
  7690. DepWhat=arg(1)
  7691. DepWhatQ=QuoteIt(DepWhat)
  7692. DepWhat=DepWhatQ||DepWhat||DepWhatQ
  7693. return(DepWhat)
  7694.  
  7695. CreateDependancyFileFromLists:
  7696. if DepFileName='' then
  7697. return
  7698. call DBG 'Making the dependancy file (' || DepFileName || ')'
  7699. call DBGIND 1
  7700. DepDrop=''
  7701. DepHook=CfgMacro("HOOK_DEPENDSON", '')
  7702. if DepHook<> '' then
  7703. do
  7704. DepIn.0=DepInCnt
  7705. DepOut.0=DepOutCnt
  7706. call ExecRexxCmd DepHook
  7707. DepInCnt=DepIn.0
  7708. DepOutCnt=DepOut.0
  7709. end
  7710. if DepDrop<> '' then
  7711. call DBG "User hook said don't create dependancy file : " ||DepDrop
  7712. else
  7713. do
  7714. call MakeDirectoryTree _filespec('drive', DepFileName) || _filespec('path',DepFileName)
  7715. call ClearDependancyTimeStampCache
  7716. call _CheckedLineout DepFileName,DependsOnFmtVer
  7717. call _CheckedLineout DepFileName, ''
  7718. DepWhatPad=0
  7719. do br_I=1 to DepOutCnt
  7720. if DepOut.br_I<> '' then
  7721. do
  7722. call DBG 'Add OUTPUT dependancy : ' ||DepOut.br_I
  7723. OutputFileTs=GetFileDateTimeButDontWarnOnError(DepOut.br_I)
  7724. call _CheckedLineout DepFileName, 'output   ' || _OutputDepWhatToFile(DepOut.br_I) || '   ~' || OutputFileTs || '~'
  7725. end
  7726. end
  7727. call _CheckedLineout DepFileName, ''
  7728. do br_I=1 to DepInCnt
  7729. if DepIn.br_I<> '' then
  7730. do
  7731. call DBG 'Add INPUT  dependancy : ' ||DepIn.br_I
  7732. call _CheckedLineout DepFileName, 'input    ' || _OutputDepWhatToFile(DepIn.br_I) || '   ~' || DepInTs.br_I || '~'
  7733. end
  7734. end
  7735. call FileClose DepFileName
  7736. end
  7737. call DBGIND-1
  7738. return
  7739.  
  7740. ProcessDependsOn:
  7741. Rest=PerformReplacementsInCmdsParameters(arg(1))
  7742. DepType=translate(GetQuotedText(Rest, "DependsOnList"))
  7743. if DependsOnList='' then
  7744. CryAndDie('No files supplied on "#DependsOn ' || DepType || '" command!')
  7745. do while DependsOnList<> ''
  7746. ThisOne=GetQuotedText(DependsOnList, "DependsOnList")
  7747. select
  7748. when DepType='OUTPUT' then
  7749. Added=AddOutputFileToDependancyList(ThisOne)
  7750. when DepType='INPUT' then
  7751. Added=AddInputFileToDependancyList(ThisOne)
  7752. when DepType='TEMP' then
  7753. Added=AddTempFileToDependancyList(ThisOne)
  7754. otherwise
  7755. CryAndDie('Unknown dependancy type of "' || DepType || '"!')
  7756. end
  7757. if Added='Y' then
  7758. call DBG DepType|| ' dependancy : ' ||ThisOne
  7759. end
  7760. return(0)
  7761.  
  7762. GetDependancyInfo:call TRACE "OFF"
  7763. parse arg bs_Type,bs_Which
  7764. bs_Type=translate(bs_Type)
  7765. if bs_Which='' then
  7766. do
  7767. select
  7768. when bs_Type='INPUT' then
  7769. return(DepInCnt)
  7770. when bs_Type='OUTPUT' then
  7771. return(DepOutCnt)
  7772. otherwise
  7773. _GetDependancyInfoErr(bs_Type)
  7774. end
  7775. end
  7776. else
  7777. do
  7778. select
  7779. when bs_Type='INPUT' then
  7780. return(DepIn.bs_Which)
  7781. when bs_Type='OUTPUT' then
  7782. return(DepOut.bs_Which)
  7783. otherwise
  7784. _GetDependancyInfoErr(bs_Type)
  7785. end
  7786. end
  7787.  
  7788. _GetDependancyInfoErr:
  7789. CryAndDie('Invalid dependanct type of "' || arg(1) || '"')
  7790.  
  7791. GetDependsStamp:
  7792. bt_4WhatVar=arg(1)
  7793. bt_4What=value(bt_4WhatVar)
  7794. if left(bt_4What,1)<> '*' then
  7795. do
  7796. bt_Ret=GetFileDateTimeButDontWarnOnError(bt_4What)
  7797. end
  7798. else
  7799. do
  7800. Stamp4U=translate(bt_4What)
  7801. select
  7802. when abbrev(Stamp4U, "*TODAY")then
  7803. do
  7804. bt_Ret=date('S')
  7805. end
  7806. when Stamp4U="*CMDLINE" then
  7807. do
  7808. bt_Ret=PpwClDep
  7809. end
  7810. when Stamp4U="*PPWPGM" then
  7811. do
  7812. bt_Ret=PgmVersion||' '||FileQuerySize(PpWizardPgmName)||' '||GetFileDateTimeButDontWarnOnError(PpWizardPgmName)
  7813. end
  7814. when abbrev(Stamp4U, "*REXX=")then
  7815. do
  7816. bt_RexxExp=translate(substr(bt_4What,7))
  7817. if pos('DEPVALUE',translate(bt_RexxExp))=0 then
  7818. bt_RexxExp='DepValue = ' ||bt_RexxExp
  7819. DepValue=time('L')
  7820. call ExecRexxCmd bt_RexxExp
  7821. bt_Ret=DepValue
  7822. end
  7823. when abbrev(Stamp4U, "*EXPIRES=")then
  7824. do
  7825. bt_ExpWhen=translate(substr(bt_4What,10))
  7826. parse var bt_ExpWhen bt_ExpCmd ';' bt_ExpTs
  7827. if bt_ExpWhen='NOW' then
  7828. bt_ExpWhen=0
  7829. bt_CurrTs=TimeSTamp()
  7830. if bt_ExpTs='' then
  7831. do
  7832. bt_ExpTs=TimeSTamp(bt_ExpWhen)
  7833. bt_4What=bt_4What|| ';' ||bt_ExpTs
  7834. call value bt_4WhatVar,bt_4What
  7835. end
  7836. if bt_CurrTs<=bt_ExpTs then
  7837. bt_Ret='Tick Tock...'
  7838. else
  7839. bt_Ret='Expired!'
  7840. end
  7841. when abbrev(Stamp4U, "*EXEC=")then
  7842. do
  7843. TheCmd=substr(bt_4What,7)
  7844. TmpFile=RexGetTmpFileName("DEPON???.???")
  7845. call AddressCmd TheCmd|| ' >' || TmpFile || ' 2>&1'
  7846. ExecRc=Rc
  7847. call DBG 'Depend value is result of (Rc=' || ExecRc || '): ' ||TheCmd
  7848. call FileClose TmpFile
  7849. TheCmdVal=charin(TmpFile,,999999)
  7850. call FileClose TmpFile
  7851. TheCmdVal=translate(TheCmdVal,, '0D0A1A'x, ' ')
  7852. TheCmdVal='RC=' || ExecRc || '->' ||TheCmdVal
  7853. bt_Ret=TheCmdVal
  7854. end
  7855. when abbrev(Stamp4U, "*FILES=")then
  7856. do
  7857. TheMask=substr(bt_4What,8)
  7858. if left(TheMask,1)<> '+' then
  7859. sdDo='N'
  7860. else
  7861. do
  7862. sdDo='Y'
  7863. TheMask=substr(TheMask,2)
  7864. end
  7865. call GetListOfFiles TheMask, 'DepDirList',sdDo
  7866. DirStamp=DepDirList.0|| ' files'
  7867. do DepIndex=1 to DepDirList.0
  7868. DirStamp=DirStamp|| '; ' || DepDirList.DepIndex || '=' ||GetFileDateTimeButDontWarnOnError(DepDirList.DepIndex)
  7869. end
  7870. bt_Ret=DirStamp
  7871. end
  7872. otherwise
  7873. CryAndDie('An incorrectly formatted "special" input dependancy was specified', 'You used "' || bt_4What || '"')
  7874. end
  7875. end
  7876. call DBG 'Stamp: ' ||bt_Ret
  7877. return(bt_Ret)
  7878.  
  7879. DEPENDON_31:
  7880. DoingImport=''
  7881. signal IMPORT_32
  7882.  
  7883. ProcessImport:
  7884. if DoingImport<> '' then
  7885. CryAndDie("Can't nest #import (started at " || DoingImport || ')')
  7886. else
  7887. DoingImport=CurrentSourceLocation()
  7888. ImportParms=PerformReplacementsInCmdsParameters(arg(1))
  7889. if AsIsModeOn='Y' then
  7890. CryAndDie("Please turn off #AsIs mode before importing.")
  7891. call _InitImportAsIsMemories
  7892. ImportFileName=GetQuotedText(ImportParms, "ImportParms")
  7893. if ImportParms='' then
  7894. CryAndDie('#import is missing import type (parm #2)!')
  7895. ImportFileType=translate(GetQuotedText(ImportParms, "ImportParms"))
  7896. if substr(ImportFileType,4)<> '-' then
  7897. DropLine=0
  7898. else
  7899. do
  7900. ImportFileType=left(ImportFileType,3)
  7901. DropLine=1
  7902. end
  7903. FirstChar=left(ImportFileType,1)
  7904. DelimiterSpec=FirstChar||FirstChar||FirstChar
  7905. CustomDelimiter='NO'
  7906. if(ImportFileType==DelimiterSpec)|(ImportFileType==DelimiterSpec|| '-')then
  7907. do
  7908. CustomDelimiter=FirstChar
  7909. TmpFilePart=''
  7910. end
  7911. else
  7912. do
  7913. TmpFilePart=ImportFileType
  7914. if pos('*' || ImportFileType || '*', '*TAB*CMA*FIX*SQL*WRAP*T2H*ML*')=0 then
  7915. CryAndDie('Invalid #import type of "' || ImportFileType || '" specified!')
  7916. end
  7917. if ImportFileType<> 'SQL' then
  7918. do
  7919. if ImportFileName='' then
  7920. CryAndDie('#import has no parameters!')
  7921. call FileClose ImportFileName
  7922. FullImportName=FileQueryExists(ImportFileName)
  7923. if FullImportName='' then
  7924. CryAndDie('The #import file "' || ImportFileName || '" does not exist!')
  7925. call OutputProcessingFileStringToScreen FullImportName
  7926. call AddInputFileToDependancyList FullImportName
  7927. end
  7928. ToInclude=RexGetTmpFileName('I_' || left(TmpFilePart, 4, '_') || '??.???')
  7929. call MustDeleteFile ToInclude
  7930. if ImportParms='' then
  7931. CryAndDie('#import is missing macro name (parm #3)!')
  7932. MacroName=GetQuotedText(ImportParms, "ImportParms")
  7933. if MacroName='' then
  7934. do
  7935. select
  7936. when ImportFileType='WRAP' then
  7937. MacroName='WRAP'
  7938. when ImportFileType='T2H' then
  7939. MacroName='T2H'
  7940. when ImportFileType='ML' then
  7941. MacroName='ML'
  7942. otherwise
  7943. MacroName='IMPORT'
  7944. end
  7945. end
  7946. call AsIsPrepare ''
  7947. if OptionDebugOn='Y' then
  7948. call DBG_IMPORT 'Generating "' || ToInclude || '" for later inclusion (#include).'
  7949. ReplaceNewLineChar=''
  7950. ReplaceTabChar=''
  7951. DisplayingFields=''
  7952. ReplaceNewLineChar=''
  7953. ReplaceTabChar=''
  7954. DoPass2=translate(GetImportValue('DO_PASS_2', 'Y'))
  7955. select
  7956. when ImportFileType='WRAP' then
  7957. ImpLinCnt=HandleLineWrapping()
  7958. when ImportFileType='T2H' then
  7959. ImpLinCnt=HandleTextToHtmlImport()
  7960. otherwise
  7961. do
  7962. call ImportTablePreparation
  7963. select
  7964. when ImportFileType='ML' then
  7965. ImpLinCnt=HandleMultiLineImport()
  7966. when CustomDelimiter<> 'NO' then
  7967. ImpLinCnt=HandleSimpleCharDelimitedFile(CustomDelimiter)
  7968. when ImportFileType='TAB' then
  7969. ImpLinCnt=HandleSimpleCharDelimitedFile(TabChar)
  7970. when ImportFileType='CMA' then
  7971. ImpLinCnt=HandleSimpleCharDelimitedFile(',')
  7972. when ImportFileType='FIX' then
  7973. ImpLinCnt=HandleFixedFieldFile()
  7974. when ImportFileType='SQL' then
  7975. ImpLinCnt=HandleSQLDataBase()
  7976. otherwise
  7977. CryAndDie('Unknown import type of "' || ImportFileType || '"')
  7978. end
  7979. call ImportTableTermination
  7980. end
  7981. end
  7982. if ImportFileType<> 'SQL' then
  7983. call FileClose FullImportName
  7984. if OptionDebugOn='Y' then
  7985. call DBG_IMPORT 'Imported ' || AddCommasToDecimalNumber(ImpLinCnt) || ' line(s) in "' || ImportFileType || '" mode.'
  7986. call FileClose ToInclude
  7987. call AsIsPrepare ''
  7988. if DoPass2='N' then
  7989. call DBG_IMPORT 'You have disabled PASS2 processing'
  7990. else
  7991. do
  7992. call DBG_IMPORT 'Now #include the generated temporary file ("' || ToInclude || '").'
  7993. call RecursiveIncludeSave
  7994. call ProcessInputFile ToInclude,, 'N', 'N'
  7995. call RecursiveIncludeRestore
  7996. call OutputProcessingFileStringToScreen
  7997. end
  7998. if GetImportValue('KEEP_TMP_FILE',  OptionDebugOn) = 'N' then
  7999. DeleteRc=_SysFileDelete(ToInclude)
  8000. DoingImport=''
  8001. return(0)
  8002.  
  8003. _ImportValueSpacer:
  8004. if OptionDebugOn='Y' then
  8005. do
  8006. call DBG_MACROVALORDEF ''
  8007. if arg(1)<> '' then
  8008. call DBG_MACROVALORDEF arg(1)
  8009. end
  8010. return
  8011.  
  8012. ImportValueExists:
  8013. ImportVar=MacroName|| '_' ||arg(1)
  8014. iveAnswer=MacroExists(ImportVar)
  8015. if OptionDebugOn='Y' then
  8016. call DBG_MACROVALORDEF 'Option(Macro) "' || ImportVar || '" Exists? : ' ||iveAnswer
  8017. return(iveAnswer)
  8018.  
  8019. GetImportValue:
  8020. ImportVar=MacroName|| '_' ||arg(1)
  8021. if MacroExists(ImportVar)='N' then
  8022. do
  8023. ImportMask=arg(2)
  8024. DebugWord='not'
  8025. end
  8026. else
  8027. do
  8028. ImportMask=GetDefineContents(ImportVar)
  8029. DebugWord='was'
  8030. end
  8031. if OptionDebugOn='Y' then
  8032. call DBG_MACROVALORDEF 'Option(Macro) "' || ImportVar || '" ' || DebugWord || ' found. Using ' ||DebugRightArrow||ImportMask||DebugLeftArrow
  8033. if ImportFileType<> "WRAP" & ImportFileType <> "T2H" then
  8034. ImportMask=ReplaceString(ImportMask,StartsMacroParm|| 'Columns' ||EndsMacroParm,DisplayingFields)
  8035. return(ImportMask)
  8036.  
  8037. GetImportValue_Tabs:
  8038. ReplaceTabChar=GetImportValue('TAB_CHAR', '')
  8039. return
  8040.  
  8041. GetImportValue_RecordFilter:
  8042. return(GetImportValue('RECORD_FILTER', ''))
  8043.  
  8044. GetImportValue_LineFilter:
  8045. LineFilter=GetImportValue('LINE_FILTER', '')
  8046.  
  8047. GetImportValue_Comments:
  8048. call _ImportValueSpacer 'Get comment options'
  8049. call DBGIND 1
  8050. ImportLineCmtChars=GetImportValue( 'LINECMT_CHARS',arg(1))
  8051. ImportInlineCmtChars=GetImportValue('INLINECMT_CHARS',arg(2))
  8052. call DBGIND-1
  8053. return
  8054.  
  8055. IsCmtLine:
  8056. if ImportLineCmtChars='' then
  8057. return(0)
  8058. else
  8059. return(abbrev(arg(1),ImportLineCmtChars))
  8060.  
  8061. ImportOneLine:
  8062. if arg(1)='Y' then
  8063. FileLine=CrLflinein(FullImportName)
  8064. else
  8065. FileLine=linein(FullImportName)
  8066. if LineFilter<> '' then
  8067. do
  8068. call DBG_IMPORT 'Calling specified line filter'
  8069. call DBGIND 1
  8070. call ExecRexxCmd LineFilter
  8071. call DBGIND-1
  8072. end
  8073. if ImportInlineCmtChars<> '' then
  8074. do
  8075. ilcPos=pos(ImportInlineCmtChars,FileLine)
  8076. if ilcPos<>0 then
  8077. FileLine=strip(left(FileLine,ilcPos-1), 'Trailing')
  8078. end
  8079. if arg(2)='Y' then
  8080. FileLine=AsIs(translate(FileLine, '',EofChar))
  8081. else
  8082. FileLine=translate(FileLine, '',EofChar)
  8083. if ReplaceNewLineChar\=='' then
  8084. FileLine=ReplaceString(FileLine,MarksNewLine,ReplaceNewLineChar)
  8085. if ReplaceTabChar\=='' then
  8086. FileLine=ReplaceString(FileLine,TabChar,ReplaceTabChar)
  8087. return(FileLine)
  8088.  
  8089. PpwLineout:
  8090. parse arg gFile,gLine
  8091. do until gLine==''
  8092. parse var gLine This1 (MarksNewLine) gLine
  8093. if 0<>charout(gFile,This1||NewLineChars)then
  8094. do
  8095. IoReason=FileDescription(gFile)
  8096. CryAndDie('Write to "' || gFile || '" failed (' || IoReason || ')!')
  8097. end
  8098. end
  8099. return
  8100.  
  8101. GenerateTagsIfNonEmpty:
  8102. OptionalTags=GetImportValue(arg(1),arg(2))
  8103. if OptionalTags\=='' then
  8104. call PpwLineout ToInclude,OptionalTags
  8105. return
  8106.  
  8107. GenerateProtectStartTags:
  8108. call GenerateTagsIfNonEmpty 'PROTECT_START', StartsStdSymbolReplacement || 'ProtectFromPpwStart' ||EndsMacroReplacement
  8109. return
  8110.  
  8111. GenerateProtectEndTags:
  8112. call GenerateTagsIfNonEmpty 'PROTECT_END',   StartsStdSymbolReplacement || 'ProtectFromPpwEnd' ||EndsMacroReplacement
  8113. return
  8114.  
  8115. GenerateBeforeTags:
  8116. call GenerateTagsIfNonEmpty 'BEFORE',arg(1)
  8117. return
  8118.  
  8119. GenerateAfterTags:
  8120. call GenerateTagsIfNonEmpty 'AFTER',arg(1)
  8121. return
  8122.  
  8123. HandleImportAsIsOptions:
  8124. call _ImportValueSpacer 'Prepare "AS IS" tagging'
  8125. call DBGIND 1
  8126. ImportAsIsMemory=GetImportValue('ASIS_TAGGING',arg(1))
  8127. call DBGIND 1
  8128. call AsIsPrepare ImportAsIsMemory
  8129. call DBGIND-2
  8130. return
  8131.  
  8132. _InitImportAsIsMemories:
  8133. if symbol('ImpMemInit') = 'VAR' then
  8134. return
  8135. ImpMemInit='Y'
  8136. call DBG_IMPORT 'Initializing named #AsIs tags for HTML Importing'
  8137. call DBGIND 1
  8138. call _ClearTempMemory
  8139. call _AddToTempMemory '&', '&'
  8140. call _AddToTempMemory '<', '<'
  8141. call _AddToTempMemory '>', '>'
  8142. call SetupNamedAsIsStorage 'IMPORT_HTML_BASIC',TmpAtCount
  8143. call _ClearTempMemory
  8144. call _AddToTempMemory '╔', '+'
  8145. call _AddToTempMemory '═', '-'
  8146. call _AddToTempMemory '╗', '+'
  8147. call _AddToTempMemory '║', '|'
  8148. call _AddToTempMemory '╝', '+'
  8149. call _AddToTempMemory '╚', '+'
  8150. call _AddToTempMemory '┌', '+'
  8151. call _AddToTempMemory '─', '-'
  8152. call _AddToTempMemory '┐', '+'
  8153. call _AddToTempMemory '│', '|'
  8154. call _AddToTempMemory '┘', '+'
  8155. call _AddToTempMemory '└', '+'
  8156. call SetupNamedAsIsStorage 'IMPORT_HTML_BOXGRAPHIC_TO_BOXTEXT',TmpAtCount
  8157. call DBGIND-1
  8158. return
  8159.  
  8160. _ClearTempMemory:
  8161. TmpAtCount=0
  8162. return
  8163.  
  8164. _AddToTempMemory:
  8165. TmpAtCount=TmpAtCount+1
  8166. ImportB.TmpAtCount=arg(1)
  8167. ImportA.TmpAtCount=arg(2)
  8168. return
  8169.  
  8170. WriteLineToTmpImportFile:call TRACE "OFF"
  8171. call PpwLineout ToInclude,arg(1)
  8172. return
  8173.  
  8174. IMPORT_32:
  8175. signal IMPORTT_33
  8176.  
  8177. ImportTablePreparation:
  8178. if ImportParms='' then
  8179. CryAndDie('#import is missing field names (parm #4 onwards)!')
  8180. NumberOfFields=0
  8181. DisplayingFields=0
  8182. do while ImportParms<> ''
  8183. NumberOfFields=NumberOfFields+1
  8184. HeadingInfo=GetQuotedText(ImportParms, "ImportParms")
  8185. ColumnNumber=DisplayingFields+1
  8186. ExtraInfo=''
  8187. if left(HeadingInfo,1)='{' then
  8188. do
  8189. EndPosn=pos('}',HeadingInfo)
  8190. if EndPosn=0 then
  8191. CryAndDie('Leading field codes on heading "' || HeadingInfo || '" invalid (expected "}")')
  8192. ExtraInfo=substr(HeadingInfo,2,EndPosn-2)
  8193. HeadingInfo=substr(HeadingInfo,EndPosn+1)
  8194. if ImportFileType<> 'SQL' then
  8195. do
  8196. parse var ExtraInfo MaybeColumnNumber','ExtraInfo
  8197. if MaybeColumnNumber<> '' & MaybeColumnNumber <> '*' then
  8198. ColumnNumber=MaybeColumnNumber
  8199. end
  8200. end
  8201. FieldHeading.NumberOfFields=HeadingInfo
  8202. FieldExtra.NumberOfFields=ExtraInfo
  8203. if HeadingInfo<> '' then
  8204. do
  8205. FieldColumn.NumberOfFields=ColumnNumber
  8206. DisplayingFields=DisplayingFields+1
  8207. end
  8208. end
  8209. call _ImportValueSpacer 'Assorted options'
  8210. call DBGIND 1
  8211. DropBlankLines=translate(GetImportValue('DROP_BLANK_LINES',  'Y'))
  8212. DropLine=GetImportValue('DROP_LINE_COUNT',DropLine)
  8213. ReplaceNewLineChar=GetImportValue('NEWLINE_CHAR', '<BR>')
  8214. call GetImportValue_Tabs
  8215. call GetImportValue_LineFilter
  8216. RecordFilter=GetImportValue_RecordFilter()
  8217. call DBGIND-1
  8218. call _ImportValueSpacer 'What happens to blank fields?'
  8219. call DBGIND 1
  8220. ReplaceBlankFields=GetImportValue('BLANK_FIELD',  '')
  8221. do Index=1 to DisplayingFields
  8222. RepBlankCol.Index=GetImportValue('BLANK_COLUMN_' ||Index,ReplaceBlankFields)
  8223. end
  8224. call DBGIND-1
  8225. call _ImportValueSpacer 'What do we do with column titles?'
  8226. call DBGIND 1
  8227. if ImportValueExists('HEADER') = 'Y' then
  8228. ForHeader=GetImportValue('HEADER', '!BUG!')
  8229. else
  8230. do
  8231. DefaultColFormatting=GetImportValue('HEADING_COLUMNS',     'ALIGN=CENTER')
  8232. DefaultBeforeData=GetImportValue('HEADING_BEFORE_DATA', '')
  8233. DefaultAfterData=GetImportValue('HEADING_AFTER_DATA',  '')
  8234. ForHeader='<TR>'
  8235. do Index=1 to DisplayingFields
  8236. ThisColFormatting=GetImportValue('HEADING_COLUMN_' ||Index,DefaultColFormatting)
  8237. ThisBeforeData=GetImportValue('HEADING_BEFORE_DATA_' ||Index,DefaultBeforeData)
  8238. ThisAfterData=GetImportValue('HEADING_AFTER_DATA_' ||Index,DefaultAfterData)
  8239. ForHeader=ForHeader|| '<TH ' || ThisColFormatting || '>' || ThisBeforeData || StartsMacroParm || 'Column' || Index || EndsMacroParm || ThisAfterData || '</TH>'
  8240. end
  8241. ForHeader=ForHeader|| '</TR>'
  8242. end
  8243. call DBGIND-1
  8244. call _ImportValueSpacer 'Working out what table data row looks like'
  8245. call DBGIND 1
  8246. if ImportValueExists('RECORD') = 'Y' then
  8247. ForEachRecord=GetImportValue('RECORD', '!BUG!')
  8248. else
  8249. do
  8250. DefaultColFormatting=GetImportValue('RECORD_COLUMNS',     'ALIGN=CENTER')
  8251. DefaultBeforeData=GetImportValue('RECORD_BEFORE_DATA', '')
  8252. DefaultAfterData=GetImportValue('RECORD_AFTER_DATA',  '')
  8253. ForEachRecord='<TR>'
  8254. do Index=1 to DisplayingFields
  8255. ThisColFormatting=GetImportValue('RECORD_COLUMN_' ||Index,DefaultColFormatting)
  8256. ThisBeforeData=GetImportValue('RECORD_BEFORE_DATA_' ||Index,DefaultBeforeData)
  8257. ThisAfterData=GetImportValue('RECORD_AFTER_DATA_' ||Index,DefaultAfterData)
  8258. ForEachRecord=ForEachRecord|| '<TD ' || ThisColFormatting || '>' || ThisBeforeData || StartsMacroParm || 'Column' || Index || EndsMacroParm  || ThisAfterData || '</TD>'
  8259. end
  8260. ForEachRecord=ForEachRecord|| '</TR>'
  8261. end
  8262. call DBGIND-1
  8263. call _ImportValueSpacer 'Start output'
  8264. call DBGIND 1
  8265. call GenerateProtectStartTags
  8266. TableAttribs=GetImportValue('TABLE_ATTRIBS', 'BORDER=5 CELLSPACING=5')
  8267. if TableAttribs<> '' then
  8268. TableAttribs=' ' ||strip(TableAttribs)
  8269. BeforeRecordsDefault='<TABLE' || TableAttribs || '>'
  8270. call GenerateBeforeTags BeforeRecordsDefault
  8271. call DBG_IMPORT 'Outputting heading fields'
  8272. call DBGIND 1
  8273. call _NewRecord 'H'
  8274. do FieldIndex=1 to NumberOfFields
  8275. call _AddField2Record FieldHeading.FieldIndex
  8276. end
  8277. call GenerateRecordFromFields
  8278. call DBGIND-2
  8279. call GetImportValue_Comments ';', ';' || ';'
  8280. if ProcessingMode='HTML' then
  8281. call HandleImportAsIsOptions "IMPORT_HTML_BASIC"
  8282. return
  8283.  
  8284. ImportTableTermination:
  8285. call GenerateAfterTags '</TABLE>'
  8286. call GenerateProtectEndTags
  8287. return
  8288.  
  8289. HandleFixedFieldFile:
  8290. if OptionDebugOn='Y' then
  8291. call DBG_IMPORT 'Importing fixed field file'
  8292. do FieldIndex=1 to NumberOfFields
  8293. parse var FieldExtra.FieldIndex StartCol'-'EndCol
  8294. if EndCol='' | EndCol = '*' then
  8295. FieldLength=''
  8296. else
  8297. FieldLength=(EndCol-StartCol)+1
  8298. FieldStartCol.FieldIndex=StartCol
  8299. FieldLength.FieldIndex=FieldLength
  8300. end
  8301. ImportFileLine=0
  8302. call DBG_IMPORT 'Reading "' || FullImportName || '"...'
  8303. do while lines(FullImportName)<>0
  8304. CurrentRecord=ImportOneLine('N', 'Y')
  8305. ImportFileLine=ImportFileLine+1
  8306. if CurrentRecord='' then
  8307. iterate
  8308. if ImportFileLine<=DropLine then
  8309. iterate
  8310. if IsCmtLine(ImportFileLine)then
  8311. iterate
  8312. call _NewRecord
  8313. do FieldIndex=1 to NumberOfFields
  8314. if FieldLength.FieldIndex='' then
  8315. ThisField=substr(CurrentRecord,FieldStartCol.FieldIndex)
  8316. else
  8317. ThisField=substr(CurrentRecord,FieldStartCol.FieldIndex,FieldLength.FieldIndex)
  8318. call _AddField2Record strip(ThisField)
  8319. end
  8320. if GenerateRecordFromFields()then
  8321. leave
  8322. end
  8323. return(ImportFileLine)
  8324.  
  8325. HandleSimpleCharDelimitedFile:
  8326. FieldDelimiter=arg(1)
  8327. if OptionDebugOn='Y' then
  8328. do
  8329. DelimiterText=c2d(FieldDelimiter)
  8330. if DelimiterText> '32' then
  8331. DelimiterText=DelimiterText|| ' ("' || FieldDelimiter || '")'
  8332. call DBG_IMPORT 'Importing simple delimited file - delimiter = ASCII ' ||DelimiterText
  8333. end
  8334. UseCrLfRoutines=GetImportValue('HANDLE_IMBEDDED_NEWLINES', 'N')
  8335. if UseCrLfRoutines='N' then
  8336. call DBG_IMPORT 'Special imbedded newline detecting code is not being used'
  8337. else
  8338. do
  8339. UseCrLfRoutines='Y'
  8340. call DBG_IMPORT 'We are using special imbedded newline detecting code'
  8341. end
  8342. call DBG_IMPORT 'Reading "' || FullImportName || '"...'
  8343. if UseCrLfRoutines='Y' then
  8344. OpenRc=CrlfOpen(FullImportName,10000)
  8345. ImportFileLine=0
  8346. do forever
  8347. if UseCrLfRoutines='Y' then
  8348. EofIf0=CrLflines(FullImportName)
  8349. else
  8350. EofIf0=lines(FullImportName)
  8351. if EofIf0=0 then
  8352. leave
  8353. CurrentRecord=ImportOneLine(UseCrLfRoutines, 'Y')
  8354. ImportFileLine=ImportFileLine+1
  8355. if CurrentRecord='' then
  8356. do
  8357. if DropBlankLines='Y' then
  8358. iterate
  8359. end
  8360. if ImportFileLine<=DropLine then
  8361. iterate
  8362. if IsCmtLine(CurrentRecord)then
  8363. iterate
  8364. call _NewRecord
  8365. bv_L=CurrentRecord
  8366. bv_Del=FieldDelimiter
  8367. bv_MinF=NumberOfFields
  8368. bv_MaxF=NumberOfFields
  8369. bv_FC=0
  8370. bv_Q='"'
  8371. bv_Q2='""'
  8372. do while bv_L<> ''
  8373. bv_Fc=bv_Fc+1
  8374. if left(bv_L,1)<>bv_Q then
  8375. do
  8376. bv_DelPos=pos(bv_Del,bv_L)
  8377. if bv_DelPos<>0 then
  8378. do
  8379. bv_F=left(bv_L,bv_DelPos-1)
  8380. bv_L=substr(bv_L,bv_DelPos+1)
  8381. end
  8382. else
  8383. do
  8384. bv_F=bv_L
  8385. bv_L=''
  8386. end
  8387. end
  8388. else
  8389. do
  8390. bv_LookFrom=2
  8391. do forever
  8392. bv_QPos=pos(bv_Q,bv_L,bv_LookFrom)
  8393. if bv_QPos=0 then
  8394. do
  8395. CryAndDie('Import of line ' || ImportFileLine || ' failed','No ending quote on field #' || bv_Fc,, 'RECORD', '~~~~~~', CurrentRecord, 'DETECTED AT', '~~~~~~~~~~~',bv_L)
  8396. end
  8397. if substr(bv_L,bv_QPos+1,1)=bv_Q then
  8398. bv_LookFrom=bv_QPos+2
  8399. else
  8400. leave
  8401. end
  8402. bv_F=ReplaceString(substr(bv_L,2,bv_QPos-2),bv_Q2,bv_Q)
  8403. bv_L=substr(bv_L,bv_QPos+1)
  8404. if bv_L<> '' then
  8405. do
  8406. if left(bv_L,1)<>bv_Del then
  8407. do
  8408. CryAndDie('Import of line ' || ImportFileLine || ' failed','Expected delimiter after field #' || bv_Fc,, 'RECORD', '~~~~~~', CurrentRecord, 'DETECTED AT', '~~~~~~~~~~~',bv_L)
  8409. end
  8410. bv_L=substr(bv_L,2)
  8411. end
  8412. end
  8413. bw_Fld.bv_Fc=bv_F
  8414. if bv_MaxF<>0 then
  8415. do
  8416. if bv_Fc>=bv_MaxF then
  8417. leave
  8418. end
  8419. end
  8420. if bv_Fc<bv_MinF then
  8421. do
  8422. do while bv_Fc<bv_MinF
  8423. bv_Fc=bv_Fc+1
  8424. bw_Fld.bv_Fc=''
  8425. end
  8426. end
  8427. bw_Fld.0=bv_Fc
  8428. do bw_i=1 to bw_Fld.0
  8429. call _AddField2Record bw_Fld.bw_i
  8430. end
  8431. if GenerateRecordFromFields()then
  8432. leave
  8433. end
  8434. if UseCrLfRoutines='Y' then
  8435. CloseRc=CrlfClose(FullImportName)
  8436. return(ImportFileLine)
  8437.  
  8438. _NewRecord:
  8439. RecordType=arg(1)
  8440. if RecordType='H' then
  8441. ThisRecordsCodes=ForHeader
  8442. else
  8443. ThisRecordsCodes=ForEachRecord
  8444. FieldCounter=0
  8445. ColumnCounter=0
  8446. DroppedCounter=0
  8447. NonBlankFieldCounter=0
  8448. return
  8449.  
  8450. _AddField2Record:
  8451. FieldCounter=FieldCounter+1
  8452. if FieldHeading.FieldCounter='' then
  8453. do
  8454. DroppedCounter=DroppedCounter+1
  8455. Dropped.DroppedCounter=arg(1)
  8456. end
  8457. else
  8458. do
  8459. ColumnCounter=ColumnCounter+1
  8460. NewValue=arg(1)
  8461. if NewValue='' then
  8462. NewValue=RepBlankCol.ColumnCounter
  8463. else
  8464. NonBlankFieldCounter=NonBlankFieldCounter+1
  8465. SaveAsIndex=FieldColumn.FieldCounter
  8466. Column.SaveAsIndex=NewValue
  8467. end
  8468. return
  8469.  
  8470. GenerateRecordFromFields:
  8471. call DBGIND 1
  8472. if DropBlankLines='Y' then
  8473. do
  8474. if NonBlankFieldCounter=0 then
  8475. do
  8476. call DBG_IMPORT 'Dropping record as all fields were blank'
  8477. call DBGIND-1
  8478. return(0)
  8479. end
  8480. end
  8481. if RecordFilter<> '' then
  8482. do
  8483. if RecordType<> 'H' then
  8484. do
  8485. Column.0=ColumnCounter
  8486. Dropped.0=DroppedCounter
  8487. call DBG_IMPORT 'Calling specified filter'
  8488. call DBGIND 1
  8489. Remove=''
  8490. call ExecRexxCmd RecordFilter
  8491. if Remove<> '' then
  8492. do
  8493. if abbrev(Remove, "EOF:")then
  8494. do
  8495. call DBG_IMPORT 'This Record and all following dropped ==> ' ||Remove
  8496. call DBGIND-2
  8497. return(1)
  8498. end
  8499. else
  8500. do
  8501. call DBG_IMPORT 'Record dropped ==> ' ||Remove
  8502. call DBGIND-2
  8503. return(0)
  8504. end
  8505. end
  8506. call DBGIND-1
  8507. end
  8508. end
  8509. do ThisOne=1 to ColumnCounter
  8510. ThisRecordsCodes=ReplaceString(ThisRecordsCodes,StartsMacroParm|| 'Column' ||ThisOne||EndsMacroParm,Column.ThisOne)
  8511. end
  8512. if ThisRecordsCodes<> '' then
  8513. do
  8514. call DBG_IMPORT 'Generating: ' ||DebugRightArrow||ThisRecordsCodes||DebugLeftArrow
  8515. call PpwLineout ToInclude,ThisRecordsCodes
  8516. end
  8517. call DBGIND-1
  8518. return(0)
  8519.  
  8520. IMPORTT_33:
  8521. signal REXXSQL_34
  8522.  
  8523. LoadRexxSql:
  8524. signal on SYNTAX name RexxSqlMissing
  8525. bx_Rc=RXFuncAdd('SQLLoadFuncs', 'rexxsql', 'SQLLoadFuncs')
  8526. call DBG_IMPORT "RXFuncAdd(rexxsql.dll), RC = " ||bx_Rc
  8527. call SQLLoadFuncs
  8528. call DBG_IMPORT "rexxsql.dll functions loaded"
  8529. return
  8530.  
  8531. RexxSqlMissing:
  8532. by_Em="Can't locate/load rexxsql.dll (Mark Hessling's SQL support)!"
  8533. by_Reason='UNKNOWN'
  8534. signal on SYNTAX name RexxSqlEmFailed
  8535. if RexWhich='REGINA' then
  8536. do
  8537. by_Tmp=RxFuncErrMsg()
  8538. by_Reason=by_Tmp
  8539. end
  8540.  
  8541. RexxSqlEmFailed:
  8542. CryAndDie(by_Em, 'REASON:',by_Reason)
  8543.  
  8544. by_Line:
  8545. by_Count=by_Count+1
  8546. by_L.by_Count=arg(1)
  8547. return
  8548.  
  8549. ErrorSql:
  8550. do by_I=1 to 10
  8551. by_L.by_I=''
  8552. end
  8553. by_Count=0
  8554. do by_I=1 to arg()
  8555. call by_Line arg(by_I)
  8556. end
  8557. if by_Count>6 then
  8558. by_Count=6
  8559. if by_L.1='' then
  8560. do
  8561. by_Count=1
  8562. by_L.1='REXXSQL ' || SQLCA.FUNCTION || '() call failed'
  8563. end
  8564. call by_Line ''
  8565. if sqlca.intcode=-1 Then
  8566. do
  8567. call by_Line 'SQLCODE:' sqlca.sqlcode
  8568. call by_Line 'SQLERRM:' sqlca.sqlerrm
  8569. call by_Line 'SQLTEXT:' sqlca.sqltext
  8570. end
  8571. else
  8572. do
  8573. call by_Line 'INTCODE:' sqlca.intcode
  8574. call by_Line 'INTERRM:' sqlca.interrm
  8575. end
  8576. CryAndDie(by_L.1,by_L.2,by_L.3,by_L.4,by_L.5,by_L.6,by_L.7,by_L.8,by_L.9,by_L.10)
  8577.  
  8578. HandleSqlDataBase:
  8579. if OptionDebugOn='Y' then
  8580. do
  8581. call DBG_IMPORT "Importing SQL via Mark Hessling's REXXSQL interface"
  8582. call DBGIND 1
  8583. end
  8584. call LoadRexxSql
  8585. bz_Imported=0
  8586. call DBG_IMPORT "REXXSQL VERSION: " || SqlVariable("VERSION")
  8587. do FieldIndex=1 to NumberOfFields
  8588. bz_FNAME=FieldExtra.FieldIndex
  8589. if bz_FNAME='' then
  8590. bz_FNAME=FieldHeading.FieldIndex
  8591. FieldName.FieldIndex=bz_FNAME
  8592. end
  8593. if OptionDebugOn='Y' then
  8594. do
  8595. call SqlVariable "DEBUG", GetImportValue('SQL_DEBUG', '3')
  8596. end
  8597. bz_Id="SQL"
  8598. bz_UserId=GetImportValue('SQL_USERID',   "")
  8599. bz_Password=GetImportValue('SQL_USERPW',   "")
  8600. bz_DataSourceId=GetImportValue('SQL_DATABASE', "")
  8601. if bz_DataSourceId='' then
  8602. CryAndDie('An SQL database was not specified')
  8603. bz_Server=GetImportValue('SQL_SERVER',   "")
  8604. call DBG_IMPORT "Connecting to the database"
  8605. if SQLConnect(bz_Id,bz_UserId,bz_Password,bz_DataSourceId,bz_Server)<0 then
  8606. ErrorSql('Connection failed to "' || bz_DataSourceId || '", have you set up ODBC datasource (control panel)?')
  8607. call DBG_IMPORT "DATABASE INFO: " || SqlGetInfo(bz_Id, 'DBMSNAME')
  8608. bz_Cmds=GetImportValue('SQL_COMMANDS', "")
  8609. if bz_Cmds<> '' then
  8610. do
  8611. call DBGIND 1
  8612. do bz_I=1 to words(bz_Cmds)
  8613. bz_Mac=word(bz_Cmds,bz_I)
  8614. bz_Cmd=GetDefineContents(bz_Mac)
  8615. if left(bz_Cmd,1)<> '-' then
  8616. bz_Doe='Y'
  8617. else
  8618. do
  8619. bz_Doe='N'
  8620. bz_Cmd=substr(bz_Cmd,2)
  8621. end
  8622. call DBG_IMPORT "Executing: " ||bz_Cmd
  8623. bz_Rc=SQLCommand(bz_Mac,bz_Cmd)
  8624. call DBGIND 1
  8625. if bz_Rc>=0 then
  8626. call DBG_IMPORT "OK, RC=" ||bz_Rc
  8627. else
  8628. do
  8629. if bz_Doe='Y' then
  8630. ErrorSql('User command from "' || bz_Mac || '" failed!')
  8631. if sqlca.intcode=-1 Then
  8632. do
  8633. bz_1='SQLCODE:' sqlca.sqlcode
  8634. bz_2='SQLERRM:' sqlca.sqlerrm
  8635. bz_3='SQLTEXT:' sqlca.sqltext
  8636. end
  8637. else
  8638. do
  8639. bz_1='INTCODE:' sqlca.intcode
  8640. bz_2='INTERRM:' sqlca.interrm
  8641. bz_3=''
  8642. end
  8643. call DBG_IMPORT "Command failed"
  8644. call DBG_IMPORT bz_1
  8645. call DBG_IMPORT bz_2
  8646. call DBG_IMPORT bz_3
  8647. end
  8648. call DBGIND-1
  8649. end
  8650. call DBGIND-1
  8651. end
  8652. bz_Query=GetImportValue('SQL_QUERY', "")
  8653. if bz_Query='' then
  8654. CryAndDie('An SQL query was not specified')
  8655. if SqlPrepare('SQLQUERY',bz_Query)<0 then
  8656. ErrorSql()
  8657. if OptionDebugOn='Y' then
  8658. do
  8659. call DBG_IMPORT "Returned Column information"
  8660. call DBGIND 1
  8661. bz_Attribs=SqlGetInfo(bz_Id, 'DESCRIBECOLUMNS')
  8662. if sqlca.intcode<0 then
  8663. bz_Attribs='NAME TYPE SIZE SCALE NULLABLE PRECISION'
  8664. bz_Pad2=0
  8665. do bz_I=1 to words(bz_Attribs)
  8666. bz_This=word(bz_Attribs,bz_I)
  8667. if length(bz_This)>bz_Pad2 then
  8668. bz_Pad2=length(bz_This)
  8669. end
  8670. bz_NumCols=SqlDescribe('SQLQUERY', 'bz_Det')
  8671. if bz_NumCols<0 then
  8672. ErrorSql()
  8673. do bz_ColIndex=1 to bz_NumCols
  8674. call DBG_IMPORT "Query Field " ||bz_ColIndex
  8675. call DBGIND 1
  8676. do bz_I=1 to words(bz_Attribs)
  8677. bz_Attrib=word(bz_Attribs,bz_I)
  8678. bz_Value=value('bz_Det.COLUMN.' || bz_Attrib || '.bz_ColIndex')
  8679. if left(bz_Value,1)='' | right(bz_Value, 1) = '' then
  8680. bz_Value='""'
  8681. call DBG_IMPORT right(bz_Attrib,bz_Pad2)|| ' = ' ||bz_Value
  8682. end
  8683. call DBGIND-1
  8684. end
  8685. call DBGIND-1
  8686. end
  8687. if SqlOpen('SQLQUERY')<0 then
  8688. ErrorSql()
  8689. bz_Rc=SqlFetch('SQLQUERY')
  8690. do while bz_Rc>0
  8691. call _NewRecord
  8692. do FieldIndex=1 to NumberOfFields
  8693. bz_ColVar='SQLQUERY.' ||FieldName.FieldIndex
  8694. if bz_Imported=0 then
  8695. do
  8696. if symbol(bz_ColVar)<> 'VAR' then
  8697. CryAndDie('The query did not return a field called "' || FieldName.FieldIndex || '"')
  8698. end
  8699. call _AddField2Record value(bz_ColVar)
  8700. end
  8701. bz_Imported=bz_Imported+1
  8702. if GenerateRecordFromFields()then
  8703. leave
  8704. bz_Rc=SqlFetch('SQLQUERY')
  8705. end
  8706. if bz_Rc<0 then
  8707. ErrorSql()
  8708. if SqlClose('SQLQUERY')<0 then
  8709. ErrorSql()
  8710. if SqlDispose('SQLQUERY')<0 then
  8711. ErrorSql()
  8712. call DBG_IMPORT "Disconnecting from the database"
  8713. if SQLDisconnect(bz_Id)<0 then
  8714. ErrorSql()
  8715. if OptionDebugOn='Y' then
  8716. call DBGIND-1
  8717. return(bz_Imported)
  8718.  
  8719. REXXSQL_34:
  8720. signal IMPORTTX_35
  8721.  
  8722. HandleTextToHtmlImport:
  8723. if ProcessingMode<> 'HTML' then
  8724. CryAndDie("Text to html file importing is only allowed when generating HTML")
  8725. if ImportParms<> '' then
  8726. CryAndDie('There are too many parameters on the T2H #import!')
  8727. UrlNameVar=StartsMacroParm|| 'Url' ||EndsMacroParm
  8728. UrlTypeVar=StartsMacroParm|| 'UrlType' ||EndsMacroParm
  8729. HeadingVar=StartsMacroParm|| 'Heading' ||EndsMacroParm
  8730. call GenerateProtectStartTags
  8731. call GenerateBeforeTags '<PRE><FONT SIZE=-1>'
  8732. T2hFilter=GetImportValue_RecordFilter()
  8733. call GetImportValue_LineFilter
  8734. call GetImportValue_Tabs
  8735. BlankLinesTo=GetImportValue('BLANK_LINES_TO', '')
  8736. HttpLink=GetImportValue('HTTP_LINK',   '<A HREF="' || UrlTypeVar || UrlNameVar || '" TARGET=_top>' || UrlTypeVar || UrlNameVar || '</A>')
  8737. FtpLink=GetImportValue('FTP_LINK',    '<A HREF="' || UrlTypeVar || UrlNameVar || '">' || UrlTypeVar || UrlNameVar || '</A>')
  8738. MailLink=GetImportValue('MAILTO_LINK', '<A HREF="mailto:' || UrlNameVar || '">' || UrlNameVar || '</A>')
  8739. DefaultAllStd=UpperCase||LowerCase||DecimalDigits
  8740. AlwaysOkInUrl=GetImportValue('ALWAYS_OK_IN_URL_CHARS',DefaultAllStd)
  8741. if AlwaysOkInUrl\=='' then
  8742. DefaultAllStd=''
  8743. ExtraValidHttpChar=GetImportValue('EXTRA_VALID_HTTP_CHARS',         DefaultAllStd || './?%+:~_')
  8744. ExtraValidFtpChar=GetImportValue('EXTRA_VALID_FTP_CHARS',ExtraValidHttpChar)
  8745. ExtraValidEmailName=GetImportValue('EXTRA_VALID_EMAIL_NAME_CHARS',   DefaultAllStd || '_.')
  8746. ExtraValidEmailSvr=GetImportValue('EXTRA_VALID_EMAIL_SVR_CHARS',    DefaultAllStd || '_.')
  8747. ValidEmailDelimiters=GetImportValue('EXTRA_VALID_EMAIL_DELIMITERS',   " '" || '",;')
  8748. ValidInHttpUrl=AlwaysOkInUrl||ExtraValidHttpChar
  8749. ValidInFtpUrl=AlwaysOkInUrl||ExtraValidFtpChar
  8750. ValidInEmailL=AlwaysOkInUrl||ExtraValidEmailName
  8751. ValidInEmailR=AlwaysOkInUrl||ExtraValidEmailSvr
  8752. call GetImportValue_Comments '', ''
  8753. if ProcessingMode='HTML' then
  8754. call HandleImportAsIsOptions "IMPORT_HTML_BASIC IMPORT_HTML_BOXGRAPHIC_TO_BOXTEXT"
  8755. T2hLineNumber=0
  8756. call DBG_IMPORT 'Reading "' || FullImportName || '"...'
  8757. do while lines(FullImportName)<>0
  8758. T2hFileLine=ImportOneLine('N', 'Y')
  8759. T2hLineNumber=T2hLineNumber+1
  8760. if IsCmtLine(T2hFileLine)then
  8761. iterate
  8762. if T2hFileLine='' then
  8763. do
  8764. if BlankLinesTo\=='' then
  8765. T2hNewLine=BlankLinesTo
  8766. else
  8767. T2hNewLine=''
  8768. end
  8769. else
  8770. do
  8771. T2hNewLine=T2hFileLine
  8772. if MailLink\=='' then
  8773. T2hNewLine=_MakeTextImportEmailChanges(T2hNewLine,ValidInEmailL,ValidInEmailR,ValidEmailDelimiters,MailLink)
  8774. if HttpLink\=='' then
  8775. T2hNewLine=_MakeTextImportLinkChanges(T2hNewLine, 'http:',ValidInHttpUrl,HttpLink)
  8776. if FtpLink\=='' then
  8777. T2hNewLine=_MakeTextImportLinkChanges(T2hNewLine, 'ftp:',ValidInFtpUrl,FtpLink)
  8778. end
  8779. if T2hFilter<> '' then
  8780. do
  8781. call DBG_IMPORT 'Calling specified filter'
  8782. call DBGIND 1
  8783. Remove=''
  8784. call ExecRexxCmd T2hFilter
  8785. if Remove<> '' then
  8786. do
  8787. if abbrev(Remove, "EOF:")then
  8788. do
  8789. call DBG_IMPORT 'This Record and all following dropped ==> ' ||Remove
  8790. call DBGIND-1
  8791. leave
  8792. end
  8793. else
  8794. do
  8795. call DBG_IMPORT 'Record dropped ==> ' ||Remove
  8796. call DBGIND-1
  8797. iterate
  8798. end
  8799. end
  8800. call DBGIND-1
  8801. end
  8802. call PpwLineout ToInclude,T2hNewLine
  8803. end
  8804. call GenerateAfterTags '</FONT></PRE>'
  8805. call GenerateProtectEndTags
  8806. return(T2hLineNumber)
  8807.  
  8808. _MakeTextImportLinkChanges:
  8809. parse arg RightBit,UrlType,tlOkInUrl,tlTransformSpec
  8810. LeftBit=''
  8811. UrlPos=pos(UrlType,RightBit)
  8812. lUrlType=length(UrlType)
  8813. do while UrlPos<>0
  8814. LeftBit=LeftBit||left(RightBit,UrlPos-1)
  8815. RightBit=substr(RightBit,UrlPos+lUrlType)
  8816. NotUrlCharPos=verify(RightBit,tlOkInUrl)
  8817. if NotUrlCharPos=0 then
  8818. do
  8819. TheUrl=RightBit
  8820. RightBit=''
  8821. end
  8822. else
  8823. do
  8824. TheUrl=left(RightBit,NotUrlCharPos-1)
  8825. RightBit=substr(RightBit,NotUrlCharPos)
  8826. end
  8827. UrlBit=ReplaceString(tlTransformSpec,UrlTypeVar,UrlType)
  8828. UrlBit=ReplaceString(UrlBit,UrlNameVar,TheUrl)
  8829. LeftBit=LeftBit||UrlBit
  8830. UrlPos=pos(UrlType,RightBit)
  8831. end
  8832. return(LeftBit||RightBit)
  8833.  
  8834. _MakeTextImportEmailChanges:
  8835. parse arg RightBit,tlOkInEmailName,tlOkInEmailSvr,tlDelimiters,tlTransformSpec
  8836. LeftBit=''
  8837. SnailPos=pos('@',RightBit)
  8838. do while SnailPos<>0
  8839. lRightBit=length(RightBit)
  8840. if SnailPos=1|SnailPos=lRightBit then
  8841. do
  8842. LeftBit=LeftBit||left(RightBit,SnailPos)
  8843. RightBit=substr(RightBit,SnailPos+1)
  8844. end
  8845. else
  8846. do
  8847. LeftPos=SnailPos-1
  8848. do until LeftPos=0
  8849. OneChar=substr(RightBit,LeftPos,1)
  8850. if pos(OneChar,tlDelimiters)<>0 then
  8851. do
  8852. LeftPos=LeftPos+1
  8853. leave
  8854. end
  8855. LeftPos=LeftPos-1
  8856. end
  8857. if LeftPos=0 then
  8858. LeftPos=LeftPos+1
  8859. EmailLeftBit=substr(RightBit,LeftPos,SnailPos-LeftPos)
  8860. RightPos=SnailPos+1
  8861. do until RightPos>lRightBit
  8862. OneChar=substr(RightBit,RightPos,1)
  8863. if pos(OneChar,tlDelimiters)<>0 then
  8864. do
  8865. RightPos=RightPos-1
  8866. leave
  8867. end
  8868. RightPos=RightPos+1
  8869. end
  8870. if RightPos>lRightBit then
  8871. RightPos=lRightBit
  8872. if substr(RightBit,RightPos,1)='.' then
  8873. RightPos=RightPos-1
  8874. EmailRightBit=substr(RightBit,SnailPos+1,RightPos-SnailPos)
  8875. if verify(EmailLeftBit,tlOkInEmailName)<>0|verify(EmailRightBit,tlOkInEmailSvr)<>0|pos('.',EmailRightBit)=0 then
  8876. do
  8877. LeftBit=LeftBit||left(RightBit,SnailPos)
  8878. RightBit=substr(RightBit,SnailPos+1)
  8879. end
  8880. else
  8881. do
  8882. EmailBit=ReplaceString(tlTransformSpec,UrlTypeVar, 'mailto:')
  8883. EmailBit=ReplaceString(EmailBit,UrlNameVar,EmailLeftBit|| '@' ||EmailRightBit)
  8884. LeftBit=LeftBit||left(RightBit,LeftPos-1)||EmailBit
  8885. RightBit=substr(RightBit,RightPos+1)
  8886. end
  8887. end
  8888. SnailPos=pos('@',RightBit)
  8889. end
  8890. return(LeftBit||RightBit)
  8891.  
  8892. IMPORTTX_35:
  8893. signal IMPORTWR_36
  8894.  
  8895. HandleLineWrapping:
  8896. if ImportParms<> '' then
  8897. CryAndDie('There are too many parameters on the WRAP #import!')
  8898. DropBlankLines=translate(GetImportValue('DROP_BLANK_LINES',  'Y'))
  8899. call GetImportValue_Tabs
  8900. WrapFilter=GetImportValue_RecordFilter()
  8901. call GetImportValue_LineFilter
  8902. call GetImportValue_Comments ';', ';' || ';'
  8903. if ProcessingMode='HTML' then
  8904. call HandleImportAsIsOptions ""
  8905. WrapLineNumber=0
  8906. NewDoubleQuote='" || d2c(34) || "'
  8907. call DBG_IMPORT 'Reading "' || FullImportName || '"...'
  8908. do while lines(FullImportName)<>0
  8909. WrapLine=ImportOneLine('N', 'Y')
  8910. WrapLineNumber=WrapLineNumber+1
  8911. if WrapLine='' then
  8912. do
  8913. if DropBlankLines='Y' then
  8914. iterate
  8915. end
  8916. if IsCmtLine(WrapLine)then
  8917. iterate
  8918. if WrapFilter='' then
  8919. do
  8920. RebuildCmd='"' || ReplaceString(WrapLine, '"', NewDoubleQuote) || '"'
  8921. SafeQuote=QuoteIt(RebuildCmd,TryQuoteListAny)
  8922. call PpwLineout ToInclude,StartsMacroReplacement||MacroName|| ' Line=' ||SafeQuote||RebuildCmd||SafeQuote||EndsMacroReplacement
  8923. end
  8924. else
  8925. do
  8926. call DBG_IMPORT 'Calling filter for line #' ||WrapLineNumber
  8927. call DBGIND 1
  8928. Remove=''
  8929. call ExecRexxCmd WrapFilter
  8930. if Remove<> '' then
  8931. do
  8932. if abbrev(Remove, "EOF:")then
  8933. do
  8934. call DBG_IMPORT 'This Record and all following dropped ==> ' ||Remove
  8935. call DBGIND-1
  8936. leave
  8937. end
  8938. else
  8939. do
  8940. call DBG_IMPORT 'Line dropped ==> ' ||Remove
  8941. call DBGIND-1
  8942. iterate
  8943. end
  8944. end
  8945. call DBGIND-1
  8946. call PpwLineout ToInclude,WrapLine
  8947. end
  8948. end
  8949. return(WrapLineNumber)
  8950.  
  8951. IMPORTWR_36:
  8952. MultiLineImportInProgress='N'
  8953. signal I_ML_37
  8954.  
  8955. HandleMultiLineImport:
  8956. if OptionDebugOn='Y' then
  8957. call DBG_IMPORT 'Importing multi line record file'
  8958. mlDelimiter=GetImportValue('DELIMITER',         '=')
  8959. mlLineSep=GetImportValue('SEPARATOR',         ' ')
  8960. mlStripL=translate(GetImportValue('STRIP_LEADING', 'Y'))
  8961. mlLineCmtChar=GetImportValue('LINE_COMMENT_CHAR',LineComment)
  8962. if mlLineCmtChar='' then
  8963. mlLineCmtChar=' '
  8964. call GetImportValue_LineFilter
  8965. MultiLineFilter=GetImportValue('MULTILINE_FILTER', '')
  8966. drop mlFIndex?.
  8967. do FieldIndex=1 to NumberOfFields
  8968. parse value translate(FieldExtra.FieldIndex)with FieldName ',' FieldOptions
  8969. if FieldName='' then
  8970. CryAndDie('No {field name} supplied for field #' ||FieldIndex)
  8971. call _valueS 'mlFIndex?.mli?' ||c2x(FieldName),FieldOptions
  8972. MlFieldName.FieldIndex=FieldName
  8973. end
  8974. MultiLineImportInProgress='Y'
  8975. LastMlStoredAs=''
  8976. ImportFileLine=0
  8977. LastCommentLine=''
  8978. call DBG_IMPORT 'Reading "' || FullImportName || '"...'
  8979. call _MlNewRecord
  8980. do while lines(FullImportName)<>0
  8981. MultiLine=strip(ImportOneLine('N', 'N'))
  8982. ImportFileLine=ImportFileLine+1
  8983. if MultiLine='' then
  8984. do
  8985. if MlFieldCnt<>0 then
  8986. do
  8987. ca_Eof=_MlGenerateRecord()
  8988. call _MlNewRecord
  8989. if ca_Eof then
  8990. leave
  8991. end
  8992. end
  8993. else
  8994. do
  8995. if left(MultiLine,1)=LineComment then
  8996. iterate
  8997. if MultiLineFilter<> '' then
  8998. do
  8999. call DBG_IMPORT 'Calling specified multi line filter'
  9000. call DBGIND 1
  9001. Remove=''
  9002. call ExecRexxCmd MultiLineFilter
  9003. if Remove<> '' then
  9004. do
  9005. if abbrev(Remove, "EOF:")then
  9006. do
  9007. call DBG_IMPORT 'Line #' || ImportFileLine || ' to EOF dropped ==> ' ||Remove
  9008. call DBGIND-1
  9009. leave
  9010. end
  9011. else
  9012. do
  9013. call DBG_IMPORT 'Line #' || ImportFileLine || ' dropped ==> ' ||Remove
  9014. call DBGIND-1
  9015. iterate
  9016. end
  9017. end
  9018. call DBGIND-1
  9019. end
  9020. parse var MultiLine MultiVar (mlDelimiter) MultiValue
  9021. if mlStripL='Y' then
  9022. MultiValue=strip(MultiValue, 'L')
  9023. else
  9024. do
  9025. if left(MultiValue,1)=' ' then
  9026. MultiValue=substr(MultiValue,2)
  9027. end
  9028. if MultiVar<> '' then
  9029. call _MlRememberFieldsValue strip(MultiVar, 'T'),MultiValue
  9030. else
  9031. do
  9032. if LastMlStoredAs='' then
  9033. CryAndDie('Line #' || ImportFileLine || ': No field to continue!')
  9034. mlNew=_valueG(LastMlStoredAs)||mlLineSep||MultiValue
  9035. call _valueS LastMlStoredAs,mlNew
  9036. end
  9037. end
  9038. end
  9039. call FileClose FullImportName
  9040. if MlFieldCnt<>0 then
  9041. call _MlGenerateRecord
  9042. MultiLineImportInProgress='N'
  9043. return(ImportFileLine)
  9044.  
  9045. _MlNewRecord:
  9046. call _NewRecord
  9047. MlFieldCnt=0
  9048. drop mlFValues?.
  9049. return
  9050.  
  9051. _MlRememberFieldsValue:
  9052. parse arg FieldN,FieldV
  9053. UFieldN=translate(FieldN)
  9054. StoredAs='mlFIndex?.mli?' ||c2x(UFieldN)
  9055. if symbol(StoredAs)<> 'VAR' then
  9056. CryAndDie('Line #' || ImportFileLine || ' - Unknown field name of "' || FieldN || '"')
  9057. FieldOptions=_valueG(StoredAs)
  9058. StoredAs='mlFValues?.mlv?' ||c2x(UFieldN)
  9059. LastMlStoredAs=StoredAs
  9060. if symbol(StoredAs)='VAR' then
  9061. CryAndDie('Line #' || ImportFileLine || ' - Field name of "' || FieldN || '" specified more than once')
  9062. if FieldV='' then
  9063. do
  9064. if pos('NONBLANK',FieldOptions)<>0 then
  9065. CryAndDie('Line #' || ImportFileLine || ' - Field "' || FieldN || '" contains a blank value')
  9066. end
  9067. if pos('NOASIS',FieldOptions)=0 then
  9068. call _valueS StoredAs,AsIs(FieldV)
  9069. else
  9070. call _valueS StoredAs,FieldV
  9071. MlFieldCnt=MlFieldCnt+1
  9072. return
  9073.  
  9074. _MlGenerateRecord:
  9075. do FieldIndex=1 to NumberOfFields
  9076. FieldName=MlFieldName.FieldIndex
  9077. StoredAs='mlFValues?.mlv?' ||c2x(FieldName)
  9078. if symbol(StoredAs)='VAR' then
  9079. call _AddField2Record _valueG(StoredAs)
  9080. else
  9081. do
  9082. FieldOptions=_valueG('mlFIndex?.mli?' ||c2x(FieldName))
  9083. if pos('REQUIRED',FieldOptions)<>0 then
  9084. CryAndDie('Line #' || ImportFileLine || ' - Required field "' || FieldName || '" was not specified')
  9085. call _AddField2Record ''
  9086. end
  9087. end
  9088. cb_Eof=GenerateRecordFromFields()
  9089. LastMlStoredAs=''
  9090. return(cb_Eof)
  9091.  
  9092. GetMlField:call TRACE "OFF"
  9093. if MultiLineImportInProgress<> 'Y' then
  9094. CryAndDie('GetMlField(): Multi line import is not in progress!')
  9095. FieldName=translate(arg(1))
  9096. StoredAs='mlFValues?.mlv?' ||c2x(FieldName)
  9097. if symbol(StoredAs)='VAR' then
  9098. return(_valueG(StoredAs))
  9099. CryAndDie('Line #' || ImportFileLine || ' - GetMlField(): Field "' || FieldName || '" is unknown!')
  9100.  
  9101. I_ML_37:
  9102. call LoopInit
  9103. signal LOOP_38
  9104.  
  9105. LoopInit:
  9106. InLoop='N'
  9107. LoopCnt=0
  9108. LoopLine=1
  9109. LoopID=0
  9110. LoopContinueIndex=0
  9111. LoopFirstLineNumber=-1
  9112. LoopAtEndLineNumber=-1
  9113. LoopIfNesting=-1
  9114. LoopLinesFromFile=-1
  9115. return
  9116.  
  9117. LoopPush:
  9118. SavedAs=arg(1)
  9119. SFI_InLoop.SavedAs=InLoop
  9120. SFI_LoopCnt.SavedAs=LoopCnt
  9121. SFI_LoopLine.SavedAs=LoopLine
  9122. SFI_LoopLinesFromFile.SavedAs=LoopLinesFromFile
  9123. SFI_LoopFirstLineNumber.SavedAs=LoopFirstLineNumber
  9124. SFI_LoopAtEndLineNumber.SavedAs=LoopAtEndLineNumber
  9125. SFI_LoopIfNesting.SavedAs=LoopIfNesting
  9126. SFI_LoopContIndex.SavedAs=LoopContinueIndex
  9127. do SaveIndex=1 to LoopCnt
  9128. SavedPpwLoop.SaveIndex.SavedAs=PpwLoop.SaveIndex
  9129. end
  9130. call LoopInit
  9131. return
  9132.  
  9133. LoopPop:
  9134. SavedAs=arg(1)
  9135. InLoop=SFI_InLoop.SavedAs
  9136. LoopCnt=SFI_LoopCnt.SavedAs
  9137. LoopLine=SFI_LoopLine.SavedAs
  9138. LoopLinesFromFile=SFI_LoopLinesFromFile.SavedAs
  9139. LoopFirstLineNumber=SFI_LoopFirstLineNumber.SavedAs
  9140. LoopAtEndLineNumber=SFI_LoopAtEndLineNumber.SavedAs
  9141. LoopIfNesting=SFI_LoopIfNesting.SavedAs
  9142. LoopContinueIndex=SFI_LoopContIndex.SavedAs
  9143. do SaveIndex=1 to LoopCnt
  9144. PpwLoop.SaveIndex=SavedPpwLoop.SaveIndex.SavedAs
  9145. end
  9146. return
  9147.  
  9148. ProcessLoopStart:
  9149. if InLoop='Y' then
  9150. CryAndDie("Can't nest loops (within one source file)")
  9151. InLoop='Y'
  9152. LoopID=LoopID+1
  9153. LoopCnt=0
  9154. LoopLine=1
  9155. cc_A=arg(1)
  9156. if cc_A="" then
  9157. cc_LoopType=''
  9158. else
  9159. do
  9160. cc_A=PerformReplacementsInCmdsParameters(cc_A)
  9161. parse var cc_A cc_LoopType cc_A
  9162. cc_LoopType=translate(cc_LoopType)
  9163. select
  9164. when cc_LoopType='FOR' then
  9165. do
  9166. parse value translate(cc_A)with cc_Var "=" cc_Strt " TO " cc_End
  9167. if cc_End="" then
  9168. CryAndDie("Incorrect FOR spec ==> " ||cc_A)
  9169. cc_Var=strip(cc_Var)
  9170. cc_Strt=strip(cc_Strt)
  9171. call _valueS cc_Var,cc_Strt
  9172. end
  9173. when cc_LoopType='SET' then
  9174. do
  9175. if translate(word(cc_A,1))<> 'COUNTER' then
  9176. cc_Var='SetLoopVar' ||LoopID
  9177. else
  9178. do
  9179. cc_Var=word(cc_A,2)
  9180. cc_A=subword(cc_A,3)
  9181. end
  9182. cc_SetCnt=0
  9183. cc_InitSet=''
  9184. cc_LoopSetCnt=0
  9185. cc_IndexList=''
  9186. cc_NewArray='SETITEMS' ||LoopID
  9187. do while cc_A<> ''
  9188. cc_SetName=GetQuotedText(cc_A, "cc_A")
  9189. if pos('=',cc_SetName)<>0 then
  9190. do
  9191. parse var cc_SetName cc_SetName '=' cc_Rest
  9192. parse var cc_Rest '{' cc_Del '}' cc_2Split
  9193. if cc_2Split=='' then
  9194. do
  9195. cc_Del=' '
  9196. cc_2Split=cc_Rest
  9197. end
  9198. call ArraySplit cc_SetName,cc_2Split,cc_Del
  9199. end
  9200. cc_SetVAR="SET_" ||cc_SetName
  9201. cc_SetStem=cc_SetName|| '.'
  9202. cc_SetCnt=cc_SetCnt+1
  9203. cc_IndexVar='cc_' ||cc_SetCnt
  9204. cc_InitSet=cc_InitSet|| 'do ' || cc_IndexVar || ' = 1 to ' || cc_SetStem || '0; '
  9205. if cc_SetCnt<>1 then
  9206. cc_IndexList=cc_IndexList|| ' || '
  9207. cc_IndexList=cc_IndexList|| '"' || cc_SetVar || '=' || cc_SetStem || '" || ' || cc_IndexVar || ' || ";"'
  9208. end
  9209. cc_InitSet=cc_InitSet|| 'cc_LoopSetCnt=cc_LoopSetCnt+1; '
  9210. cc_InitSet=cc_InitSet||cc_NewArray|| '.cc_LoopSetCnt=strip(' || cc_IndexList || '); '
  9211. do cc_I=1 to cc_SetCnt
  9212. cc_InitSet=cc_InitSet|| 'end; '
  9213. end
  9214. call ExecRexxCmd cc_InitSet
  9215. call _valueS cc_NewArray|| '.0',cc_LoopSetCnt
  9216. cc_End=cc_LoopSetCnt
  9217. call _valueS cc_Var,1
  9218. end
  9219. otherwise
  9220. CryAndDie('Invalid loop specification (command "' || cc_LoopType || '" unknown)')
  9221. end
  9222. end
  9223. if cc_LoopType='FOR' | cc_LoopType = 'SET' then
  9224. do
  9225. call DBG 'Adding FOR/SET loop lines'
  9226. LoopCnt=LoopCnt+1
  9227. PpwLoop.LoopCnt='#if [' || cc_Var || ' > ' || cc_End || ']'
  9228. LoopCnt=LoopCnt+1
  9229. PpwLoop.LoopCnt='#break'
  9230. LoopCnt=LoopCnt+1
  9231. PpwLoop.LoopCnt='#endif'
  9232. if cc_LoopType='SET' then
  9233. do
  9234. call DBG 'Adding SET loop lines for ' || cc_LoopSetCnt || ' loops'
  9235. LoopCnt=LoopCnt+1
  9236. PpwLoop.LoopCnt='#evaluate ^^ ^<' || '??' || cc_NewArray || '.' || cc_Var || '>^'
  9237. end
  9238. end
  9239. LoopFirstLineNumber=IncludeLineNumber
  9240. LoopIfNesting=IfNesting
  9241. if IncludeMemBufferNextLine=='' then
  9242. LoopLinesFromFile=1
  9243. else
  9244. LoopLinesFromFile=0
  9245. LengthEndCmd=length(CmdHashLoopE)
  9246. FoundEnd='N'
  9247. do forever
  9248. if LoopLinesFromFile=1 then
  9249. do
  9250. if IncludeFileLines()=0 then
  9251. leave
  9252. LoopCnt=LoopCnt+1
  9253. PpwLoop.LoopCnt=IncludeFileLineIn()
  9254. InputLines=InputLines+1
  9255. end
  9256. else
  9257. do
  9258. if IncludeMemBufferNextLine=='' then
  9259. leave
  9260. LoopCnt=LoopCnt+1
  9261. parse var IncludeMemBufferNextLine PpwLoop.LoopCnt (MarksNewLine) IncludeMemBufferNextLine
  9262. end
  9263. MaybeEndCmd=left(strip(PpwLoop.LoopCnt, 'L'),LengthEndCmd)
  9264. if MaybeEndCmd=CmdHashLoopE then
  9265. do
  9266. FoundEnd='Y'
  9267. LoopCnt=LoopCnt-1
  9268. if LoopCnt=0 then
  9269. CryAndDie("No commands found in body of loop!")
  9270. leave
  9271. end
  9272. end
  9273. LoopAtEndLineNumber=IncludeLineNumber
  9274. if FoundEnd='N' then
  9275. do
  9276. if LoopLinesFromFile then
  9277. eLoop='EOF'
  9278. else
  9279. eLoop='end of macro'
  9280. CryAndDie('Could not find "' || CmdHashLoopE || '" before ' || eLoop, 'Searched ' || LoopCnt || ' line(s)')
  9281. end
  9282. if cc_LoopType='FOR' | cc_LoopType = 'SET' then
  9283. do
  9284. call DBG 'Adding FOR/SET loop lines'
  9285. LoopCnt=LoopCnt+1
  9286. PpwLoop.LoopCnt='#RexxVar ^' || cc_Var || '^ + 1'
  9287. LoopContinueIndex=LoopCnt
  9288. end
  9289. else
  9290. do
  9291. LoopContinueIndex=1
  9292. end
  9293. call DBG 'Loop is ' || LoopCnt || ' line(s) long and ends on line ' ||AddCommasToDecimalNumber(IncludeLineNumber)
  9294. return(0)
  9295.  
  9296. GetLoopLineIntoFileLine:
  9297. FileLine=PpwLoop.LoopLine
  9298. if LoopLinesFromFile then
  9299. IncludeLineNumber=LoopFirstLineNumber+LoopLine
  9300. LoopLine=LoopLine+1
  9301. if LoopLine>LoopCnt then
  9302. LoopLine=1
  9303. return(FileLine)
  9304.  
  9305. ProcessLoopBreak:
  9306. call DBG 'Exiting loop'
  9307. InLoop='N'
  9308. IfNesting=LoopIfNesting
  9309. IncludeLineNumber=LoopAtEndLineNumber
  9310. return(0)
  9311.  
  9312. ProcessLoopContinue:
  9313. LoopLine=LoopContinueIndex
  9314. call DBG 'Back to "start" of loop - Loop Line #' ||LoopContinueIndex
  9315. IfNesting=LoopIfNesting
  9316. return(0)
  9317.  
  9318. LOOP_38:
  9319. _RestrictKeyMinimum=CharsLUN
  9320. _giCounter=0
  9321. signal GetId_39
  9322.  
  9323. GetIdPrepare:call TRACE "OFF"
  9324. giHandle=arg(1)
  9325. giUniqueId=translate(arg(2))
  9326. interpret 'drop GI?'  || giHandle || '.'
  9327. call _valueS 'GI?'  || giHandle || '.GI?UID',giUniqueId
  9328. return
  9329.  
  9330. SetId:call TRACE "OFF"
  9331. giHandle=arg(1)
  9332. giName=arg(2)
  9333. giId=arg(3)
  9334. giSaveAsPrefix='GI?'  || giHandle || '.GI?'
  9335. if giName\=='' then
  9336. do
  9337. if _valueG(giSaveAsPrefix|| 'UID') = 'Y' then
  9338. CryAndDie("You have asked for UNIQUE ID's to be generated. Don't use SetId()!!!")
  9339. giKeySavedAs=giSaveAsPrefix|| 'KEY_' ||c2x(giName)
  9340. if symbol(giKeySavedAs)='VAR' then
  9341. CryAndDie('SetId(): The KEY of "' || giName || '" has already been used')
  9342. call _valueS giKeySavedAs,giId
  9343. end
  9344. IdSavedAs=giSaveAsPrefix|| 'ID_' ||c2x(giId)
  9345. if symbol(IdSavedAs)='VAR' then
  9346. CryAndDie('SetId(): The ID of "' || giId || '" has already been used')
  9347. call _valueS IdSavedAs, ''
  9348. return('')
  9349.  
  9350. GetId:call TRACE "OFF"
  9351. giHandle=arg(1)
  9352. giType=translate(arg(2))
  9353. giName=arg(3)
  9354. giSaveAsPrefix='GI?'  || giHandle || '.GI?'
  9355. giUniqueId=_valueG(giSaveAsPrefix|| 'UID')
  9356. if giUniqueId<> 'Y' then
  9357. do
  9358. giKeySavedAs=giSaveAsPrefix|| 'KEY_' ||c2x(giName)
  9359. if symbol(giKeySavedAs)='VAR' then
  9360. return(_valueG(giKeySavedAs))
  9361. end
  9362. GiMaxLength=''
  9363. select
  9364. when giType="MAXCHARS" then
  9365. do
  9366. CanBeDuplicated='Y'
  9367. GiMaxLength=arg(5)
  9368. if GiMaxLength='' then
  9369. GiMaxLength=8
  9370. giId=_Id_2_(giName,arg(4))
  9371. if length(giId)>GiMaxLength then
  9372. giId=left(giId,GiMaxLength)
  9373. end
  9374. when giType="C2X" then
  9375. do
  9376. CanBeDuplicated='N'
  9377. giId=_Id_c2x(giName,arg(4))
  9378. end
  9379. when giType="2_" then
  9380. do
  9381. CanBeDuplicated='Y'
  9382. giId=_Id_2_(giName,arg(4))
  9383. end
  9384. otherwise
  9385. CryAndDie('GetId(): Invalid type of "' || giType || '" specified')
  9386. end
  9387. if CanBeDuplicated='Y' then
  9388. do
  9389. IdSavedAs=giSaveAsPrefix|| 'ID_' ||c2x(giId)
  9390. if symbol(IdSavedAs)='VAR' then
  9391. do
  9392. GiIndex=1
  9393. do forever
  9394. if GiMaxLength='' then
  9395. giTryId=giId||GiIndex
  9396. else
  9397. do
  9398. giChopLength=GiMaxLength-length(GiIndex)
  9399. if length(giId)>giChopLength then
  9400. giTryId=left(giId,giChopLength)||GiIndex
  9401. else
  9402. giTryId=giId||GiIndex
  9403. end
  9404. GiIndex=GiIndex+1
  9405. IdSavedAs=giSaveAsPrefix|| 'ID_' ||c2x(giTryId)
  9406. if symbol(IdSavedAs)<> 'VAR' then
  9407. do
  9408. giId=giTryId
  9409. leave
  9410. end
  9411. end
  9412. end
  9413. call _valueS IdSavedAs, ''
  9414. end
  9415. if giUniqueId<> 'Y' then
  9416. call _valueS giKeySavedAs,giId
  9417. return(giId)
  9418.  
  9419. _Id_2_:
  9420. parse arg KeyR,RestrictTo
  9421. RestrictTo=_RestrictKeyMinimum||RestrictTo
  9422. KeyL=''
  9423. InvPos=verify(KeyR,RestrictTo)
  9424. do while InvPos<>0
  9425. KeyL=KeyL||left(KeyR,InvPos-1)|| '_'
  9426. KeyR=substr(KeyR,InvPos+1)
  9427. InvPos=verify(KeyR,RestrictTo)
  9428. end
  9429. KeyL=strip(KeyL||KeyR,, '_')
  9430. do until BeforeCount=ReplaceCount
  9431. BeforeCount=ReplaceCount
  9432. KeyL=ReplaceString(KeyL, "__", "_")
  9433. end
  9434. if KeyL='' then
  9435. return('_')
  9436. else
  9437. return(KeyL)
  9438.  
  9439. _Id_c2x:
  9440. parse arg KeyR,RestrictTo
  9441. RestrictTo=_RestrictKeyMinimum||RestrictTo
  9442. KeyL=''
  9443. InvPos=verify(KeyR,RestrictTo)
  9444. do while InvPos<>0
  9445. KeyL=KeyL||left(KeyR,InvPos-1)|| 'x' ||c2x(substr(KeyR,InvPos,1))
  9446. KeyR=substr(KeyR,InvPos+1)
  9447. InvPos=verify(KeyR,RestrictTo)
  9448. end
  9449. return(KeyL||KeyR)
  9450.  
  9451. GetId_39:
  9452. call GetIdPrepare "IMAGEHW"
  9453. Add2Stem=''
  9454. _ValCharsHttp=UpperCase||LowerCase||DecimalDigits|| "./?%+:~_-,"
  9455. _ValCharsFtp=_ValCharsHttp
  9456. signal Evaluate_40
  9457.  
  9458. _ScaleSide:
  9459. parse arg SideBefore,SideScale
  9460. PercentPos=pos('%',SideScale)
  9461. if PercentPos=0 then
  9462. return(SideScale)
  9463. else
  9464. return((SideBefore*left(SideScale,PercentPos-1))%100)
  9465.  
  9466. _GetSizeTags:
  9467. if OptionDebugOn='Y' then
  9468. do
  9469. call DBGIND 1
  9470. call DBG_EVALUATE 'Real size = ' || ImageWidth || 'x' ||ImageHeight
  9471. call DBGIND-1
  9472. end
  9473. ImgScaleW=ImageScaleW
  9474. ImgScaleH=ImageScaleH
  9475. if ImgScaleW='?' | ImgScaleH = '?' then
  9476. do
  9477. if ImgScaleW='?' then
  9478. do
  9479. NewHeight=_ScaleSide(ImageHeight,ImgScaleH)
  9480. ImgScaleW=(NewHeight*100)%ImageHeight|| '%'
  9481. NewWidth=_ScaleSide(ImageWidth,ImgScaleW)
  9482. end
  9483. else
  9484. do
  9485. NewWidth=_ScaleSide(ImageWidth,ImgScaleW)
  9486. ImgScaleH=(NewWidth*100)%ImageWidth|| '%'
  9487. NewHeight=_ScaleSide(ImageHeight,ImgScaleH)
  9488. end
  9489. end
  9490. else
  9491. do
  9492. NewWidth=_ScaleSide(ImageWidth,ImgScaleW)
  9493. NewHeight=_ScaleSide(ImageHeight,ImgScaleH)
  9494. end
  9495. if ImageOldFormat='Y' then
  9496. ImageReturn='WIDTH='  || NewWidth || ' HEIGHT=' ||NewHeight
  9497. else
  9498. ImageReturn='WIDTH="' || NewWidth || '" HEIGHT="' || NewHeight || '"'
  9499. if ImageCacheKey<> '' then
  9500. call value ImageCacheKey,ImageReturn
  9501. return(ImageReturn)
  9502.  
  9503. CheckFileInfo:
  9504. parse arg iFile,iType,iId,iExpected
  9505. if iId==iExpected then
  9506. return
  9507. call FileClose iFile
  9508. Line1='"' || iFile || '" does not appear to be a "' || iType || '" file.'
  9509. Line2='It is ' || FileQuerySize(iFile) || ' bytes long. '
  9510. if iId=='' then
  9511. Line2=Line2|| 'This appears to be too short.'
  9512. else
  9513. Line2=Line2|| 'The ID is "x' || c2x(iId) || '" (expected "x' || c2x(iExpected) || '")'
  9514. CryAndDie(Line1,Line2)
  9515.  
  9516. _GetGifSize:
  9517. GifFormatId=left(charin(ImageFile,1,6),3)
  9518. call CheckFileInfo ImageFile, 'GIF', GifFormatId, 'GIF'
  9519. WidthLow=charin(ImageFile,,1)
  9520. WidthHigh=charin(ImageFile,,1)
  9521. ImageWidth=c2d(WidthHigh||WidthLow)
  9522. HeightLow=charin(ImageFile,,1)
  9523. HeightHigh=charin(ImageFile,,1)
  9524. ImageHeight=c2d(HeightHigh||HeightLow)
  9525. call FileClose ImageFile
  9526. return(_GetSizeTags())
  9527.  
  9528. _GetPngSize:
  9529. PngFormatId=charin(ImageFile,1,8)
  9530. call CheckFileInfo ImageFile, 'PNG', PngFormatId, '89'x || 'PNG' || '0D 0A 1A 0A'x
  9531. PngFormatId=charin(ImageFile,,4)
  9532. PngFormatId=charin(ImageFile,,4)
  9533. call CheckFileInfo ImageFile, 'PNG', PngFormatId, 'IHDR'
  9534. ImageWidth=c2d(charin(ImageFile,,4))
  9535. ImageHeight=c2d(charin(ImageFile,,4))
  9536. call FileClose ImageFile
  9537. return(_GetSizeTags())
  9538.  
  9539. _GetJpgSize:
  9540. FileType=c2x(Charin(ImageFile,1,2))
  9541. call CheckFileInfo ImageFile, 'JPEG', FileType, "FFD8"
  9542. NxtSeg=3
  9543. ImageHeight="IMAGEHEIGHT"
  9544. Type=''
  9545. do while(Type<> "D9") & (NxtSeg <> -1) & (Imageheight = "IMAGEHEIGHT")
  9546. NxtSeg=_ReadJpgSegment(NxtSeg)
  9547. end
  9548. call FileClose ImageFile
  9549. return(_GetSizeTags())
  9550.  
  9551. _ReadJpgSegment:
  9552. SegPos=arg(1)
  9553. Marker=c2x(charIn(ImageFile,SegPos))
  9554. if Marker<> "FF" then
  9555. return(-1)
  9556. Type=c2x(charIn(ImageFile))
  9557. Res=SegPos+2
  9558. select
  9559. when Type="01" | Type >= "D0" & Type <= "D9" then
  9560. SegmentLength=0
  9561. otherwise
  9562. SegmentLength=c2d(CharIn(ImageFile,,2))
  9563. End
  9564. Res=Res+SegmentLength
  9565. if Type="C0" | Type = "C2" then
  9566. do
  9567. Imagebps=c2d(CharIn(ImageFile))
  9568. ImageHeight=c2d(CharIn(ImageFile,,2))
  9569. ImageWidth=c2d(CharIn(ImageFile,,2))
  9570. end
  9571. return(Res)
  9572.  
  9573. GetImageHeightWidth:call TRACE "OFF"
  9574. parse arg ImageFile,ImageScaleW,ImageScaleH,ImageOldFormat,ImageNoCache
  9575. if ImageScaleW='' then
  9576. ImageScaleW='100%'
  9577. if ImageScaleH='' then
  9578. ImageScaleH='?'
  9579. if OptionDebugOn='Y' then
  9580. call DBG_EVALUATE 'GetImageHeightWidth("' || ImageFile || '", "' || ImageScaleW || '", "' || ImageScaleH || '")'
  9581. if ImageNoCache='Y' then
  9582. ImageCacheKey=''
  9583. else
  9584. do
  9585. ImageCacheKey='I_' || ImageFile || '_w' || c2x(ImageScaleW) || '_h' || c2x(ImageScaleH) || '_f' ||ImageOldFormat
  9586. ImageCacheKey=GetId("IMAGEHW", 'MAXCHARS',ImageCacheKey,,200)
  9587. if symbol(ImageCacheKey)='VAR' then
  9588. do
  9589. if OptionDebugOn='N' then
  9590. return(value(ImageCacheKey))
  9591. else
  9592. do
  9593. SizeString=value(ImageCacheKey)
  9594. call DBG_EVALUATE 'Returning "' || SizeString || '" (from cache)'
  9595. return(SizeString)
  9596. end
  9597. end
  9598. end
  9599. DotPos=lastpos('.',ImageFile)
  9600. if DotPos=0 then
  9601. CryAndDie('Unknown graphic file type on "' || ImageFile || '".')
  9602. ImageExtn=translate(substr(ImageFile,DotPos+1))
  9603. if QueryExists(ImageFile)='' then
  9604. do
  9605. CryAndDie('Graphic file "' || ImageFile || '" does not exist.')
  9606. return('')
  9607. end
  9608. call DBGIND 1
  9609. select
  9610. when ImageExtn='GIF' then
  9611. SizeString=_GetGifSize()
  9612. when ImageExtn='PNG' then
  9613. SizeString=_GetPngSize()
  9614. when ImageExtn='JPG' | ImageExtn = 'JPEG' then
  9615. SizeString=_GetJpgSize()
  9616. otherwise
  9617. CryAndDie('Currently only support "GIF", "JPEG" & "PNG" files.')
  9618. end
  9619. if OptionDebugOn='Y' then
  9620. call DBG_EVALUATE 'Returning "' || SizeString || '"'
  9621. call DBGIND-1
  9622. return(SizeString)
  9623.  
  9624. ToLowerCase:call TRACE "OFF"
  9625. if OptionDebugOn='Y' then
  9626. call DBG_EVALUATE 'ToLowerCase()'
  9627. return(translate(arg(1),LowerCase,UpperCase))
  9628.  
  9629. EnsureFileHasCorrectCase:call TRACE "OFF"
  9630. cFileI=arg(1)
  9631. if OptionTranslateFileNames='N' then
  9632. return(cFileI)
  9633. if OptionTranslateFileNames='UPPER' then
  9634. cFileO=translate(cFileI)
  9635. else
  9636. cFileO=ToLowerCase(cFileI)
  9637. if OptionDebugOn='Y' then
  9638. do
  9639. if cFileI<>cFileO then
  9640. do
  9641. call DBG_EVALUATE 'A files case was adjusted'
  9642. call DBGIND 1
  9643. call DBG_EVALUATE 'FROM: "' || cFileI || '"'
  9644. call DBG_EVALUATE '  TO: "' || cFileO || '"'
  9645. call DBGIND-1
  9646. end
  9647. end
  9648. return(cFileO)
  9649.  
  9650. GetAmPmTime:call TRACE "OFF"
  9651. if OptionDebugOn='Y' then
  9652. call DBG_EVALUATE 'GetAmPmTime()'
  9653. return(GetAmPmTimeFromHhMmSs(time('N'),arg(1),arg(2)))
  9654.  
  9655. GetAmPmTimeFromHhMmSs:call TRACE "OFF"
  9656. parse arg cd_PT,cd_AddSS,cd_AmPm
  9657. if cd_AmPm='' then
  9658. cd_AmPm='am;pm'
  9659. parse var cd_AmPm cd_AmTxt ';' cd_PmTxt
  9660. if pos(':',cd_PT)=0 then
  9661. parse var cd_PT cd_HH 3 cd_MM 5 cd_SS
  9662. else
  9663. parse var cd_PT cd_HH ':' cd_MM ':' cd_SS
  9664. if cd_HH>=12 then
  9665. cd_AmPm=cd_PmTxt
  9666. else
  9667. cd_AmPm=cd_AmTxt
  9668. if cd_HH>12 then
  9669. cd_HH=cd_HH-12
  9670. cd_HH=cd_HH+0
  9671. cd_MM=right(cd_MM,2, '0')
  9672. if cd_AddSS='' then
  9673. do
  9674. if cd_SS='' then
  9675. cd_AddSS='N'
  9676. else
  9677. cd_AddSS='Y'
  9678. end
  9679. if cd_AddSS='N' then
  9680. cd_SS=''
  9681. else
  9682. cd_SS=':' || right(cd_SS, 2, '0')
  9683. cd_T=cd_HH|| ':' ||cd_MM||cd_SS||cd_AmPm
  9684. if OptionDebugOn='Y' then
  9685. call DBG_EVALUATE 'GetAmPmTimeFromHhMmSs(' || cd_PT || ') = ' ||cd_T
  9686. return(cd_T)
  9687.  
  9688. AddCommasToDecimalNumber:procedure;call TRACE "OFF"
  9689. NoComma=strip(arg(1))
  9690. if pos(',',NoComma)<>0 then
  9691. return(NoComma)
  9692. DotPos=pos('.',NoComma)
  9693. if DotPos=0 then
  9694. AfterDecimal=''
  9695. else
  9696. do
  9697. if DotPos=1 then
  9698. return("0" ||NoComma)
  9699. AfterDecimal=substr(NoComma,DotPos+1)
  9700. NoComma=left(NoComma,DotPos-1)
  9701. end
  9702. NoComma=reverse(NoComma)
  9703. ResultWithCommas=""
  9704. do while length(NoComma)>3
  9705. ResultWithCommas=ResultWithCommas||left(NoComma,3)|| ','
  9706. NoComma=substr(NoComma,4)
  9707. end
  9708. ResultWithCommas=ResultWithCommas||NoComma
  9709. ResultWithCommas=reverse(ResultWithCommas)
  9710. if AfterDecimal<> '' then
  9711. ResultWithCommas=ResultWithCommas|| '.' ||AfterDecimal
  9712. return(ResultWithCommas)
  9713.  
  9714. PadString:procedure;call TRACE "OFF"
  9715. parse arg TheString,TheMaxSize,PadType
  9716. StringSize=length(TheString)
  9717. if StringSize>=TheMaxSize then
  9718. return(TheString)
  9719. SpacesRequired=TheMaxSize-StringSize
  9720. if PadType='R' then
  9721. return(copies(' ',SpacesRequired)||TheString)
  9722. else
  9723. do
  9724. if PadType<> 'C' then
  9725. return(TheString||copies(' ',SpacesRequired))
  9726. else
  9727. do
  9728. SpacesOnLeft=SpacesRequired%2
  9729. return(copies(' ', SpacesOnLeft) || TheString || copies(' ',SpacesRequired-SpacesOnLeft))
  9730. end
  9731. end
  9732.  
  9733. BreakAt:call TRACE "OFF"
  9734. if OptionDebugOn='Y' then
  9735. call DBG_EVALUATE 'BreakAt()'
  9736. parse arg baMaxSize,baString,baChars,baBreakWith
  9737. if baChars=='' then
  9738. baChars='./:#'
  9739. if baBreakWith='' then
  9740. baBreakWith='<BR>'
  9741. baPos=pos('-',baMaxSize)
  9742. if baPos=0 then
  9743. baMinSize=baMaxSize%3
  9744. else
  9745. parse var baMaxSize baMinSize'-'baMaxSize
  9746. baReturn=''
  9747. do while length(baString)>baMaxSize
  9748. baLeftBit=left(baString,baMaxSize)
  9749. baString=substr(baString,baMaxSize+1)
  9750. baBestPos=0
  9751. baCharList=baChars
  9752. do while baCharList\==''
  9753. baThisChar=left(baCharList,1)
  9754. baCharList=substr(baCharList,2)
  9755. baThisPos=lastpos(baThisChar,baLeftBit)
  9756. if baThisPos>baBestPos then
  9757. do
  9758. baBestPos=baThisPos
  9759. end
  9760. end
  9761. if baReturn<> '' then
  9762. baReturn=baReturn||baBreakWith
  9763. if baBestPos=0 then
  9764. baReturn=baReturn||baLeftBit
  9765. else
  9766. do
  9767. baReturn=baReturn||left(baLeftBit,baBestPos)
  9768. baString=substr(baLeftBit,baBestPos+1)||baString
  9769. end
  9770. end
  9771. if baReturn<> '' then
  9772. return(baReturn||baBreakWith||baString)
  9773. else
  9774. return(baReturn||baString)
  9775.  
  9776. MacroGet:call TRACE "OFF"
  9777. if OptionDebugOn='Y' then
  9778. call DBG_EVALUATE 'MacroGet()'
  9779. GotValue=GetDefineContents(arg(1))
  9780. if OptionDebugOn='Y' then
  9781. call DBG_EVALUATE 'MacroGet("' || arg(1) || '") = ' ||DebugRightArrow||GotValue||DebugLeftArrow
  9782. return(GotValue)
  9783.  
  9784. Defined:call TRACE "OFF"
  9785. if OptionDebugOn='Y' then
  9786. call DBG_EVALUATE 'Defined()'
  9787. DefinedAnswer=MacroExists(arg(1))
  9788. if OptionDebugOn='Y' then
  9789. call DBG_EVALUATE 'Defined("' || arg(1) || '") = "' || DefinedAnswer || '"'
  9790. return(DefinedAnswer)
  9791.  
  9792. DataSave:call TRACE "OFF"
  9793. if OptionDebugOn='Y' then
  9794. call DBG_EVALUATE 'DataSave()'
  9795. parse arg StoreApp,StoreKey,StoreData
  9796. call _valueS "DSAP_" || c2x(StoreApp) || '.DSKY_' ||c2x(StoreKey),StoreData
  9797. return
  9798.  
  9799. DataGet:call TRACE "OFF"
  9800. if OptionDebugOn='Y' then
  9801. call DBG_EVALUATE 'DataGet()'
  9802. parse arg StoreApp,StoreKey,StoreDefault
  9803. DataVarName="DSAP_" || c2x(StoreApp) || '.DSKY_' ||c2x(StoreKey)
  9804. if symbol(DataVarName)<> 'VAR' then
  9805. return(StoreDefault)
  9806. else
  9807. return(_valueG(DataVarName))
  9808.  
  9809. UrlEncode:call TRACE "OFF"
  9810. if OptionDebugOn='Y' then
  9811. call DBG_EVALUATE 'UrlEncode()'
  9812. UrlIn=arg(1)
  9813. ueCmd=translate(arg(2))
  9814. SpaceToPlus='N'
  9815. select
  9816. when ueCmd='TO%' then
  9817. do
  9818. UrlBadChars=arg(3)
  9819. if UrlBadChars=='' then
  9820. UrlBadChars='+<>%"/?# '
  9821. end
  9822. when ueCmd='TO%EXCEPT' then
  9823. do
  9824. UrlOkChars=arg(3)
  9825. if UrlOkChars=='' then
  9826. UrlOkChars=CharsLUN|| '-._'
  9827. UrlBadChars=space(translate(xrange('00'x, 'FF'x), '',UrlOkChars),0)
  9828. if pos(' ',UrlOkChars)=0 then
  9829. UrlBadChars=UrlBadChars|| ' '
  9830. end
  9831. when ueCmd='ENCODEALL' then
  9832. UrlBadChars=xrange('00'x, 'FF'x)
  9833. otherwise
  9834. CryAndDie('Invalid UrlEncode() command of "' || ueCmd || '"')
  9835. end
  9836. UrlOut=''
  9837. UrlCount=length(UrlIn)
  9838. do CharPosn=1 to UrlCount
  9839. ThisChar=substr(UrlIn,CharPosn,1)
  9840. if pos(ThisChar,UrlBadChars)=0 then
  9841. UrlOut=UrlOut||ThisChar
  9842. else
  9843. do
  9844. if ThisChar==' ' & SpaceToPlus = 'Y' then
  9845. UrlOut=UrlOut|| '+'
  9846. else
  9847. UrlOut=UrlOut|| '%' || right(c2x(ThisChar), 2, '0')
  9848. end
  9849. end
  9850. return(UrlOut)
  9851.  
  9852. UrlDecode:call TRACE "OFF"
  9853. if OptionDebugOn='Y' then
  9854. call DBG_EVALUATE 'UrlDecode()'
  9855. parse arg UrlIn,udCmd
  9856. UrlPlusIsSpace='Y'
  9857. if udCmd<> '' then
  9858. do
  9859. if translate(udCmd)='LEAVE+' then
  9860. UrlPlusIsSpace='N'
  9861. else
  9862. CryAndDie('Invalid UrlDecode() command of "' || udCmd || '"')
  9863. end
  9864. UrlOut=''
  9865. CharPosn=1
  9866. UrlCount=length(UrlIn)
  9867. do while CharPosn<=UrlCount
  9868. ThisChar=substr(UrlIn,CharPosn,1)
  9869. CharPosn=CharPosn+1
  9870. if UrlPlusIsSpace<> 'N' & ThisChar = '+' then
  9871. ThisChar=' '
  9872. else
  9873. do
  9874. if ThisChar='%' then
  9875. do
  9876. ThisChar=substr(UrlIn,CharPosn,2)
  9877. CharPosn=CharPosn+2
  9878. if CharPosn>(UrlCount+1)then
  9879. CryAndDie('Invalid URL encoding of "%' || strip(ThisChar) || '" at end of URL')
  9880. ThisChar=x2c(ThisChar)
  9881. end
  9882. end
  9883. UrlOut=UrlOut||ThisChar
  9884. end
  9885. return(UrlOut)
  9886.  
  9887. GetFileTimeStamp:call TRACE "OFF"
  9888. parse arg ce_FN,ce_OnErr
  9889. ce_OnErr=translate(ce_OnErr)
  9890. if OptionDebugOn='Y' then
  9891. do
  9892. call DBG_EVALUATE 'GetFileTimeStamp("' || ce_FN || '")'
  9893. call DBGIND 1
  9894. end
  9895. ce_ST=FileInMemoryTimeStamp(ce_FN)
  9896. if ce_ST='' then
  9897. do
  9898. ce_FT=FileQueryDateTime(ce_FN)
  9899. if OptionDebugOn='Y' then
  9900. call DBG_EVALUATE 'Is time stamped : "' || ce_FT || '"'
  9901. if ce_FT='' then
  9902. do
  9903. ce_M='The file "' || ce_FN || '" does not exist.'
  9904. select
  9905. when ce_OnErr='Q' then
  9906. call DBG ce_M
  9907. when ce_OnErr='D' then
  9908. CryAndDie(ce_M)
  9909. otherwise
  9910. call OutputWarningToScreen 'TS00',ce_M
  9911. end
  9912. if OptionDebugOn='Y' then
  9913. call DBGIND-1
  9914. return(-1)
  9915. end
  9916. ce_FT=space(ce_FT)
  9917. parse var ce_FT Month'-'Day'-'Year' 'Hour':'Minute':'Second
  9918. if Year<80 then
  9919. Year=100+Year
  9920. Year=1900+Year
  9921. ce_ST=Year||Month||Day||Hour||Minute||Second
  9922. end
  9923. if OptionDebugOn='Y' then
  9924. do
  9925. call DBG_EVALUATE 'Returning       : "' || ce_ST || '"'
  9926. call DBGIND-1
  9927. end
  9928. return(ce_ST)
  9929.  
  9930. Warning:call TRACE "OFF"
  9931. call OutputWarningToScreen arg(1),arg(2)
  9932. return(0)
  9933.  
  9934. Error:call TRACE "OFF"
  9935. 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)
  9936. return(0)
  9937.  
  9938. Info:call TRACE "OFF"
  9939. call OutputInformationToScreen arg(1)
  9940. return(0)
  9941.  
  9942. DieIfIoErrorOccurred:call TRACE "OFF"
  9943. if OptionDebugOn='Y' then
  9944. call DBG_EVALUATE 'DieIfIoErrorOccurred("' || arg(1) || '")'
  9945. FileState=FileState(arg(1))
  9946. if FileState='READY' then
  9947. return
  9948. IoReason=FileDescription(arg(1))
  9949. if IoReason\=='NOTREADY:EOF' then
  9950. do
  9951. if RexWhich='REGINA' & IoReason = '' then
  9952. do
  9953. if OptionDebugOn='Y' then
  9954. do
  9955. call DBG 'DieIfIoErrorOccurred(): Bug first reported to Mark Hessling 3/10/99 for 0.08h beta'
  9956. call DBGIND 1
  9957. call DBG 'I/O failure on "' || arg(1) || '" (' || IoReason || ').'
  9958. call DBGIND-1
  9959. end
  9960. return
  9961. end
  9962. call CryAndDie 'I/O failure on "' || arg(1) || '" (' || IoReason || ').'
  9963. end
  9964. return
  9965.  
  9966. _ValidateIcLevel:
  9967. icLevel=arg(1)
  9968. if icLevel='' then
  9969. icLevel=IncludeLevel
  9970. if datatype(icLevel, 'WholeNumber')<>1 then
  9971. return(0)
  9972. if icLevel<1|icLevel>IncludeLevel then
  9973. return(0)
  9974. return(icLevel)
  9975.  
  9976. InputComponentLevel:call TRACE "OFF"
  9977. if OptionDebugOn='Y' then
  9978. call DBG_EVALUATE 'InputComponentLevel()'
  9979. icLevel=_ValidateIcLevel(arg(1))
  9980. if icLevel=0 then
  9981. return('')
  9982. else
  9983. return(IncludeFileName.icLevel)
  9984.  
  9985. InputComponentLineLevel:call TRACE "OFF"
  9986. if OptionDebugOn='Y' then
  9987. call DBG_EVALUATE 'InputComponentLineLevel()'
  9988. icLevel=_ValidateIcLevel(arg(1))
  9989. if icLevel=0 then
  9990. return('')
  9991. else
  9992. do
  9993. if icLevel=IncludeLevel then
  9994. return(IncludeLineNumber)
  9995. else
  9996. return(_IncludeLineNumber.icLevel)
  9997. end
  9998.  
  9999. GenerateFileName:call TRACE "OFF"
  10000. parse arg cf_SrcFile,cf_EdtMsk
  10001. if OptionDebugOn='Y' then
  10002. do
  10003. call DBG 'GenerateFileName(' || cf_SrcFile || ') using "' || cf_EdtMsk || '"'
  10004. call DBGIND 1
  10005. call DBG 'Current directory is "' || GetCurrentDirectory() || '"'
  10006. end
  10007. ShortName=_filespec('name',cf_SrcFile)
  10008. ShortNameNE=_filespec('withoutextn',ShortName)
  10009. InputPath=_filespec('location',cf_SrcFile)
  10010. cf_Full=ReplaceString(cf_EdtMsk, "?",InputPath)
  10011. cf_Full=ReplaceString(cf_Full, "*.*",ShortName)
  10012. cf_Full=ReplaceString(cf_Full, "*",ShortNameNE)
  10013. cf_Full=ReplaceString(cf_Full, "{$PATH}",InputPath)
  10014. cf_Full=ReplaceString(cf_Full, "{$BASE}",ShortNameNE)
  10015. cf_Full=ReplaceString(cf_Full, "{$SHORT}",ShortName)
  10016. cf_Full=ReplaceString(cf_Full, "{$FULL}",cf_SrcFile)
  10017. if pos('{$path}',cf_Full)<>0 then
  10018. do
  10019. call DBGIND 1
  10020. cf_Bd=BaseDir4CurrentInputFile
  10021. call DBG '{$path} found, base directory is "' || cf_Bd || '"'
  10022. call ValidateBaseDirUse cf_BD,cf_SrcFile
  10023. cf_SrcDir=_filespec('Location',cf_SrcFile)
  10024. cf_RelDir=substr(cf_SrcDir,length(cf_Bd)+1)
  10025. call DBG '{$path} = "' || cf_RelDir || '"'
  10026. cf_Full=ReplaceString(cf_Full, "{$path}",cf_RelDir)
  10027. call DBGIND-1
  10028. end
  10029. if OptionUncUsed='N' then
  10030. cf_Full=ReplaceString(cf_Full,RexDirChar||RexDirChar,RexDirChar)
  10031. cf_Full=EnsureFileHasCorrectCase(cf_Full)
  10032. if OptionDebugOn='Y' then
  10033. call DBG 'Generated Name = "' || cf_Full || '"'
  10034. if OptionDebugOn='Y' then
  10035. call DBGIND 1
  10036. call MakeDirectoryTree _filespec('drive', cf_Full) || _filespec('path',cf_Full)
  10037. if OptionDebugOn='Y' then
  10038. call DBGIND-2
  10039. return(cf_Full)
  10040.  
  10041. ProcessNext:call TRACE "OFF"
  10042. if OptionDebugOn='Y' then
  10043. call DBG_EVALUATE 'ProcessNext()'
  10044. if IncludeMemBufferNextLine=='' then
  10045. IncludeMemBufferNextLine=arg(1)
  10046. else
  10047. IncludeMemBufferNextLine=arg(1)||MarksNewLine||IncludeMemBufferNextLine
  10048. return
  10049.  
  10050. Tabs2Spaces:call TRACE "OFF"
  10051. if OptionDebugOn='Y' then
  10052. call DBG_EVALUATE 'Tabs2Spaces()'
  10053.  
  10054. ExpandTabs:
  10055. parse arg t2sRightBit,t2sTabWidth
  10056. if pos('09'x,t2sRightBit)=0 then
  10057. return(t2sRightBit)
  10058. t2sLeftBit=''
  10059. t2sLeftBitL=0
  10060. t2sTabPos=pos('09'x,t2sRightBit)
  10061. if t2sTabWidth='' then
  10062. t2sTabWidth=8
  10063. do while t2sTabPos<>0
  10064. t2sLeftBit=t2sLeftBit||left(t2sRightBit,t2sTabPos-1)
  10065. t2sLeftBitL=t2sLeftBitL+(t2sTabPos-1)
  10066. Spaces4Tab=t2sTabWidth-((t2sLeftBitL+1)//t2sTabWidth)
  10067. t2sLeftBit=t2sLeftBit||copies(' ',Spaces4Tab)
  10068. t2sLeftBitL=t2sLeftBitL+Spaces4Tab
  10069. t2sRightBit=substr(t2sRightBit,t2sTabPos+1)
  10070. t2sTabPos=pos('09'x,t2sRightBit)
  10071. end
  10072. return(t2sLeftBit||t2sRightBit)
  10073.  
  10074. RexxVarDefined:call TRACE "OFF"
  10075. if OptionDebugOn='Y' then
  10076. call DBG_EVALUATE 'RexxVarDefined()'
  10077. vsValue=symbol(arg(1))
  10078. if vsValue='BAD' then
  10079. do
  10080. vsLength=length(arg(1))
  10081. if symbol(copies('A', vsLength)) <> 'BAD' then
  10082. Reason=''
  10083. else
  10084. Reason='A symbol length of "' || vsLength || ' bytes seems to be too long for your rexx interpreter!'
  10085. CryAndDie('RexxVarDefined()', 'Invalid symbol of "' || arg(1) || '" passed.',Reason)
  10086. end
  10087. if vsValue='VAR' then
  10088. return(1)
  10089. else
  10090. return(0)
  10091.  
  10092. ReplaceCurlyHexCodes:call TRACE "OFF"
  10093. if OptionDebugOn='Y' then
  10094. call DBG_EVALUATE 'ReplaceCurlyHexCodes()'
  10095. Before=arg(1)
  10096. RightBit=Before
  10097. LeftBit=''
  10098. StartPos=pos('{x',RightBit)
  10099. do while StartPos<>0
  10100. Codes2=substr(RightBit,StartPos+2,2)
  10101. if datatype(Codes2, 'X') <> 1 | substr(RightBit, StartPos+4, 1) <> '}' then
  10102. do
  10103. LeftBit=LeftBit||left(RightBit,StartPos+1)
  10104. RightBit=substr(RightBit,StartPos+2)
  10105. end
  10106. else
  10107. do
  10108. LeftBit=LeftBit||left(RightBit,StartPos-1)||x2c(Codes2)
  10109. RightBit=substr(RightBit,StartPos+5)
  10110. end
  10111. StartPos=pos('{x',RightBit)
  10112. end
  10113. LeftBit=LeftBit||RightBit
  10114. if OptionDebugOn='Y' then
  10115. do
  10116. if Before<>LeftBit then
  10117. call DebugOutputAfterReplacement LeftBit, '{xXX}'
  10118. end
  10119. return(LeftBit)
  10120.  
  10121. RandomString:call TRACE "OFF"
  10122. parse arg RsString,RsPickFrom
  10123. if RsPickFrom='' then
  10124. RsPickFrom=DecimalDigits||UpperCase
  10125. RsMax=length(RsPickFrom)
  10126. QPos=pos('?',RsString)
  10127. do while QPos<>0
  10128. RsString=left(RsString,QPos-1)||substr(RsPickFrom,random(1,RsMax),1)||substr(RsString,QPos+1)
  10129. QPos=pos('?',RsString)
  10130. end
  10131. return(RsString)
  10132.  
  10133. _FindFileInPathList:
  10134. parse arg cg_Look4,cg_PathList
  10135. call DBGIND 1
  10136. if OptionDebugOn='Y' then
  10137. call DBG_EVALUATE 'Searching for "' || cg_Look4 || '" in "' || cg_PathList || '"'
  10138. if RexSystemOpSys="UNIX" then
  10139. cg_SepChar=':'
  10140. else
  10141. cg_SepChar=';'
  10142. cg_Found=''
  10143. do while cg_PathList<> ''
  10144. parse var cg_PathList cg_Path (cg_SepChar) cg_PathList
  10145. if right(cg_Path,1)<>RexDirChar then
  10146. cg_Path=cg_Path||RexDirChar
  10147. cg_Found=FileQueryExists(cg_Path||cg_Look4)
  10148. if cg_Found<> '' then
  10149. leave
  10150. end
  10151. if OptionDebugOn='Y' then
  10152. call DBG_EVALUATE 'Found "' || cg_Found || '"'
  10153. call DBGIND-1
  10154. return(cg_Found)
  10155.  
  10156. FindFileInPath:call TRACE "OFF"
  10157. parse arg ch_Look4,ch_LookIn
  10158. if RexSystemOpSys="UNIX" then
  10159. ch_SepChar=':'
  10160. else
  10161. ch_SepChar=';'
  10162. if OptionDebugOn='Y' then
  10163. call DBG_EVALUATE 'FindFileInPath(): Looking for "' || ch_Look4 || '" in "' || ch_LookIn || '"'
  10164. call DBGIND 1
  10165. ch_Searched=''
  10166. do while ch_LookIn<> ''
  10167. parse var ch_LookIn ch_ThisBit (ch_SepChar) ch_LookIn
  10168. if ch_ThisBit='' then
  10169. iterate
  10170. ch_Left1=left(ch_ThisBit,1)
  10171. select
  10172. when ch_Left1='*' then
  10173. do
  10174. ch_LookIn=GetEnv(substr(ch_ThisBit,2))||ch_SepChar||ch_LookIn
  10175. end
  10176. when ch_Left1='+' then
  10177. do
  10178. ch_List.0=0
  10179. ch_Mask=substr(ch_ThisBit,2)||RexDirChar|| '*.*'
  10180. call _SysFileTree ch_Mask, 'ch_List', 'DOS'
  10181. ch_Comb=''
  10182. do ch_Index=1 to ch_List.0
  10183. if ch_Index=1 then
  10184. ch_Comb=ch_List.ch_Index
  10185. else
  10186. ch_Comb=ch_Comb||ch_SepChar||ch_List.ch_Index
  10187. end
  10188. ch_LookIn=ch_Comb||ch_SepChar||ch_LookIn
  10189. end
  10190. otherwise
  10191. do
  10192. if ch_Searched='' then
  10193. ch_Searched=ch_ThisBit
  10194. else
  10195. ch_Searched=ch_Searched||ch_SepChar||ch_ThisBit
  10196. end
  10197. end
  10198. end
  10199. ch_Found=_FindFileInPathList(ch_Look4,ch_Searched)
  10200. if ch_Found<> '' then
  10201. ch_Found=FileQueryExists(ch_Found)
  10202. if OptionDebugOn='Y' then
  10203. call DBG_EVALUATE 'Result: "' || ch_Found || '"'
  10204. call DBGIND-1
  10205. return(ch_Found)
  10206.  
  10207. FindFile:call TRACE "OFF"
  10208. ci_Look4=arg(1)
  10209. ci_Found=''
  10210. if OptionDebugOn='Y' then
  10211. call DBG_EVALUATE 'FindFile(): Looking for "' || ci_Look4 || '"'
  10212. call DBGIND 1
  10213. if ci_Found='' then
  10214. do
  10215. call DBG_EVALUATE 'Looking in current directory'
  10216. ci_Found=QueryExists(ci_Look4)
  10217. end
  10218. if ci_Found='' then
  10219. do
  10220. do ci_Index=1 to OptionIncludePathCnt until ci_Found<> ''
  10221. ci_Found=FindFileInPath(ci_Look4,OptionIncludePath.ci_Index)
  10222. end
  10223. end
  10224. if ci_Found='' then
  10225. ci_Found=FindFileInPath(ci_Look4, '*PPWIZARD_INCLUDE')
  10226. if ci_Found='' then
  10227. ci_Found=FindFileInPath(ci_Look4, '*INCLUDE')
  10228. if ci_Found='' then
  10229. do
  10230. call DBG_EVALUATE 'Looking in same directory as PPWIZARD'
  10231. parse source . . ci_Found
  10232. ci_Found=_filespec('Location',ci_Found)||ci_Look4
  10233. if QueryExists(ci_Found)='' then
  10234. ci_Found=''
  10235. end
  10236. if ci_Found<> '' then
  10237. ci_Found=FileQueryExists(ci_Found)
  10238. if OptionDebugOn='Y' then
  10239. call DBG_EVALUATE 'Result: "' || ci_Found || '"'
  10240. call DBGIND-1
  10241. return(ci_Found)
  10242.  
  10243. _SysSearchPath:call TRACE "OFF"
  10244. return(FindFileInPath(arg(2), '*' ||arg(1)))
  10245.  
  10246. SSTRIP:call TRACE "OFF"
  10247. parse arg cj_S,cj_M,cj_C
  10248. if cj_M=='' then
  10249. cj_M='B'
  10250. if cj_C=='' then
  10251. cj_C='00'x
  10252. cj_S=translate(cj_S, '', cj_C, ' ')
  10253. return(strip(cj_S,cj_M))
  10254.  
  10255. Add2:call TRACE "OFF"
  10256. parse arg ck_V,ck_S
  10257. if ck_S<> '' then
  10258. Add2Stem=ck_S|| '.'
  10259. if Add2Stem='' then
  10260. CryAndDie("Add to which array?")
  10261. ck_CV=Add2Stem|| '0'
  10262. if symbol(ck_CV)<> 'VAR' then
  10263. ck_C=0
  10264. else
  10265. ck_C=value(ck_CV)
  10266. ck_C=ck_C+1
  10267. call value Add2Stem||ck_C,ck_V
  10268. call value ck_CV,ck_C
  10269. return(ck_C)
  10270.  
  10271. QueryExists:call TRACE "OFF"
  10272. parse arg cl_File,cl_MustExist
  10273. if cl_File='' then
  10274. CryAndDie('The filename "" is invalid!')
  10275. else
  10276. do
  10277. cl_Rc=FileQueryExists(cl_File)
  10278. if cl_Rc='' & cl_MustExist = 'Y' then
  10279. CryAndDie('The filename "' || cl_File || '" does not exist!')
  10280. return(cl_Rc)
  10281. end
  10282.  
  10283. MustDeleteFile:call TRACE "OFF"
  10284. cm_File=arg(1)
  10285. if OptionDebugOn='Y' then
  10286. do
  10287. call DBG_EVALUATE 'MustDeleteFile(' || cm_File || ')'
  10288. call DBGIND 1
  10289. end
  10290. call FileClose cm_File
  10291. if QueryExists(cm_File)='' then
  10292. do
  10293. if OptionDebugOn='Y' then
  10294. call DBG_EVALUATE 'File does not exist'
  10295. end
  10296. else
  10297. do
  10298. if OptionDebugOn='Y' then
  10299. call DBG_EVALUATE 'Deleting the file'
  10300. call FileClose cm_File
  10301. if OptionDebugOn='Y' then
  10302. call DBGIND 1
  10303. DeleteRc=_SysFileDelete(cm_File)
  10304. if OptionDebugOn='Y' then
  10305. call DBGIND-1
  10306. if QueryExists(cm_File)<> "" then
  10307. CryAndDie('Could not delete "' || cm_File || '", it must be in use (DosRc=' || DeleteRc || ')...')
  10308. end
  10309. if OptionDebugOn='Y' then
  10310. call DBGIND-1
  10311. return
  10312.  
  10313. OptionGet:call TRACE "OFF"
  10314. if OptionDebugOn='Y' then
  10315. call DBG_EVALUATE 'OptionGet()'
  10316. call DBGIND 1
  10317. cn_Ans=OptionGetValue(arg(1))
  10318. call DBGIND-1
  10319. return(cn_Ans)
  10320.  
  10321. OptionSet:call TRACE "OFF"
  10322. if OptionDebugOn='Y' then
  10323. call DBG_EVALUATE 'OptionSet()'
  10324. call DBGIND 1
  10325. call OptionSetValue arg(1),arg(2)
  10326. call DBGIND-1
  10327. return
  10328.  
  10329. MakeWebLinks:call TRACE "OFF"
  10330. parse arg co_R,co_ProtU,co_T
  10331. co_Prot=co_ProtU|| '://'
  10332. co_Pos=pos(co_Prot,co_R)
  10333. if co_Pos=0 then
  10334. return(co_R)
  10335. if co_ProtU='ftp' then
  10336. co_Valid=_ValCharsFtp
  10337. else
  10338. co_Valid=_ValCharsHttp
  10339. co_ProtL=length(co_Prot)
  10340. if co_T='' then
  10341. co_T='<a href="{URL}">{URL}</a>'
  10342. co_L=''
  10343. do until co_Pos=0
  10344. co_L=co_L||left(co_R,co_Pos-1)
  10345. co_R=substr(co_R,co_Pos)
  10346. co_Pos=verify(co_R,co_Valid, 'N')
  10347. if co_Pos=0 then
  10348. do
  10349. co_Url=co_R
  10350. co_R=''
  10351. end
  10352. else
  10353. do
  10354. co_Url=left(co_R,co_Pos-1)
  10355. co_R=substr(co_R,co_Pos)
  10356. end
  10357. co_Insert=ReplaceString(co_T, "{URL}",co_Url)
  10358. co_Insert=ReplaceString(co_Insert, "{URL-}",substr(co_Url,co_ProtL+1))
  10359. co_L=co_L||co_Insert
  10360. co_Pos=pos(co_Prot,co_R)
  10361. end
  10362. return(co_L||co_R)
  10363.  
  10364. TimeStamp:call TRACE "OFF"
  10365. parse arg cp_CmdList,cp_Ts
  10366. cp_AddSec=0
  10367. do while cp_CmdList<> ''
  10368. parse var cp_CmdList cp_Cmd cp_CmdList
  10369. cp_Unit=translate(right(cp_Cmd,1))
  10370. cp_Units=left(cp_Cmd,length(cp_Cmd)-1)
  10371. select
  10372. when cp_Unit='W' then
  10373. cp_CmdSec=cp_Units*604800
  10374. when cp_Unit='D' then
  10375. cp_CmdSec=cp_Units*86400
  10376. when cp_Unit='H' then
  10377. cp_CmdSec=cp_Units*3600
  10378. when cp_Unit='M' then
  10379. cp_CmdSec=cp_Units*60
  10380. when cp_Unit='S' then
  10381. cp_CmdSec=cp_Units
  10382. otherwise
  10383. cp_CmdSec=cp_Cmd
  10384. end
  10385. cp_AddSec=cp_AddSec+cp_CmdSec
  10386. end
  10387. if cp_Ts='' then
  10388. do
  10389. cp_Bd=basedate()
  10390. cp_Sec=time('S')
  10391. end
  10392. else
  10393. do
  10394. cp_Bd=basedate(left(cp_Ts,8))
  10395. parse value substr(cp_Ts,9)with cp_HH+2 cp_MM+2 cp_SS
  10396. cp_Sec=(cp_HH*3600)+(cp_MM*60)+cp_SS
  10397. end
  10398. cp_TotSec=cp_Sec+cp_AddSec
  10399. cp_PlusDay=cp_TotSec%86400
  10400. cp_Sec=cp_TotSec//86400
  10401. cp_Date=Bd2Date(cp_Bd+cp_PlusDay)
  10402. cp_HH=right(cp_Sec%3600,2, '0')
  10403. cp_Sec=cp_Sec//3600
  10404. cp_MM=right(cp_Sec%60,2, '0')
  10405. cp_Sec=cp_Sec//60
  10406. cp_SS=right(cp_Sec,2, '0')
  10407. return(cp_Date||cp_HH||cp_MM||cp_SS)
  10408.  
  10409. ArraySplit:call TRACE "OFF"
  10410. parse arg cq_Stem,cq_Value,cq_Del,cq_Spaces,cq_KeepBlank
  10411. cq_Stem=cq_Stem|| '.'
  10412. if cq_Del=='' then
  10413. cq_Del=' '
  10414. if cq_Spaces='' then
  10415. cq_Spaces='B'
  10416. cq_Cnt=0
  10417. do while cq_Value\==''
  10418. parse var cq_Value cq_Before (cq_Del) cq_Value
  10419. if cq_Spaces<> 'K' then
  10420. do
  10421. if cq_Spaces='BM' then
  10422. cq_Before=space(cq_Before)
  10423. else
  10424. cq_Before=strip(cq_Before,cq_Spaces)
  10425. end
  10426. if cq_Before='' then
  10427. do
  10428. if cq_KeepBlank<> 'Y' then
  10429. iterate
  10430. end
  10431. cq_Cnt=cq_Cnt+1
  10432. call _valueS cq_Stem||cq_Cnt,cq_Before
  10433. end
  10434. call _valueS cq_Stem|| '0',cq_Cnt
  10435. return(cq_Cnt)
  10436.  
  10437. ArrayRemoveDup:
  10438. parse arg cr_Stem,cr_MaxInRow
  10439. if cr_MaxInRow='' then
  10440. cr_MaxRpt=0
  10441. else
  10442. cr_MaxRpt=cr_MaxInRow-1
  10443. cr_Stem=cr_Stem|| '.'
  10444. cr_End=value(cr_Stem|| '0')
  10445. cr_DstI=0
  10446. cr_Last=''
  10447. cr_RepeatCnt=0
  10448. do cr_SrcI=1 to cr_End
  10449. cr_Value=value(cr_Stem||cr_SrcI)
  10450. if cr_Value\==cr_Last then
  10451. cr_RepeatCnt=0
  10452. else
  10453. do
  10454. if cr_SrcI<>1 then
  10455. do
  10456. cr_RepeatCnt=cr_RepeatCnt+1
  10457. if cr_RepeatCnt>cr_MaxRpt then
  10458. iterate
  10459. end
  10460. end
  10461. cr_Last=cr_Value
  10462. cr_DstI=cr_DstI+1
  10463. call value cr_Stem||cr_DstI,cr_Value
  10464. end
  10465. call value cr_Stem|| '0',cr_DstI
  10466. return(cr_DstI)
  10467.  
  10468. ArrayTranslate:
  10469. parse arg cs_Stem,cs_Spaces,cs_Case
  10470. cs_Stem=cs_Stem|| '.'
  10471. if cs_Spaces='' then
  10472. cs_Spaces='B'
  10473. cs_End=value(cs_Stem|| '0')
  10474. do cs_SrcI=1 to cs_End
  10475. cs_Value=value(cs_Stem||cs_SrcI)
  10476. if cs_Spaces<> 'K' then
  10477. do
  10478. if cs_Spaces='BM' then
  10479. cs_Value=space(cs_Value)
  10480. else
  10481. cs_Value=strip(cs_Value,cs_Spaces)
  10482. end
  10483. if cs_Case<> '' then
  10484. do
  10485. if cs_Case='L' then
  10486. cs_Value=ToLowerCase(cs_Value)
  10487. else
  10488. cs_Value=translate(cs_Value)
  10489. end
  10490. call value cs_Stem||cs_SrcI,cs_Value
  10491. end
  10492. return(cs_End)
  10493.  
  10494. ReverseArray:
  10495.  
  10496. ArrayReverse:call TRACE "OFF"
  10497. if OptionDebugOn='Y' then
  10498. call DBG_EVALUATE 'ReverseArray()'
  10499. riArray=translate(arg(1))|| '.'
  10500. riCount=_valueG(riArray||0)
  10501. riHalfWay=riCount%2
  10502. do riFrom=1 to riHalfWay
  10503. riTo=(riCount-riFrom)+1
  10504. riTemp=_valueG(riArray||riFrom)
  10505. call _valueS riArray||riFrom,_valueG(riArray||riTo)
  10506. call _valueS riArray||riTo,riTemp
  10507. end
  10508. return(riCount)
  10509.  
  10510. SortArray:
  10511.  
  10512. ArraySort:call TRACE "OFF"
  10513. if OptionDebugOn='Y' then
  10514. call DBG_EVALUATE 'ArraySort()'
  10515. parse arg bsArray,bsStartCol,bsEndCol,bsStrict
  10516. bsArray=translate(bsArray)|| '.'
  10517. if bsStartCol='' then
  10518. bsStartCol=0
  10519. else
  10520. do
  10521. if bsEndCol='' then
  10522. bsLength=0
  10523. else
  10524. bsLength=bsEndCol-bsStartCol
  10525. end
  10526. bsM=1
  10527. bsCount=_valueG(bsArray||0)
  10528. do while(9*bsM+4)<bsCount
  10529. bsM=bsM*3+1
  10530. end
  10531. do while bsM>0
  10532. bsK=bsCount-bsM
  10533. do bsJ=1 to bsK
  10534. bsIndex1=bsJ
  10535. do while bsIndex1>0
  10536. bsIndex2=bsIndex1+bsM
  10537. if bsStartCol=0 then
  10538. do
  10539. bsVal1=_valueG(bsArray||BSINDEX1)
  10540. bsVal2=_valueG(bsArray||BSINDEX2)
  10541. end
  10542. else
  10543. do
  10544. if bsLength=0 then
  10545. do
  10546. bsVal1=substr(_valueG(bsArray||BSINDEX1),bsStartCol)
  10547. bsVal2=substr(_valueG(bsArray||BSINDEX2),bsStartCol)
  10548. end
  10549. else
  10550. do
  10551. bsVal1=substr(_valueG(bsArray||BSINDEX1),bsStartCol,bsLength)
  10552. bsVal2=substr(_valueG(bsArray||BSINDEX2),bsStartCol,bsLength)
  10553. end
  10554. end
  10555. if bsStrict='Y' then
  10556. bsGreater=bsVal1>>bsVal2
  10557. else
  10558. bsGreater=bsVal1>bsVal2
  10559. if bsGreater then
  10560. do
  10561. bsTemp=_valueG(bsArray||BSINDEX1)
  10562. call _valueS bsArray||BSINDEX1,_valueG(bsArray||BSINDEX2)
  10563. call _valueS bsArray||BSINDEX2,bsTemp
  10564. end
  10565. else
  10566. leave
  10567. bsIndex1=bsIndex1-bsM
  10568. end
  10569. end
  10570. bsM=bsM%3
  10571. end
  10572. return(bsCount)
  10573.  
  10574. MakeDirectoryTree:call TRACE "OFF"
  10575. WholeDirectory=arg(1)
  10576. if right(WholeDirectory,1)=RexDirChar then
  10577. WholeDirectory=left(WholeDirectory,length(WholeDirectory)-1)
  10578. if WholeDirectory='' then
  10579. return(0)
  10580. if OptionDebugOn='Y' then
  10581. do
  10582. call DBG 'MakeDirectoryTree("' || WholeDirectory || '")'
  10583. call DBGIND 1
  10584. end
  10585. if RexWhich='REGINA' then
  10586. do
  10587. if DirQueryExists(WholeDirectory)<> '' then
  10588. do
  10589. if OptionDebugOn='Y' then
  10590. do
  10591. call DBG 'Directory already exists (no need to make)'
  10592. call DBGIND-1
  10593. end
  10594. return(0)
  10595. end
  10596. end
  10597. else
  10598. do
  10599. if OptionDebugOn='Y' then
  10600. call DBG "Under OS/2 rexx we can't easily tell if directory already exists"
  10601. end
  10602. if RexSystemOpSys="DOS" then
  10603. ct_Dq=''
  10604. else
  10605. ct_Dq='"'
  10606. if RexSystemOpSys="UNIX" then
  10607. MakeDirCmd='mkdir '
  10608. else
  10609. MakeDirCmd='md '
  10610. SearchFromPosn=1
  10611. do until SlashPosn=0
  10612. SlashPosn=pos(RexDirChar,WholeDirectory,SearchFromPosn)
  10613. if SlashPosn<>1 then
  10614. do
  10615. if SlashPosn=0 then
  10616. MakeDir=WholeDirectory
  10617. else
  10618. MakeDir=left(WholeDirectory,SlashPosn-1)
  10619. DirBit=filespec('name',MakeDir)
  10620. if right(MakeDir,1)<> ':' & DirBit <> '.' & DirBit <> '..' then
  10621. do
  10622. if OptionDebugOn='N' then
  10623. call AddressCmd MakeDirCmd||ct_Dq||MakeDir||ct_Dq||AllCmdOutput2Nul()
  10624. else
  10625. do
  10626. TmpMkDirFile=RexGetTmpFileName()
  10627. call AddressCmd MakeDirCmd||ct_Dq||MakeDir||ct_Dq||RedirectStdOutAndErr2(TmpMkDirFile),TmpMkDirFile
  10628. if Rc=0 then
  10629. call DBG 'Made Directory "' || MakeDir || '"'
  10630. call _SysFileDelete TmpMkDirFile
  10631. end
  10632. end
  10633. end
  10634. SearchFromPosn=SlashPosn+1
  10635. end
  10636. if OptionDebugOn='Y' then
  10637. call DBGIND-1
  10638. return(0)
  10639.  
  10640. FileCopy:call TRACE "OFF"
  10641. parse arg cu_Src,cu_Dst,cu_When,cu_ContOnError
  10642. call DBG 'Copy "' || cu_Src || '" to "' || cu_Dst || '"?'
  10643. call DBGIND 1
  10644. if FileQueryExists(cu_Src)='' then
  10645. do
  10646. if cu_ContOnError<> 'Y' then
  10647. CryAndDie('The FileCopy() source file "' || cu_Src || '" does not exist...')
  10648. return(2)
  10649. end
  10650. cu_When=translate(cu_When)
  10651. cu_Do=''
  10652. select
  10653. when cu_When='' then
  10654. cu_Do='we always copy'
  10655. when cu_When='EQUAL' then
  10656. do
  10657. cu_Ss=stream(cu_Src, 'c', 'query size') || ' - ' || stream(cu_Src, 'c', 'query datetime')
  10658. if FileQueryExists(cu_Dst)='' then
  10659. cu_Ds='Destination does not exist'
  10660. else
  10661. cu_Ds=stream(cu_Dst, 'c', 'query size') || ' - ' || stream(cu_Dst, 'c', 'query datetime')
  10662. call DBG 'Want files EQUAL...'
  10663. call DBGIND 1
  10664. call DBG 'SRC: ' ||cu_Ss
  10665. call DBG 'DST: ' ||cu_Ds
  10666. call DBGIND-1
  10667. if cu_Ss<>cu_Ds then
  10668. cu_Do='files unequal'
  10669. end
  10670. otherwise
  10671. CryAndDie('Unknown FileCopy() mode of "' || cu_When || '"')
  10672. end
  10673. if cu_Do<> '' then
  10674. call DBG 'Source will be copied as ' ||cu_Do
  10675. else
  10676. do
  10677. call DBG 'The source does not need copying'
  10678. call DBGIND-1
  10679. return(0)
  10680. end
  10681. call AddInputFileToDependancyList cu_Src
  10682. call AddOutputFileToDependancyList cu_Dst
  10683. cu_QSD='"' || cu_Src || '" "' || cu_Dst || '"'
  10684. select
  10685. when RexSystemOpSys="UNIX" then
  10686. cu_CpyS='cp --force --verbose'
  10687. when RexSystemOpSys="WIN32" then
  10688. cu_CpyS='copy /Y /B'
  10689. when RexSystemOpSys="OS/2" then
  10690. cu_CpyS='copy'
  10691. otherwise
  10692. cu_CpyS='copy'
  10693. end
  10694. CopyCmd=cu_CpyS|| ' ' ||cu_QSD
  10695. TmpMkDirFile=RexGetTmpFileName()
  10696. cu_CpyRc=AddressCmd(CopyCmd||RedirectStdOutAndErr2(TmpMkDirFile),TmpMkDirFile)
  10697. call _SysFileDelete TmpMkDirFile
  10698. if cu_CpyRc=0 then
  10699. call DBG 'File successfully copied'
  10700. else
  10701. do
  10702. call DBG 'Copy failed'
  10703. if cu_ContOnError<> 'Y' then
  10704. CryAndDie('File copy failed (Rc=' || cu_CpyRc || ')!', 'From: "' || cu_Src || '"', 'To  : "' || cu_Dst || '"')
  10705. end
  10706. call DBGIND-1
  10707. return(cu_CpyRc)
  10708.  
  10709. QuoteIt:call TRACE "OFF"
  10710. if OptionDebugOn='Y' then
  10711. call DBG_EVALUATE 'QuoteIt()'
  10712. parse arg cv_Q4,cv_TryQ,cv_RetQuotedStr
  10713. if cv_RetQuotedStr='' then
  10714. cv_RetQuotedStr='N'
  10715. if cv_TryQ='' then
  10716. cv_TryQ='"' || "'"
  10717. else
  10718. do
  10719. if translate(cv_TryQ)='ANY' then
  10720. cv_TryQ=TryQuoteListAny
  10721. end
  10722. TryQuoteLng=length(cv_TryQ)
  10723. do cv_I=1 to TryQuoteLng
  10724. cv_PosQ=substr(cv_TryQ,cv_I,1)
  10725. if pos(cv_PosQ,cv_Q4)=0 then
  10726. do
  10727. if cv_RetQuotedStr='N' then
  10728. return(cv_PosQ)
  10729. else
  10730. return(cv_PosQ||cv_Q4||cv_PosQ)
  10731. end
  10732. end
  10733. CryAndDie('QuoteIt(): Could not find safe quote for ' ||DebugRightArrow||cv_Q4||DebugLeftArrow)
  10734.  
  10735. QuoteAsRexxLit:call TRACE "OFF"
  10736. return( "'" || ReplaceString(arg(1), "'", "''") || "'" )
  10737.  
  10738. FormatTime:call TRACE "OFF"
  10739. parse arg cw_Fmt,cw_Ts,cw_Pre
  10740. if cw_Ts='' then
  10741. cw_Ts=TimeStamp()
  10742. if cw_Pre='' then
  10743. cw_Pre='FORMATTIME'
  10744. if OptionDebugOn='Y' then
  10745. do
  10746. call DBG_EVALUATE 'FormatTime(' || cw_Ts || ')'
  10747. call DBGIND 1
  10748. end
  10749. parse var cw_Ts cw_YYYY+4 cw_MM+2 cw_DD+2 cw_HH+2 cw_Min+2 cw_SS
  10750. cw_R=''
  10751. cw_Pos=pos('%',cw_Fmt)
  10752. do while cw_Pos<>0
  10753. cw_R=cw_R||left(cw_Fmt,cw_Pos-1)
  10754. cw_C=substr(cw_Fmt,cw_Pos+1,1)
  10755. cw_Fmt=substr(cw_Fmt,cw_Pos+2)
  10756. if cw_HH>12 then
  10757. cw_II=cw_HH-12
  10758. else
  10759. cw_II=cw_HH+0
  10760. if cw_II=0 then
  10761. cw_II=12
  10762. select
  10763. when cw_C='d' then
  10764. cw_N=cw_DD
  10765. when cw_C='e' then
  10766. cw_N=right(cw_DD+0,2, ' ')
  10767. when cw_C='#' then
  10768. cw_N=cw_DD+0
  10769. when cw_C='m' then
  10770. cw_N=cw_MM
  10771. when cw_C='y' then
  10772. cw_N=right(cw_YYYY,2)
  10773. when cw_C='Y' then
  10774. cw_N=cw_YYYY
  10775. when cw_C='H' then
  10776. cw_N=cw_HH
  10777. when cw_C='!' then
  10778. cw_N=cw_HH+0
  10779. when cw_C='I' then
  10780. cw_N=right(cw_II,2, '0')
  10781. when cw_C='@' then
  10782. cw_N=cw_II
  10783. when cw_C='M' then
  10784. cw_N=cw_Min
  10785. when cw_C='S' then
  10786. cw_N=cw_SS
  10787. when cw_C='j' then
  10788. cw_N=right(BaseDate(cw_Ts)-basedate(cw_YYYY|| '0101')+1, 3, '0')
  10789. when cw_C='$' then
  10790. cw_N=BaseDate(cw_Ts)-basedate(cw_YYYY|| '0101')+1
  10791. when cw_C='Z' then
  10792. cw_N=''
  10793. when cw_C='%' then
  10794. cw_N='%'
  10795. when cw_C='a' then
  10796. do
  10797. cw_N=CfgMacro(cw_Pre|| '_DAY_NAMES_SHORT',    'Mon Tue Wed Thu Fri Sat Sun')
  10798. cw_N=word(cw_N,(BaseDate(cw_Ts)//7)+1)
  10799. end
  10800. when cw_C='A' then
  10801. do
  10802. cw_N=CfgMacro(cw_Pre|| '_DAY_NAMES_LONG',    'Monday Tuesday Wednesday Thursday Friday Saturday Sunday')
  10803. cw_N=word(cw_N,(BaseDate(cw_Ts)//7)+1)
  10804. end
  10805. when cw_C='b' then
  10806. do
  10807. cw_N=CfgMacro(cw_Pre|| '_MONTH_NAMES_SHORT', 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec')
  10808. cw_N=word(cw_N,cw_MM)
  10809. end
  10810. when cw_C='B' then
  10811. do
  10812. cw_N=CfgMacro(cw_Pre|| '_MONTH_NAMES_LONG',  'January February March April May June July August September October November December')
  10813. cw_N=word(cw_N,cw_MM)
  10814. end
  10815. when cw_C='p' then
  10816. do
  10817. if cw_HH>=12 then
  10818. cw_N=CfgMacro(cw_Pre|| '_PM_TEXT', 'pm')
  10819. else
  10820. cw_N=CfgMacro(cw_Pre|| '_AM_TEXT', 'am')
  10821. end
  10822. when cw_C='x' then
  10823. do
  10824. cw_N=CfgMacro(cw_Pre|| '_DATE_FORMAT', '%a %b %# %Y')
  10825. cw_Fmt=cw_N||cw_Fmt
  10826. cw_N=''
  10827. end
  10828. when cw_C='X' then
  10829. do
  10830. cw_N=CfgMacro(cw_Pre|| '_TIME_FORMAT', '%@:%M:%S%p')
  10831. cw_Fmt=cw_N||cw_Fmt
  10832. cw_N=''
  10833. end
  10834. when cw_C='c' then
  10835. do
  10836. cw_N=CfgMacro(cw_Pre|| '_DATE_TIME_FORMAT', '%x at %X')
  10837. cw_Fmt=cw_N||cw_Fmt
  10838. cw_N=''
  10839. end
  10840. when cw_C='D' then
  10841. do
  10842. cw_Fmt='%m/%d/%y' ||cw_Fmt
  10843. cw_N=''
  10844. end
  10845. when cw_C='v' then
  10846. do
  10847. cw_Fmt='%e-%b-%Y' ||cw_Fmt
  10848. cw_N=''
  10849. end
  10850. when cw_C='R' then
  10851. do
  10852. cw_Fmt='%H:%M' ||cw_Fmt
  10853. cw_N=''
  10854. end
  10855. when cw_C='r' then
  10856. do
  10857. cw_Fmt='%I:%M:%S%p' ||cw_Fmt
  10858. cw_N=''
  10859. end
  10860. when cw_C='T' then
  10861. do
  10862. cw_Fmt='%H:%M:%S' ||cw_Fmt
  10863. cw_N=''
  10864. end
  10865. otherwise
  10866. cw_N='%' ||cw_C
  10867. end
  10868. cw_R=cw_R||cw_N
  10869. cw_Pos=pos('%',cw_Fmt)
  10870. end
  10871. cw_R=cw_R||cw_Fmt
  10872. if OptionDebugOn='Y' then
  10873. do
  10874. call DBG_EVALUATE 'Returning: ' ||cw_R
  10875. call DBGIND-1
  10876. end
  10877. return(cw_R)
  10878.  
  10879. Evaluate_40:
  10880. TraceBpListsLoaded=''
  10881. TraceAutoAliasCnt=0
  10882. TraceAutoAliasMax=0
  10883. signal ExecCmd_41
  10884.  
  10885. ExecRexxCmd:
  10886. InterpretThisAsPassed=arg(1)
  10887. if RexWhich='REGINA' then
  10888. UseEos=MarksNewLine
  10889. else
  10890. UseEos=';'
  10891. InterpretThisC=ReplaceEos(InterpretThisAsPassed)
  10892. InterpretThis=InterpretThisC
  10893. TraceBreakPoint=''
  10894. PrevTracedLine=''
  10895. if OptionDebugOn='Y' then
  10896. do
  10897. call DBG_INTERPRET 'Interpreting ' ||DebugRightArrow||InterpretThisC||DebugLeftArrow
  10898. call DBG_INTERPRET 'Rexx code is ' || AddCommasToDecimalNumber(length(InterpretThisC)) || ' bytes long'
  10899. if bitand(DebugLevel,SeeRexxTrace)==SeeRexxTrace then
  10900. do
  10901. if RexWhich='REGINA' then
  10902. TrcDef='OFF'
  10903. else
  10904. TrcDef='INTERMEDIATES'
  10905. TraceLevel4Rexx=translate(CfgMacro('REXXTRACE',TrcDef))
  10906. if TraceLevel4Rexx<> 'OFF' then
  10907. InterpretThis='TRACE ' || TraceLevel4Rexx || ';' || InterpretThisC || ';call TRACE "OFF";'
  10908. TraceBreakPoint=strip(CfgMacro('REXX_BP', ''))
  10909. if TraceBreakPoint='' then
  10910. TraceBpList=''
  10911. else
  10912. do
  10913. if length(TraceBreakPoint)>1&left(TraceBreakPoint,1)='=' then
  10914. do
  10915. TraceBreakPoint='=' ||MacroGet(strip(substr(TraceBreakPoint,2)))
  10916. TraceBreakPoint=ReplaceEos(PerformReplacementsInCmdsParameters(TraceBreakPoint))
  10917. end
  10918. if TraceAutoAliasMax=0 then
  10919. do
  10920. TraceAutoAliasMax=CfgMacro('REXX_BP_MAX_AUTO_CMD',22)
  10921. if datatype(TraceAutoAliasMax, 'W')=0 then
  10922. TraceAutoAliasMax=22
  10923. if TraceAutoAliasMax<10 then
  10924. TraceAutoAliasMax=22
  10925. end
  10926. TraceBpList=CfgMacro('REXX_BP_ALIAS', '')
  10927. if TraceBpList<>TraceBpListsLoaded then
  10928. TraceBpListsLoaded=''
  10929. end
  10930. call Line1 ''
  10931. call Line1 '---------- REXX TRACE - START(' || TraceLevel4Rexx || ') ----------'
  10932. end
  10933. end
  10934. signal ON SYNTAX NAME _SyntaxErrorDuringInterpret
  10935. signal ON NOVALUE NAME _UnknownVariableDuringInterpret
  10936. interpret InterpretThis
  10937. TraceBreakPoint=''
  10938. if OptionDebugOn='Y' then
  10939. do
  10940. if bitand(DebugLevel,SeeRexxTrace)==SeeRexxTrace then
  10941. do
  10942. call Line1 '---------- REXX TRACE - END(' || TraceLevel4Rexx || ') ----------'
  10943. call Line1 ''
  10944. end
  10945. end
  10946. return
  10947.  
  10948. _UnknownVariableDuringInterpret:
  10949. TrappingLine=SIGL
  10950. call TRACE "OFF"
  10951. call CommonTrapHandler TrappingLine, 'NoValue Abort!', 'Unknown Variable', condition('D'),space(InterpretThisAsPassed),TraceBreakPoint
  10952.  
  10953. _SyntaxErrorDuringInterpret:
  10954. TrappingLine=SIGL
  10955. call TRACE "OFF"
  10956. call CommonTrapHandler TrappingLine, 'Syntax Error!', 'Reason',errortext(Rc),space(InterpretThisAsPassed),TraceBreakPoint
  10957.  
  10958. ReplaceEos:
  10959. return(ReplaceString(arg(1),DefRexxSpecialSepTag,UseEos))
  10960.  
  10961. AddToBpSearch:
  10962. RtSearchText=RtSearchText|| '{SOL}' || space(arg(1)) || '{EOL}'
  10963. return
  10964.  
  10965. RexxTrace:call TRACE "OFF"
  10966. if OptionDebugOn='N' then
  10967. return
  10968. if bitand(DebugLevel,SeeRexxTrace)\==SeeRexxTrace then
  10969. return
  10970. signal on NOVALUE name RexxTrapUninitializedVariable
  10971. signal on SYNTAX name RexxTrapSyntaxError
  10972. parse arg rtText,rtDumpList,rtDbgCmd,rtDbgTrapped
  10973. rtSay='$TRACE: ' ||rtText
  10974. call Line1 PpwRexxTraceColor||rtSay||Reset
  10975. RtSearchText=''
  10976. call AddToBpSearch rtText
  10977. if rtDbgTrapped<> 'Y' then
  10978. do
  10979. rtThis=''
  10980. if rtDbgCmd='Y' then
  10981. do
  10982. rtThis=PrevTracedLine|| ' ' ||rtText
  10983. PrevTracedLine=rtText
  10984. end
  10985. else
  10986. rtThis=rtDumpList
  10987. if rtThis<> '' then
  10988. do
  10989. if rtThis<> '?' then
  10990. call DumpVarsInExpression rtThis, '', '', 'TraceVarSay'
  10991. else
  10992. do
  10993. call Line1 'ALL KNOWN VARIABLES'
  10994. call Line1 '~~~~~~~~~~~~~~~~~~~'
  10995. call DumpVarsInExpression InterpretThisC, '', '', 'TraceVarSay'
  10996. end
  10997. end
  10998. end
  10999. call Line1 ''
  11000. if rtDbgTrapped='Y' then
  11001. rtStop='Y'
  11002. else
  11003. do
  11004. if TraceBreakPoint='' then
  11005. rtStop='N'
  11006. else
  11007. do
  11008. select
  11009. when TraceBreakPoint='?' then
  11010. rtStop='Y'
  11011. when left(TraceBreakPoint,1)='=' then
  11012. do
  11013. rtStop='N'
  11014. call ExecuteUsersTraceCmd substr(TraceBreakPoint,2)
  11015. end
  11016. otherwise
  11017. do
  11018. if pos(TraceBreakPoint,RtSearchText)<>0 then
  11019. rtStop='Y'
  11020. else
  11021. rtStop='N'
  11022. end
  11023. end
  11024. end
  11025. end
  11026. if rtStop='N' then
  11027. return
  11028. call LoadBpLists
  11029. do forever
  11030. call charout,InfoColor|| '<' || '$TRACE, ' || BpAliasCnt || ' aliases> ' ||Reset
  11031. rtCmd=strip(linein())
  11032. if rtCmd='' then
  11033. return
  11034. rtCmdU=translate(rtCmd)
  11035. select
  11036. when left(rtCmd,1)='/' then
  11037. do
  11038. EqPos=pos('=',rtCmd)
  11039. if EqPos<>0 then
  11040. do
  11041. call AddBpAlias rtCmd, "user"
  11042. STo=SaveBpAliasFile()
  11043. if STo='' then
  11044. STxt='Done (not permanently saved)!'
  11045. else
  11046. STxt='Done, saved to "' || STo || '".'
  11047. call Line1 HighlightColor||STxt||Reset
  11048. end
  11049. else
  11050. do
  11051. rtAlias=strip(substr(rtCmd,2))
  11052. if left(rtAlias,1)='#' | datatype(rtAlias, 'W')then
  11053. do
  11054. if left(rtAlias,1)='#' then
  11055. rtAliasI=strip(substr(rtAlias,2))
  11056. else
  11057. rtAliasI=rtAlias
  11058. if rtAliasI>TraceAutoAliasCnt then
  11059. do
  11060. call Line1 ErrorColor|| '#Alias "#' || rtAliasI || '" does not exist!' ||Reset||Beep
  11061. iterate
  11062. end
  11063. rtAliasI=(TraceAutoAliasCnt-rtAliasI)+1
  11064. rtCmd=Aalias.rtAliasI
  11065. end
  11066. else
  11067. do
  11068. rtCmd=FindBpAlias(rtAlias)
  11069. if rtCmd='' then
  11070. do
  11071. call Line1 ErrorColor|| 'Alias "' || rtAlias || '" not found!' ||Reset||Beep
  11072. iterate
  11073. end
  11074. end
  11075. call Line1 HighlightColor||rtCmd||Reset
  11076. call ExecuteUsersTraceCmd rtCmd
  11077. end
  11078. end
  11079. when left(rtCmd,1)='?' then
  11080. do
  11081. rtCmdU=substr(rtCmdU,2)
  11082. call Char1 PpwRexxTraceColor
  11083. select
  11084. when rtCmdU='' then
  11085. do
  11086. call Line1 PpwRexxTraceColor||rtText||Reset
  11087. end
  11088. when abbrev('VARIABLES',rtCmdU)then
  11089. do
  11090. call Line1 'ALL KNOWN VARIABLES'
  11091. call Line1 '~~~~~~~~~~~~~~~~~~~'
  11092. call DumpVarsInExpression InterpretThisC, '', '', 'TraceVarSay'
  11093. end
  11094. when abbrev('ALIASES',rtCmdU)then
  11095. do
  11096. call Line1 'ALL ALIASES'
  11097. call Line1 '~~~~~~~~~~~'
  11098. do Index=1 to BpAliasCnt
  11099. call Line1 left(BpAlias.Index.BpAName,BpLongestAlias)|| ' = ' ||BpAlias.Index.BpAValue
  11100. end
  11101. end
  11102. when abbrev('#ALIASES',rtCmdU)then
  11103. do
  11104. if TraceAutoAliasCnt=0 then
  11105. call Line1 ErrorColor|| 'No commands have been remembered yet!' ||Reset||Beep
  11106. else
  11107. do
  11108. MaxLng=length(TraceAutoAliasCnt)
  11109. call Line1 'ALL # ALIASES'
  11110. call Line1 '~~~~~~~~~~~~~'
  11111. do Index=1 to TraceAutoAliasCnt
  11112. IndexR=(TraceAutoAliasCnt-Index)+1
  11113. call Line1 '/#' || left(IndexR, MaxLng)  || ' = ' ||Aalias.Index
  11114. end
  11115. end
  11116. end
  11117. otherwise
  11118. call Line1 ErrorColor|| 'Unknown ? command of "' || rtCmd || '"!' ||Reset||Beep
  11119. end
  11120. call Char1 Reset
  11121. end
  11122. when rtCmdU='BP' then
  11123. do
  11124. call charout,InfoColor|| "New Breakpoint (blank = none) => " ||Reset
  11125. TraceBreakPoint=strip(linein())
  11126. end
  11127. otherwise
  11128. do
  11129. if ExecuteUsersTraceCmd(rtCmd)=0 then
  11130. do
  11131. if AddAutoAlias(rtCmd)<>0 then
  11132. call SaveBpAliasFile
  11133. end
  11134. end
  11135. end
  11136. end
  11137. return
  11138.  
  11139. TraceVarSay:
  11140. call Line1 PpwRexxTraceColor|| "      | " ||arg(1)||Reset
  11141. call AddToBpSearch arg(1)
  11142. return
  11143.  
  11144. ExecuteUsersTraceCmd:
  11145. signal ON SYNTAX NAME _SyntaxErrorDuringExecuteUsersTraceCmd
  11146. signal ON NOVALUE NAME _UnknownVariableDuringExecuteUsersTraceCmd
  11147. interpret arg(1)
  11148. return(0)
  11149.  
  11150. _SyntaxErrorDuringExecuteUsersTraceCmd:
  11151. call Line1 ErrorColor|| 'SYNTAX ERROR: ' ||errortext(Rc)||Reset
  11152. call Line1 Beep
  11153. return(1)
  11154.  
  11155. _UnknownVariableDuringExecuteUsersTraceCmd:
  11156. call Line1 ErrorColor|| 'NOVALUE ERROR: VAR=' || condition('D')||Reset
  11157. call Line1 Beep
  11158. return(1)
  11159.  
  11160. LoadBpLists:
  11161. if TraceBpListsLoaded<> '' then
  11162. return
  11163. BpSaveTo=''
  11164. BpList=TraceBpList
  11165. BpAliasCnt=0
  11166. BpFileNumb=0
  11167. do while BpList<> ''
  11168. parse var BpList BpList1';'BpList
  11169. BpFileNumb=BpFileNumb+1
  11170. if BpFileNumb=1 then
  11171. BpSaveTo=BpList1
  11172. if BpList1='' then
  11173. iterate
  11174. BpList1=FindFile(BpList1)
  11175. if BpList1='' then
  11176. iterate
  11177. call FileClose BpList1
  11178. BpListLine=0
  11179. BpLongestAlias=0
  11180. do while lines(BpList1)<>0
  11181. CurrentLine=strip(linein(BpList1))
  11182. BpListLine=BpListLine+1
  11183. if CurrentLine='' | left(CurrentLine, 1) = ';' then
  11184. iterate
  11185. AliasSource='line #' || BpListLine || ' of ' ||BpList1
  11186. call AddBpAlias CurrentLine,AliasSource,BpFileNumb
  11187. end
  11188. call FileClose BpList1
  11189. end
  11190. TraceBpListsLoaded=TraceBpList
  11191. return
  11192.  
  11193. AddBpAlias:
  11194. parse arg AliasCmd,AliasSrc,FromFile
  11195. parse var AliasCmd '/'BpAliasName'='BpAliasValue
  11196. if BpAliasValue='' then
  11197. do
  11198. call DBG 'Alias Command from ' || AliasSrc || ' incorrectly formatted!'
  11199. return
  11200. end
  11201. BpAliasName=translate(BpAliasName)
  11202. if left(BpAliasName,1)=='#' then
  11203. do
  11204. call AddAutoAlias BpAliasValue
  11205. return
  11206. end
  11207. if length(BpAliasName)>BpLongestAlias then
  11208. BpLongestAlias=length(BpAliasName)
  11209. FoundIndex=0
  11210. do Index=1 to BpAliasCnt
  11211. if BpAliasName=BpAlias.Index.BpAName then
  11212. do
  11213. FoundIndex=Index
  11214. leave
  11215. end
  11216. end
  11217. if FoundIndex<>0 then
  11218. do
  11219. if FromFile<> '' then
  11220. return
  11221. end
  11222. else
  11223. do
  11224. BpAliasCnt=BpAliasCnt+1
  11225. FoundIndex=BpAliasCnt
  11226. end
  11227. BpAlias.FoundIndex.BpAName=BpAliasName
  11228. BpAlias.FoundIndex.BpAValue=BpAliasValue
  11229. BpAlias.FoundIndex.BpFNumb=FromFile
  11230. return
  11231.  
  11232. FindBpAlias:
  11233. BpAliasName=translate(strip(arg(1)))
  11234. do Index=1 to BpAliasCnt
  11235. if BpAliasName=BpAlias.Index.BpAName then
  11236. return(BpAlias.Index.BpAValue)
  11237. end
  11238. return('')
  11239.  
  11240. SaveBpAliasFile:
  11241. if BpSaveTo='' then
  11242. return('')
  11243. call MustDeleteFile BpSaveTo
  11244. call lineout BpSaveTo, ';***'
  11245. call lineout BpSaveTo, ';*** Automatically saved at: ' ||NiceDateTime()
  11246. call lineout BpSaveTo, ';***'
  11247. call lineout BpSaveTo, ''
  11248. FoundF='N'
  11249. do Index=1 to BpAliasCnt
  11250. if BpAlias.Index.BpFNumb=1 then
  11251. do
  11252. if FoundF='N' then
  11253. call lineout BpSaveTo, ';--- Loaded From File ---'
  11254. FoundF='Y'
  11255. call lineout BpSaveTo, '/' || BpAlias.Index.BpAName || '=' ||BpAlias.Index.BpAValue
  11256. end
  11257. end
  11258. call FileClose BpSaveTo
  11259. FoundU='N'
  11260. do Index=1 to BpAliasCnt
  11261. if BpAlias.Index.BpFNumb=''then
  11262. do
  11263. if FoundU='N' then
  11264. do
  11265. if FoundF='Y' then
  11266. call lineout BpSaveTo, ''
  11267. call lineout BpSaveTo, ';--- User Modified This Session ---'
  11268. end
  11269. FoundU='Y'
  11270. call lineout BpSaveTo, '/' || BpAlias.Index.BpAName || '=' ||BpAlias.Index.BpAValue
  11271. end
  11272. end
  11273. call FileClose BpSaveTo
  11274. if TraceAutoAliasCnt<>0 then
  11275. do
  11276. call lineout BpSaveTo, ''
  11277. call lineout BpSaveTo, ';--- Last Few Commands Used ---'
  11278. do Index=1 to TraceAutoAliasCnt
  11279. IndexN=(TraceAutoAliasCnt-Index)+1
  11280. call lineout BpSaveTo, '/#' || IndexN  || '=' ||Aalias.Index
  11281. end
  11282. end
  11283. call FileClose BpSaveTo
  11284. return(BpSaveTo)
  11285.  
  11286. FindAutoAlias:
  11287. FindWhat=arg(1)
  11288. do FndIndex=1 to TraceAutoAliasCnt
  11289. if FindWhat=Aalias.FndIndex then
  11290. return(FndIndex)
  11291. end
  11292. return(0)
  11293.  
  11294. DeleteAutoAlias:
  11295. DelIndex=arg(1)
  11296. do DelIndexT=DelIndex to TraceAutoAliasCnt-1
  11297. DelIndexF=DelIndexT+1
  11298. Aalias.DelIndexT=Aalias.DelIndexF
  11299. end
  11300. TraceAutoAliasCnt=TraceAutoAliasCnt-1
  11301. return
  11302.  
  11303. AddAutoAlias:
  11304. SaveWhat=strip(arg(1))
  11305. if SaveWhat='' then
  11306. return(0)
  11307. FoundAt=FindAutoAlias(SaveWhat)
  11308. if FoundAt<>0 then
  11309. call DeleteAutoAlias FoundAt
  11310. if TraceAutoAliasCnt>=TraceAutoAliasMax then
  11311. call DeleteAutoAlias 1
  11312. TraceAutoAliasCnt=TraceAutoAliasCnt+1
  11313. Aalias.TraceAutoAliasCnt=SaveWhat
  11314. return(TraceAutoAliasCnt)
  11315.  
  11316. ExecCmd_41:
  11317. ExpandXEarly='N'
  11318. ExpandXLate='N'
  11319. ExpandXCmd='N'
  11320. signal EndExpandX
  11321.  
  11322. EXPANDX_DEBUG:
  11323. if OptionDebugOn='Y' then
  11324. do
  11325. if ExpandX='NONE' then
  11326. call OptionDebugShow 'EXPANDX', 'X codes are never expanded'
  11327. else
  11328. call OptionDebugShow 'EXPANDX', 'X codes are expanded "' || ExpandX || '"'
  11329. end
  11330. return
  11331.  
  11332. EXPANDX_GET:
  11333. call EXPANDX_DEBUG
  11334. return(ExpandX)
  11335.  
  11336. EXPANDX_SET:
  11337. ExpandX=translate(arg(1))
  11338. if ProcessedCmdLine='N' then
  11339. do
  11340. call OptionDebugShow 'EXPANDX', 'Setting default value of "X" var expansion to "' || EXPANDX || '"'
  11341. Default4_EXPANDX=ExpandX
  11342. return(0)
  11343. end
  11344. if ExpandX=='' then
  11345. ExpandX=Default4_EXPANDX
  11346. ExpandXEarly='N'
  11347. ExpandXLate='N'
  11348. ExpandXCmd='N'
  11349. if ExpandX<> 'NONE' then
  11350. do
  11351. TmpList=translate(ExpandX)
  11352. do while TmpList<> ''
  11353. parse var TmpList ThisItem','TmpList
  11354. select
  11355. when ThisItem='COMMAND' then
  11356. ExpandXCmd='Y'
  11357. when ThisItem='EARLY' then
  11358. ExpandXEarly='Y'
  11359. when ThisItem='LATE' then
  11360. ExpandXLate='Y'
  11361. otherwise
  11362. CryAndDie('Unknown EXPANDX option of "' || ThisItem || '"')
  11363. end
  11364. end
  11365. end
  11366. call EXPANDX_DEBUG
  11367. return
  11368.  
  11369. SetXCode:call TRACE "OFF"
  11370. parse arg cx_N,cx_V
  11371. cx_XN='XVAR?.X?' ||c2x(translate(cx_N))
  11372. call _valueS cx_XN,cx_V
  11373. return
  11374.  
  11375. InitializeCharCodes:
  11376. call DBG_DEFINING 'Initializing <' || '?x00-FF> codes + <' || '?xRexxEos> + some others'
  11377. do CharCode=0 to 255
  11378. call _valueS 'XVAR?.X?' ||c2x(translate(d2x(CharCode,2))),d2c(CharCode)
  11379. end
  11380. call _valueS 'XVAR?.X?'  || c2x(translate("RexxEos")),RexEOL
  11381. Val='<' || '?xml version="1.0" encoding="UTF-8"?>' ||MarksNewLine
  11382. Val=Val|| '<' || '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">' ||MarksNewLine
  11383. Val=Val|| '<html xmlns="http://www.w3.org/1999/xhtm" xml:lang="en" lang="en">' ||MarksNewLine
  11384. call _valueS 'XVAR?.X?'  || c2x(translate("HTML10")),Val
  11385. return
  11386.  
  11387. ExpandXCodes:call TRACE "OFF"
  11388.  
  11389. ReplaceXCodesIfNotDisabled:
  11390. if pos(StartsStdSymbolReplacement_x,arg(1))=0 then
  11391. return(arg(1))
  11392.  
  11393. ReplaceTheXCodesWeKnowExist:
  11394. LeftBit=''
  11395. RightBit=arg(1)
  11396. StartPos=pos(StartsStdSymbolReplacement_x,RightBit)
  11397. do while StartPos<>0
  11398. ReplaceCount=ReplaceCount+1
  11399. EndPos=pos(EndsMacroReplacement,RightBit,StartPos+1)
  11400. XVarName='XVAR?.X?' ||c2x(translate(substr(RightBit,StartPos+3,(EndPos-StartPos)-3)))
  11401. if symbol(XVarName)='VAR' then
  11402. LeftBit=LeftBit||left(RightBit,StartPos-1)||_valueG(XVarName)
  11403. else
  11404. do
  11405. CryAndDie(StartsStdSymbolReplacement_x||substr(RightBit,StartPos+3,(EndPos-StartPos)-3)||EndsMacroReplacement|| ' is not defined (use "#RexxVar =x=" command)!')
  11406. end
  11407. RightBit=substr(RightBit,EndPos+1)
  11408. StartPos=pos(StartsStdSymbolReplacement_x,RightBit)
  11409. end
  11410. if OptionDebugOn='Y' then
  11411. call DebugOutputAfterReplacement LeftBit||RightBit, '?xXX'
  11412. return(LeftBit||RightBit)
  11413.  
  11414. EndExpandX:
  11415. call InitOnExitProcessing
  11416. signal OnExit_42
  11417.  
  11418. InitOnExitProcessing:
  11419. OnExitCnt=0
  11420. LinesFromOnExit='N'
  11421. do cy_I=1 to 100
  11422. OnExitLst.cy_I=''
  11423. end
  11424. return
  11425.  
  11426. SetUpOnExitProcessingIfEndOfMainFile:
  11427. if IncludeLevel=1 then
  11428. do
  11429. if OnExitCnt<>0 then
  11430. do
  11431. call DBG ''
  11432. call DBG '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
  11433. call DBG '!!! "#OnExit" processing follows !!!'
  11434. call DBG '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
  11435. call DBG ''
  11436. call DBGIND 1
  11437. cy_All=''
  11438. do cy_I=1 to 100
  11439. cy_Txt=OnExitLst.cy_I
  11440. if cy_Txt\=='' then
  11441. do
  11442. call DBG 'FROM: ' ||OnExitLoc.cy_I
  11443. call DBGIND 1
  11444. call DBG 'SLOT #' || cy_I || ': ' ||cy_Txt
  11445. call DBGIND-1
  11446. if cy_All='' then
  11447. cy_All=cy_Txt
  11448. else
  11449. cy_All=cy_All||MarksNewLine||cy_Txt
  11450. end
  11451. end
  11452. call DBGIND-1
  11453. IncludeMemBufferNextLine=cy_All
  11454. LinesFromOnExit='Y'
  11455. OnExitCnt=0
  11456. return('Y')
  11457. end
  11458. end
  11459. return('N')
  11460.  
  11461. ProcessOnExit:
  11462. cz_R=strip(arg(1))
  11463. if left(cz_R,1)<> '#' then
  11464. cz_Slot=50
  11465. else
  11466. do
  11467. cz_Slot=substr(word(cz_R,1),2)
  11468. cz_R=subword(cz_R,2)
  11469. if translate(cz_Slot)='EXEC' then
  11470. do
  11471. cz_R=PerformReplacementsInCmdsParameters(cz_R)
  11472. if left(cz_R,1)='{' then
  11473. parse var cz_R '{' cz_RcTest '}' cz_R
  11474. else
  11475. do
  11476. cz_R=cz_R
  11477. cz_RcTest=''
  11478. end
  11479. if OptionValidation<> '' then
  11480. CryAndDie("Already have a command specified for execution!")
  11481. OptionValidation=cz_R
  11482. OptionValidationRc=cz_RcTest
  11483. return(0)
  11484. end
  11485. end
  11486. if cz_R='' then
  11487. CryAndDie('No #OnExit text specified!')
  11488. if datatype(cz_Slot, 'W')=0|cz_Slot<1|cz_Slot>100 then
  11489. CryAndDie('Invalid slot number of "' || cz_Slot || '"')
  11490. call DBG '#OnExit (slot #' || cz_Slot || ') we will process => ' ||DebugRightArrow||cz_R||DebugLeftArrow
  11491. OnExitCnt=OnExitCnt+1
  11492. if OnExitLst.cz_Slot='' then
  11493. do
  11494. OnExitLst.cz_Slot=cz_R
  11495. OnExitLoc.cz_Slot=CurrentSourceLocation()
  11496. end
  11497. else
  11498. do
  11499. if cz_Slot<>50 then
  11500. CryAndDie('You are attempting to reuse #OnExit slot ' || cz_Slot, 'The slot was already used at ' || OnExitLoc.cz_Slot, 'Only slot 50 can be reused.')
  11501. OnExitLst.cz_Slot=OnExitLst.cz_Slot||MarksNewLine||cz_R
  11502. end
  11503. return(0)
  11504.  
  11505. OnExit_42:
  11506. IncludeIntoMemory=''
  11507. signal Include_43
  11508.  
  11509. RecursiveIncludeSave:
  11510. call LoopPush IncludeLevel
  11511. _DebugCurrentFileNumber.IncludeLevel=DebugCurrentFileNumber
  11512. _IncludeMemHandle.IncludeLevel=IncludeMemHandle
  11513. _IncludeEofLine.IncludeLevel=IncludeEofLine
  11514. _IncludeFragmentText.IncludeLevel=IncludeFragmentText
  11515. _IncludeLineNumber.IncludeLevel=IncludeLineNumber
  11516. _IncludeMemBufferNextLine.IncludeLevel=IncludeMemBufferNextLine
  11517. _EofForced.IncludeLevel=EofForced
  11518. EofForced=''
  11519. return
  11520.  
  11521. RecursiveIncludeRestore:
  11522. DebugCurrentFileNumber=_DebugCurrentFileNumber.IncludeLevel
  11523. IncludeMemHandle=_IncludeMemHandle.IncludeLevel
  11524. IncludeEofLine=_IncludeEofLine.IncludeLevel
  11525. IncludeFragmentText=_IncludeFragmentText.IncludeLevel
  11526. IncludeLineNumber=_IncludeLineNumber.IncludeLevel
  11527. IncludeMemBufferNextLine=_IncludeMemBufferNextLine.IncludeLevel
  11528. EofForced=_EofForced.IncludeLevel
  11529. IncludeFileName=IncludeFileName.IncludeLevel
  11530. call LoopPop IncludeLevel
  11531. return
  11532.  
  11533. FileInMemoryTimeStamp:
  11534. fimFullFileName=arg(1)
  11535. if RexSystemOpSys="UNIX" then
  11536. ifHandle='_IF_' || c2x(fimFullFileName) || '.'
  11537. else
  11538. ifHandle='_IF_' || c2x(translate(fimFullFileName)) || '.'
  11539. if symbol(ifHandle|| '!TS') <> 'VAR' then
  11540. return('')
  11541. else
  11542. do
  11543. Ts=_valueG(ifHandle|| '!TS')
  11544. if OptionDebugOn='Y' then
  11545. call DBG 'Cached Timestamp: "' || Ts || '"'
  11546. return(Ts)
  11547. end
  11548.  
  11549. IncludeFileOpen:
  11550. ifFullFileName=arg(1)
  11551. ifLoad2Mem=arg(2)
  11552. if RexSystemOpSys="UNIX" then
  11553. ifHandle='_IF_' || c2x(ifFullFileName) || '.'
  11554. else
  11555. ifHandle='_IF_' || c2x(translate(ifFullFileName)) || '.'
  11556. if symbol(ifHandle|| '0') = 'VAR' then
  11557. do
  11558. if OptionDebugOn='Y' then
  11559. call DBG '"' || ifFullFileName || '" will be read from memory cache'
  11560. return(_valueG(ifHandle|| '0') || ';' ||ifHandle)
  11561. end
  11562. call FileClose ifFullFileName
  11563. OpenRc=FileOpenReadOnly(ifFullFileName)
  11564. if ifLoad2Mem='' then
  11565. ifLoad2Mem=IncludeIntoMemory
  11566. if ifLoad2Mem='N' then
  11567. do
  11568. if OptionDebugOn='Y' then
  11569. call DBG 'Will read "' || ifFullFileName || '" directly from file'
  11570. return('')
  11571. end
  11572. if OptionDebugOn='Y' then
  11573. call DBG 'Will read "' || ifFullFileName || '" into memory cache'
  11574. Ts=GetFileTimeStamp(ifFullFileName)
  11575. call _valueS ifHandle|| '!TS',Ts
  11576. ifLineNum=0
  11577. do while lines(ifFullFileName)<>0
  11578. ifLineNum=ifLineNum+1
  11579. ifLineTxt=linein(ifFullFileName)
  11580. call _valueS ifHandle||ifLineNum,ifLineTxt
  11581. end
  11582. call _valueS ifHandle|| '0',ifLineNum
  11583. call DieIfIoErrorOccurred ifFullFileName, 'Y'
  11584. call FileClose ifFullFileName
  11585. if OptionDebugOn='Y' then
  11586. do
  11587. call DBGIND 1
  11588. call DBG 'Read ' || AddCommasToDecimalNumber(ifLineNum) || ' lines'
  11589. call DBGIND-1
  11590. end
  11591. return(ifLineNum|| ';' ||ifHandle)
  11592.  
  11593. IncludeFileClose:
  11594. if IncludeMemHandle='' then
  11595. do
  11596. call DieIfIoErrorOccurred IncludeFileName, 'Y'
  11597. call FileClose IncludeFileName
  11598. end
  11599. return
  11600.  
  11601. IncludeFileLines:
  11602. if IncludeMemHandle='' then
  11603. return(lines(IncludeFileName))
  11604. else
  11605. return(IncludeLineNumber<IncludeEofLine)
  11606.  
  11607. IncludeFileLineIn:
  11608. IncludeLineNumber=IncludeLineNumber+1
  11609. if IncludeMemHandle='' then
  11610. ifLineTxt=linein(IncludeFileName)
  11611. else
  11612. ifLineTxt=_valueG(IncludeMemHandle||IncludeLineNumber)
  11613. if ExtraWhiteSpace=='' then
  11614. return(ifLineTxt)
  11615. else
  11616. return(translate(ifLineTxt, '', ExtraWhiteSpace, ' '))
  11617.  
  11618. Include_43:
  11619. SummaryUserAllBldCount=0
  11620. SummaryUserOverallCount=0
  11621. SummaryUserThisBldCount=0
  11622. signal Summary_44
  11623.  
  11624. Summary:call TRACE "OFF"
  11625. parse arg SummaryLeft,SummaryRight,SummaryMode
  11626. SummaryLeft=strip(SummaryLeft)
  11627. SummaryMode1=translate(left(SummaryMode,1))
  11628. select
  11629. when SummaryMode1='D' then
  11630. do
  11631. call DBG "Don't" || ' want "' || SummaryLeft || '" in any summaries'
  11632. call _valueS '!SUMMDROP.!' ||c2x(SummaryLeft),CurrentSourceLocation()
  11633. end
  11634. when SummaryMode1='O' then
  11635. do
  11636. SummaryUserOverallCount=SummaryUserOverallCount+1
  11637. SummaryUserOverallL.SummaryUserOverallCount=SummaryLeft
  11638. SummaryUserOverallR.SummaryUserOverallCount=SummaryRight
  11639. end
  11640. when SummaryMode1='A' then
  11641. do
  11642. SummaryUserAllBldCount=SummaryUserAllBldCount+1
  11643. SummaryUserAllBldL.SummaryUserAllBldCount=SummaryLeft
  11644. SummaryUserAllBldR.SummaryUserAllBldCount=SummaryRight
  11645. end
  11646. otherwise
  11647. do
  11648. SummaryUserThisBldCount=SummaryUserThisBldCount+1
  11649. SummaryUserThisBldL.SummaryUserThisBldCount=SummaryLeft
  11650. SummaryUserThisBldR.SummaryUserThisBldCount=SummaryRight
  11651. end
  11652. end
  11653. return
  11654.  
  11655. GenerateUserSummaryThisBuild:
  11656. do SummLine=1 to SummaryUserThisBldCount
  11657. call AddSummaryLine SummaryUserThisBldL.SummLine,SummaryUserThisBldR.SummLine
  11658. end
  11659. SummaryUserThisBldCount=0
  11660. return
  11661.  
  11662. GenerateUserSummaryAllBuilds:
  11663. do SummLine=1 to SummaryUserAllBldCount
  11664. call AddSummaryLine SummaryUserAllBldL.SummLine,SummaryUserAllBldR.SummLine
  11665. end
  11666. return
  11667.  
  11668. GenerateUserSummaryOverall:
  11669. do SummLine=1 to SummaryUserOverallCount
  11670. call AddSummaryLine SummaryUserOverallL.SummLine,SummaryUserOverallR.SummLine
  11671. end
  11672. return
  11673.  
  11674. AboutToGenerateSummary:
  11675. MaxSummaryLeft=0
  11676. SummaryLines=0
  11677. call Line1 ''
  11678. if arg(1)<> 'N' then
  11679. do
  11680. TitleText='Summary'
  11681. call Line1 TitleColor
  11682. call Line1 TitleText
  11683. call Line1 copies('~',length(TitleText))||Reset
  11684. end
  11685. return
  11686.  
  11687. AddSummaryLine:
  11688. parse arg SummaryLeft,SummaryRight
  11689. SummaryLeft=strip(SummaryLeft)
  11690. DropSym='!SUMMDROP.!' ||c2x(SummaryLeft)
  11691. if symbol(DropSym)='VAR' then
  11692. do
  11693. call DBG 'Summary line for "' || SummaryLeft || '" unwanted (dropped at ' || _valueG(DropSym) || ')'
  11694. return
  11695. end
  11696. if length(SummaryLeft)>MaxSummaryLeft then
  11697. MaxSummaryLeft=length(SummaryLeft)
  11698. SummaryLines=SummaryLines+1
  11699. SummaryL.SummaryLines=SummaryLeft
  11700. SummaryR.SummaryLines=SummaryRight
  11701. return
  11702.  
  11703. GenerateSummaryLines:
  11704. do SummLine=1 to SummaryLines
  11705. call Line1 "   " || left(SummaryL.SummLine, MaxSummaryLeft) || ': ' ||SummaryR.SummLine
  11706. end
  11707. return
  11708.  
  11709. Summary_44:
  11710. PpwCompTime=NiceDateTime()
  11711. PpwCompTs=TimeStamp()
  11712. if RexSystemOpSys="OS/2" then
  11713. do
  11714. call SetColorCodes
  11715. call SetBeepCode
  11716. end
  11717. else
  11718. do
  11719. call RemoveColorCodes
  11720. call SetBeepCode
  11721. end
  11722. InputInterfaceVer="98.131"
  11723. OutputInterfaceVer="98.132"
  11724. call SetEnv "PPWIZARD_VER_II",InputInterfaceVer
  11725. call SetEnv "PPWIZARD_VER_OI",OutputInterfaceVer
  11726. ProtectPrefix='{PROTECT_' || time('Seconds') || '}'
  11727. ProtectFromPpwS="option PUSH LeaveBlankLines=YES KeepIndent=YES linecomment='NULL' LineContinuation='NULL' HashPrefix='" || ProtectPrefix || "'"
  11728. ProtectFromPpwE=ProtectPrefix|| 'option POP'
  11729. call QuickCheckForDebugSwitch
  11730. signal on NOVALUE name RexxTrapUninitializedVariable
  11731. signal on SYNTAX name RexxTrapSyntaxError
  11732. signal on HALT name RexxCtrlC
  11733. TrapHandler='FULL'
  11734. call ProcessCommandLine
  11735. call CheckRexxInterpreter 'Y'
  11736. call DebugShowAsMuchEnvironmentDetailAsPossible
  11737. PpwUserDescription='PPWIZARD version ' || PgmVersion || ' on ' || PpWizardOpSysREAL ||  ', FREE tool for Windows, OS/2, DOS and UNIX by ' || PgmAuthor || ' (' || PgmHomePage || ')'
  11738. PgmDefaultHtmlMetaTags='<meta name="GENERATOR" content="' || PpwUserDescription || '"' || OptionXSlash || '>'
  11739. if HaveGeneratorTags='N' then
  11740. OptionHtmlGeneratorTags=PgmDefaultHtmlMetaTags
  11741. InputMasksAllowed='N'
  11742. InpFileCount=0
  11743. InpFileCountActuallyMade=0
  11744. AllSameExtn=''
  11745. do SpecIndex=1 to InputMaskCount
  11746. InputList.0=0
  11747. TmpMask=InputMask.SpecIndex
  11748. call DBG 'Looking for files matching "' || TmpMask || '"'
  11749. if left(TmpMask,1)<> '+' then
  11750. FollowDirs='N'
  11751. else
  11752. do
  11753. FollowDirs='Y'
  11754. TmpMask=substr(TmpMask,2)
  11755. end
  11756. call GetListOfFiles TmpMask, 'InputList',FollowDirs
  11757. call DBGIND 1
  11758. call DBG 'Found ' || InputList.0 || ' files(s)'
  11759. call DBGIND 1
  11760. if InputList.0=0 then
  11761. do
  11762. call CheckForNotBeingAbleToExecAnything
  11763. WeWantToDie='Y'
  11764. if LookLikeASingleFile(TmpMask)='Y' then
  11765. do
  11766. if OptionDebugOn='N' then
  11767. do
  11768. call RemoveBeepCode
  11769. call RemoveColorCodes
  11770. OptionDebugOn='Y'
  11771. OptionWantInfoMsgs='Y'
  11772. call DebugStateChanged
  11773. call DBG 'Debug forced on as we seem to have a file find problem!'
  11774. call DBGIND 1
  11775. call DBG 'We could not find "' || TmpMask || '", yet it seems to exist! We will solder on!'
  11776. call DBG 'Please send redirected output to "' || PgmAuthor || '" (' || PgmAuthorEmail || ')'
  11777. call DBG 'You could easily use a "GetFileList" ' || OptChar || 'Hook to workaround this.'
  11778. call DBGIND 1
  11779. call GetListOfFiles TmpMask, 'InputList',FollowDirs
  11780. call DBGIND-2
  11781. call DBG 'Turning off debug again'
  11782. OptionDebugOn='N'
  11783. call DebugStateChanged
  11784. end
  11785. InputList.0=1
  11786. InputList.1=TmpMask
  11787. WeWantToDie='N'
  11788. end
  11789. if WeWantToDie='Y' then
  11790. do
  11791. if InputMask0FilesOk.SpecIndex='Y' then
  11792. call DBG 'You indicated that 0 files were OK...'
  11793. else
  11794. do
  11795. Left1=left(InputMask.SpecIndex,1)
  11796. if Left1<> '-' & Left1 <> '/' then
  11797. Extra=''
  11798. else
  11799. Extra=' (all switches under ' || PpWizardOpSysREAL || ' must start with "' || OptChar || '")'
  11800. UserSyntaxError('No input files matched "' || InputMask.SpecIndex || '"' ||Extra)
  11801. end
  11802. end
  11803. end
  11804. do InputIndex=1 to InputList.0
  11805. TheFile=InputList.InputIndex
  11806. call DBG TheFile
  11807. InpFileCount=InpFileCount+1
  11808. InpFile.InpFileCount=TheFile
  11809. InpFileMaskIndex.InpFileCount=SpecIndex
  11810. DotPos=lastpos('.',TheFile)
  11811. if DotPos<>0 then
  11812. do
  11813. FileExtn=translate(substr(TheFile,DotPos+1))
  11814. if InpFileCount=1 then
  11815. AllSameExtn=FileExtn
  11816. if AllSameExtn<>FileExtn then
  11817. AllSameExtn=''
  11818. end
  11819. end
  11820. call DBGIND-2
  11821. end
  11822. if InputMaskCount<>0&InpFileCount=0 then
  11823. do
  11824. if Option0FilesTotalOk='N' then
  11825. UserSyntaxError('No files matched any of the input file masks (' || InputMaskCount || ') supplied!')
  11826. end
  11827. if AllSameExtn<> '' then
  11828. do
  11829. call DBG 'All input files end in the same extension (".' || AllSameExtn || '")'
  11830. call DBGIND 1
  11831. if OptionPrjExtn='' then
  11832. call DBG 'User has turned off Extensions based project files'
  11833. else
  11834. do
  11835. ExtnFile=ReplaceString(OptionPrjExtn, '*',AllSameExtn)
  11836. ExtnFile=FindProjectFile(ExtnFile)
  11837. if ExtnFile<> '' then
  11838. call ProcessCommandLineBit ExtnFile,OptChar|| 'LIST:' || ReplaceString(ExtnFile, ' ', '{x20}')
  11839. end
  11840. call DBGIND-1
  11841. end
  11842. if ProcessingMode='' then
  11843. do
  11844. call DBG 'User did not specify what mode we are processing with, will default'
  11845. select
  11846. when AllSameExtn='X' then
  11847. call PModeSwitch "REXX"
  11848. otherwise
  11849. call PModeSwitch "HTML"
  11850. end
  11851. call DBG 'Processing all input files in "' || ProcessingMode || '" mode'
  11852. end
  11853. if NewLineChars==CrLf then
  11854. LinesEndWith="CR followed by LF"
  11855. else
  11856. LinesEndWith="LF only"
  11857. call DBG 'Output lines are terminated with ' ||LinesEndWith
  11858. if ProcessingMode='HTML' then
  11859. OptionDefaultInputName="DEFAULT.IT"
  11860. else
  11861. OptionDefaultInputName=""
  11862. if OptionDependsOn<> '' & OptionCgiModeOn = 'Y' then
  11863. UserSyntaxError("Can't do dependancy checking in CGI mode!")
  11864. if ProcessingMode<> 'HTML' & OptionCgiModeOn = 'Y' then
  11865. UserSyntaxError("Must stay in HTML mode when /CGI switch used!")
  11866. if ProcessingMode='HTML' then
  11867. call DBG 'HTML Generator Tags are ' ||DebugRightArrow||OptionHtmlGeneratorTags||DebugLeftArrow
  11868. else
  11869. OptionHtmlGeneratorTags=''
  11870. if OptionOutput='' then
  11871. do
  11872. if ProcessingMode='REXX' then
  11873. do
  11874. if RexSystemOpSys="OS/2" then
  11875. da_O='*.cmd'
  11876. else
  11877. da_O='*.rex'
  11878. end
  11879. else
  11880. do
  11881. da_O='*.htm'
  11882. end
  11883. OptionOutput=da_O
  11884. end
  11885. if OptionWantCopyright='Y' then
  11886. do
  11887. if OptionQuietDependsOn='N' then
  11888. call DisplayCopyright
  11889. end
  11890. call DebugStateChanged
  11891. if InputMaskCount=0 then
  11892. do
  11893. call DBG 'No input masks were specified (or no files matched)...'
  11894. if OptionDefaultInputName='' then
  11895. UserSyntaxError('No input files were specified!')
  11896. if FileQueryExists(OptionDefaultInputName)='' then
  11897. UserSyntaxError('No input files were specified and "' || OptionDefaultInputName || '" not found!')
  11898. InputMask.1=OptionDefaultInputName
  11899. InpFileCount=1
  11900. InpFile.InpFileCount=OptionDefaultInputName
  11901. InpFileMaskIndex.InpFileCount=1
  11902. end
  11903. if IncludeIntoMemory='' then
  11904. do
  11905. if InpFileCount=1 then
  11906. IncludeIntoMemory='N'
  11907. else
  11908. IncludeIntoMemory='Y'
  11909. end
  11910. call DBG 'Will read files into memory cache: ' ||IncludeIntoMemory
  11911. LastProcessingMode=ProcessingMode
  11912. LastOptionOutput=OptionOutput
  11913. LastOptionDependsOn=OptionDependsOn
  11914. PpwExitRc=0
  11915. ActuallyProcessed=0
  11916. FailedProcessingWarning=0
  11917. do InputIndex=1 to InpFileCount
  11918. ThisFile=InpFile.InputIndex
  11919. if symbol("_EXCLUDE_._EXF_" || c2x(ThisFile)) = 'VAR' then
  11920. do
  11921. call DBG ThisFile|| ' excluded - ' || _valueG("_EXCLUDE_._EXF_" ||c2x(ThisFile))
  11922. iterate
  11923. end
  11924. ActuallyProcessed=ActuallyProcessed+1
  11925. call _valueS "_EXCLUDE_._EXF_" || c2x(ThisFile), "Already processed"
  11926. SpecIndex=InpFileMaskIndex.InputIndex
  11927. BaseDir4CurrentInputFile=InputMaskBDir.SpecIndex
  11928. da_Pm=InputMaskPMode.SpecIndex
  11929. if da_Pm='' then
  11930. da_Pm=LastProcessingMode
  11931. ProcessingMode=da_Pm
  11932. da_Om=InputMaskOutMask.SpecIndex
  11933. if da_Om='' then
  11934. da_Om=LastOptionOutput
  11935. OptionOutput=da_Om
  11936. da_Dm=InputMaskDepMask.SpecIndex
  11937. if da_Dm='' then
  11938. da_Dm=LastOptionDependsOn
  11939. OptionDependsOn=da_Dm
  11940. if OptionTemplate='' then
  11941. GenerateRc=GenerateOutput(ThisFile, '')
  11942. else
  11943. GenerateRc=GenerateOutput(OptionTemplate,ThisFile)
  11944. if GenerateRc>PpwExitRc then
  11945. PpwExitRc=GenerateRc
  11946. if OptionDebugOn='Y' then
  11947. call DBG 'The Exit Rc is currently "' || PpwExitRc || '"'
  11948. end
  11949. if ActuallyProcessed=0 then
  11950. do
  11951. if InpFileCount<>0 then
  11952. do
  11953. if Option0FilesTotalAfterExcludeOk='N' then
  11954. UserSyntaxError('All input files (' || InpFileCount || ') were excluded by you!')
  11955. end
  11956. end
  11957. call OutputAnySpellingAdditions
  11958. if OptionQuietDependsOn='Y' &InpFileCountActuallyMade=0 then
  11959. OptionSummary='N'
  11960. if OptionSummary='Y' then
  11961. do
  11962. if ActuallyProcessed<>1 then
  11963. do
  11964. call AboutToGenerateSummary
  11965. call GenerateUserSummaryOverall
  11966. call AddSummaryLine 'Operating Syst' ,PpWizardOpSys
  11967. call AddSummaryLine 'Rexx Version' ,RexVersionInfo
  11968. if InpFileCount=InpFileCountActuallyMade then
  11969. call AddSummaryLine '# files' ,InpFileCount
  11970. else
  11971. call AddSummaryLine '# files made' ,InpFileCountActuallyMade || ' out of ' ||InpFileCount
  11972. call AddSummaryLine 'Exit Code' ,PpwExitRc
  11973. if FailedProcessingWarning<>0 then
  11974. call AddSummaryLine '# Warnings' ,FailedProcessingWarning
  11975. call AddSummaryLine 'Elapsed Time'     ,trunc(time('Elapsed'), 2) || ' seconds'
  11976. call GenerateSummaryLines
  11977. end
  11978. end
  11979. ThatsAllFolks(PpwExitRc)
  11980.  
  11981. SetColorCodes:
  11982. EscapeChar=d2c(27)
  11983. Reset=EscapeChar|| '[0m'
  11984. HighlightColor=EscapeChar|| '[1;35m'
  11985. TitleColor=EscapeChar|| '[0;32m'
  11986. PpwRexxTraceColor=EscapeChar|| '[0;32m'
  11987. ErrorColor=EscapeChar|| '[1;31m'
  11988. WarningColor=EscapeChar|| '[0;33m'
  11989. InfoColor=EscapeChar|| '[0;1m'
  11990. return
  11991.  
  11992. RemoveColorCodes:
  11993. Reset=''
  11994. HighlightColor=''
  11995. TitleColor=''
  11996. ErrorColor=''
  11997. WarningColor=''
  11998. InfoColor=''
  11999. PpwRexxTraceColor=''
  12000. return
  12001.  
  12002. SetBeepCode:
  12003. Beep=''
  12004. return
  12005.  
  12006. RemoveBeepCode:
  12007. Beep=''
  12008. return
  12009.  
  12010. GetSourceFileDateTimeDieOnError:
  12011. DateTimeRc=GetFileDateTimeButDontWarnOnError(arg(1))
  12012. if DateTimeRc=-1 then
  12013. CryAndDie('Could not get date/time stamp of "' || arg(1) || '".')
  12014. return(DateTimeRc)
  12015.  
  12016. GenerateOutput:
  12017. InputFile=arg(1)
  12018. TemplateDataFile=arg(2)
  12019. call ClearCollectedDependancyInfo
  12020. if OptionTemplate='' then
  12021. do
  12022. call DBG 'Main file is not a template, no point loading into memory'
  12023. InFile=InputFile
  12024. ForceBaseFile2Mem='N'
  12025. end
  12026. else
  12027. do
  12028. call DBG 'Main file is a template'
  12029. InFile=TemplateDataFile
  12030. ForceBaseFile2Mem=''
  12031. end
  12032. CurrentOutFile=GenerateFileName(InFile,OptionOutput)
  12033. call ClearDependancyTimeStampCache
  12034. if NeedToRemake(InFile)='N' then
  12035. return(0)
  12036. InpFileCountActuallyMade=InpFileCountActuallyMade+1
  12037. if OptionWantCopyright='Y' then
  12038. do
  12039. if OptionQuietDependsOn='Y' then
  12040. call DisplayCopyright
  12041. end
  12042. InputFileFull=QueryExists(InputFile)
  12043. db_T=value('PPWMAKING_' ||ProcessingMode)
  12044. db_T=ReplaceString(db_T, '{IS}', _filespec('N',InputFileFull))
  12045. db_T=ReplaceString(db_T, '{OS}', _filespec('N',CurrentOutFile))
  12046. db_T=ReplaceString(db_T, '{ID}', _filespec('L',InputFileFull))
  12047. db_T=ReplaceString(db_T, '{OD}', _filespec('L',CurrentOutFile))
  12048. db_T=ReplaceString(db_T, '{IL}',InputFileFull)
  12049. db_T=ReplaceString(db_T, '{OL}',CurrentOutFile)
  12050. db_T=ReplaceString(db_T, '{PM}',ProcessingMode)
  12051. call Line1 TitleColor||db_T
  12052. if ProcessingMode<> 'COPY' then
  12053. call Line1 copies('~',length(db_T))||Reset
  12054. if OptionTemplate='' then
  12055. TmpTemplate=''
  12056. else
  12057. TmpTemplate=TemplateDataFile
  12058. call RexxHookSetBuildingParms InFile,CurrentOutFile,TmpTemplate
  12059. if RexxHookBefore<> '' then
  12060. call CallHook "BEFORE"
  12061. call SetUpOptionsForThisBuild
  12062. Dummy=time('Reset')
  12063. call DBGINDInit
  12064. call StackInitForBuild
  12065. call CompletelyInitializeAutoTagState
  12066. call InitTransformationCode
  12067. call InitOutputHold
  12068. call InitializeCharCodes
  12069. call InitializeDefineRexx
  12070. call InitializeOneLine
  12071. call InitCondNlCount
  12072. call InitOnExitProcessing
  12073. DebugIncludeNumber=0
  12074. Warnings=0
  12075. LineSourceBeingProcessed='?'
  12076. GeneratedLines=0
  12077. InputLines=0
  12078. PartialLine=''
  12079. IncludeLevel=0
  12080. EofForced=''
  12081. LineQueued=''
  12082. PPwizardUnique=0
  12083. StackCnt=0
  12084. OptionStackCnt=0
  12085. HtmlGeneratorTags=OptionHtmlGeneratorTags
  12086. AsIsModeOn='N'
  12087. if OptionCompleteAddToToDepFile='Y' then
  12088. do
  12089. call AddInputFileToDependancyList "*PpwPgm"
  12090. call AddInputFileToDependancyList "*CmdLine"
  12091. end
  12092. call PrepareSpellingForThisBuild
  12093. NewestSourcefile=GetSourceFileDateTimeDieOnError(PpWizardPgmName)
  12094. call InitializeHashDefinesForThisCompile
  12095. IfNesting=0
  12096. IfState.WantLines.0='Y'
  12097. IfState.IfTrue.0='Y'
  12098. IfState.InTrue.0='Y'
  12099. WantLineCache='Y'
  12100. GenerateRc=0
  12101. call CheckRexxInterpreter
  12102. if ProcessingMode='COPY' then
  12103. do
  12104. db_Rc=FileCopy(InputFileFull,CurrentOutFile, 'EQUAL')
  12105. call CreateDependancyFileFromLists
  12106. return(0)
  12107. end
  12108. OutputLevel=0
  12109. Ok2OutputHeader='Y'
  12110. call HaveNewOutputFile CurrentOutFile,,'N',ProcessingMode
  12111. do db_HI=1 to OptionHashIncludeCnt
  12112. db_This=OptionHashInclude.db_HI
  12113. call DBG '/#Include "' ||db_This
  12114. GenerateRc=GenerateRc+ProcessInputFile(db_This)
  12115. end
  12116. GenerateRc=GenerateRc+ProcessInputFile(InputFile,,,ForceBaseFile2Mem)
  12117. if GenerateRc=0 then
  12118. do
  12119. call StackValidation
  12120. if OptionDebugOn='Y' then
  12121. call DBG 'Generation successful so far, look for nesting and other errors'
  12122. select
  12123. when IfNesting<>0 then
  12124. do
  12125. do Index=1 to IfNesting
  12126. NestingLevel=(IfNesting-Index)+1
  12127. call DBG 'Missing #endif at EOF - Nesting Level #' ||NestingLevel||MatchesIfDebugText(NestingLevel)
  12128. end
  12129. CryAndDie('Missing #endif at EOF' ||MatchesIfDebugText(IfNesting))
  12130. end
  12131. when StackCnt<>0 then
  12132. do
  12133. do Index=1 to StackCnt
  12134. NestingLevel=(StackCnt-Index)+1
  12135. call DBG 'Missing #RexxVar pop at EOF - Nesting Level #' ||NestingLevel||MatchesStackPushDebugText(NestingLevel)
  12136. end
  12137. CryAndDie('Incorrect #RexxVar push/pop nesting at EOF' ||MatchesStackPushDebugText(StackCnt))
  12138. end
  12139. when OptionStackCnt<>0 then
  12140. do
  12141. do Index=1 to OptionStackCnt
  12142. NestingLevel=(OptionStackCnt-Index)+1
  12143. call DBG 'Missing pop() at EOF - Nesting Level #' ||NestingLevel||MatchesOptionStackPushDebugText(NestingLevel)
  12144. end
  12145. CryAndDie('Missing #Option pop at EOF' ||MatchesOptionStackPushDebugText(OptionStackCnt))
  12146. end
  12147. when AutoTagStateCnt<>0 then
  12148. do
  12149. do Index=1 to AutoTagStateCnt
  12150. NestingLevel=(AutoTagStateCnt-Index)+1
  12151. call DBG 'Missing #AutoTagState- at EOF - Nesting Level #' ||NestingLevel||MatchesAutoTagStateIncDebugText(NestingLevel)
  12152. end
  12153. CryAndDie('Missing #AutoTagState- at EOF' ||MatchesAutoTagStateIncDebugText(AutoTagStateCnt))
  12154. end
  12155. when DefRexxVar<> '' then
  12156. CryAndDie('Missing #DefineRexx[+] at EOF', 'Block started at ' ||DefRexxStartLoc)
  12157. when TransformCode<> '' then
  12158. CryAndDie('Missing #transform (end) at EOF', 'Block started at ' ||TransformStartLoc)
  12159. when OutputLevel>1 then
  12160. CryAndDie('Missing ' || OutputLevel - 1 || ' #output command(s) at EOF')
  12161. when OutputHoldLvl<>0 then
  12162. CryAndDie('Missing #OutputHold (end) at EOF', 'LAST Block started at ' ||OutHold_.OutputHoldLvl.!OutpHoldStartLoc)
  12163. otherwise
  12164. call DieIfHoldingOutput
  12165. end
  12166. if GeneratedLines=0 then
  12167. call OutputWarningToScreen 'GEN0', 'No output lines generated'
  12168. if OptionDebugOn='Y' then
  12169. call DBG 'No fatal errors detected so far'
  12170. end
  12171. call FileClose CurrentOutFile
  12172. if RexxHookAfter<> '' then
  12173. call CallHook "AFTER"
  12174. if GenerateRc=0 then
  12175. do
  12176. if OptionDebugOn='Y' then
  12177. call DBG 'Looks OK so far, look for even more errors'
  12178. if PartialLine<> '' then
  12179. CryAndDie('A line continued to EOF')
  12180. if ProcessingMode='REXX' then
  12181. call CheckRexxModuleForSyntaxErrors
  12182. else
  12183. call DoSyntaxCheckingOnFileIfEnabled CurrentOutFile
  12184. if OptionValidation<> '' then
  12185. do
  12186. ToExec=ReplaceHashAndStandardDefines(OptionValidation)
  12187. call RunExecOrValidateCmd 'VALIDATE',OptionValidationRc,ToExec
  12188. end
  12189. if Warnings<>0 then
  12190. do
  12191. FailedProcessingWarning=FailedProcessingWarning+1
  12192. GenerateRc=WantedWarningRc
  12193. end
  12194. if OptionNoDepFileOnWarnings='Y' &Warnings<>0 then
  12195. call DBG 'Dependancy file not created as warnings exist'
  12196. else
  12197. call CreateDependancyFileFromLists
  12198. if OptionSummary='Y' then
  12199. do
  12200. if InpFileCount=1 then
  12201. call AboutToGenerateSummary
  12202. else
  12203. call AboutToGenerateSummary 'N'
  12204. call GenerateUserSummaryThisBuild
  12205. call GenerateUserSummaryAllBuilds
  12206. if InpFileCount=1 then
  12207. call GenerateUserSummaryOverall
  12208. if Warnings<>0 then
  12209. call AddSummaryLine 'Warnings'        ,'YES (' || AddCommasToDecimalNumber(Warnings) || ')'
  12210. if InpFileCount=1 then
  12211. do
  12212. call AddSummaryLine 'Operating Syst' ,PpWizardOpSys
  12213. call AddSummaryLine 'Rexx Version' ,RexVersionInfo
  12214. end
  12215. call AddSummaryLine 'Return Code' ,GenerateRc
  12216. call AddSummaryLine 'Elapsed Time'        ,trunc(time('Elapsed'), 2) || ' seconds'
  12217. call GenerateSummaryLines
  12218. end
  12219. end
  12220. call Line1 ''
  12221. call RexxHookSetBuildingParms
  12222. return(GenerateRc)
  12223.  
  12224. MyLineNumber:
  12225. return(SIGL)
  12226.  
  12227. ProcessInputFile:
  12228. RequestedFile=arg(1)
  12229. IncludeFragmentText=arg(2)
  12230. AddToDepFile=arg(3)
  12231. ForceLoadingIntoMemory=arg(4)
  12232. IncludeLineNumber=0
  12233. IncludeMemBufferNextLine=''
  12234. DebugIncludeNumber=DebugIncludeNumber+1
  12235. DebugCurrentFileNumber=DebugIncludeNumber
  12236. IncludeFileName=FindFile(RequestedFile)
  12237. if IncludeFileName='' then
  12238. do
  12239. if IncludeLevel<>0 then
  12240. call RecursiveIncludeRestore
  12241. CryAndDie('File "' || RequestedFile || '" does not exist!')
  12242. end
  12243. IncludeLevel=IncludeLevel+1
  12244. IncludeFileName.IncludeLevel=IncludeFileName
  12245. if IncludeLevel>=InfiniteIncludeLoopWhen then
  12246. do
  12247. if InfiniteIncludeLoopWhen<>0 then
  12248. do
  12249. say 'Infinite #include loop detected, at level #' ||IncludeLevel
  12250. say 'Use "/define:INFINITE_INCLUDE_LOOP_WHEN=0"   to turn off detection'
  12251. say 'Use "/define:INFINITE_INCLUDE_LOOP_WHEN=100" to increase detection threshold etc'
  12252. IncludeLevel=IncludeLevel-1
  12253. call RecursiveIncludeRestore
  12254. CryAndDie("We seem to be in an infinite #include loop!")
  12255. end
  12256. end
  12257. MemUpdateIndex=0
  12258. do IncIndex=1 to IncludeLevel-1
  12259. if RexSystemOpSys="UNIX" then
  12260. IncSame=(IncludeFileName=IncludeFileName.IncIndex)
  12261. else
  12262. IncSame=(translate(IncludeFileName)=translate(IncludeFileName.IncIndex))
  12263. if IncSame=1 then
  12264. do
  12265. if _IncludeMemHandle.IncIndex<> '' then
  12266. call DBG 'File already being processed, already reading from memory cache!'
  12267. else
  12268. do
  12269. call DBG 'File already being processed, forcing use from memory cache'
  12270. call FileClose IncludeFileName
  12271. MemUpdateIndex=IncIndex
  12272. ForceLoadingIntoMemory='Y'
  12273. end
  12274. leave
  12275. end
  12276. end
  12277. if AddToDepFile<> 'N' then
  12278. call AddInputFileToDependancyList(IncludeFileName)
  12279. call OutputProcessingFileStringToScreen '',IncludeFragmentText
  12280. ThisDateTime=GetSourceFileDateTimeDieOnError(IncludeFileName)
  12281. if ThisDateTime>NewestSourcefile then
  12282. NewestSourcefile=ThisDateTime
  12283. parse value IncludeFileOpen(IncludeFileName,ForceLoadingIntoMemory)with IncludeEofLine ';' IncludeMemHandle
  12284. if MemUpdateIndex<>0 then
  12285. do
  12286. _IncludeMemHandle.MemUpdateIndex=IncludeMemHandle
  12287. _IncludeEofLine.MemUpdateIndex=IncludeEofLine
  12288. end
  12289. if IncludeFragmentText<> '' then
  12290. do
  12291. call DBG 'Looking for the start of the fragment'
  12292. do while IncludeFileLines()<>0
  12293. InputLines=InputLines+1
  12294. FileLine=IncludeFileLineIn()
  12295. if pos(IncludeFragmentText,FileLine)<>0 then
  12296. leave
  12297. end
  12298. if IncludeFileLines()=0 then
  12299. do
  12300. FT=IncludeFragmentText
  12301. LP=IncludeLineNumber
  12302. IncludeLevel=IncludeLevel-1
  12303. if IncludeLevel<>0 then
  12304. call RecursiveIncludeRestore
  12305. CryAndDie('Did not find the START of the code fragment "' || FT || '" (processed ' || AddCommasToDecimalNumber(LP) || ' lines)')
  12306. end
  12307. end
  12308. do forever
  12309. LastLineAfterMacroRep=''
  12310. select
  12311. when IncludeMemBufferNextLine\=='' then
  12312. do
  12313. if InLoop='Y' &LoopLinesFromFile=0 then
  12314. do
  12315. db_LC='{'
  12316. FileLine=GetLoopLineIntoFileLine()
  12317. end
  12318. else
  12319. do
  12320. db_LC='#'
  12321. parse var IncludeMemBufferNextLine FileLine (MarksNewLine) IncludeMemBufferNextLine
  12322. end
  12323. LastLine=FileLine
  12324. LineSrc='M'
  12325. if LinesFromOnExit='Y' then
  12326. LastFileLine=FileLine
  12327. if OptionDebugOn='Y' then
  12328. call DebugShowCurrentLineWithLineNumber FileLine,db_LC
  12329. end
  12330. when LineQueued\=='' then
  12331. do
  12332. call FlushQueuedOutput
  12333. iterate
  12334. end
  12335. when InLoop='Y' |IncludeFileLines()<>0 then
  12336. do
  12337. if EofForced<> '' then
  12338. do
  12339. if OptionDebugOn='Y' then
  12340. call DBG '#EOF (at ' || EofForced || ') told us to stop processing this file any further'
  12341. if SetUpOnExitProcessingIfEndOfMainFile()='Y' then
  12342. iterate
  12343. leave
  12344. end
  12345. if InLoop='Y' then
  12346. FileLine=GetLoopLineIntoFileLine()
  12347. else
  12348. do
  12349. InputLines=InputLines+1
  12350. FileLine=IncludeFileLineIn()
  12351. end
  12352. LastFileLine=FileLine
  12353. LastLine=FileLine
  12354. LineSrc='F'
  12355. if OptionDebugOn='Y' then
  12356. call DebugShowCurrentLineWithLineNumber FileLine
  12357. if IncludeFragmentText<> '' then
  12358. do
  12359. if pos(IncludeFragmentText,FileLine)<>0 then
  12360. do
  12361. call DBG 'Found the end of the fragment'
  12362. IncludeFragmentText=''
  12363. leave
  12364. end
  12365. end
  12366. if OptionFilterIn<> '' then
  12367. do
  12368. FileLine=HtmlFilterIn("I",FileLine,IncludeFileName,IncludeLineNumber,InputLines,MarksNewLine)
  12369. if pos(MarksNewLine,FileLine)<>0 then
  12370. do
  12371. IncludeMemBufferNextLine=FileLine
  12372. iterate
  12373. end
  12374. if left(FileLine,1)=NullChar then
  12375. do
  12376. if FileLine=NullChar then
  12377. iterate
  12378. else
  12379. CryAndDie(substr(FileLine,2))
  12380. end
  12381. end
  12382. end
  12383. otherwise
  12384. do
  12385. if SetUpOnExitProcessingIfEndOfMainFile()='Y' then
  12386. iterate
  12387. leave
  12388. end
  12389. end
  12390. if LineSrc<> 'F' then
  12391. do
  12392. LineContinued='N'
  12393. Word1=word(FileLine,1)
  12394. end
  12395. else
  12396. do
  12397. if InterceptCode<> '' then
  12398. do
  12399. if FileLine=InterceptOffMarker then
  12400. do
  12401. if OptionDebugOn='Y' then
  12402. call DBG 'Intercepted line looks like end of block, not processed'
  12403. end
  12404. else
  12405. do
  12406. BeforeLine=FileLine
  12407. call ExecRexxCmd InterceptCode
  12408. if OptionDebugOn='Y' then
  12409. do
  12410. if BeforeLine==FileLine then
  12411. call DBG 'Intercepted line was not changed'
  12412. else
  12413. call DBG 'Intercepted Line changed to ' ||DebugRightArrow||FileLine||DebugLeftArrow
  12414. end
  12415. if BeforeLine\==FileLine then
  12416. do
  12417. if pos(MarksNewLine,FileLine)<>0 then
  12418. do
  12419. if IncludeMemBufferNextLine=='' then
  12420. IncludeMemBufferNextLine=FileLine
  12421. else
  12422. IncludeMemBufferNextLine=FileLine||MarksNewLine||IncludeMemBufferNextLine
  12423. iterate
  12424. end
  12425. end
  12426. end
  12427. end
  12428. if NextIdReplOn='Y' then
  12429. do
  12430. NidReplaceCount=ReplaceCount
  12431. FileLine=ReplaceString(FileLine,NextIdMarker,NextIdNew)
  12432. if NidReplaceCount<>ReplaceCount then
  12433. NextIdUsed='Y'
  12434. end
  12435. if AsIsModeOn='Y' then
  12436. FileLine=ExpandAsIsTags(FileLine)
  12437. if AutoTagOn='Y' then
  12438. FileLine=AutoTag(FileLine)
  12439. if pos(TabChar,FileLine)<>0 then
  12440. do
  12441. if OptionDebugOn='Y' then
  12442. call DBG 'Tab(s) found'
  12443. select
  12444. when OptionTabs='W' then
  12445. do
  12446. call OutputWarningToScreen 'T000', 'There are TABS in the source (converted to spaces)!'
  12447. FileLine=translate(FileLine, ' ',TabChar)
  12448. end
  12449. when OptionTabs='T' then
  12450. do
  12451. FileLine=translate(FileLine, ' ',TabChar)
  12452. end
  12453. when OptionTabs='E' then
  12454. do
  12455. FileLine=ExpandTabs(FileLine,WidthOfTab)
  12456. end
  12457. otherwise
  12458. do
  12459. end
  12460. end
  12461. end
  12462. if OptionHideCmdS_L<>0 then
  12463. do
  12464. PosS=pos(OptionHideCmdS,FileLine)
  12465. if PosS<>0 then
  12466. do
  12467. if OptionDebugOn='Y' then
  12468. do
  12469. call DBG 'At least one hidden command'
  12470. call DBGIND 1
  12471. end
  12472. RightBit=FileLine
  12473. LeftBit=''
  12474. do while PosS<>0
  12475. PosE=pos(OptionHideCmdE,RightBit,PosS)
  12476. if PosE=0 then
  12477. CryAndDie('Found start of hidden command ("' || OptionHideCmd || '"), but not the end!')
  12478. Hidden=strip(substr(RightBit,PosS+OptionHideCmdS_L,(PosE-PosS)-OptionHideCmdS_L))
  12479. if OptionDebugOn='Y' then
  12480. call DBG 'Found: ' ||DebugRightArrow||Hidden||DebugLeftArrow
  12481. LeftBit=LeftBit||left(RightBit,PosS-1)||Hidden
  12482. RightBit=substr(RightBit,PosE+OptionHideCmdE_L)
  12483. PosS=pos(OptionHideCmdS,RightBit)
  12484. end
  12485. FileLine=LeftBit||RightBit
  12486. if OptionDebugOn='Y' then
  12487. do
  12488. call DBG 'NewLine: ' ||DebugRightArrow||FileLine||DebugLeftArrow
  12489. call DBGIND-1
  12490. end
  12491. end
  12492. end
  12493. FileLine=strip(FileLine, 'T')
  12494. CmtPos=lastpos(InLineComment,FileLine)
  12495. if CmtPos<>0 then
  12496. do
  12497. AddToEnd=''
  12498. if right(FileLine,1)=LineContChar then
  12499. do
  12500. Right2=right(FileLine,2)
  12501. if Right2=LineContAddNewLine|Right2=LineContAddNewLineObs|Right2=LineContWithoutSpace|Right2=LineContWithSpace|Right2=LineContDefault then
  12502. do
  12503. AddToEnd=' ' ||Right2
  12504. end
  12505. end
  12506. FileLine=strip(left(FileLine,CmtPos-1), 'T')||AddToEnd
  12507. end
  12508. if ProcessingMode='REXX' then
  12509. do
  12510. if OptionDebugOn='N' then
  12511. do
  12512. if OptionKeepRexxCmts='N' &right(FileLine,2)=RexxCmtEnd then
  12513. do
  12514. StartCmtPos=lastpos(RexxCmtStart,FileLine)
  12515. if StartCmtPos<>0 then
  12516. do
  12517. if StartCmtPos=0 then
  12518. FileLine=''
  12519. else
  12520. FileLine=strip(left(FileLine,StartCmtPos-1), 'T')
  12521. if FileLine='' then
  12522. iterate
  12523. end
  12524. end
  12525. end
  12526. end
  12527. if LineContChar=NullChar then
  12528. LineContinued='N'
  12529. else
  12530. do
  12531. if right(FileLine,1)<>LineContChar then
  12532. LineContinued='N'
  12533. else
  12534. do
  12535. Right2=right(FileLine,2)
  12536. MainBit=strip(left(FileLine,length(FileLine)-2), 'T')
  12537. select
  12538. when Right2=LineContWithoutSpace then
  12539. do
  12540. LineContinued='Y'
  12541. FileLine=MainBit
  12542. end
  12543. when Right2=LineContWithSpace|Right2=LineContDefault then
  12544. do
  12545. FileLine=MainBit
  12546. LineContinued='YS'
  12547. end
  12548. when Right2=LineContAddNewLine then
  12549. do
  12550. LineContinued='Y'
  12551. FileLine=MainBit||CodexNewLine
  12552. end
  12553. when Right2=LineContAddNewLineObs then
  12554. do
  12555. call WarnAboutDepreciatedFeature 'Line continuation using downarrow.  Replace with -> "%\"'
  12556. LineContinued='Y'
  12557. FileLine=MainBit||CodexNewLine
  12558. end
  12559. otherwise
  12560. LineContinued='N'
  12561. end
  12562. end
  12563. end
  12564. if FileLine='' then
  12565. do
  12566. if LeaveBlankLines='N' then
  12567. do
  12568. if OptionDebugOn='Y' then
  12569. call DebugShowLineDropped "Blank Line"
  12570. if LineContinued='N' & PartialLine \== '' then
  12571. do
  12572. if IncludeMemBufferNextLine=='' then
  12573. IncludeMemBufferNextLine=PartialLine
  12574. else
  12575. IncludeMemBufferNextLine=PartialLine||MarksNewLine||IncludeMemBufferNextLine
  12576. PartialLine=''
  12577. end
  12578. iterate
  12579. end
  12580. end
  12581. Word1=word(FileLine,1)
  12582. if left(Word1,1)=LineComment then
  12583. do
  12584. if LineContinued='N' & PartialLine \== '' then
  12585. do
  12586. if OptionDebugOn='Y' then
  12587. call DebugWarning 'Line continuation ends with a comment line'
  12588. if IncludeMemBufferNextLine=='' then
  12589. IncludeMemBufferNextLine=PartialLine
  12590. else
  12591. IncludeMemBufferNextLine=PartialLine||MarksNewLine||IncludeMemBufferNextLine
  12592. PartialLine=''
  12593. end
  12594. iterate
  12595. end
  12596. if LineSrc='F' then
  12597. do
  12598. if KeepIndent='N' then
  12599. FileLine=strip(FileLine, 'L')
  12600. else
  12601. FileLine=LeftIndent||FileLine
  12602. end
  12603. if PartialLine<> '' then
  12604. do
  12605. if left(Word1,HashPrefixLng)<>HashPrefix then
  12606. do
  12607. PartialLine=PartialLine||FileLine
  12608. end
  12609. else
  12610. do
  12611. parse var FileLine TheHashCmd TheRest
  12612. TheRest=strip(TheRest)
  12613. FileLine=TheHashCmd|| ' ' ||TheRest
  12614. PartialLine=PartialLine||PpwCmdDivider1||FileLine||PpwCmdDivider1
  12615. if LineContinued='YS' then
  12616. LineContinued='Y'
  12617. end
  12618. end
  12619. if LineContinued='N' then
  12620. do
  12621. if PartialLine\=='' then
  12622. do
  12623. if IncludeMemBufferNextLine=='' then
  12624. IncludeMemBufferNextLine=PartialLine
  12625. else
  12626. IncludeMemBufferNextLine=PartialLine||MarksNewLine||IncludeMemBufferNextLine
  12627. PartialLine=''
  12628. iterate
  12629. end
  12630. end
  12631. else
  12632. do
  12633. if PartialLine=='' then
  12634. do
  12635. PartialLine=FileLine
  12636. if translate(left(Word1,length(CmdHashDefine)))=CmdHashDefine then
  12637. PpwCmdDivider1=MarksNewLineInHashDefine
  12638. else
  12639. PpwCmdDivider1=MarksNewLine
  12640. end
  12641. if LineContinued='YS' then
  12642. PartialLine=PartialLine|| ' '
  12643. iterate
  12644. end
  12645. end
  12646. if OneLineLevel<>0 then
  12647. do
  12648. FileLine=AddToOneLine(FileLine)
  12649. if FileLine=='' then
  12650. iterate
  12651. else
  12652. do
  12653. if IncludeMemBufferNextLine=='' then
  12654. IncludeMemBufferNextLine=FileLine
  12655. else
  12656. IncludeMemBufferNextLine=FileLine||MarksNewLine||IncludeMemBufferNextLine
  12657. LastFileLine=FileLine
  12658. iterate
  12659. end
  12660. end
  12661. if left(Word1,HashPrefixLng)=HashPrefix then
  12662. do
  12663. parse var FileLine HashCmd SecondWordEtc
  12664. HashCmd=translate(HashCmd)
  12665. HashRc='?'
  12666. select
  12667. when HashCmd=CmdHashIf then
  12668. do
  12669. HashRc=ProcessHashIfTest(FileLine)
  12670. end
  12671. when HashCmd=CmdHashIfDef then
  12672. do
  12673. HashRc=ProcessHashIfTest(FileLine)
  12674. end
  12675. when HashCmd=CmdHashIfnDef then
  12676. do
  12677. HashRc=ProcessHashIfTest(FileLine)
  12678. end
  12679. when HashCmd=CmdHashElseifL|HashCmd=CmdHashElseifS then
  12680. HashRc=ProcessHashElse(SecondWordEtc)
  12681. when HashCmd=CmdHashEndifL|HashCmd=CmdHashEndifS then
  12682. HashRc=ProcessHashEndif(SecondWordEtc)
  12683. otherwise
  12684. end
  12685. if HashRc<> '?' then
  12686. do
  12687. if HashRc<> 'OK' then
  12688. call CryAndDie 'Hash command failed, Rc = ' ||HashRc
  12689. else
  12690. do
  12691. WantLineCache=WantLine()
  12692. iterate
  12693. end
  12694. end
  12695. end
  12696. if WantLineCache='N' then
  12697. do
  12698. if OptionDebugOn='Y' then
  12699. call DebugShowLineDropped "False"
  12700. iterate
  12701. end
  12702. if left(Word1,HashPrefixLng)=HashPrefix then
  12703. do
  12704. call ProcessHashCommand FileLine
  12705. end
  12706. else
  12707. do
  12708. if DefRexxVar<> '' then
  12709. do
  12710. call AddDefineRexxLine FileLine
  12711. iterate
  12712. end
  12713. if ReplacementsAllowed='Y' then
  12714. do
  12715. NowCount=ReplaceCount
  12716. FileLine=ReplaceHashAndStandardDefines(FileLine,, 'Y')
  12717. if HtmlGeneratorTags<> '' then
  12718. do
  12719. FileLineU=translate(FileLine)
  12720. InsertTags=''
  12721. LookFor="<HEAD>"
  12722. TagPos=pos(LookFor,FileLineU)
  12723. if TagPos<>0 then
  12724. do
  12725. InsertTags=TagSvNewLine||HtmlGeneratorTags||TagSvNewLine
  12726. InsertAt=TagPos+length(LookFor)
  12727. end
  12728. else
  12729. do
  12730. LookFor="<BODY"
  12731. TagPos=pos(LookFor,FileLineU)
  12732. if TagPos<>0 then
  12733. do
  12734. InsertTags='<head>' || TagSvNewLine || '  ' || HtmlGeneratorTags || TagSvNewLine || '</head>' ||TagSvNewLine
  12735. InsertAt=TagPos
  12736. end
  12737. end
  12738. if InsertTags\=='' then
  12739. do
  12740. call DBG 'Found "' || LookFor || '" so inserted HTML generator tags'
  12741. FileLine=insert(InsertTags,FileLine,InsertAt-1)
  12742. FileLine=ReplaceHashAndStandardDefines(FileLine,, 'Y')
  12743. HtmlGeneratorTags=''
  12744. end
  12745. end
  12746. if ExpandXEarly='Y' then
  12747. do
  12748. if pos(StartsStdSymbolReplacement_x,FileLine)<>0 then
  12749. FileLine=ReplaceTheXCodesWeKnowExist(FileLine)
  12750. end
  12751. if NowCount<>ReplaceCount then
  12752. do
  12753. if pos(MarksNewLine,FileLine)<>0 then
  12754. do
  12755. if IncludeMemBufferNextLine=='' then
  12756. IncludeMemBufferNextLine=FileLine
  12757. else
  12758. IncludeMemBufferNextLine=FileLine||MarksNewLine||IncludeMemBufferNextLine
  12759. iterate
  12760. end
  12761. end
  12762. if ExpandXLate='Y' then
  12763. do
  12764. if pos(StartsStdSymbolReplacement_x,FileLine)<>0 then
  12765. FileLine=ReplaceTheXCodesWeKnowExist(FileLine)
  12766. end
  12767. end
  12768. if TransformCode<> '' then
  12769. do
  12770. BeforeLine=FileLine
  12771. FileRest=FileLine
  12772. FileAfter=''
  12773. AppendWith=''
  12774. do until FileRest==''
  12775. parse var FileRest FileLine (MarksNewLine) FileRest
  12776. call ExecRexxCmd TransformCode
  12777. FileAfter=FileAfter||AppendWith||FileLine
  12778. AppendWith=MarksNewLine
  12779. end
  12780. FileLine=FileAfter
  12781. if OptionDebugOn='Y' then
  12782. do
  12783. if BeforeLine==FileLine then
  12784. call DBG 'Line was not transformed'
  12785. else
  12786. call DBG 'Line transformed to ' ||DebugRightArrow||FileLine||DebugLeftArrow
  12787. end
  12788. end
  12789. if LineSrc='M' then
  12790. do
  12791. LineQueued=LineQueued||FileLine
  12792. iterate
  12793. end
  12794. do until FileLine == ''; parse var FileLine This1 (MarksNewLine) FileLine; if  ProcessingMode  = 'REXX' then call OutputRexxLine This1; else do; if  ProcessingMode <> 'HTML' then call GenerateOneLine This1; else do; call GenerateOneLine This1; end; end; end
  12795. end
  12796. end
  12797. EofForced=''
  12798. call IncludeFileClose
  12799. if IncludeFragmentText<> '' then
  12800. CryAndDie('Did not find the END of the code fragment "' || IncludeFragmentText || '"!')
  12801. IncludeLevel=IncludeLevel-1
  12802. if OptionDebugOn='Y' then
  12803. call DBG 'Finished processing the input file'
  12804. return(0)
  12805.  
  12806. OutputProcessingFileStringToScreen:
  12807. parse arg ProcessingWhat,ProcessingFrag
  12808. if ProcessingWhat='' then
  12809. ProcessingWhat=IncludeFileName
  12810. if ProcessingFrag<> '' then
  12811. ProcessingFrag='(' || ProcessingFrag || ')'
  12812. call Line1 copies("  ", IncludeLevel) || ' * Processing: ' ||ProcessingWhat||ProcessingFrag
  12813. return
  12814.  
  12815. FlushQueuedOutput:
  12816. if LineQueued=='' then
  12817. return
  12818. LineSrc='Q'
  12819. FileLine=LineQueued
  12820. LineQueued=''
  12821. if OptionDebugOn='Y' then
  12822. call DebugShowCurrentLineWithLineNumber FileLine, '+'
  12823. do until FileLine == ''; parse var FileLine This1 (MarksNewLine) FileLine; if  ProcessingMode  = 'REXX' then call OutputRexxLine This1; else do; if  ProcessingMode <> 'HTML' then call GenerateOneLine This1; else do; call GenerateOneLine This1; end; end; end
  12824. return
  12825.  
  12826. OutputInformationToScreen:
  12827. if OptionWantInfoMsgs='Y' then
  12828. do
  12829. InfoText=arg(1)
  12830. if IncludeLevel=0 then
  12831. LineText=''
  12832. else
  12833. LineText='(@' || AddCommasToDecimalNumber(IncludeLineNumber) || ')'
  12834. call Line1 copies("  ", IncludeLevel) || InfoColor || '   ' || LineText || 'INFO: ' ||InfoText||Reset
  12835. end
  12836. return
  12837.  
  12838. ProcessHashCommand:
  12839. HashCmdMc=word(arg(1),1)
  12840. HashCmd=translate(HashCmdMc)
  12841. HashCmdParms=subword(arg(1),2)
  12842. select
  12843. when HashCmd=CmdHashDefine then
  12844. return(ProcessDefine(HashCmdParms))
  12845. when HashCmd=CmdHashDefinePlus then
  12846. return(ProcessDefine(HashCmdParms, 'Y'))
  12847. when HashCmd=CmdHashRexxVar then
  12848. return(ProcessRexxVar(HashCmdParms))
  12849. when HashCmd=CmdHashEvaluateL|HashCmd=CmdHashEvaluateS then
  12850. return(ProcessEvaluate(HashCmdParms))
  12851. when HashCmd=CmdHashEvaluatePlusL|HashCmd=CmdHashEvaluatePlusS then
  12852. return(ProcessEvaluate(HashCmdParms, 'Y'))
  12853. when HashCmd=CmdHashAutoTag then
  12854. do
  12855. ProcessRc=ProcessAutoTag(HashCmdParms)
  12856. return(ProcessRc)
  12857. end
  12858. when HashCmd=CmdHashUndefL|HashCmd=CmdHashUndefS then
  12859. return(HandleUndefCommand(HashCmdParms))
  12860. when HashCmd=CmdHashOption then
  12861. return(ProcessOption(HashCmdParms))
  12862. when HashCmd=CmdHashLoopS then
  12863. return(ProcessLoopStart(HashCmdParms))
  12864. when HashCmd=CmdHashLoopBreak then
  12865. return(ProcessLoopBreak(HashCmdParms))
  12866. when HashCmd=CmdHashLoopContinue then
  12867. return(ProcessLoopContinue(HashCmdParms))
  12868. when HashCmd=CmdHashInclude then
  12869. do
  12870. IncludeParms=strip(PerformReplacementsInCmdsParameters(HashCmdParms))
  12871. if IncludeParms="" then
  12872. return(CryAndDie("No filename specified on #include line!"))
  12873. QuoteChar=left(IncludeParms,1)
  12874. if QuoteChar<> '"' & QuoteChar <> "'" & QuoteChar <> "<" then
  12875. do
  12876. parse var IncludeParms IncludeName Fragment
  12877. end
  12878. else
  12879. do
  12880. if QuoteChar="<" then
  12881. QuoteChar='>'
  12882. IncludeParms=substr(IncludeParms,2)
  12883. QuotePos=pos(QuoteChar,IncludeParms)
  12884. if QuotePos=0 then
  12885. CryAndDie('Could not find the ending quote for the included filename')
  12886. IncludeName=left(IncludeParms,QuotePos-1)
  12887. Fragment=substr(IncludeParms,QuotePos+1)
  12888. if IncludeName='' then
  12889. CryAndDie('Invalid #include command, no filename passed!')
  12890. end
  12891. if Fragment<> '' then
  12892. Fragment=GetQuotedText(Fragment)
  12893. call RecursiveIncludeSave
  12894. call ProcessInputFile IncludeName,Fragment
  12895. call RecursiveIncludeRestore
  12896. call OutputProcessingFileStringToScreen '',IncludeFragmentText
  12897. return(0)
  12898. end
  12899. when HashCmd=CmdHashImport then
  12900. return(ProcessImport(HashCmdParms))
  12901. when HashCmd=CmdHashOutput then
  12902. return(ProcessHashOutput(HashCmdParms))
  12903. when HashCmd=CmdHashOutputHold then
  12904. return(ProcessHashOutputHold(HashCmdParms))
  12905. when HashCmd=CmdHashDefineRexx then
  12906. return(ProcessDefineRexx(HashCmdParms))
  12907. when HashCmd=CmdHashDefineRexxPlus then
  12908. return(ProcessDefineRexx(HashCmdParms, 'Y'))
  12909. when HashCmd=CmdHashDefineIfReq then
  12910. return(ProcessDefine(HashCmdParms, '?'))
  12911. when HashCmd=CmdHash1Line then
  12912. return(ProcessOneLine(HashCmdParms,CmdHash1LineEnd))
  12913. when HashCmd=CmdHashOneLine then
  12914. return(ProcessOneLine(HashCmdParms))
  12915. when HashCmd=CmdHashMacroSpace then
  12916. do
  12917. call NotAvailableUnderNtYet HashCmd
  12918. Rest=PerformReplacementsInCmdsParameters(HashCmdParms)
  12919. MsCommand=translate(GetQuotedText(Rest, "Rest"))
  12920. MsFile=GetQuotedText(Rest, "Rest")
  12921. if Rest='' then
  12922. MsFunction=''
  12923. else
  12924. MsFunction=GetQuotedText(Rest)
  12925. if MsCommand<> 'ADD' & MsCommand <> 'DROP' then
  12926. CryAndDie('The macro space command "' || MsCommand || '" is unknown!')
  12927. if QueryExists(MsFile)='' then
  12928. CryAndDie('The rexx file "' || MsFile || '" does not exist!')
  12929. call DoMacroSpaceOperation MsCommand,MsFile,MsFunction
  12930. return(0)
  12931. end
  12932. when HashCmd=CmdHashAsIs then
  12933. return(ProcessAsIs(HashCmdParms))
  12934. when HashCmd=CmdHashWarningL|HashCmd=CmdHashWarningS then
  12935. return(ProcessHashWarning(HashCmdParms))
  12936. when HashCmd=CmdHashInfo then
  12937. do
  12938. InfoMsg=PerformReplacementsInCmdsParameters(HashCmdParms)
  12939. InfoMsg=GetQuotedRest(InfoMsg)
  12940. call OutputInformationToScreen InfoMsg
  12941. return(0)
  12942. end
  12943. when HashCmd=CmdHashPush then
  12944. return(ProcessPush(HashCmdParms))
  12945. when HashCmd=CmdHashPop then
  12946. return(ProcessPop(HashCmdParms))
  12947. when HashCmd=CmdHashAutoTagState then
  12948. return(ProcessAutoTagState(HashCmdParms))
  12949. when HashCmd=CmdHashAutoTagClear then
  12950. return(ProcessAutoTagClear(HashCmdParms))
  12951. when HashCmd=CmdHashDependsOn then
  12952. return(ProcessDependsOn(HashCmdParms))
  12953. when HashCmd=CmdHashOnExit then
  12954. return(ProcessOnExit(HashCmdParms))
  12955. when HashCmd=CmdHashEof then
  12956. do
  12957. if HashCmdParms<> '' then
  12958. do
  12959. EndifCounter=GetQuotedText(HashCmdParms)
  12960. EndifCounter=PerformReplacementsInCmdsParameters(EndifCounter)
  12961. if datatype(EndifCounter, 'W')=0 then
  12962. CryAndDie('Invalid #endif simulate count of "' || EndifCounter || '" supplied!')
  12963. do EndifIndex=1 to EndifCounter
  12964. call ProcessHashEndif
  12965. end
  12966. end
  12967. EofForced=CurrentSourceLocation()
  12968. return(0)
  12969. end
  12970. when HashCmd=CmdHashTransform then
  12971. return(ProcessTransform(HashCmdParms))
  12972. when HashCmd=CmdHashIntercept then
  12973. return(ProcessIntercept(HashCmdParms,HashCmdMc))
  12974. when HashCmd=CmdHashSystem then
  12975. return(ProcessSystem(HashCmdParms))
  12976. when HashCmd=CmdHashDebug then
  12977. return(ProcessHashDebug(HashCmdParms))
  12978. when HashCmd=CmdHashRequire then
  12979. return(ProcessRequire(HashCmdParms))
  12980. when HashCmd=CmdHashNextId then
  12981. return(ProcessNextId(HashCmdParms))
  12982. when HashCmd=CmdHashErrorL|HashCmd=CmdHashErrorS then
  12983. call ProcessHashError HashCmdParms
  12984. otherwise
  12985. do
  12986. if UserHashCmds='' then
  12987. call LookForUnknownCmdHandler
  12988. if UserHashCmds<> '' then
  12989. return(ProcessUnknownHashCommand(HashCmd,HashCmdParms))
  12990. if HashCmd=CmdHashLoopE then
  12991. CryAndDie('Missing "' || CmdHashLoopS || '" command')
  12992. else
  12993. CryAndDie("Invalid '#' command line of: " ||HashCmd)
  12994. end
  12995. end
  12996. return(0)
  12997.  
  12998. ProcessHashError:
  12999. ErrorMsg=GetQuotedRest(PerformReplacementsInCmdsParameters(arg(1)))
  13000. ErrorMsg=ReplaceString(ErrorMsg, '{NL}',MarksNewLine)
  13001. CryAndDie(ErrorMsg)
  13002.  
  13003. IsStringOnOrOffCmd:
  13004. OoCmd=translate(arg(1))
  13005. if OoCmd='+' | OoCmd = 'YES' |  OoCmd = 'ON' then
  13006. return('Y')
  13007. else
  13008. do
  13009. if OoCmd='-' | OoCmd = 'NO' |  OoCmd = 'OFF' then
  13010. return('N')
  13011. end
  13012. return('')
  13013.  
  13014. SetOnorOffVariable:
  13015. parse arg OnOffSrc,VarName
  13016. OnOrOffText=translate(GetQuotedText(OnOffSrc))
  13017. OnOrOff=IsStringOnOrOffCmd(OnOrOffText)
  13018. if OnOrOff='' then
  13019. CryAndDie(HashCmd|| ' command does not specify a correct value value (ON/OFF)!')
  13020. call _valueS VarName,OnOrOff
  13021. return(0)
  13022.  
  13023. DisplayCopyright:
  13024. if CopyrightDisplayed='N' then
  13025. do
  13026. if symbol("WizName") <> "VAR" then
  13027. WizName='PPWIZARD.REX'
  13028. call Char1 HighlightColor
  13029. call Line1 '[]---------------------------------------------------------[]'
  13030. call Line1 '| ' || WizName || ': Version ' || PgmVersion || ' (' || PgmAuthorEmail || ')   |'
  13031. call Line1 '| ' || PgmAuthorHomePage || '            |'
  13032. call Line1 '| (C)opyright ' || PgmAuthor || ' 1997-2001. ALL RIGHTS RESERVED. |'
  13033. call Line1 '[]---------------------------------------------------------[]'
  13034. call Line1 Reset
  13035. CopyrightDisplayed='Y'
  13036. end
  13037. return
  13038.  
  13039. CheckRexxInterpreter:
  13040. if RexWhich='REGINA' then
  13041. do
  13042. if pos(RexVerRegina,SupportedReginaVersions)<>0 then
  13043. return(0)
  13044. criText='The Regina "' || RexVerRegina || '" interpreter is unsupported, use ' || SupportedReginaVersions || ' instead! I recommend "' || RecommendedReginaVersions || '"'
  13045. if arg(1)='Y' then
  13046. call DBG criText
  13047. else
  13048. call OutputWarningToScreen 'URI0',criText
  13049. return(1)
  13050. end
  13051. return(0)
  13052.  
  13053. GetCurrentDirectory:
  13054. if RexWhich='STANDARD_OS/2' then
  13055. cwDir=directory()
  13056. else
  13057. do
  13058. cwDir=FileQueryExists('.')
  13059. cwDirRegina=cwDir
  13060. cwLength=length(cwDir)
  13061. if lastpos(RexDirChar,cwDir)=cwLength then
  13062. do
  13063. if RexSystemOpSys="UNIX" then
  13064. do
  13065. if cwDir<>RexDirChar then
  13066. cwDir=left(cwDir,cwLength-1)
  13067. end
  13068. else
  13069. do
  13070. cwColonPos=pos(':',cwDir)
  13071. if cwColonPos+1<>cwLength then
  13072. cwDir=left(cwDir,cwLength-1)
  13073. end
  13074. end
  13075. if cwDirRegina<>cwDir then
  13076. call DBG 'Regina returned "' || cwDirRegina || '" for current directory'
  13077. end
  13078. if OptionDebugOn='Y' then
  13079. call DBG 'Current Directory = "' || cwDir || '"'
  13080. return(cwDir)
  13081.  
  13082. GetListOfFiles:
  13083. parse arg glfMask,glfStem,glfFollowDirs
  13084. call DBG 'GetListOfFiles("' || glfMask || '"): Follow Directories = "' || glfFollowDirs || '"'
  13085. call DBGIND 1
  13086. call _valueS glfStem|| '.0',0
  13087. if RexxHookGetFileList='' then
  13088. do
  13089. if glfFollowDirs='N' then
  13090. glfFollowDirs=''
  13091. else
  13092. glfFollowDirs='S'
  13093. call DBG 'Using "_SysFileTree()" as "GetFileList" hook not used'
  13094. call _SysFileTree glfMask,glfStem, 'FO' ||glfFollowDirs
  13095. end
  13096. else
  13097. do
  13098. call DBG 'Not using "_SysFileTree()" as user specified use of "' || RexxHookGetFileList || '"'
  13099. glfTmpFile=RexGetTmpFileName()
  13100. call MustDeleteFile glfTmpFile
  13101. glfLocn=_filespec('Location',glfMask)
  13102. glfName=_filespec('Name',glfMask)
  13103. call CallHook "GETFILELIST",,glfLocn,glfName,glfFollowDirs,glfTmpFile
  13104. if QueryExists(glfTmpFile)='' then
  13105. CryAndDie('"' || RexxHookGetFileList || '" did not create the file list!')
  13106. glfLine=0
  13107. glfCount=0
  13108. do while lines(glfTmpFile)<>0
  13109. CurrentLine=linein(glfTmpFile)
  13110. glfLine=glfLine+1
  13111. if CurrentLine<> '' then
  13112. do
  13113. FullFile=QueryExists(CurrentLine)
  13114. if FullFile='' then
  13115. CryAndDie('"' || RexxHookGetFileList || '" specified an invalid file of "' || CurrentLine || '" on line #' ||glfLine)
  13116. glfCount=glfCount+1
  13117. call _valueS glfStem|| '.' ||glfCount,CurrentLine
  13118. end
  13119. end
  13120. call FileClose glfTmpFile
  13121. call _valueS glfStem|| '.0',glfCount
  13122. if OptionDebugOn='N' then
  13123. call MustDeleteFile glfTmpFile
  13124. end
  13125. call DBGIND-1
  13126. return
  13127.  
  13128. NiceDateTime:
  13129. return(date('Weekday') || ', ' || date() || ' ' ||GetAmPmTime())
  13130.  
  13131. GetInputFileNameAndLine:call TRACE "OFF"
  13132.  
  13133. CurrentSourceLocation:
  13134. if IncludeLevel<>0 then
  13135. return('line ' || AddCommasToDecimalNumber(IncludeLineNumber) || ' of "' || IncludeFileName || '"')
  13136. else
  13137. do
  13138. if arg(1, 'E')then
  13139. return(arg(1))
  13140. else
  13141. return("unknown")
  13142. end
  13143.  
  13144. GetLineBeingProcessed:call TRACE "OFF"
  13145. return(strip(LastLine))
  13146.  
  13147. GetFileLineBeingProcessed:call TRACE "OFF"
  13148. return(strip(LastFileLine))
  13149.  
  13150. DumpVarsIfCompoundVariable:
  13151. if pos('.',arg(1))<>0 then
  13152. ExpressionKilledUs=arg(1)
  13153. return
  13154.  
  13155. CheckForNotBeingAbleToExecAnything:
  13156. if RexWhich='REGINA' then
  13157. do
  13158. if RexSystemOpSys="UNIX" then
  13159. Exe=''
  13160. else
  13161. Exe='.exe'
  13162. RexxExe="rexx" ||Exe
  13163. ReginaExe="regina" ||Exe
  13164. DoWhat='Test for use of buggy regina "' || ReginaExe || '" rather than "' || RexxExe || '" executable'
  13165. call DBG DoWhat
  13166. TmpFile=RexGetTmpFileName()
  13167. call AddressCmd 'echo ' ||DoWhat||RedirectStdOutAndErr2(TmpFile),TmpFile
  13168. if FileQueryExists(TmpFile)='' then
  13169. do
  13170. Line1="Can't execute shell functions!"
  13171. if RexSystemOpSys<> "UNIX" then
  13172. do
  13173. Line3='It''s possible that your "TMP" or "TEMP" environment variables'
  13174. Line4='are corrupt.'
  13175. end
  13176. else
  13177. do
  13178. Line3='If you used regina''s "' || ReginaExe || '" executable then try the "' || RexxExe || '"'
  13179. Line4='one instead!'
  13180. end
  13181. Line5='Could not create "' || TmpFile || '"'
  13182. Line7='Please report the problem to "' || PgmAuthorEmail || '" (please attach'
  13183. Line8='zipped output with "' || OptChar  || 'debug" switch used)!'
  13184. CryAndDie(Line1, '', Line3, Line4, Line5, '',Line7,Line8)
  13185. end
  13186. call _SysFileDelete TmpFile
  13187. call DBG 'Looks OK to me!'
  13188. end
  13189. return
  13190.  
  13191. LookLikeASingleFile:
  13192. FileName=arg(1)
  13193. call DBG 'No files matched "' || FileName || '", does it look like a single file?'
  13194. if verify(FileName, '*?', 'M')<>0 then
  13195. NormalFile='N'
  13196. else
  13197. do
  13198. if FileQueryExists(FileName)='' then
  13199. NormalFile='N'
  13200. else
  13201. NormalFile='Y'
  13202. end
  13203. call DBGIND 1
  13204. call DBG 'Normal File: ' ||NormalFile
  13205. call DBGIND-1
  13206. return(NormalFile)
  13207.  
  13208. CryAndDie:
  13209. SynErrLine=SIGL
  13210. SynErrLineC=AddCommasToDecimalNumber(SynErrLine)
  13211. call DBGINDInit
  13212. call DBG 'Fatal Error Detected (at line ' || SynErrLineC || ' of ppwizard)'
  13213. call DBGIND 1
  13214. PpwSize=FileQuerySize(PpWizardPgmName)
  13215. if PpwSize<> '' then
  13216. PpwSize=AddCommasToDecimalNumber(PpwSize)
  13217. PpwDateTime=GetFileTimeStamp(PpWizardPgmName)
  13218. call AllFollowingOutputGoesToErrorFile
  13219. call Char1 ErrorColor
  13220. call Line1 ''
  13221. call Line1 copies('!!',38)
  13222. call Line1 copies('!!', 15) || '[ Fatal  Error ]' || copies('!!',15)
  13223. call Line1 copies('!!',38)
  13224. call CgiStartFatalError
  13225. if IncludeLevel<>0 then
  13226. do
  13227. LastFileLine=strip(LastFileLine)
  13228. LastLine=strip(LastLine)
  13229. call Line1 'Location  : ' ||CurrentSourceLocation()
  13230. call Line1 'File Line : ' ||LastFileLine
  13231. if LastLine<>LastFileLine then
  13232. call Line1 'Fail Line : ' ||LastLine
  13233. if LastLineAfterMacroRep<> '' &LastLine<>LastLineAfterMacroRep&LastFileLine<>LastLineAfterMacroRep then
  13234. call Line1 'After Repl: ' ||LastLineAfterMacroRep
  13235. if MacroBeingExpanded<> '' then
  13236. call Line1 'Expanding : ' || StartsMacroReplacement || MacroBeingExpanded || ' ...' ||EndsMacroReplacement
  13237. end
  13238. else
  13239. do
  13240. if PpwDoing<> '' then
  13241. call Line1 'Doing What: ' ||PpwDoing
  13242. end
  13243. call Line1 'Detected @: Line ' || SynErrLineC || ' of ' || _filespec('name', PpWizardPgmName) || ' (v' || PgmVersion || ')'
  13244. call Line1 'PPWIZARD  : Length ' || PpwSize || ' bytes.  TimeStamped ' ||PpwDateTime
  13245. call Line1 'Running In: ' || DebugGetOpSysText() || ', ' ||RexVersionInfo
  13246. call Line1 'Reason'
  13247. call Line1 '~~~~~~'
  13248. LastArg=1
  13249. do LineIndex=1 to arg()
  13250. if arg(LineIndex)<> '' then
  13251. LastArg=LineIndex
  13252. end
  13253. do LineIndex=1 to LastArg
  13254. call Line1 arg(LineIndex)
  13255. end
  13256. if ExpressionKilledUs<> '' then
  13257. call DumpVarsInExpression ExpressionKilledUs,, "KNOWN VARIABLES"
  13258. call CgiEndFatalError
  13259. call Line1 copies('!!',38)
  13260. call Line1 ''
  13261. call Line1 ''
  13262. call Char1 Beep||Reset
  13263. if RexxHookError<> '' then
  13264. do
  13265. do LineIndex=1 to LastArg
  13266. call SetEnv "PPWH_ERROR" ||LineIndex,arg(LineIndex)
  13267. end
  13268. call CallHook "ERROR",,LastArg
  13269. do LineIndex=1 to LastArg
  13270. call SetEnv "PPWH_ERROR" || LineIndex, ''
  13271. end
  13272. end
  13273. AbnormalExit(SynErrLine)
  13274.  
  13275. RexSystemFailure:
  13276. FailedAt=SIGL
  13277. if TrapHandler='FULL' then
  13278. call DBG 'RexSystemFailure(REXSYSTM.XH routine failed)'
  13279. call DisplayCopyright
  13280. call RexDumpSystemInfo
  13281. say ''
  13282. if TrapHandler='FULL' then
  13283. CryAndDie(arg(1))
  13284. say 'ERROR'
  13285. say '~~~~~'
  13286. say arg(1)
  13287. call CallErrorHookForSimpleOneLiner arg(1)
  13288. ExitNowCallingAnyHandlers(FailedAt)
  13289.  
  13290. CallErrorHookForSimpleOneLiner:
  13291. if RexxHookError<> '' then
  13292. do
  13293. call SetEnv "PPWH_ERROR1",arg(1)
  13294. call CallHook "ERROR",,1
  13295. call SetEnv "PPWH_ERROR1", ''
  13296. end
  13297. return
  13298.  
  13299. AbnormalExit:
  13300. call DBG 'AbnormalExit(' || arg(1) || ') called.'
  13301. if arg(2)<> '' then
  13302. call CallErrorHookForSimpleOneLiner arg(2)
  13303. ThatsAllFolks(arg(1))
  13304.  
  13305. ThatsAllFolks:
  13306. dc_Rc=arg(1)
  13307. call DBG 'ThatsAllFolks() called to exit program.'
  13308. if CurrentOutFile<> '' then
  13309. call FileClose CurrentOutFile
  13310. if IncludeLevel<>0 then
  13311. do
  13312. do FileIndex=1 to IncludeLevel
  13313. call FileClose IncludeFileName.FileIndex
  13314. end
  13315. end
  13316. call CloseCgiFileIfOpen
  13317. if OptionFilterIn<> '' then
  13318. call DoMacroSpaceOperation "DROP", OptionFilterIn,  "HtmlFilterIn",  "QUIET"
  13319. if OptionFilterOut<> '' then
  13320. call DoMacroSpaceOperation "DROP", OptionFilterOut, "HtmlFilterOut", "QUIET"
  13321. call DBG 'Exiting with a return code of ' ||dc_Rc
  13322. if OptionCgiModeOn='N' then
  13323. do
  13324. if dc_Rc<=1 then
  13325. OnExitSleepFor=OnExitSleepForOk
  13326. else
  13327. OnExitSleepFor=OnExitSleepForError
  13328. if OnExitSleepFor<>0 then
  13329. do
  13330. call DBG 'Sleeping for ' || OnExitSleepFor || ' second(s)'
  13331. call _SysSleep OnExitSleepFor
  13332. end
  13333. end
  13334. ExitNowCallingAnyHandlers(dc_Rc)
  13335.  
  13336. ExitNowCallingAnyHandlers:
  13337. dd_Rc=arg(1)
  13338. if dd_Rc=0|dd_Rc=1 then
  13339. call _CallExitHandler PpwOnOK, "success"
  13340. else
  13341. do
  13342. call DeletingOnError
  13343. call _CallExitHandler PpwOnERROR, "failure"
  13344. end
  13345. exit(dd_Rc)
  13346.  
  13347. _CallExitHandler:
  13348. de_Handler=arg(1)
  13349. de_Type=arg(2)
  13350. if de_Handler<> '' then
  13351. do
  13352. call DBG 'A ' || de_Type || ' exit handler exists...'
  13353. call DBGIND 1
  13354. de_Handler=_ReplaceConsoleHandlers(de_Handler, 'ConsoleFile',ConsoleFile)
  13355. de_Handler=_ReplaceConsoleHandlers(de_Handler, 'ErrorFile',ConsoleErrorFile)
  13356. if de_Handler<> '' then
  13357. call AddressCmd de_Handler
  13358. call DBGIND-1
  13359. end
  13360. return
  13361.  
  13362. _ReplaceConsoleHandlers:
  13363. parse arg de_Val,de_Bef,de_Aft
  13364. de_Before='{' || de_Bef || '}'
  13365. if pos(de_Before,de_Val)<>0 then
  13366. do
  13367. if de_Aft='' then
  13368. do
  13369. call Line1 'No value known for "' || de_Before || '"' ||d2c(7)
  13370. call Sleep 3
  13371. return('')
  13372. end
  13373. de_Val=ReplaceString(de_Val,de_Before,de_Aft)
  13374. end
  13375. return(de_Val)
  13376. signal INDENT_45
  13377.  
  13378. EXTRAINDENT_DEBUG:
  13379. if OptionDebugOn='Y' then
  13380. call OptionDebugShow 'EXTRAINDENT', 'Extra left indent is now "' || LeftIndent || '"'
  13381. return
  13382.  
  13383. EXTRAINDENT_GET:
  13384. call EXTRAINDENT_DEBUG
  13385. return(LeftIndentSet2)
  13386.  
  13387. EXTRAINDENT_SET:
  13388. LeftIndentSet2=arg(1)
  13389. if ProcessedCmdLine='N' then
  13390. do
  13391. call OptionDebugShow 'EXTRAINDENT', 'Setting default value of extra left indent to "' || LeftIndentSet2 || '"'
  13392. Default4_LeftIndent=LeftIndentSet2
  13393. return(0)
  13394. end
  13395. if LeftIndentSet2=='' then
  13396. LeftIndentCmd=Default4_LeftIndent
  13397. else
  13398. LeftIndentCmd=LeftIndentSet2
  13399. if translate(LeftIndentCmd)='NULL' then
  13400. LeftIndent=''
  13401. else
  13402. call ExecRexxCmd "LeftIndent = " ||LeftIndentCmd
  13403. call EXTRAINDENT_DEBUG
  13404. return
  13405.  
  13406. INDENT_45:
  13407.  
  13408. _DieAsNoTextConditionSupplied:
  13409. CryAndDie('No test condition supplied on "#if" command')
  13410.  
  13411. _PerformSimpleHashIfTest:
  13412. SimpleTest=arg(1)
  13413. if left(SimpleTest,1)<> '[' | right(SimpleTest, 1) <> ']' then
  13414. CryAndDie('Incorrectly bracketed simple #if command.')
  13415. SimpleTest=substr(SimpleTest,2,length(SimpleTest)-2)
  13416. if SimpleTest='' then
  13417. call _DieAsNoTextConditionSupplied
  13418. Parm1=GetSimpleRexxValue(SimpleTest, "SimpleTest")
  13419. parse var SimpleTest FastOperator SimpleTest
  13420. if SimpleTest='' then
  13421. CryAndDie('#if [] has too few parameters (you must put spaces around operator!)')
  13422. Parm3=GetSimpleRexxValue(SimpleTest, "SimpleTest")
  13423. if SimpleTest<> '' then
  13424. CryAndDie('#if [] has too many parameters, expected 3!')
  13425. select
  13426. when FastOperator='==' then
  13427. return(Parm1==Parm3)
  13428. when FastOperator='<>' then
  13429. return(Parm1<>Parm3)
  13430. when FastOperator='=' then
  13431. return(Parm1=Parm3)
  13432. when FastOperator='<' then
  13433. return(Parm1<Parm3)
  13434. when FastOperator='>' then
  13435. return(Parm1>Parm3)
  13436. when FastOperator='<=' then
  13437. return(Parm1<=Parm3)
  13438. when FastOperator='>=' then
  13439. return(Parm1>=Parm3)
  13440. otherwise
  13441. CryAndDie("Unsupported operator of '" || FastOperator || "' used on simple " || HashCmd, '', 'ONLY "==, <>, =, <, >, <=, >=" are supported!')
  13442. end
  13443. CryAndDie('BUG: Did not expect to get here!')
  13444.  
  13445. MatchesIfDebugText:
  13446. MatchIndex=arg(1)
  13447. if MatchIndex<=0 then
  13448. return('')
  13449. else
  13450. return(' (matches #if at ' || IfState.IfAtLine.MatchIndex || ')')
  13451.  
  13452. WantLine:
  13453. if IfState.WantLines.IfNesting='N' then
  13454. return('N')
  13455. else
  13456. do
  13457. if IfState.IfTrue.IfNesting=IfState.InTrue.IfNesting then
  13458. return('Y')
  13459. else
  13460. return('N')
  13461. end
  13462.  
  13463. ProcessHashIfTest:
  13464. if OptionDebugOn='Y' then
  13465. do
  13466. call DBG_CONDITIONAL '#If? at nesting level ' ||IfNesting+1
  13467. call DBGIND 1
  13468. end
  13469. WantTheLines=WantLine()
  13470. if WantTheLines='N' then
  13471. IfResult='N'
  13472. else
  13473. do
  13474. if OptionDebugOn='Y' then
  13475. call DBGIND 1
  13476. parse value PerformReplacementsInCmdsParameters(arg(1))with HashCmd TestCondition
  13477. TestCondition=strip(TestCondition)
  13478. if translate(HashCmd)=CmdHashIf then
  13479. do
  13480. if left(TestCondition,1)<> '[' then
  13481. do
  13482. if TestCondition='' then
  13483. call _DieAsNoTextConditionSupplied
  13484. call ExecRexxCmd 'IfResult = (' || TestCondition || ')'
  13485. end
  13486. else
  13487. do
  13488. IfResult=_PerformSimpleHashIfTest(TestCondition)
  13489. end
  13490. if IfResult then
  13491. IfResult='Y'
  13492. else
  13493. IfResult='N'
  13494. end
  13495. else
  13496. do
  13497. if TestCondition='' then
  13498. CryAndDie(HashCmd|| ' command does not specify the macro name!')
  13499. if pos('CommentBlock  /* ',TestCondition)<>0 then
  13500. IfResult='N'
  13501. else
  13502. IfResult=MacroExists(TestCondition)
  13503. if translate(HashCmd)=CmdHashIfndef then
  13504. IfResult=translate(IfResult, 'YN', 'NY')
  13505. end
  13506. if OptionDebugOn='Y' then
  13507. do
  13508. call DBGIND-1
  13509. if IfResult='N' then
  13510. Tf='FALSE'
  13511. else
  13512. Tf='TRUE'
  13513. if OptionDebugOn='Y' then
  13514. call DBG_CONDITIONAL 'Answer is ' ||Tf
  13515. end
  13516. end
  13517. IfNesting=IfNesting+1
  13518. IfState.WantLines.IfNesting=WantTheLines
  13519. IfState.InTrue.IfNesting='Y'
  13520. IfState.IfTrue.IfNesting=IfResult
  13521. IfState.IfAtLine.IfNesting=CurrentSourceLocation()
  13522. if OptionDebugOn='Y' then
  13523. call DBGIND-1
  13524. return('OK')
  13525.  
  13526. ProcessHashElse:
  13527. if OptionDebugOn='Y' then
  13528. call DBG_CONDITIONAL '#elseif at level #' ||IfNesting||MatchesIfDebugText(IfNesting)
  13529. if IfNesting=0 then
  13530. CryAndDie("Found #elseif without matching #if")
  13531. if IfState.InTrue.IfNesting='N' then
  13532. CryAndDie("Found unexpected #elseif - duplicated #elseif?" ||MatchesIfDebugText(IfNesting))
  13533. if arg(1)<> '' then
  13534. CryAndDie('The #elseif command does not take parameters')
  13535. IfState.InTrue.IfNesting='N'
  13536. return('OK')
  13537.  
  13538. ProcessHashEndif:
  13539. if OptionDebugOn='Y' then
  13540. call DBG_CONDITIONAL 'Endif at level #' ||IfNesting||MatchesIfDebugText(IfNesting)
  13541. if IfNesting=0 then
  13542. CryAndDie("Found #endif without matching #if")
  13543. IfNesting=IfNesting-1
  13544. return('OK')
  13545.  
  13546. _ReportCurrentOutputFile:
  13547. call DBG 'Current Output file = "' || CurrentOutFile || '" (level ' || OutputLevel || ')'
  13548. return
  13549.  
  13550. HaveNewOutputFile:
  13551. df_Append=arg(3)
  13552. df_Mode=arg(4)
  13553. if OutputLevel<>0 then
  13554. call FileClose CurrentOutFile
  13555. if OptionCgiModeOn='Y' then
  13556. do
  13557. CurrentOutFile=RexStdoutStream
  13558. call DBG 'In CGI mode, will output to "' || CurrentOutFile || '" (standard output)'
  13559. end
  13560. else
  13561. do
  13562. if arg(2)<> '' then
  13563. CurrentOutFile=GenerateFileName(arg(1),arg(2))
  13564. else
  13565. do
  13566. CurrentOutFile=arg(1)
  13567. call MakeDirectoryTree _filespec('drive', CurrentOutFile) || _filespec('path',CurrentOutFile)
  13568. end
  13569. end
  13570. CurrentOutLine=0
  13571. do ChkIndex=1 to OutputLevel
  13572. if Output.ChkIndex.File=CurrentOutFile then
  13573. do
  13574. if df_Append='Y' then
  13575. call OutputWarningToScreen 'OFO0', 'Appending to currently opened file ("' || CurrentOutFile || '")!'
  13576. else
  13577. do
  13578. WhereOpened=Output.ChkIndex.!Locn
  13579. if WhereOpened='' then
  13580. Extra='Check "/Output" mask for correctness'
  13581. else
  13582. Extra='File opened at ' ||WhereOpened
  13583. CryAndDie('Already have "' || CurrentOutFile || '" open for output!',Extra)
  13584. end
  13585. end
  13586. end
  13587. OutputLevel=OutputLevel+1
  13588. Output.OutputLevel.File=CurrentOutFile
  13589. Output.OutputLevel.Line=CurrentOutLine
  13590. Output.OutputLevel.!Locn=CurrentSourceLocation('')
  13591. Output.OutputLevel.!PMODE=ProcessingMode
  13592. if ProcessingMode<>df_Mode then
  13593. do
  13594. call DBG 'Processing mode for "' || CurrentOutFile || '" is "' || df_Mode || '" (changed from "' || ProcessingMode || '")'
  13595. ProcessingMode=df_Mode
  13596. end
  13597. df_Hdr='Y'
  13598. if OptionCgiModeOn='N' then
  13599. do
  13600. if QueryExists(CurrentOutFile)<> "" then
  13601. do
  13602. if df_Append='Y' then
  13603. do
  13604. call DBG 'Appending to "' || CurrentOutFile || '"'
  13605. df_Hdr='N'
  13606. end
  13607. else
  13608. do
  13609. call DBG 'Deleting "' || CurrentOutFile || '"'
  13610. call MustDeleteFile CurrentOutFile
  13611. end
  13612. end
  13613. end
  13614. call AddOutputFileToDependancyList CurrentOutFile
  13615. call charout CurrentOutFile, ""
  13616. call FileClose CurrentOutFile
  13617. call _ReportCurrentOutputFile
  13618. if df_Hdr='Y' then
  13619. do
  13620. if Ok2OutputHeader='Y' then
  13621. call OutputHeaderIfWantedOrRequired
  13622. end
  13623. call OutputSyntaxCheckingHeaderIfWantedOrRequired
  13624. Output.OutputLevel.!SYNRC=OutSyntaxRc
  13625. Output.OutputLevel.!SYNCMD=OutSyntaxCmd
  13626. Output.OutputLevel.!SYNMSG=OutSyntaxMsg
  13627. return
  13628.  
  13629. _BackToPreviousOutput:
  13630. call FileClose CurrentOutFile
  13631. call DBG 'Closed the Output file = "' || CurrentOutFile || '" (wrote ' || CurrentOutLine || ' line(s))'
  13632. call DoSyntaxCheckingOnFileIfEnabled CurrentOutFile
  13633. if OutputLevel<=1 then
  13634. CryAndDie('No output files on stack!')
  13635. else
  13636. do
  13637. OutputLevel=OutputLevel-1
  13638. CurrentOutFile=Output.OutputLevel.File
  13639. CurrentOutLine=Output.OutputLevel.Line
  13640. OutSyntaxRc=Output.OutputLevel.!SYNRC
  13641. OutSyntaxCmd=Output.OutputLevel.!SYNCMD
  13642. OutSyntaxMsg=Output.OutputLevel.!SYNMSG
  13643. if ProcessingMode<>Output.OutputLevel.!PMODE then
  13644. do
  13645. ProcessingMode=Output.OutputLevel.!PMODE
  13646. call DBG 'Restoring mode for "' || CurrentOutFile || '" to "' || ProcessingMode || '"'
  13647. end
  13648. call DieIfHoldingOutput
  13649. call OutputHoldPop
  13650. end
  13651. call _ReportCurrentOutputFile
  13652. return
  13653.  
  13654. StoreOutHeader:
  13655. dg_Spec=arg(1)
  13656. dg_Del=left(dg_Spec,1)
  13657. parse var dg_Spec (dg_Del) dg_Extn (dg_Del) dg_S (dg_Del) dg_M (dg_Del) dg_E (dg_Del) .
  13658. dg_Key='OUTHDR_' ||c2x(dg_Extn)
  13659. call value dg_Key,dg_S|| '00'x || dg_M || '00'x||dg_E
  13660. return
  13661.  
  13662. StoreSyntaxCheckCode4Header:
  13663. dh_Spec=arg(1)
  13664. dh_Del=left(dh_Spec,1)
  13665. parse var dh_Spec (dh_Del) dh_Extn (dh_Del) dh_Cmd (dh_Del) dh_Rc (dh_Del) dh_Lines
  13666. dh_Key='OUTHDRSYN_' ||c2x(dh_Extn)
  13667. if dh_Cmd='' then
  13668. drop(dh_Key)
  13669. else
  13670. do
  13671. ReplaceCount=0
  13672. dh_Lines=ReplaceString(dh_Lines,dh_Del, 'FF'x)
  13673. call value dh_Key,dh_Cmd|| '00'x || dh_Rc || '00'x||dh_Lines
  13674. end
  13675. return
  13676.  
  13677. OutputHeaderIfWantedOrRequired:
  13678. di_CmtS=''
  13679. di_CmtM=''
  13680. di_CmtE=''
  13681. if ProcessingMode='REXX' then
  13682. do
  13683. di_CmtS=RexxCmtStart
  13684. di_CmtM=' * '
  13685. di_CmtE=' ' ||RexxCmtEnd
  13686. end
  13687. di_Extn=_filespec('EXTN',CurrentOutFile)
  13688. di_ExtnU=translate(di_Extn)
  13689. di_Key='OUTHDR_' ||c2x(di_Extn)
  13690. di_KeyU='OUTHDR_' ||c2x(di_ExtnU)
  13691. di_KeyA='OUTHDR_' || c2x('*')
  13692. if symbol(di_Key)='VAR' then
  13693. di_UseKey=di_Key
  13694. else
  13695. do
  13696. if symbol(di_KeyU)='VAR' then
  13697. di_UseKey=di_KeyU
  13698. else
  13699. do
  13700. if symbol(di_KeyA)='VAR' then
  13701. di_UseKey=di_KeyA
  13702. else
  13703. di_UseKey=''
  13704. end
  13705. end
  13706. if di_UseKey<> '' then
  13707. do
  13708. call DBG 'Output Header definition was found'
  13709. parse value value(di_UseKey)with di_CmtS '00'x di_CmtM '00'x di_CmtE
  13710. end
  13711. if di_CmtS||di_CmtM||di_CmtE\=='' then
  13712. do
  13713. if left(di_CmtS,1)='@' & di_CmtM||di_CmtE = '' then
  13714. do
  13715. di_Inc=substr(di_CmtS,2)
  13716. call DBG 'Include output header - "' ||di_Inc
  13717. if IncludeLevel=0 then
  13718. GenerateRc=GenerateRc+ProcessInputFile(di_Inc)
  13719. else
  13720. do
  13721. call RecursiveIncludeSave
  13722. GenerateRc=GenerateRc+ProcessInputFile(di_Inc)
  13723. call RecursiveIncludeRestore
  13724. end
  13725. end
  13726. else
  13727. do
  13728. call GenerateOneLine di_CmtS
  13729. call GenerateOneLine di_CmtM|| 'Generator   : PPWIZARD version ' ||PgmVersion
  13730. call GenerateOneLine di_CmtM|| '            : FREE tool for Windows, OS/2, DOS and UNIX by ' || PgmAuthor  || ' (' || PgmAuthorEmail || ')'
  13731. call GenerateOneLine di_CmtM|| '            : ' ||PgmHomePage
  13732. call GenerateOneLine di_CmtM|| "Time        : " ||space(PpwCompTime)
  13733. call GenerateOneLine di_CmtM|| "Input File  : " ||InputFile
  13734. call GenerateOneLine di_CmtM|| "Output File : " ||FileQueryExists(Output.OutputLevel.File)
  13735. call GenerateOneLine di_CmtE
  13736. call GenerateOneLine ''
  13737. end
  13738. end
  13739. if ProcessingMode='REXX' then
  13740. do
  13741. call GenerateOneLine 'if arg(1)="' || SyntaxOkText || '" then exit(' || SyntaxOkRc || ')'
  13742. call GenerateOneLine ''
  13743. end
  13744. return
  13745.  
  13746. OutputSyntaxCheckingHeaderIfWantedOrRequired:
  13747. OutSyntaxRc=''
  13748. OutSyntaxCmd=''
  13749. OutSyntaxMsg=''
  13750. di_Lines=''
  13751. di_Key='OUTHDRSYN_' ||c2x(di_Extn)
  13752. di_KeyU='OUTHDRSYN_' ||c2x(di_ExtnU)
  13753. di_KeyA='OUTHDRSYN_' || c2x('*')
  13754. if symbol(di_Key)='VAR' then
  13755. di_UseKey=di_Key
  13756. else
  13757. do
  13758. if symbol(di_KeyU)='VAR' then
  13759. di_UseKey=di_KeyU
  13760. else
  13761. do
  13762. if symbol(di_KeyA)='VAR' then
  13763. di_UseKey=di_KeyA
  13764. else
  13765. di_UseKey=''
  13766. end
  13767. end
  13768. if di_UseKey<> '' then
  13769. do
  13770. call DBG 'Output syntax checking header code definition was found'
  13771. parse value value(di_UseKey)with OutSyntaxCmd '00'x OutSyntaxRc '00'x di_Lines
  13772. end
  13773. if OutSyntaxCmd<> '' then
  13774. do
  13775. if left(OutSyntaxCmd,1)='@' & (OutSyntaxRc || di_Lines) = '' then
  13776. do
  13777. di_Inc=substr(OutSyntaxCmd,2)
  13778. call DBG 'Include output header - "' ||di_Inc
  13779. OutSyntaxRc=''
  13780. OutSyntaxCmd=''
  13781. OutSyntaxMsg=''
  13782. if IncludeLevel=0 then
  13783. GenerateRc=GenerateRc+ProcessInputFile(di_Inc)
  13784. else
  13785. do
  13786. call RecursiveIncludeSave
  13787. GenerateRc=GenerateRc+ProcessInputFile(di_Inc)
  13788. call RecursiveIncludeRestore
  13789. if OutSyntaxCmd='' | OutSyntaxRc = '' then
  13790. CryAndDie('You must set the rexx variables:', ' * OutSyntaxCmd', ' * OutSyntaxRc')
  13791. end
  13792. end
  13793. else
  13794. do
  13795. do while di_Lines<> ''
  13796. parse var di_Lines di_This 'FF'x di_Lines
  13797. call GenerateOneLine di_This
  13798. end
  13799. call GenerateOneLine ''
  13800. end
  13801. end
  13802. return
  13803.  
  13804. DoSyntaxCheckingOnFileIfEnabled:
  13805. if OutSyntaxRc='' then
  13806. return
  13807. dj_File=FileQueryExists(arg(1))
  13808. dj_Cmd=ReplaceString(OutSyntaxCmd, '{?}',dj_File)
  13809. call DBGIND 1
  13810. call DBG 'Calling stub in generated code ("' || dj_File || '")'
  13811. CheckRc='*?*'
  13812. CheckRc=AddressCmd(dj_Cmd)
  13813. if CheckRc<>OutSyntaxRc then
  13814. do
  13815. if left(OutSyntaxMsg,1)<> '-' then
  13816. CryAndDie('Probable Syntax Error detected while checking generated file', 'Got unexpected RC of "' || CheckRc || '" (expected RC of ' || OutSyntaxRc || ')', 'Error message probably visible above...', 'Error checking "' || dj_File || '"',OutSyntaxMsg)
  13817. else
  13818. do
  13819. CryAndDie(substr(OutSyntaxMsg,2))
  13820. end
  13821. end
  13822. call say ''
  13823. call DBGIND-1
  13824. return
  13825.  
  13826. ProcessHashOutput:
  13827. call DieIfCgiModeOn
  13828. if LineQueued\=='' then
  13829. do
  13830. if OptionDebugOn='Y' then
  13831. do
  13832. call DBG 'Need to flush queued data'
  13833. call DBGIND 3
  13834. end
  13835. call FlushQueuedOutput
  13836. if OptionDebugOn='Y' then
  13837. call DBGIND-3
  13838. end
  13839. dk_Parms=PerformReplacementsInCmdsParameters(arg(1))
  13840. if dk_Parms='' then
  13841. call _BackToPreviousOutput
  13842. else
  13843. do
  13844. dk_NewFile=GetQuotedText(dk_Parms, "dk_Parms")
  13845. dk_Parms=translate(dk_Parms)
  13846. dk_AsIs='N'
  13847. dk_Append='N'
  13848. Ok2OutputHeader='Y'
  13849. dk_Mode=ProcessingMode
  13850. do while dk_Parms<> ''
  13851. ThisParm=GetQuotedText(dk_Parms, "dk_Parms")
  13852. select
  13853. when ThisParm="ASIS" then
  13854. dk_AsIs='Y'
  13855. when ThisParm="NOHEADER" then
  13856. Ok2OutputHeader='N'
  13857. when ThisParm="APPEND" then
  13858. dk_Append='Y'
  13859. when ThisParm="HTML" | ThisParm = "REXX" | ThisParm = "OTHER" then
  13860. dk_Mode=ThisParm
  13861. otherwise
  13862. CryAndDie('The parameter "' || ThisParm || '" is unknown!')
  13863. end
  13864. end
  13865. call OutputHoldPushAndClear
  13866. if dk_AsIs='N' then
  13867. call HaveNewOutputFile dk_NewFile,OptionOutput,dk_Append,dk_Mode
  13868. else
  13869. call HaveNewOutputFile dk_NewFile,,dk_Append,dk_Mode
  13870. end
  13871. return(0)
  13872.  
  13873. GetQuotedText:
  13874. parse arg TheString,RestVarName,QuoteDel
  13875. TheString=strip(TheString, 'L')
  13876. QuoteDel=' ' ||QuoteDel
  13877. if OptionDebugOn='Y' then
  13878. do
  13879. call DBG_QUOTING 'GetQuotedText(): ' ||DebugRightArrow||TheString||DebugLeftArrow
  13880. call DBGIND 1
  13881. end
  13882. if TheString='' then
  13883. call _ErrorNoQuotedParm
  13884. QuoteChar=left(TheString,1)
  13885. if datatype(QuoteChar, 'Alphanumeric')then
  13886. do
  13887. if OptionDebugOn='Y' then
  13888. call DBG_QUOTING 'Text is unquoted'
  13889. DelPos=verify(TheString,QuoteDel, 'M')
  13890. if DelPos=0 then
  13891. do
  13892. QuotedString=TheString
  13893. TheRest=''
  13894. end
  13895. else
  13896. do
  13897. QuotedString=substr(TheString,1,DelPos-1)
  13898. TheRest=substr(TheString,DelPos)
  13899. end
  13900. end
  13901. else
  13902. do
  13903. if OptionDebugOn='Y' then
  13904. call DBG_QUOTING 'Text is quoted with ' ||DebugRightArrow||QuoteChar||DebugLeftArrow
  13905. SecondQuotePosn=pos(QuoteChar,TheString,2)
  13906. if SecondQuotePosn=0 then
  13907. call _ErrorNoEndQuote
  13908. QuotedString=substr(TheString,2,SecondQuotePosn-2)
  13909. TheRest=substr(TheString,SecondQuotePosn+1)
  13910. end
  13911. if TheRest<> '' then
  13912. do
  13913. if QuoteDel<> 'Y' then
  13914. do
  13915. if pos(left(TheRest,1),QuoteDel)=0 then
  13916. do
  13917. Line1='There is no whitespace after the 2nd quote char of "' || QuoteChar || '" (did not expect to find "' || left(TheRest, 1) || '")'
  13918. Line2='The rest of the line:'
  13919. Line3=copies(' ',8)||DebugRightArrow||TheRest||DebugLeftArrow
  13920. CryAndDie(Line1,Line2,Line3)
  13921. end
  13922. end
  13923. end
  13924. TheRest=strip(TheRest, 'L')
  13925. if RestVarName<> '' then
  13926. call _valueS RestVarName,TheRest
  13927. else
  13928. do
  13929. if TheRest<> '' then
  13930. call DieIfExtraUnexpectedParms TheRest
  13931. end
  13932. if OptionDebugOn='Y' then
  13933. do
  13934. call DBG_QUOTING 'Text is ' ||DebugRightArrow||QuotedString||DebugLeftArrow
  13935. call DBGIND-1
  13936. end
  13937. return(QuotedString)
  13938.  
  13939. GetQuotedRest:
  13940. TheString=strip(arg(1))
  13941. if OptionDebugOn='Y' then
  13942. do
  13943. call DBG_QUOTING 'GetQuotedRest(): ' ||DebugRightArrow||TheString||DebugLeftArrow
  13944. call DBGIND 1
  13945. end
  13946. if TheString='' then
  13947. call _ErrorNoQuotedParm
  13948. QuoteChar=left(TheString,1)
  13949. if datatype(QuoteChar, 'Alphanumeric')then
  13950. do
  13951. QuotedString=TheString
  13952. if OptionDebugOn='Y' then
  13953. call DBG_QUOTING 'Text is unquoted'
  13954. end
  13955. else
  13956. do
  13957. if OptionDebugOn='Y' then
  13958. call DBG_QUOTING 'Text is quoted with '||DebugRightArrow||QuoteChar||DebugLeftArrow
  13959. SecondQuotePosn=length(TheString)
  13960. if SecondQuotePosn<2|substr(TheString,SecondQuotePosn,1)<>QuoteChar then
  13961. call _ErrorNoEndQuote
  13962. QuotedString=substr(TheString,2,SecondQuotePosn-2)
  13963. end
  13964. if OptionDebugOn='Y' then
  13965. do
  13966. call DBG_QUOTING 'Text is  ' ||DebugRightArrow||QuotedString||DebugLeftArrow
  13967. call DBGIND-1
  13968. end
  13969. return(QuotedString)
  13970.  
  13971. DieIfExtraUnexpectedParms:
  13972. if arg(1)='' then
  13973. return
  13974. CryAndDie('Unexpected parameter(s) of "' || strip(arg(1)) || '" found!')
  13975.  
  13976. _ErrorNoQuotedParm:
  13977. CryAndDie('Expect a quoted string, not enough parameters available!')
  13978.  
  13979. _ErrorNoEndQuote:
  13980. Line1='Could not find a matching end quote character of "' || QuoteChar || '"!'
  13981. Line2='Processing:'
  13982. Line3=copies(' ',8)||DebugRightArrow||TheString||DebugLeftArrow
  13983. CryAndDie(Line1,Line2,Line3)
  13984.  
  13985. GetRexxVarValueOrDie:
  13986. grvVar=arg(1)
  13987. if symbol(grvVar)='VAR' then
  13988. return(_valueG(grvVar))
  13989. else
  13990. do
  13991. if symbol(grvVar)='BAD' then
  13992. Reason="contains invalid character(s)"
  13993. else
  13994. Reason="is unknown"
  13995. call DumpVarsIfCompoundVariable grvVar
  13996. CryAndDie('The rexx variable "' || grvVar || '" ' || Reason || '!')
  13997. end
  13998.  
  13999. ProcessRexxVar:
  14000. ResultVar=GetQuotedText(PerformReplacementsInCmdsParameters(arg(1)), "Rest")
  14001. XVarName=''
  14002. ResultVarU=translate(ResultVar)
  14003. if ResultVarU="PUSH" then
  14004. do
  14005. do while Rest<> ''
  14006. ResultVar=GetQuotedText(Rest, "Rest")
  14007. call _StackPush GetRexxVarValueOrDie(ResultVar)
  14008. end
  14009. return(0)
  14010. end
  14011. if ResultVarU="POP" then
  14012. do
  14013. TmpVarCnt=0
  14014. do while Rest<> ''
  14015. ResultVar=GetQuotedText(Rest, "Rest")
  14016. TmpVarCnt=TmpVarCnt+1
  14017. TmpVar.TmpVarCnt=ResultVar
  14018. end
  14019. do while TmpVarCnt<>0
  14020. call _valueS TmpVar.TmpVarCnt,_StackPop()
  14021. TmpVarCnt=TmpVarCnt-1
  14022. end
  14023. return(0)
  14024. end
  14025. parse var Rest FastOperator Rest
  14026. if FastOperator<> '=' then
  14027. do
  14028. FastOperator=translate(FastOperator)
  14029. if left(FastOperator,1)='=' then
  14030. do
  14031. if FastOperator='=X=' then
  14032. do
  14033. XVarName=ResultVar
  14034. ResultVar='XVAR?.X?' ||c2x(translate(XVarName))
  14035. end
  14036. else
  14037. do
  14038. Rest=strip(Rest)
  14039. if symbol(Rest)='VAR' then
  14040. ResultValue=GetRexxVarValueOrDie(Rest)
  14041. else
  14042. ResultValue=GetQuotedRest(Rest)
  14043. select
  14044. when FastOperator='=ASIS=' then
  14045. do
  14046. RestVar=AsIs(ResultValue)
  14047. end
  14048. otherwise
  14049. CryAndDie('Unsupported "=?=" operator of "' || FastOperator || '" used on ' ||HashCmd)
  14050. end
  14051. Rest='RestVar'
  14052. end
  14053. FastOperator='='
  14054. end
  14055. end
  14056. select
  14057. when FastOperator='=' then
  14058. do
  14059. Rest=strip(Rest)
  14060. if symbol(Rest)='VAR' then
  14061. ResultValue=GetRexxVarValueOrDie(Rest)
  14062. else
  14063. ResultValue=GetQuotedRest(Rest)
  14064. end
  14065. when FastOperator='PUSH' then
  14066. do
  14067. call DieIfExtraUnexpectedParms Rest
  14068. call _StackPush GetRexxVarValueOrDie(ResultVar)
  14069. return(0)
  14070. end
  14071. when FastOperator='POP' then
  14072. do
  14073. call DieIfExtraUnexpectedParms Rest
  14074. ResultValue=_StackPop()
  14075. end
  14076. otherwise
  14077. do
  14078. AfterOperator=GetSimpleRexxValue(Rest, "Rest")
  14079. if Rest<> '' then
  14080. SourceValue=GetSimpleRexxValue(Rest)
  14081. else
  14082. SourceValue=GetRexxVarValueOrDie(ResultVar)
  14083. if OptionDebugOn='Y' then
  14084. call DBG_REXXVAR 'Evaluating: ' || SourceValue || ' ' || FastOperator || ' ' ||AfterOperator
  14085. select
  14086. when FastOperator='+' then
  14087. ResultValue=SourceValue+AfterOperator
  14088. when FastOperator='-' then
  14089. ResultValue=SourceValue-AfterOperator
  14090. when FastOperator='||' then
  14091. ResultValue=SourceValue||AfterOperator
  14092. when FastOperator='*' then
  14093. ResultValue=SourceValue*AfterOperator
  14094. when FastOperator='/' then
  14095. ResultValue=SourceValue/AfterOperator
  14096. when FastOperator='//' then
  14097. ResultValue=SourceValue//AfterOperator
  14098. when FastOperator='%' then
  14099. ResultValue=SourceValue%AfterOperator
  14100. otherwise
  14101. CryAndDie("Unsupported operator of '" || FastOperator || "' used on " ||HashCmd)
  14102. end
  14103. end
  14104. end
  14105. call _valueS ResultVar,ResultValue
  14106. if OptionDebugOn='Y' then
  14107. do
  14108. call DBGIND 1
  14109. if XVarName='' then
  14110. DbgPrefix=ResultVar
  14111. else
  14112. DbgPrefix='"X" Variable ' ||XVarName
  14113. call DBG_REXXVAR DbgPrefix|| ' = ' ||DebugRightArrow||ResultValue||DebugLeftArrow
  14114. call DBGIND-1
  14115. end
  14116. return(0)
  14117.  
  14118. GetSimpleRexxValue:
  14119. sParm=strip(arg(1), 'L')
  14120. sRestVar=arg(2)
  14121. sQuote=left(sParm,1)
  14122. if sQuote="'" | sQuote = '"' then
  14123. do
  14124. sEndPos=pos(sQuote,sParm,2)
  14125. if sEndPos=0 then
  14126. CryAndDie('Incorrectly quoted rexx literal (could not find ending quote)')
  14127. sValue=substr(sParm,2,sEndPos-2)
  14128. sRest=substr(sParm,sEndPos+1)
  14129. end
  14130. else
  14131. do
  14132. parse var sParm sValue sRest
  14133. if datatype(sValue, 'Number')=0 then
  14134. sValue=GetRexxVarValueOrDie(sValue)
  14135. end
  14136. if sRestVar<> '' then
  14137. call _valueS sRestVar,sRest
  14138. else
  14139. do
  14140. if sRestVar<> '' then
  14141. CryAndDie('Extra unexpected parameters of "' || sRestVar || '" found')
  14142. end
  14143. return(sValue)
  14144.  
  14145. _StackPush:
  14146. StackCnt=StackCnt+1
  14147. Stack.StackCnt.StackData=arg(1)
  14148. Stack.StackCnt.StackPosn=CurrentSourceLocation()
  14149. if OptionDebugOn='Y' then
  14150. call DBG_REXXVAR 'Stack Push(#' || StackCnt || ') = ' ||DebugRightArrow||arg(1)||DebugLeftArrow
  14151. return
  14152.  
  14153. _StackPop:
  14154. if StackCnt<=0 then
  14155. CryAndDie('There is nothing on the stack!')
  14156. spData=Stack.StackCnt.StackData
  14157. if OptionDebugOn='Y' then
  14158. do
  14159. call DBG_REXXVAR 'Stack pop(#' || StackCnt || ') = ' ||DebugRightArrow||spData||DebugLeftArrow
  14160. call DBG_REXXVAR 'matched push() at ' ||Stack.StackCnt.StackPosn
  14161. end
  14162. StackCnt=StackCnt-1
  14163. return(spData)
  14164.  
  14165. MatchesStackPushDebugText:
  14166. MatchIndex=arg(1)
  14167. if MatchIndex<=0 then
  14168. return('')
  14169. else
  14170. return(' (matches "#RexxVar PUSH" at ' || Stack.MatchIndex.StackPosn || ')')
  14171.  
  14172. _EnsureVersionY2KSafe:
  14173. TheVer=ReplaceString(translate(arg(1)), '2K', '00')
  14174. if datatype(TheVer, 'Number')=0|(length(TheVer)<>6&length(TheVer)<>8)then
  14175. CryAndDie('The version number "' || TheVer || '" is not valid')
  14176. if TheVer<100 then
  14177. do
  14178. if TheVer>98 then
  14179. TheVer='19' ||TheVer
  14180. else
  14181. TheVer='20' ||TheVer
  14182. end
  14183. return(TheVer)
  14184.  
  14185. ProcessRequireCommon:
  14186. dl_MinVer=_EnsureVersionY2KSafe(GetQuotedText(arg(1), 'dl_Rest'))
  14187. if dl_Rest='' then
  14188. dl_MaxVer='9999.99'
  14189. else
  14190. do
  14191. dl_MaxVer=_EnsureVersionY2KSafe(GetQuotedText(dl_Rest))
  14192. dl_Rest='"' || dl_MaxVer || '"'
  14193. end
  14194. dl_ThisVer=_EnsureVersionY2KSafe(PgmVersion)
  14195. if OptionDebugOn='Y' then
  14196. do
  14197. call DBG 'You require "' || dl_MinVer || '" - ' ||dl_Rest
  14198. call DBG 'You have    "' || dl_ThisVer || '"'
  14199. end
  14200. dl_U='You are using version "' || dl_ThisVer || '"'
  14201. if dl_ThisVer<dl_MinVer then
  14202. CryAndDie('You required at least PPWIZARD version "' || dl_MinVer || '"',dl_U)
  14203. if dl_ThisVer>dl_MaxVer then
  14204. CryAndDie('You need a PPWIZARD version EARLIER than "' || dl_MaxVer || '"',dl_U)
  14205. return(0)
  14206.  
  14207. ProcessRequire:
  14208. return(ProcessRequireCommon(PerformReplacementsInCmdsParameters(arg(1))))
  14209.  
  14210. RexxCtrlC:
  14211. LineCtrlC=SIGL
  14212. TRACE OFF
  14213. call AllFollowingOutputGoesToErrorFile
  14214. call Line1 ''
  14215. call Line1 HighlightColor||copies('=+',39)||ErrorColor
  14216. call CgiStartFatalError
  14217. call Line1 "Come on, you pressed Ctrl+C or Break didn't you!"
  14218. call CgiEndFatalError
  14219. call Line1 HighlightColor||copies('=+',39)||Reset
  14220. AbnormalExit(LineCtrlC, "CTRL+C Pressed")
  14221.  
  14222. QuickSourceLine:
  14223. LineNum=arg(1)
  14224. slKey='PPWSL!.' ||LineNum
  14225. if symbol(slKey)='VAR' then
  14226. return(_valueG(slKey))
  14227. SrcLine=sourceline(LineNum)
  14228. call _valueS slKey,SrcLine
  14229. return(SrcLine)
  14230.  
  14231. _FindLastLabel:
  14232. FailedOnLine=arg(1)
  14233. TryLine=FailedOnLine
  14234. do while TryLine>1
  14235. TryLine=TryLine-1
  14236. TheLine=QuickSourceLine(TryLine)
  14237. ColonPos=pos(':',TheLine)
  14238. if ColonPos<>0 then
  14239. do
  14240. MaybeLabel=strip(left(TheLine,ColonPos-1))
  14241. if symbol(MaybeLabel)<> 'BAD' then
  14242. do
  14243. FoundLabelOnLine=TryLine
  14244. return(MaybeLabel|| ':  (line #' || AddCommasToDecimalNumber(TryLine) || ')')
  14245. end
  14246. end
  14247. end
  14248. FoundLabelOnLine=0
  14249. return('')
  14250.  
  14251. CommonTrapHandler:
  14252. signal on NOVALUE name SimpleRexxTrapUninitializedVariable
  14253. signal on SYNTAX name SimpleRexxTrapSyntaxError
  14254. FailingLine=arg(1)
  14255. TrapHeading=arg(2)
  14256. TextDescription=arg(3)
  14257. Text=arg(4)
  14258. CmdBeingEvaluated=arg(5)
  14259. UserBreakPoint=arg(6)
  14260. HaveCapturedTrapDetails='Y'
  14261. call AllFollowingOutputGoesToErrorFile
  14262. call Line1 ''
  14263. call Line1 HighlightColor||copies('=+',39)||ErrorColor
  14264. call CgiStartFatalError
  14265. call Line1 TrapHeading
  14266. call Line1 copies('~',length(TrapHeading))
  14267. call Line1 substr(TextDescription,1,16)|| ': ' ||Text
  14268. BetterErrorText=Condition('D')
  14269. if BetterErrorText<> '' &BetterErrorText<>Text then
  14270. call Line1 copies(' ',18)||BetterErrorText
  14271. if IncludeLevel<>0 then
  14272. do
  14273. call Line1 'Processing locn : ' ||CurrentSourceLocation()
  14274. LastFileLine=strip(LastFileLine)
  14275. LastLine=strip(LastLine)
  14276. call Line1 'Line from file  : ' ||LastFileLine
  14277. if LastLine<>LastFileLine then
  14278. call Line1 'Failing line    : ' ||LastLine
  14279. if LastLineAfterMacroRep<> '' &LastLine<>LastLineAfterMacroRep&LastFileLine<>LastLineAfterMacroRep then
  14280. call Line1 'After Replace   : ' ||LastLineAfterMacroRep
  14281. if MacroBeingExpanded<> '' then
  14282. call Line1 'Expanding Macro : ' || StartsMacroReplacement || MacroBeingExpanded || ' ...' ||EndsMacroReplacement
  14283. end
  14284. else
  14285. do
  14286. if PpwDoing<> '' then
  14287. call Line1 'PPWIZARD was    : ' ||PpwDoing
  14288. end
  14289. if CmdBeingEvaluated<> '' then
  14290. do
  14291. CmdBeingEvaluated=ReplaceString(CmdBeingEvaluated,DefRexxSpecialSepTag, ";")
  14292. EvPrefix='Evaluating This : '
  14293. ShowThisS=CmdBeingEvaluated
  14294. if length(ShowThisS)>300 then
  14295. ShowThisS=left(ShowThisS,300)|| ' ...(Too much to show all)'
  14296. CmdSepL=RexEOL||copies(' ',length(EvPrefix))
  14297. ShowThisL=EvPrefix||ReplaceString(CmdBeingEvaluated, ";",CmdSepL)
  14298. ShowThisL=ReplaceString(ShowThisL, '0D'x, '')
  14299. call Line1 ShowThisS,ShowThisL
  14300. end
  14301. if RexWhich='REGINA' then
  14302. ReginaUname=' (' || uname() || ')'
  14303. else
  14304. ReginaUname=''
  14305. FailingLineText=AddCommasToDecimalNumber(FailingLine)
  14306. call Line1 'Operating System: ' ||RexSystemOpSys||ReginaUname
  14307. call Line1 'Rexx Version    : ' ||RexVersionInfo
  14308. if CmdBeingEvaluated='' then
  14309. DumpSource='Y'
  14310. else
  14311. do
  14312. DumpSource='N'
  14313. call DumpVarsInExpression CmdBeingEvaluated,, 'KNOWN VARIABLES', 'Line1'
  14314. end
  14315. if DumpSource='Y' then
  14316. do
  14317. call Line1 'Failing Module  : ' || PpWizardPgmName || ' (' || PgmVersion || ')'
  14318. call Line1 'Failing Line #  : ' ||FailingLineText
  14319. InRoutine=_FindLastLabel(FailingLine)
  14320. StartAt=FailingLine-7
  14321. if FoundLabelOnLine<>0 then
  14322. do
  14323. if FoundLabelOnLine>StartAt then
  14324. StartAt=FoundLabelOnLine
  14325. else
  14326. do
  14327. if FoundLabelOnLine<>0 then
  14328. do
  14329. if(FailingLine-FoundLabelOnLine)<10 then
  14330. StartAt=FoundLabelOnLine
  14331. else
  14332. call Line1 'After label     : ' ||InRoutine
  14333. end
  14334. end
  14335. end
  14336. call Line1 'SOURCE'
  14337. call Line1 '~~~~~~'
  14338. vlist.0=0
  14339. do ShowLine=StartAt to FailingLine
  14340. FailingSrcLineTxt=strip(QuickSourceLine(ShowLine))
  14341. call Line1 left(AddCommasToDecimalNumber(ShowLine),length(FailingLineText))|| ' : ' ||FailingSrcLineTxt
  14342. call DumpVarsInExpression FailingSrcLineTxt, 'vlist'
  14343. end
  14344. call DumpVarsInExpressionNow 'vlist', 'KNOWN VARIABLES', 'Line1'
  14345. end
  14346. HookText=TrapHeading|| ' at line ' || FailingLineText || '. ' || TextDescription || ': ' ||Text
  14347. call CgiEndFatalError
  14348. call Line1 HighlightColor||copies('=+',39)||Reset
  14349. call Line1 ''
  14350. if UserBreakPoint<> '' then
  14351. do
  14352. call RexxTrace HookText,,,'Y'
  14353. end
  14354. AbnormalExit(FailingLine,HookText)
  14355.  
  14356. RexxTrapUninitializedVariable:
  14357. TrappingLine=SIGL
  14358. call CommonTrapHandler TrappingLine, 'NoValue Abort!', 'Unknown Variable', condition('D')
  14359.  
  14360. RexxTrapSyntaxError:
  14361. TrappingLine=SIGL
  14362. call CommonTrapHandler TrappingLine, 'Syntax Error!', 'Reason',errortext(Rc)
  14363.  
  14364. SimpleCommonTrapHandler:
  14365. if HaveCapturedTrapDetails='N' then
  14366. do
  14367. FailingLine=arg(1)
  14368. TrapHeading=arg(2)
  14369. TextDescription=arg(3)
  14370. Text=arg(4)
  14371. end
  14372. FailingLineText=AddCommasToDecimalNumber(FailingLine)
  14373. say ''
  14374. say copies('*-',39)
  14375. say TrapHeading
  14376. say copies('~',length(TrapHeading))
  14377. if HaveCapturedTrapDetails='Y' then
  14378. say 'Trap within Trap: Original trap details saved and displayed below!'
  14379. say substr(TextDescription,1,16)|| ': ' ||Text
  14380. BetterErrorText=Condition('D')
  14381. if BetterErrorText<> '' &BetterErrorText<>Text then
  14382. call Line1 copies(' ',18)||BetterErrorText
  14383. parse source . . PpWizardPgmName
  14384. parse version VersionOfRexx
  14385. FailingSrcLineTxt=strip(QuickSourceLine(FailingLine))
  14386. say 'Failed at       : ' || PpWizardPgmName || ' (line ' || FailingLineText || ', version ' || PgmVersion || ')'
  14387. say 'Source Code     : ' ||FailingSrcLineTxt
  14388. say 'Rexx Version    : ' ||VersionOfRexx
  14389. call DumpVarsInExpression FailingSrcLineTxt, '', 'KNOWN VARIABLES'
  14390. HookText=TrapHeading|| ' at line ' || FailingLineText || '. ' || TextDescription || ': ' ||Text
  14391. if HaveCapturedTrapDetails='Y' then
  14392. do
  14393. FailingLine=arg(1)
  14394. TrapHeading=arg(2)
  14395. TextDescription=arg(3)
  14396. Text=arg(4)
  14397. say ''
  14398. say 'Reason for secondary trap'
  14399. say '~~~~~~~~~~~~~~~~~~~~~~~~~'
  14400. say substr(TextDescription,1,16)|| ': ' ||Text
  14401. say 'Failed at       : ' || PpWizardPgmName || ' (line ' || FailingLineText || ', version ' || PgmVersion || ')'
  14402. say 'Source Code     : ' ||strip(QuickSourceLine(FailingLine))
  14403. end
  14404. say copies('*-',39)
  14405. call CallErrorHookForSimpleOneLiner HookText
  14406. ExitNowCallingAnyHandlers(FailingLine)
  14407.  
  14408. SimpleRexxTrapUninitializedVariable:
  14409. TrappingLine=SIGL
  14410. call SimpleCommonTrapHandler TrappingLine, 'NoValue Abort!', 'Unknown Variable', condition('D')
  14411.  
  14412. SimpleRexxTrapSyntaxError:
  14413. TrappingLine=SIGL
  14414. call SimpleCommonTrapHandler TrappingLine, 'Syntax Error!', 'Reason',errortext(Rc)
  14415.