Thanks to those who replied to my request for help optimizing:
SETVAR JUNK ORD(RTF_CCTL)
ECHO ![___!JUNK]!RTF_DATA
Unfortunately, the suggestions don't actually do the same thing as the
original code, although it might not be easy to see why without looking at
looking at the entire (long) command file.
The good news is, I get a about a 13% reduction in execution time for the
entire command file just by combining the 'setvar' above with an earlier
line that I did not include in the original post. It still bugs me that
such a minor tweak makes such a big difference to a big routine that does
actual file I/O.
It turns out that
SETVAR JUNK ORD(STR (RTF_REC,1,1))
ECHO ![___!JUNK]!RTF_DATA
is quite a bit faster than
SETVAR RTF_CCTL STR (RTF_REC,1,1)
SETVAR JUNK ORD(RTF_CCTL)
ECHO ![___!JUNK]!RTF_DATA
and the only surprise is why I didn't see it earlier.
Still tweaking the rest of the file, but execution time is already down to
bit less than half what I sent to a few sites last week. In a another day
or two I hope to have a new version ready.
Some background/context for the above code.... It replaces HP
carriage-control codes with corresponding RTF codes, for example:
HP new page, chr(49) becomes '\page '
single-space, chr(129) becomes '\par '
double-space, chr(130) becomes '\par\par ', etc.
In initialization, I set up a array of variables containing the RTF codes,
such as: ___49 = '\page ', ___129 = '\par ', etc.
Then in the loop that processes each record, using form-feed as an example,
STR (RTF_REC,1,1) = 49, JUNK = 49, and the properly dereferenced,
![___!JUNK] is '\page ', which is what the output file must contain. And it
is enough faster to be worth the extra trickiness, compared to the old
series of IFs & ELSEIFs.
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|