8< ----------------------------
)This is not "better", I just wanted to point out that repl() exists
)and could be useful for doubling CI metacharacters in lines that
)you may be echoing to a file.
)
)Jeff Vance, CSY
)
)--
... and the evaluator function repl makes it possible to avoid
unwanted variable dereference in lines 2/last of the job file;
our script can look as follows
(must be on MPE/iX 5.5):
parm _job,char='!',AT='',day='',date='', in='',_step='STEP1'
if '!_step' = 'STEP1' then
xeq !hpfile '!_job', _step='STEP2' <!_job
setvar timespec ' '
if '!at' > ' '
setvar timespec ';AT=' + '!AT'
endif
if '!day' > ' '
setvar timespec timespec + ';DAY=' + '!DAY'
endif
if '!date' > ' '
setvar timespec timespec + ';DATE=' + '!DATE'
endif
if '!in' > ' '
setvar timespec timespec + ';IN=' + '!IN'
endif
reset tempjob
stream tempjob,!char !timespec
purge tempjob,temp
deletevar _l, _nrecs, timespec
else
if '!_step' = 'STEP2' then
file tempjob=tempjob,oldtemp
if finfo('*tempjob','exists') then
purge tempjob,temp
endif
file tempjob;temp;disc=![finfo('!_job','end of file')]
fcopy from=!_job;to=*tempjob;new;subset=0,0 > $null
file tempjob=tempjob,oldtemp
setvar _nrecs finfo('!_job','end of file')
input _l
setvar _nrecs, _nrecs-1
if str(_l,1,1) = '!' then
setvar _l '!' + _l
endif
echo !_l >*tempjob
while _nrecs > 0 do
input _l
setvar _nrecs, _nrecs-1
setvar _l repl(_l,'!','!!')
echo !_l>>*tempjob
endwhile
endif
endif
|