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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print 3 by 4 inch labels? 1

Status
Not open for further replies.

Eviltwin

Programmer
Apr 11, 2001
39
US
Greetings all!
I am trying to print 3 by 4 inch labels on an Okidata ML320 dot matrix printer using Pdox 10. Page setup says that I can create a user defined page size. But the report still will not behave. Any of you know a solution for this?

I have already used the great code supplied by Rick Kelly
on and it solved many of my printer issues but not this one.

Thanks
 
EvilTwin,

A lot depends on what you mean by "the report still will not behave." If you could expand on that, it might be a bit easier to help.

Basically, mailing labels in Paradox require setting up the report page so it mimics the page layout of your labels. This means no foots, headers, or groups. Also, it helps to define an MRO to contain the proper set of labels that print on each page. You need to define each MRO record as being fixed in size.

Hope this helps...

-- Lance
 
Footpad,
When I specify user defined paper size in page setup and then print from the default windows menu I get this message: Print layout settings (page, size, paper orientation) have been changed within the print dialogue. This will require each page report to be regenerated. This can take a long time for large reports. Would you like to continue?

If I select "yes" using any of the printers we have the reports never print correctly. I used Rick Kelly's code and Libraries to create an interface that allows me to directly print to any of the printers. That solved all my problems with the other printers except for the Okidata. I have not been able to specify a userdefined pagesize for that printer that is the correct size for the labels we wish to use.

I understand that the fields should not be allowed to grow etc.

Pardon my ingnorance but please define MRO :)

Thanks
Eviltwin
 
Any time I print to a dot matrix printer I write a text stream directly to the printer port doing away with the Paradox reports and the GUI interface completely. I have several apps that print labels to okidata printers all day long without any problems and do so extremely fast.

eg:

var
ts textstream
endvar

ts.open("C:\\lpt1","nw")
ts.writeLine("String to print")
ts.close()


Perrin
 
EvilTwin,

Looks like Perrin's idea might be worth looking at.

MRO == Multi-Record Object, e.g. the *other* container you can place on forms and reports, e.g. the one most frequently used with mailing labels (IMHO, of course...YMMV. ;))

Hope this helps...

-- Lance
 
Thanks footpad and kliot--
Definately points me in a good direction.
Eviltwin
 
Hello Kliot-
I would be very grateful if you could expand upon your solution. I looked at the help screens and there was very little. I have not had occasion to work with textstreams before so I am quite ignorant about them.

Footpad--Thanks for your info it got me close but not quite there.

Still beating my head against this.

Thanks again.
 
I'd be happy to, I'm heading out of the office but I'll post some sample code when I get home tonight. The use of the text stream, specifically writing directly to a port is not well documented but it works great. I also use it for printing barcodes and receipts to thermal printers.

Perrin
 
Eviltwin,

Textstream is fairly simple, it’s commonly used to write to a file but it can also be used to write directly to a port, such as your lpt printer port. Writestring writes a string and WriteLine writes a string with a carriage at the end of it, writeline is pretty much all I use. The idea for printing labels with a text stream is you want to create a table with the desired data then do a scan through the data and send the appropriate data to the textStream adding blank lines for a header and filling in blank lines after the data to complete the label. I really think this is the only way to go for printing to a dot matrix printer, the windows GUI interface has never worked with dot matrix printers, it’s frustrating and slow at best. The textStream method can work really well, I use it in an office envroment across a network with a windows 2000 server printing on multiple machines with local/shared printers on individual workstations with no problems other than an occasional mapping problem that is unrelated to Paradox. I even use virtual ports such as lpt4-9 for my network printers giving me great flexibility.

Here is some sample code

method pushButton(var eventInfo Event)
var
ts textstream
tc tcursor
headerLines, textLines, labelLength number
endvar

ts.open("C:\\a.txt","nw")
tc.open(":priv:answer")

headerLines = 4 ; number of blank lines to be fed before printing begins

textLines = 3 ; number of lines of text to be printed

labelLength = 19 ; label length in lines should be around 19 for a 3" label

scan tc:
ts.writeLine(fill("\n",headerLines)) ; just printing carriage returns for the header
ts.writeLine(tc.firstName"+" "+tc.lastName)
ts.writeLine(tc.address)
ts.writeLine(tc.city+", "+tc.state +" "+tc.zip)
ts.writeLine(fill("\n",labelLength - headerLines - textLines)) ; prints carriage returns to fill in the label length

endscan
ts.close()
tc.close()
endMethod


This code is fairly simple and you should add some error hanlding, you may also have a variable nuber of lines in the address and you will have to adjust the textLines variable to accomidate things like a second address line or a country line. You will also have to limit the length of the lines of text to keep them from rinning off the label or wrap them if necessary. Let me know how this works and if you have any problems please let me know and I’ll help you through them.

Perrin
 
Oops,

the ts.open() should read
ts.open("C:\\lpt1","nw") or whatever port you're using.

I had it set to write to a file so I could test my code at home.

You can also send escape code to the printer using the textStream, I use ts.writeString("\027E") on my epson printers to set the print to bold to give a more readable mailing label.
 
Hi Kliot-
Thanks for the example :) I think if I can get up to speed on this it will solve my conundrum.

