Microsoft Visual FoxPro 6.0 Printing (The FoxPro For DOS way)

Posted by Rey Dacoco in

One of the most important features that a good database system should have is its ability to generate printed reports. In this tutorial we will learn how to print the contents of a Visual FoxPro from…the good old FoxPro for DOS way. Actually there is another way, the one that involves using Advanced Programmers Interface or API but since I hate to complicate simple things, we will be using the easiest way, the DOS way.For the sake of example, we will use the form below, actually it’s not a form…it’s a sketch. But in this tutorial, I would like you to think of it as a real form. Just for now, okay?


OUR FORM



What we have here, ladies, is a form with two labels (Name and Last name) and two textboxes beside each labels. Of course don’t forget those tiny buttons named Print and Exit. Let us make up a name for the print button because that’s the object where we will place our codes later on, let’s call it Print… what do you think?So our aim here is…if the user runs the form and types a text on those textboxes, and clicks the Print button, whatever ever text that was entered by the user will be sent onto the printer. Of course it is only possible if we attach a code onto the Print button. To do that, double click the Print button in the design time then type the following codes in the click procedure event.


SET CONSOLE OFF
//The text that is being printed will appear on the screen if
//you turn this ON, you don’t want that, wont you?
SET PRINTER ON
//Send the text onto the printer.
? ThisForm.Text1.Text''
//The question mark symbol displays our text on a new line while
//ThisForm.Text1.value indicates the source of the text that will be sent onto the
//printer, in this case, it’s text1 or the textbox beside the name label.
? ThisForm.Text2.Text
//Prints the contents of text2 or the textbox beside the Last name label.
Wait Window ‘Please wait…Printing’
//Some Hollywood special effects
SET PRINTER OFF
//If you turn it ON, you should also know how to turn it off…Good Boy.
And that’s it. No Sweat. We are done. If you have 10 textboxes in your form then just add ? Thisform.text3.text, ?Thisform.text4.text, and so on. It is just that simple and you don’t have to be good –looking and rich to do that. Let us have a quick glance at those codes again…



SET CONSOLE OFF
SET PRINTER ON
? ThisForm.Text1.Text
? ThisForm.Text2.Text
Wait Window ‘Please wait…Printing’
SET PRINTER OFF
You can copy, paste and edit these codes Just don’t forget to thank me. You can send me some love letters too.

2 comments

Tnx for sharing it. Helped me.

problem solved.thanks.

Post a Comment

Contributor

My photo
I am just a simple man with a simple mind. And this is my simple blog. New Posts will be available soon. Enjoy reading and never stop learning:)

Total Pageviews

Link List

Archives

Got questions? You can reach me here: