• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1918
  • Last Modified:

Using Foxpro to print an ASCII text file that contains printer control characters

I have an old Foxpro program that creates an ASCII text file that contains printer control characters.  Presently the end users select a default printer from with in the program, this captures an LPT port and I simply copy the text file to the LPT port and it prints.  (Basic DOS print)  However I have recently been running into a network security issue with certain users that are not able to capture/redirect to the LPT port.
Because I am not a domain admin on this particular network troubleshooting this is difficult....but I thought I would update the program and try to use the Windows interface, like a common dialog box on the form where a user can select their default printer instead of using the LPT capture.  However I am running into difficulty for example if I use somthing like the 'TYPE' command to output the file to the printer, it does not recognize the ASCII spaces embedded in the file correctly so nothing on the report lines up...it looks like crap.  I am trying to avoid creating a very detailed report template in Foxpro for this...there are just so many fields and tables it would take hours.  Is there a way to simply print an ASCII text file with embedded printer control characters from FoxPro using the Windows common dialog or other command?  Any feedback would be greatly appreciated.  PCELBA....I could use your help on this one.
1 Solution
CaptainCyrilFounder, Software Engineer, Data ScientistCommented:
I don't know how your program is done but the way I did it as follows:

1) Send the report with Control Characters to a text file
2) Run a DOS Shell and print that file to a port: PRINT trialbal.txt > lpt1:

This way it prints much faster specially if the report is big. I am talking 700+ pages.
Patmac951Author Commented:
Thanks for reply Captain.  Your reply is basically what I have been doing with this program for the last 10 or 12 years, printing via DOS. This program is installed in a large company of over 300 users and the majority of the users work fine using my DOS print procedure.  However there are some computers on the network that will not allow an LPT capture unless the user is a local admin.   Secondly I am trying to convert the program to print the ASCII file via the true Windows interface so remote users via RDP can print to their locally installed printers.  I am really hoping to find a true Windows solution to this without having to use the old DOS technique.
Hi Patmac

Use the ??? command, like in:
set printer to GetPrinter()
??? "Your ASCII String here"
** or **
??? FiletoStr( YourAsciiFile )
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now