executing this code:

method pushButton(var eventInfo Event)
var
ts textstream
tc tcursor
headerLines, textLines, labelLength number
endvar

ts.open("M:\\lpt1","nw")
tc.open("tractortest.db")

headerLines = 4 ; number of blank lines to be fed before printing begins

textLines = 3 ; number of lines of text to be printed

labelLength = 19 ; label length in lines should be around 19 for a 3" label

scan tc:
ts.writeLine(fill("\n",headerLines)) ; just printing carriage returns for the header
ts.writeLine(tc.tractorpage)

ts.writeLine(fill("\n",labelLength - headerLines - textLines)) ; prints carriage returns to fill in the label length

endscan
ts.close()
tc.close()

endMethod

Generates the error message:
"There was an error found when printing the document "No Document Name" to LPT1:. The device is not connected. Do you want to retry or cancel the job?"

I have an Okidata 320 turbo connected to a network computer across the room from my station. I mapped the drive on that machine(cronus) as M:\.

Ideas?

Thanks
Kevin
 
Hi kliot-
I directly touched the station that the printer is hooked up to and changed the ts.open() to ts.open(c:\\lpt1."nw") and the code worked just fine. I can see this is a network issue. What would be the best way to port to this machine in a win 2000 server environment?
Thanks
Kevin
 
Kevin,

I'm glad to hear you're getting things working. To redirect the networked printer run from the command prompt (Start - Run "cmd").

net use lptX: \\workstation\printerName

set X to the port you want to redirect to, 1-9. I redirect to ports 4-9 so I don't interfere with local ports 1-3:
set workstation to the workstation where the printer is located and printerName to the shared name of the printer, make sure sharing is turned on.

Once run the port mapping should be remembered but you will have to do it for each computer on the network, you can also set it to run from a login script.

Perrin
 
Perrin,
Using the cmd: net use "lpt4:\\cronus\okidata" returns: System error 67 has occurred. The network name cannot be found.

I know that machine is connected. I get the same message when I use the cmd on workstation "cronus".

Should I slap myself once or twice?


Kevin

 
Kevin

Just once and then try it again, this time leaving a space after lpt4: if you don't leave the space you will get a "System error 67". computers can be so fussy :)

"lpt4: \\cronus\okidata"

Let me know how it goes.

Perrin
 
Perrin,
The command completed successfully.
Houston we have liftoff!

Now-- do you have some tips on controlling the label format? I am creating tags for a theatrical costume shop that list the production name, actor name, character name, costume description, inventory number and accesories. Would it be best if I put all this information in a temporary table or setup multiple tcursor scans? Some of the field data needs descriptions so the customers can understand what they are looking at.

Thank you very much!! The people that contribute to this site are awesome.
Kevin
 
Great,

Personally I prefer to do a query and scan the temp table with one tcursor but you can do it pretty much any way you want. The only thing I should warn you about is that you are writing raw data to the port so things like data that runs more than one line won't wrap correctly you will have to write code to break up the data appropriatly. It's a bit of a pain but well worth the effort. Let me know if you need more help.

Perrin
 
As mentioned elsewhere if you are using P10 try passing your report arguments via an array

var
daratRpi dynarray[] anytype
LabelPrn string

endvar

printerSetCurrent(LabelPrn)
daratRpi["name"] = "MailLabels"
daratRpi["panelOptions"]=PrintClipToWidth ;solves xtra blank page problem
;etc
r.print(daratRpi)

This is the Paradox10 way to handle reports
 
Perrin,
I setup the code to populate the tag table and everything works just great! The only issue I have left is two fields that may require more than one line. These fields are set for 200 characters. How can I split the data if it exceeds my maximum line length?

You were right about the labels printing fast--they zip!

Kevin
 
Kevin,

I'm so glad you've got it working, it's definitely a slick to print to dot matrix. To print multiple lines you have to do a little work. If your text is 200 characters and your field length is say 70 characters you have to split up the text up into 70 character chunks then back track until you hit a space so you don't break up a word in the middle. At least that's the way I've done it in the past. I wrote code to do it a while ago for a note field on a receipt, I'll see if I can dig up the code and post it for you. You can also do some formating using the printers escape codes, for bold etc. I'll see if I can find those codes for you.

Perrin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top