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

network printing with "???"

Status
Not open for further replies.

fotojock

Programmer
Jun 1, 2000
9
US
Using DOS Foxpro 2.5, I can print to a local printer with the code:<br><br>SET PRINTER TO lpt1<br>SET PRINTER ON<br>??? codestring<br>SET PRINTER OFF<br><br>But using Windows Foxpro 2.6, Win95, and Netware 3.2, I'm unable to print to a network printer attached to an HP Jetdirect box when using the same &quot;direct&quot; technique.&nbsp;&nbsp;The server name is SERVER1, and the printer & queue name is ORION (for an Eltron Orion label printer), and the codes I'm using are:<br><br>SET PRINTER TO \\SPOOLER \N\S=SERVER1\Q=ORION<br>SET PRINTER ON<br>??? codestring<br>SET PRINTER OFF<br><br>This fails on the line &quot;SET PRINTER ON&quot; or on the line &quot;??? codestring&quot; if I comment out the &quot;SET PRINTER ON&quot; line.&nbsp;&nbsp;Error message is &quot;Printer Not Ready,&quot; but the printer is on and ready.<br><br>This printer works if I use the Windows driver, and I'd prefer to use it, but the resulting barcodes are not readible on my tiny label (2&quot;x1&quot;), the fonts are not very good, and the printer hesitates between labels.&nbsp;&nbsp;These problems don't exist with the &quot;direct&quot; technique, using the printer's internal barcode, font, and control features, and that's why I need to get this to work.<br><br>There is one parameter for the &quot;SET PRINTER TO&quot; line that I haven't tried, and that's the &quot;\P&quot; parameter, which specifies a printer number.&nbsp;&nbsp;I don't know WHAT number this refers to, so I can't use it (though I did try 0 and 1 anyway).&nbsp;&nbsp;Any help, please?&nbsp;&nbsp;
 
That is one reason that we went from JetDirect to Axis.&nbsp;&nbsp;They are much better behaved.
 
You need 3 more lines of code for network printing.<br><br>Set Device to Print<br>set print on<br>set print to xxx<br>???<br>set printer off<br>set device to screen<br>set printer off<br><br>Yes you need both set printer off commands.<br>You can stop the second set printer off if you run the Novell Capture command befroe the print job.&nbsp;&nbsp;Make sure you add the /au /ti=10 /nbb /nt /nff switches <br><br>The /p parameter is only needed if there are more then one printer assigned to the Print Queue, If there is more then 1 printers and you do not add the /p switch the job will go to printer 0 assigned to the print queue.<br>To determine the printer number go to the computer that is the Print Server and the printer number will be listed on the Print Console Screen.&nbsp;&nbsp;If you are using nprinter, go to that computer and drop to dos and type nstatus. <p>David W. Grewe<br><a href=mailto:Dave@internationalbid.net>Dave@internationalbid.net</a><br><a href= > </a><br>
 
how would you go about this same thing when working with NT instead of a Novell??
 
FoxPpo 2.5 DOS - You Lose<br>FoxPro 2.6 DOS - You Lose Again<br>FoxPro 2.6 Win - You can do it.<br>But the bad part about NT printing is the user and the OS itself .&nbsp;&nbsp;NT allows the users to name the printers anything that want.&nbsp;&nbsp;So, if you have one printer and 10 computers using it you could have 10 different names for that printer.&nbsp;&nbsp;On my Network The users are not allowed to set up printers. All printer names are stored in a common free table for all programs to access.&nbsp;&nbsp;MicroSoft has routines available for download in thier knowledge base that changes the default printer but you need to know the EXACT PRINTER NAME ON THAT COMPUTER<br><br>select 0<br>use PRINTERS <br>locate for xxxxx<br>run routines to set default printer.<br>Set Device to Print<br>set print on<br>???<br>set printer off<br>set device to screen<br><br>If you use VFP you can drop the change the default printer routines for one command <br>select 0<br>use PRINTERS <br>locate for xxxxx<br>set printer to name (alltrim(PRINTERS.WIN_NAME))<br>???<br>set printer off<br>set device to screen<br><br>Again Your NT Network Print Services may not be set up like mine so this may not work for you.<br> <p>David W. Grewe<br><a href=mailto:Dave@internationalbid.net>Dave@internationalbid.net</a><br><a href= > </a><br>
 
Thanks for your help, Dave!&nbsp;&nbsp;The code as you listed did not work, but a variation of it did, as follows:<br><br>RUN CAPTURE TI=0 NA NB NT NFF QUEUE=ORION<br>SET PRINTER TO LPT1<br>SET PRINTER ON<br><br>??? etc<br><br>SET PRINTER OFF<br>ENDCAP<br><br>The SET DEVICE TO PRINT line you suggested had no effect.&nbsp;&nbsp;I tried all manner of combinations of all these commands until I got it to work. The black DOS screen flashes by twice, at CAPTURE and ENDCAP, even tho I set FOXRUN.PIF to run minimized.&nbsp;&nbsp;Be nice if it didn't show at all.<br><br>There is one real problem left: each time SET PRINTER TO LPT1 is executed, some code is sent to my default printer!&nbsp;&nbsp;I was able to view the code with XTREE while it sat in the queue, and it was 5 lines of PJL code to set resolution, page protect, and language, and such for my laser printer.&nbsp;&nbsp;This causes a blank page to print on my laser.&nbsp;&nbsp;I tried setting the default printer to several different printers, and the print job was sent each time to whichever printer was set to the default.&nbsp;&nbsp;I tried all kinds of commands in the Foxpro code to try to eliminate this extraneous &quot;print job&quot;, but to no avail.&nbsp;&nbsp;Any ideas on this one?<br><br>Randy
 
Do not believe the extra print job is FoxPro generarted, I think it is Novell doing it and do not believe you can stop it. It seems like novell can not tell then the user is finished with a print job so it issues that code to prevent one job from being printed on the same page as a different job.&nbsp;&nbsp;I remember trying to eliminate it and the dos window screen and never could do it,&nbsp;&nbsp;Seems like I finally gave up using the ??? command.&nbsp;&nbsp;I wrote what I wanted printed to a text file with Fopen(), fput() fclose() then printed the text file when I was finished.&nbsp;&nbsp;Can not remember why I did it that way but I do remember doing it and it solved some problem with the ??? command. Seems like the if you had 2 computers running a program with the ??? command, you are adding new print job with each ??? call.&nbsp;&nbsp;Novell would print all ??? calls from one computer on one page until the second computer started sending print requests to the printer with the ??? command. Novell printeted the info from the first computer and then stared a new print job for the second computer.&nbsp;&nbsp;Then first computer started back in with the ??? calls the process was repeated and the info fo the second conputer was printed.&nbsp;&nbsp;You end up with several pieces of paper with parts of one page of info on several sheets of paper.<br><br>It has been a long time since I had to play with it and my memory is not clear. (Must be old age)<br><br>Anyway,<br>On your capture command add the A(novell3) or AU (novell4) switch also.&nbsp;&nbsp;<br>Have you tried adding the LPT1 port to the capture command and not using the Set Printer to LPT1 line? <p>David W. Grewe<br><a href=mailto:Dave@internationalbid.net>Dave@internationalbid.net</a><br><a href= > </a><br>
 
The &quot;A&quot; is the default for CAPTURE anyway, but I used ENDCAP to force the print immediately (as opposed to on program exit).&nbsp;&nbsp;The default for LPT in CAPTURE is 1, and I see no other parameter where I could specify LPT.&nbsp;&nbsp;Novell prints using queues, so I guess I have to say QUEUE=ORION.<br><br>I tried NOT using CAPTURE, connecting the printer directly to LPT1, and it worked the same as with CAPTURE . . . the laser page was still ejected!&nbsp;&nbsp;Then I tried it on Windows 98 with the same results.&nbsp;&nbsp;I do have the same code and setup (no CAPTURE, LPT1 connection, Orion printer) on another computer.&nbsp;&nbsp;The Foxpro program there is a 2.5 DOS program, and it is run from Windows 95, and it does NOT eject the laser page!&nbsp;&nbsp;So this eliminates Novell as the culprit and points to Windows, especially since it always prints to the Windows DEFAULT printer.&nbsp;&nbsp;Now I wonder if there's a command I could call from Foxpro (or some value I could modify) to automatically change the Windows default printer on the fly.&nbsp;&nbsp;Then I could switch the default to a dummy printer (LPT3), print my labels, then switch it back.&nbsp;&nbsp;That might work, but I need that command.&nbsp;&nbsp;Anyone know if there is one?&nbsp;&nbsp;I'll post the question on a new thread here and in the Windows 95 forum too.&nbsp;&nbsp;Thanks!
 
