Output file ownership
Tom
tla at aldridgeinc.com
Sat May 20 16:36:20 PDT 2006
>
> The code below is a combination of your code, and some of my code from
> elsewhere modified to fit your code. If you're using 'ln' as a variable
> elsewhere, you'll want to change the name; essentially it acts the same as
> your 'x' but I didn't want to break anything in this quick example.
>
> This is how I'd have done it, and I'll toss in a few extra comments for you
> to follow:
>
> ::declare rptstring, jobname(8,*), IHandle(8,.0), OHandle(8,.0), FPos(20,.0):
> ::declare tmpfile,htmlfile,FLine,FSize(20,.0):
> :'added a few extra declares:':
> ::jobname="we"{doedit(4,"mdy","6"):
> :jobname co chr("32") 'eliminate any space in job name
> :jobname=xlate(jobname,chr("32"),""):
> ::rptstring="/appl/fp/rreport scheddet -f sched -v schedsel -a -ia -u -r" <1 <"-rw" <4 <"-rx" <5:
> :'Left your code alone through here.:':
> ::rptstring=rptstring <"-h" <"\"" <jobname <"\"" <"-pn nocodes -p /appl/fpmerge/html/ " {jobname&".tmp":
> :'In the line above, I modified it to use a .tmp extension:'going back to the two-file approach here:
> ::system rptstring:
> ::tmpfile="/appl/fpmerge/html/"&jobname&".tmp":
> ::htmlfile="/appl/fpmerge/html/"&jobname&".html":
> ::OHandle=open(htmlfile,"wc0b"):
> :'I always do my file operations in binary mode for portability.:'This actually has no effect on *nix systems:
> :OHandle lt "0":end:
> ::FLine="<PRE>";ln=writeline(OHandle,FLine):
> :'There, we wrote the beginning of the file with the pre tag:'Time to start copying the other file in:
> ::IHandle=open(tmpfile,"rb"):
> :IHandle lt "0":end:
> ::FSize=filesize(IHandle):
> ::FPos="0":
> :'File opened, size determined, tracker zeroed, start copying:':
> cploop::ln=read(IHandle,FLine,"8192"):
> :FPos lt FSize and ln eq "0" 'Premture end of file:end:
> ::lo=write(OHandle,FLine):
> :lo ne ln 'Couldn't write as much as we read:end:
> :FPos lt FSize:FPos=FPos+ln;goto cploop:
> :'Fall through to here when nothing left to copy:'Now we finish off with the pre close tag:
> ::ln=writeline(OHandle,"</PRE>"):
> ::ln=close(IHandle);ln=close(OHandle);end:
>
>
Mark,
Thanks. That worked well and I even understand it :)
Tom
More information about the Filepro-list
mailing list