|
> Another problem with the above code is what happens if the ~~~~ occur on > the 1024 byte boundary? If I only get 2 '~'s at the end of the USERAREA > buffer the scan won't work. That's easy. Instead of: C eval usrspcptr = usrspcptr + 1024 use C eval usrspcptr = usrspcptr + 1021 It's not immediately obvious, but the three-character overlap between 1024-byte chunks will guarantee that any given four-byte substring will be found in exactly one chunk. Think about it! Another optimisation you could use: while scanning for the '~~~~'s, you could remember where you found them in the user space (perhaps storing them in a user index). Then, instead of having to re-scan the user space, you could use the stored offsets to position directly into the space, and substitute the total page count directly. One final thought: instead of outputting '~~~~' for the total page count, I would probably modify the original report to output '~~~~~~~~~~~~~~~~~' as a placeholder for the entire page number heading. Then, rather than substitute ' 25' for '~~~~', I would substitute ' Page 1 of 25' for the entire placeholder. For my money, this looks greatly superior to 'Page 1 of 25' on the final report, and is not really any more difficult to do. (Note that this would change my '1021' solution above to a '1008' solution -- the pointer increment must always be the the chunk length, less the length of the string being sought, plus one.) My EUR 0.02... -- Paul +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.