Dave, I managed to write the codes into a file, but all attempts to print the file have failed, with stuff still going to my default printer.&nbsp;&nbsp;Code I tried was &quot;TYPE file.dat TO PRINTER.&quot;&nbsp;&nbsp;Is there another way to print the file?
 
I blow the dust off this old dos routine,&nbsp;&nbsp;see if it will do you any good.&nbsp;&nbsp;Alter, modify, pass around, distroy as you see fit.<br><br><br>procedure ASCPRT<br>*/***************************************************************************<br>*/Program&nbsp;&nbsp;&nbsp;:<br>*/System&nbsp;&nbsp;&nbsp;&nbsp;:<br>*/Purpose&nbsp;&nbsp;&nbsp;: Prints any file to a port lpt1<br>*/Syntax&nbsp;&nbsp;&nbsp;&nbsp;: AscPrt(file,font.eject)<br>*/Returns&nbsp;&nbsp;&nbsp;: Logical, .t. if successful<br>*/Parameter : String - FILE - Name Of The FILE To Print<br>*/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: String - Font - Font to use in windows<br>*/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: logical - eject - eject a page when complete.<br>*/Defaults&nbsp;&nbsp;: None<br>*/Requires&nbsp;&nbsp;: Nothing<br>*/Changes&nbsp;&nbsp;&nbsp;: Nothing<br>*/Calls&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: Nothing<br>*/Drawback&nbsp;&nbsp;: Function will not reset printer pitch, Lines Per Inch, Ect.<br>*/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: It Prints At the current printer defaults<br>*/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: See procedure SetPrn for positive printer control.<br>*/Calls&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:<br>*/Version&nbsp;&nbsp;&nbsp;:<br>*/Dated&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7/10/91<br>*/Written By: David W. Grewe<br>*/***************************************************************************<br>*& File Handling-Text<br>*/***************************************************************************<br>*/ Record Of Change<br>*/ <br>*/***************************************************************************<br>parameter P_FILE, P_FONT, P_EJECT<br>private P_FILE, P_FONT, L_PARA, L_ASCPRT<br>L_PARA = parameters()<br>L_ASCPRT = .f.<br>*<br>if L_PARA &lt; 3 or type(&quot;P_EJECT&quot;)&lt;&gt;&quot;L&quot;<br>&nbsp;&nbsp;P_EJECT=.f.<br>endif<br>*<br>if L_PARA &lt; 2 or empty(P_FONT)<br>&nbsp;&nbsp;P_FONT=&quot;'MS Sans Serf',8&quot;<br>endif<br>*<br>if L_PARA &lt; 1 .or. type(&quot;P_FILE&quot;) # &quot;C&quot;<br>&nbsp;&nbsp;wait window &quot;Function AscPrt, Requires A File Name to Print As A Parameter.&quot;<br>else<br>&nbsp;&nbsp;if file(P_FILE)<br>&nbsp;&nbsp;&nbsp;&nbsp;set talk off<br>&nbsp;&nbsp;&nbsp;&nbsp;set printer on<br>&nbsp;&nbsp;&nbsp;&nbsp;set console off<br>&nbsp;&nbsp;&nbsp;&nbsp;set device to print<br>&nbsp;&nbsp;&nbsp;&nbsp;if ERRPRNW(.t.)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;L_FILE=fopen(P_FILE)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do while ! feof(L_FILE)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;L_TEXT=fgets(L_FILE)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if _dos<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;? L_TEXT<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;? L_TEXT font (P_FONT)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endif<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enddo<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=fclose(L_FILE)<br>&nbsp;&nbsp;&nbsp;&nbsp;endif<br>&nbsp;&nbsp;&nbsp;&nbsp;set device to screen<br>&nbsp;&nbsp;&nbsp;&nbsp;set console on<br>&nbsp;&nbsp;&nbsp;&nbsp;set printer off<br>&nbsp;&nbsp;&nbsp;&nbsp;set printer to<br>&nbsp;&nbsp;&nbsp;&nbsp;set printer off<br>&nbsp;&nbsp;&nbsp;&nbsp;set printer to<br>&nbsp;&nbsp;&nbsp;&nbsp;if P_EJECT<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eject<br>&nbsp;&nbsp;&nbsp;&nbsp;endif<br>&nbsp;&nbsp;&nbsp;&nbsp;L_ASCPRT = .t.<br>&nbsp;&nbsp;endif<br>endif<br>return L_ASCPRT<br> <p>David W. Grewe<br><a href=mailto:Dave@internationalbid.net>Dave@internationalbid.net</a><br><a href= > </a><br>
 
After rereading the above post, I figured you will need this program also<br><br>*/***************************************************************************<br>*/Program&nbsp;&nbsp;&nbsp;: Function ErrPrnw<br>*/System&nbsp;&nbsp;&nbsp;&nbsp;:<br>*/Purpose&nbsp;&nbsp;&nbsp;: This Function Tests The Printer For Being On Line<br>*/Syntax&nbsp;&nbsp;&nbsp;&nbsp;: ErrPrn(SPO)&nbsp;&nbsp;or on error L_test = errprnw()<br>*/Return&nbsp;&nbsp;&nbsp;&nbsp;: Logical&nbsp;&nbsp;.t. Printer is Ready&nbsp;&nbsp;&nbsp;&nbsp;.f. Printer is not ready<br>*/Parameter : Logical - SPO - Set Printer On and Console off<br>*/Defaults&nbsp;&nbsp;: SPO = .f.<br>*/Requires&nbsp;&nbsp;: Nothing<br>*/Changes&nbsp;&nbsp;&nbsp;: Nothing<br>*/Calls&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: Nothing<br>*/Calls&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:<br>*/Version&nbsp;&nbsp;&nbsp;: 1.0<br>*/Dated&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: 7/09/91<br>*/Written By: David W. Grewe<br>*/***************************************************************************<br>*& Error Handling<br>*/***************************************************************************<br>*/ Record Of Change<br>*/<br>*/***************************************************************************<br>parameter P_SPO<br>private P_SPO<br>if parameters() &lt; 1 .or. type(&quot;P_Spo&quot;) # &quot;L&quot;<br>&nbsp;&nbsp;P_SPO = .f.<br>endif<br>**************<br>L_ESC=set(&quot;escape&quot;)<br>L_CUR=set(&quot;cursor&quot;)<br>L_PRN=set(&quot;printer&quot;)<br>L_CON=set(&quot;console&quot;)<br>set cursor off<br>set console off<br>set escape off<br><br>L_ERRPRN = .f.<br>do while .t.<br>&nbsp;&nbsp;if sys(13) # &quot;OFFLINE&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;if P_SPO = .t.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set device to print<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set printer on<br>&nbsp;&nbsp;&nbsp;&nbsp;endif<br>&nbsp;&nbsp;&nbsp;&nbsp;L_ERRPRN = .t.<br>&nbsp;&nbsp;&nbsp;&nbsp;exit<br>&nbsp;&nbsp;endif<br>&nbsp;&nbsp;**<br>&nbsp;&nbsp;define window ERRORS from 0,0 to 14,60 font &quot;FOXFONT&quot;,9 system ;<br>&nbsp;&nbsp;&nbsp;&nbsp;title &quot;Printer Error Message&quot; ;<br>&nbsp;&nbsp;&nbsp;&nbsp;footer &quot;Press Any Key To Retry, or Esc To Exit&quot; ;<br>&nbsp;&nbsp;&nbsp;&nbsp;noclose nofloat nogrow nozoom nomdi shadow color scheme 7<br>&nbsp;&nbsp;activate window ERRORS noshow<br>&nbsp;&nbsp;move window ERRORS center<br>&nbsp;&nbsp;@ 1,10 say &quot;There Is Something Wrong With The Printer.&quot;<br>&nbsp;&nbsp;@ 2,10 say &quot;&nbsp;&nbsp;There Are Several Things To Check&quot;<br>&nbsp;&nbsp;@ 4,10 say &quot;&nbsp;&nbsp;&nbsp;&nbsp;1. The Printer Is Not On Line.&quot;<br>&nbsp;&nbsp;@ 5,10 say &quot;&nbsp;&nbsp;&nbsp;&nbsp;2. The Printer Is Out Of Paper.&quot;<br>&nbsp;&nbsp;@ 6,10 say &quot;&nbsp;&nbsp;&nbsp;&nbsp;3. There Is A Cable I/O Problem.&quot;<br>&nbsp;&nbsp;@ 7,10 say &quot;&nbsp;&nbsp;&nbsp;&nbsp;4. The Printer Has Timed Out.&quot;<br>&nbsp;&nbsp;@ 8,10 say &quot;&nbsp;&nbsp;&nbsp;&nbsp;5. The Printer Is Busy.&quot;<br>&nbsp;&nbsp;@ 9,10 say &quot;&nbsp;&nbsp;&nbsp;&nbsp;6. Not Capture To Network Printer.&quot;<br>&nbsp;&nbsp;@ 11,10 say &quot;Please Check The Printer.&quot;<br>&nbsp;&nbsp;activate window ERRORS<br>&nbsp;&nbsp;wait &quot;&quot; to NOTHING<br>&nbsp;&nbsp;deactivate window ERRORS<br>&nbsp;&nbsp;release window ERRORS<br>&nbsp;&nbsp;if lastkey() = 27<br>&nbsp;&nbsp;&nbsp;&nbsp;exit<br>&nbsp;&nbsp;endif<br>enddo<br><br>set escape&nbsp;&nbsp;&L_ESC<br>set cursor&nbsp;&nbsp;&L_CUR<br>set printer &L_PRN<br>set console &L_CON<br><br>release P_SPO<br>return L_ERRPRN<br> <p>David W. Grewe<br><a href=mailto:Dave@internationalbid.net>Dave@internationalbid.net</a><br><a href= > </a><br>
 
Thanks for all that code!&nbsp;&nbsp;But I just can't make it work.&nbsp;&nbsp;Am now printing the labels beautifully with ???, though the blank page still comes out on the default printer.&nbsp;&nbsp;I can live with that, but now I've tested for errors (printer off, out of labels, etc), and Foxpro crashes with a GDF.&nbsp;&nbsp;I get this (seemingly DOS) message: &quot;System Error - Cannot Write to Device LPT1 - Make sure the network is working - if it is a local drive, check the disk and the device driver.&quot;&nbsp;&nbsp;When I hit &quot;Retry,&quot; the GDF occurs.&nbsp;&nbsp;When I hit &quot;Cancel,&quot; the following message pops up: &quot;Printer Driver is Corrupted.&quot;&nbsp;&nbsp;When I hit &quot;Ignore&quot; or &quot;Cancel&quot; with this message, the GDF also occurs.&nbsp;&nbsp;Don't see a solution to this one.&nbsp;&nbsp;Now I'm wondering how I might use the Windows driver to send the strings of special codes to this label printer.&nbsp;&nbsp;Maybe just create a REPORT with the code strings as fields?&nbsp;&nbsp;This is one solution not tried yet.&nbsp;&nbsp;My first attempt to use the Windows driver had the REPORT using only the data fields to be printed on the label, but not the command strings that manipulate the printer's built-in fonts and other variables.&nbsp;&nbsp;This worked but did not produce a useable label since the Truetype barcode was unreadable and there was no fixing it.&nbsp;&nbsp;Seems to me that the command strings will just be treated as data and PRINTED onto the label, rather than the printer understanding them as COMMANDS.&nbsp;&nbsp;I really don't know WHAT it will do, so guess will try it.&nbsp;&nbsp;Any comments?
 
I have the same problem with ??? in FoxPro 2.6a on newer machines (with a USB port) and even with older machines with newer versions of Windows 95 (that support USB ports). I have not found a solution, but have found Visual Foxpro to work. I need a fix for 2.6a as well. It is not a Network printing problem, as I have tried printing to a file (I set up a printer driver for Generic to print to a file C:\xxx).<br><u>My solution:</u> Find an older machine that does not have a USB port, and load an old original version of Windows 95 (without USB support)<br><br>If anybody has a solution that works on newer systems with newer OS's, please HELP!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top