Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help parsing a .ps file 1

Status
Not open for further replies.

PatMcLaughlin

Programmer
Dec 10, 2010
97
US
We have postscript files that are produced in a Foxpro process with Crystal Reports. These files are and will always be duplex-no tumble when printed at the printer, however, with no changes we can find being made on any systems, hardware or files they are no longer created duplex. We have examined all parts of Crystal to insure that it in fact is calling for duplex. Changed printer drivers for the 'postscript' printer. Forced the driver itself to call for Duplex but all to no avail. We have determined that there is one line in each of the .ps files that sets the printer to duplex so as a last resort we have decided to try to parse the postscript file to find and change the line from

'.../Duplex false put setpagedevice'
to
'.../Duplex true put setpagedevice'

This should put these printjobs back into usable production. My problem comes from ignorance of the coding. I have searched for individual characters in a line of text (i.e. changed "'" to ""). I should be able to use a
Code:
Do While ! FEOF(postscript.ps)
lcRead = FGets(postscript.ps)
to walk the file. I believe I can then do
Code:
IIF(substr(lcRead, 16, 47) = "/Duplex false  put setpagedevice", "/Duplex true put setpagedevice"

Am I close at all?

but now how do I save the complete but updated file so that it can be forwarded to the print process?


 
You IIf() is off target, so I won't bother what IIF is for.

Strtran() (string translation) is there to change from one to another string:
Code:
lcRead = STRTRAN(lcRead,"/Duplex false","/Duplex true")

If the files are less than 16 MB there's no need to proecess them line by line, you can then do:
lcFile = FILETOSTR("postscript.ps"), lcFile = STRTRAN(...), and STRTOFILE(lcFile,"postscript2.ps")

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top