Printing to network printer with mapped lpt1 (net use lpt1...)

2,157 views
Skip to first unread message

innerservice

unread,
Feb 4, 2014, 4:07:58 PM2/4/14
to harbou...@googlegroups.com
Hi

I have managed to recompile my previous clipper application so far ok but the printing conversion
on Window 8.1 took some creative steps - I have managed to map an lpt1 port to a network printer
and with pooling method sent a job via the spooler to the printer fine - however the job sticks in the
spooler until I completely exit the application - (back to the dos prompt).

I did have to set the printer's advanced options to "TEXT" mode to get the job to actually print as
the native RAW printer processing mode did not actually transpire to process the job output.

So I am seeking an assistance on have the job release while the application is actually active and
not have to exit to free the spooling.

I also tried to remove spooling completely from the printer properties but it is apparent that
printer "pooling" seems to mandate the spooler.

Any ideas would be great - even if it means adding some printer code to close the spooler in
low level characters or what ever.

Thanks in advance -

MB

Massimo Belgrano

unread,
Feb 4, 2014, 4:14:54 PM2/4/14
to harbou...@googlegroups.com

2014-02-04 innerservice <inners...@gmail.com>:

pooling method sent a job via the spooler to the printer fine - however the job sticks in the
spooler until I completely exit the application - (back to the dos prompt)

is this your problem?

innerservice .

unread,
Feb 4, 2014, 4:40:44 PM2/4/14
to harbou...@googlegroups.com
hi Massimo,

first thanks for the prompt reply, I just "just" got it working, evidently
through some further threads in the group. 

I even appear to been able to delete the lpt1 net use mapping and it now works
with the device directly to the share name.

I am still exercising various options to skinny it down to minimal changes.

I will test also after I remove the print pooling and try to eliminate the lpt1 second port.

if it is just base shared network name and a change to the advanced printer processing to Text then that would be the best.

so far so good but some scenarios need to be confirmed yet.

I am happy with the status quo but may get better still...

MB

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users
 
---
You received this message because you are subscribed to a topic in the Google Groups "Harbour Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/harbour-users/nPg40CFpLFQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to harbour-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

innerservice .

unread,
Feb 4, 2014, 4:52:48 PM2/4/14
to harbou...@googlegroups.com
Massimo

I managed to remove the printer port lpt1 and the print pooling option as well with successful output and the spooler functions fine.

still requires the advanced printer processor option set to text though.

so the PS is likely interfering with the raw option....

this is very positive though... I can work this no problem.

thx

MB

Klas Engwall

unread,
Feb 4, 2014, 8:09:37 PM2/4/14
to harbou...@googlegroups.com
Hi MB,

> I managed to remove the printer port lpt1 and the print pooling option
> as well with successful output and the spooler functions fine.
>
> still requires the advanced printer processor option set to text though.
>
> so the PS is likely interfering with the raw option....
>
> this is very positive though... I can work this no problem.

Can you show us the code you use to setup and to finish the print job,
reducing the report to just printing "Hello World"? The behaviour you
describe has been discussed many times over the years, especially in the
comp.lang.clipper newsgroup. Maybe there is a small detail missing in
your current code that we might be able to help you find.

Also, is this a network printer? And is there also a physical LPT1 port
in the computer? If so, redirecting the network printer to LPT1 may
result in circular redirection, and that would only be solved after
quitting the application. But bypassing redirection entirely and
printing straight to \\theserver\theprinter, as you seem to be doing now
according to your report above, will also prevent circular redirection.

I don't think the print spooler should interfere with the raw option, so
there is probably something in the setup of the print job that is missing.

Regards,
Klas

innerservice

unread,
Feb 5, 2014, 9:25:47 AM2/5/14
to harbou...@googlegroups.com
Klas,

Im not sure about the printer advanced options set to TEXT but I have tested the
default RAW and it never completes the print job - so The TEXT option appears to
be somehow related to the formatting / Post Script or otherwise.

I add  the snippet of the code which works for reference - I have sort of thrown the
kitchen sink at it as far as the printer command sets (SET DEVIVCE/SET PRINTER)
however it works as is so I am ok with the construct.

I had initially used the NET USE for the mapping as I read so many references (EVEN XP)
that this was the conduit to make the connection - it was only once I added the temp file to
the base network //machine/share/temp that it started to work without the mapping.

I'm new to the Harbour way(s) however I expect to be here for a while as I am resurrecting
my coding and I expect to take this program to the GUI level once I get it converted to
32/64 bit as the old client is moving away from the 16 bit architecture so it's a new
breath into an old app -

This code was compiled and tested on WIN 7 - 64 bit and it will later today be tested on WIN 8.1
so I am still at it - I expect the same results in summary.

So thank you for the assistance -

Mark -

PROC MAIN()

******************************************************

* PROGRAM ID : Printer.prg

*

SetMode( 24, 79 )

CLEAR

SET ESCAPE on

SET BELL OFF

SET TALK OFF

SET HEADING OFF

SET MENU OFF

SET STATUS OFF

SET SCOREBOARD OFF

SET SAFETY OFF

SET INTENSITY ON

***************************

* SET UP MENU

***************************

CLEAR

DO WHILE .T.

**********************************

* Set color to White on Blue

**********************************

SET COLOR TO W/B

CHOICE=" "

CLEAR

*********************************

* CREATE MENU BOX

*********************************

@09,14 clear to 15,65

@09,10 TO 16,69 DOUBLE

@11,16 SAY "1 SEND PRINT TEST"

@12,16 SAY "X EXIT"

@14,32 SAY "OPTION: " GET CHOICE

READ

IF CHOICE = "1"

SET DEVICE TO PRINTER

SET PRINTER TO "\\MB-T510\495\TEST"

SET PRINTER ON

@0,0 SAY "HELLO WORLD"

@0,20 SAY "GOODBYE WORLD"

SET PRINTER OFF

SET PRINTER TO

SET DEVICE TO SCREEN

ENDIF

IF UPPER(CHOICE) = "X"

CLEAR

CLOSE ALL

SET COLOR TO

CLEAR

QUIT

ENDIF

ENDDO

RETURN

innerservice

unread,
Feb 5, 2014, 9:31:37 AM2/5/14
to harbou...@googlegroups.com
Klas

I should also answer the questions -

This is a network wireless printer, a brother MFC-495 only wireless configured -

The WIN 7 test is on a laptop LENOVO T510 - there are no physical LPT ports -

The Net Use mapping did not interfere with the initial successful test - I removed it
anyhow as it appears to service the network printer without it.

I will be testing on various other printers which will likely be USB connected - but
set to share anyway to allow the connection to work.

I will also test the advanced options on the other printers as well to see if that TEXT
mandate is different in any way.

All best - thanks

Mark

Massimo Belgrano

unread,
Feb 5, 2014, 10:35:07 AM2/5/14
to harbou...@googlegroups.com


2014-02-05 innerservice <inners...@gmail.com>:

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users
 
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Klas Engwall

unread,
Feb 5, 2014, 6:57:54 PM2/5/14
to harbou...@googlegroups.com
Hi Mark,

It seems I was jumping to conclusions last night. You did not spell out
"PostScript" yesterday, so when you finally typed "PS" in your last
message I assumed that you got tired of typing "print spooler" over and
over :-)

> This is a network wireless printer, a brother MFC-495 only wireless
> configured -

I tried to research the features of this printer on the web, but did not
find anything about emulations. But I did find a note about "PostScript
via GDI" or a similar phrase. So is that the only thing it understands?
No PCL, for example? Or simple text mode? Your sample code seems to
indicate that it does understand plain text.

> The WIN 7 test is on a laptop LENOVO T510 - there are no physical LPT
> ports -

OK

> The Net Use mapping did not interfere with the initial successful test -
> I removed it
> anyhow as it appears to service the network printer without it.

In Clipper we had to redirect, since the only valid device names we
could specify were PRN, LPT<n> and COM<n>. Harbour does not have that
limitation, so we can access the printer using the UNC path as long as
the printer exists on that path.

> I will be testing on various other printers which will likely be USB
> connected - but
> set to share anyway to allow the connection to work.

You can print to any locally installed printer using the name it has
been installed under. There are functions in the hbwin contrib lib to
get a list of the printers, etc. But setting up a share and printing to
it is fine too, also on the local machine.

> I will also test the advanced options on the other printers as well to
> see if that TEXT
> mandate is different in any way.

I did see a discussion on the web about advanced configuration options
for the MFC-495 that prevented printing of more than one copy. Maybe
disabling or even just toggling "something" back and forth in the
printer driver might help setting things right (by shaking the registry
a little :-) ).

> Im not sure about the printer advanced options set to TEXT but I
> have tested the
> default RAW and it never completes the print job - so The TEXT
> option appears to
> be somehow related to the formatting / Post Script or otherwise.

Possibly, but if you are not actually using PostScript ... or are you?

> I add the snippet of the code which works for reference - I have
> sort of thrown the
> kitchen sink at it as far as the printer command sets (SET
> DEVIVCE/SET PRINTER)
> however it works as is so I am ok with the construct.
>
> I had initially used the NET USE for the mapping as I read so many
> references (EVEN XP) that this was the conduit to make the
> connection - it was only once I added the temp file to the base
> network //machine/share/temp that it started to work without the
> mapping.

Your code says:

> SET PRINTER TO "\\MB-T510\495\TEST"

This looks a little odd. I take it that the printer is installed locally
on the maching running the test (the LENOVO T510) and that it is shared.
What is the share name? "495\TEST" is the odd part. Why "TEST"? Is that
really part of the share name, and if so, why? I suspect that you were
having problems with Harbour adding ".prn" at the end of the printer
name and you needed to get rid of the extension and that "\TEST" was
something arbitrary you added. There is a SET() that will handle that
problem. Or add a dot, like "\495.", if you do not want all default
extensions in the application to be skipped. That will make it look
cleaner, at least, and less confusing.

About the kitchen sink, maybe we can reduce it a little :-)
I would try something like this:

//-----------------
#include "set.ch"
procedure main()
local i := 0
set( _SET_DEFEXTENSIONS, .F. ) // Do not add ".prn"
do while .T.
? "Press <Esc> to exit, any other key to print"
inkey ( 0 )
if lastkey() == 27
exit
endif
set printer to "\\MB-T510\495"
set device to printer
@ 0,0 say "Hello world"
eject
set device to screen
set printer to
i++
? "Printed " + hb_ntos( i ) + " times"
enddo
return
//-----------------

As you can see, I added an EJECT. I also removed SET PRINTER ON/OFF
since they are related to console commands like ? and ?? and do not
affect @...SAY at all. I also swapped the lines around a little. I
wonder if it might help.

Regards,
Klas

Clippero

unread,
Feb 6, 2014, 5:55:56 AM2/6/14
to harbou...@googlegroups.com
See this:

https://groups.google.com/forum/#!searchin/harbour-users/fopen%28\\/harbour-users/xT26omdrm5I/RwkIwHDLlVEJ

And this:

After print:

   SET PRINTER ON
   SET PRINTER TO
   SET PRINT OFF
   SET CONSOLE ON

Qatan

unread,
Feb 6, 2014, 7:02:56 AM2/6/14
to harbou...@googlegroups.com
Hello Massimo,
 
It would be helpful to have some information on your blog about printing with Harbour.
Just an idea....
 
Qatan

Przemyslaw Czerpak

unread,
Feb 6, 2014, 7:06:16 AM2/6/14
to harbou...@googlegroups.com
Hi,

SET PRINTER TO

is enough. It closes printer handle so the spooler knows that the
job has been finished and data can be farther transferred to printer.
Settings like:
SET PRINTER ON
SET PRINT OFF
SET CONSOLE ON
are only internal Harbour/Clipper switches which have no effect on
printer spooler.

BTW to force printer output buffer flush keeping the same printer
redirection it's enough to use:
SET( _SET_PRINTFILE, SET( _SET_PRINTFILE ), .T. )

best regards,
Przemek

innerservice .

unread,
Feb 6, 2014, 5:42:55 PM2/6/14
to harbou...@googlegroups.com
Hi Klas

I tried to research the features of this printer on the web, but did not find anything about emulations. But I did find a note about "PostScript via GDI" or a similar phrase. So is that the only thing it understands? No PCL, for example? Or simple text mode? Your sample code seems to indicate that it does understand plain text.

>> The options which I was altering were in the printer properties box under the Advanced tab -  There is a section option called "Print Process" and in that
area there are two lists to select different emulation/conversion options - This was the main item which permitted successful printing of the job. As the original
clipper program only appeared to handle/ send clear text I selected the TEXT option of the selection sets and the printing was successful.

I am not familiar enough with these options to make any further conclusions but just more or less sharing the grief of finally getting to this stage and receiving
the output -

Note that when I moved the lab setup to the Windows 8.1 - I installed a USB attached Dell 1100 laser printer and noticed the same advanced setting options
which again only succeeded when I selected the TEXT option - there are many different combinations of these two lists but the TEXT option
got me to the working model so I did not really make variants to see other options would apply.


Possibly, but if you are not actually using PostScript ... or are you?

This I am not certain - this was programmed in clipper with only Straight TEXT - there were not any other additional
or special characters in any of the jobs.

Your code says:

SET PRINTER TO "\\MB-T510\495\TEST"

This looks a little odd. I take it that the printer is installed locally on the maching running the test (the LENOVO T510) and that it is shared. What is the share name? "495\TEST" is the odd part. Why "TEST"? Is that really part of the share name, and if so, why? I suspect that you were having problems with Harbour adding ".prn" at the end of the printer name and you needed to get rid of the extension and that "\TEST" was something arbitrary you added. There is a SET() that will handle that problem. Or add a dot, like "\495.", if you do not want all default extensions in the application to be skipped. That will make it look cleaner, at least, and less confusing.

>> This was the real game changer and after reading over a dozen articles in the blog - there was only one which made reference to the use of a Dummy file name - until I added this dummy file name - I could
not successfully compile the code - which was a real show stopper - so I added it and voila - the compile proceeded and the fist output  was working ... so I do not know why this was not clearer in some
other threads but it sure made my day.

About the kitchen sink, maybe we can reduce it a little :-)
I would try something like this:

>> I was not clear on the reference manuals, at least between the old clipper school of thought and the mix of Harbour, so I just threw it all in one place, I will skinny it down in the long run now that I have
got the output working - I trust that I have gone into overdrive so easier to clean up than to diagnose a short coming - at least it has not added any interference.

I have been out of the programming arena for 20 years and stepping back into it now reveals that there has been substantial evolution with the coding bases and options, I have a lot to
learn in short but this printing hurdle was the first in the conversion at hand and I am quite happy it is behind me now, the rest is pretty straight up.

Thanks for the feedback - much appreciated.

Mark





--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.

Web: http://groups.google.com/group/harbour-users

--- You received this message because you are subscribed to a topic in the Google Groups "Harbour Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/harbour-users/nPg40CFpLFQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to harbour-users+unsubscribe@googlegroups.com.

Klas Engwall

unread,
Feb 6, 2014, 8:10:25 PM2/6/14
to harbou...@googlegroups.com
Hi Mark,

> >> The options which I was altering were in the printer properties box
> under the Advanced tab - There is a section option called "Print
> Process" and in that
> area there are two lists to select different emulation/conversion
> options - This was the main item which permitted successful printing of
> the job. As the original
> clipper program only appeared to handle/ send clear text I selected the
> TEXT option of the selection sets and the printing was successful.
>
> I am not familiar enough with these options to make any further
> conclusions but just more or less sharing the grief of finally getting
> to this stage and receiving
> the output -
>
> Note that when I moved the lab setup to the Windows 8.1 - I installed a
> USB attached Dell 1100 laser printer and noticed the same advanced
> setting options
> which again only succeeded when I selected the TEXT option - there are
> many different combinations of these two lists but the TEXT option
> got me to the working model so I did not really make variants to see
> other options would apply.

I have never seen a printer that did not work when set to RAW, so this
is strange.

>> Possibly, but if you are not actually using PostScript ... or are you?
>
> This I am not certain - this was programmed in clipper with only
> Straight TEXT - there were not any other additional
> or special characters in any of the jobs.

You would know if you were using PostScript, it is a lot more work :-),
so you are using a more basic emulation. Unfortunately there was no
emulation info available on the web for the Brother. And not for the
Dell 1100 either. It is hopeless to try to find that kind of info
nowadays, all specs are for dummies ...

>> Your code says:
>>
>> SET PRINTER TO "\\MB-T510\495\TEST"
>>
>> This looks a little odd. I take it that the printer is installed locally
>> on the maching running the test (the LENOVO T510) and that it is shared.
>> What is the share name? "495\TEST" is the odd part. Why "TEST"? Is that
>> really part of the share name, and if so, why? I suspect that you were
>> having problems with Harbour adding ".prn" at the end of the printer
>> name and you needed to get rid of the extension and that "\TEST" was
>> something arbitrary you added. There is a SET() that will handle that
>> problem. Or add a dot, like "\495.", if you do not want all default
>> extensions in the application to be skipped. That will make it look
>> cleaner, at least, and less confusing.
>
> >> This was the real game changer and after reading over a dozen
> articles in the blog - there was only one which made reference to the
> use of a Dummy file name - until I added this dummy file name - I could
> not successfully compile the code - which was a real show stopper - so I
> added it and voila - the compile proceeded and the fist output was
> working ... so I do not know why this was not clearer in some
> other threads but it sure made my day.

A cleaner way than using a dummy file name would be to do what I did in
the example, turning off default file extensions. You can do it
specifically for the line where you SET PRINTER TO, like in this example
from the changelog when the Set() was introduced eight years ago:

lOldValue := Set( _SET_DEFEXTENSIONS, .F. )
SET PRINTER TO \\myserver\myprinter
Set( _SET_DEFEXTENSIONS, lOldValue )

> >> I was not clear on the reference manuals, at least between the old
> clipper school of thought and the mix of Harbour, so I just threw it all
> in one place, I will skinny it down in the long run now that I have
> got the output working - I trust that I have gone into overdrive so
> easier to clean up than to diagnose a short coming - at least it has not
> added any interference.

OK

> I have been out of the programming arena for 20 years and stepping back
> into it now reveals that there has been substantial evolution with the
> coding bases and options, I have a lot to
> learn in short but this printing hurdle was the first in the conversion
> at hand and I am quite happy it is behind me now, the rest is pretty
> straight up.

You can always ask here if you run into additional troubles

> Thanks for the feedback - much appreciated.

You're welcome

Regards,
Klas

innerservice .

unread,
Feb 6, 2014, 8:54:27 PM2/6/14
to harbou...@googlegroups.com
Hi Klas,

could you run a test in your environment just to emulate my results and see if the raw works on my script compiled on hbmk2?

I'm curious as both my Win 7 and Win 8.1 would not process the raw on that script on both the brother and the dell.

It would certainly raise some concern from my lab point as to why both my direct connect and wireless devices are acting out of normal expectations.

would you have a the time to run it on any printer you have a disposal?

I have no tried the direct connect not shared sim yet but if that is viable that May be a test I can run through now, perhaps mulling out the test file extension would enable it.

Thank for the support, I think I will be around for a while here :)

Mark


--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.

Web: http://groups.google.com/group/harbour-users

--- You received this message because you are subscribed to a topic in the Google Groups "Harbour Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/harbour-users/nPg40CFpLFQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to harbour-user...@googlegroups.com.

Dragan Cizmarevic

unread,
Feb 7, 2014, 2:25:01 AM2/7/14
to harbou...@googlegroups.com
Clipper and Windows printer is always a problem
It was easy when they were dot matrix printers, partly from the HP PCL know that, but the new cheap windows only

Solution exists, free and elegant, http://sourceforge.net/projects/winprint/
See the author and will be clear

use: Create a report with EPSON ESC sequences and copy it to a folder that looks winprint

Web: http://groups.google.com/group/harbour-users

--- You received this message because you are subscribed to a topic in the Google Groups "Harbour Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/harbour-users/nPg40CFpLFQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to harbour-users+unsubscribe@googlegroups.com.

Massimo Belgrano

unread,
Feb 7, 2014, 4:45:39 AM2/7/14
to harbou...@googlegroups.com


--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users
 
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Klas Engwall

unread,
Feb 7, 2014, 8:28:52 AM2/7/14
to harbou...@googlegroups.com
Hi Mark,

> could you run a test in your environment just to emulate my results and
> see if the raw works on my script compiled on hbmk2?

Yes it worked just fine with my RAW setting, but only after I added the
EJECT that I mentioned a couple of messages ago. Without EJECT the print
job just sits in the printer waiting for the timeout.

Did you try the code snippet that I posted?

Regards,
Klas

innerservice .

unread,
Feb 8, 2014, 8:11:23 AM2/8/14
to harbou...@googlegroups.com
Hi Klas,

Not yet but I will run it and let you know. Next step for sure.
I will add the eject and try raw as well but I'm not sure that  
being in text mode would sim add any page controls. will test that though.

not clear on text vs raw but will keep testing it for clues.


Mark.


innerservice .

unread,
Feb 8, 2014, 1:17:58 PM2/8/14
to harbou...@googlegroups.com
Klas

I ran some tests with your code snippet,

It did not print output with the print process set back to default raw -

It did print fine with the print process option set to TEXT

See attached diagram of the print process options page to see what I
am changing -

Not too sure why you are printing raw and I cannot - very strange.

Have a look and let me know if this setting is the same optioned by you -

Mark



--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.

Web: http://groups.google.com/group/harbour-users

--- You received this message because you are subscribed to a topic in the Google Groups "Harbour Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/harbour-users/nPg40CFpLFQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to harbour-users+unsubscribe@googlegroups.com.
PrintProcess.jpg

innerservice .

unread,
Feb 8, 2014, 5:21:00 PM2/8/14
to harbou...@googlegroups.com
Klas,

Could you help me with creating this network printer string into a macro which I could generalize
when coding the SET PRINTER TO (Network path)

I would like to remove the static path and add it as a public variable at the beginning of the program
to avoid having to encode these paths throughout the program - and be able to
modify the text file to match the network changes.

eventually I would like to read a small text file to be included in the native directory which has these two printers
defined in the text file and read it on start up which could then be macro'd into the program compile version.

I cannot seem to get the macro to work added to the SET PRINTER TO...

Can you offer some guidance on this - that would be great -

Thanks

Mark



On Fri, Feb 7, 2014 at 8:28 AM, Klas Engwall <har...@engwall.com> wrote:
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.

Web: http://groups.google.com/group/harbour-users

--- You received this message because you are subscribed to a topic in the Google Groups "Harbour Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/harbour-users/nPg40CFpLFQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to harbour-users+unsubscribe@googlegroups.com.

Klas Engwall

unread,
Feb 8, 2014, 8:18:50 PM2/8/14
to harbou...@googlegroups.com
Hi Mark,

> I ran some tests with your code snippet,
> It did not print output with the print process set back to default raw -
> It did print fine with the print process option set to TEXT
> See attached diagram of the print process options page to see what I
> am changing -
> Not too sure why you are printing raw and I cannot - very strange.
> Have a look and let me know if this setting is the same optioned by you -

Yes, that is what I have done since back in the NT4 days (or even the
Win95 days). I have never had a problem with it, and there have been
quite a few printers involved in those years. Right now I cannot think
of an explanation why it doesn't work for you. I will have to scratch my
head ...

Regards,
Klas

Klas Engwall

unread,
Feb 8, 2014, 8:42:49 PM2/8/14
to harbou...@googlegroups.com
Hi Mark,

> Could you help me with creating this network printer string into a macro
> which I could generalize
> when coding the SET PRINTER TO (Network path)
>
> I would like to remove the static path and add it as a public variable
> at the beginning of the program
> to avoid having to encode these paths throughout the program - and be
> able to modify the text file to match the network changes.
>
> eventually I would like to read a small text file to be included in the
> native directory which has these two printers
> defined in the text file and read it on start up which could then be
> macro'd into the program compile version.
>
> I cannot seem to get the macro to work added to the SET PRINTER TO...

So what goes wrong?

> Can you offer some guidance on this - that would be great -

Step 1: Set up the variable either straight in the application code or
by reading its content from a file
Step 2: Use one of the three SET PRINTER options in the modified code
snippet below

The "read from file" option is *very* basic. For this version to work
without cleaning up what you read there must be no quotes, no CRLFs or
anything else except the UNC string in the file. Or you can use common
.ini file syntax and build your own ini file handler or borrow the one
from the TESTS directory of the Harbour source tree. But that is a
different exercise ...

//--------------------------------
#include "set.ch"
procedure main()
local i := 0
// public cPrinter := "\\THESERVER\THEPRINTER"
public cPrinter := hb_memoread( 'printer.txt' )
// Where the content of the file is *only*
// \\THESERVER\THEPRINTER
set( _SET_DEFEXTENSIONS, .F. ) // Do not add '.prn'
do while .T.
? "Press <Esc> to exit, any other key to print"
inkey ( 0 )
if lastkey() == 27
exit
endif
set( _SET_PRINTER, cPrinter )
// set printer to ( cPrinter )
// set printer to &cPrinter
set device to printer
@ 0,0 say "Hello world"
eject
set device to screen
set printer to
i++
? "Printed " + hb_ntos( i ) + " times"
enddo
return
//--------------------------------

Regards,
Klas

innerservice .

unread,
Feb 8, 2014, 9:21:08 PM2/8/14
to harbou...@googlegroups.com
 Klas,

Thank you for the guidance / script, I will run it tomorrow, I'm not too sure where I 
went wrong but when I attempted to declare the printer map into a static var the code would complain about not lpt1 resource in an alert. I think the quotes may have been problematic.

I had the same target in the SET PRINTER TO with &variable going on.

I note the #include "set.ch "which was not in my code as there are no libraries in the original clipper code.

This should get me into good shape though, thanks for the help.

Going back to the raw issue, I am familiar that the latest Windows versions have the heuristic tcp stack which is quite different than the earlier versions It was blended in after or during the Vista Rollin and also in the server R2 flavours, this could be affecting the network map as the stack is very sealed and untenable. Did you run that on Win 7 or later Win 8 to see if it might be a factor?

what version did you run my code on ?

My background is networking and I went through some very specific challenges with MS on this new Next Gen TCP stack, as Performance tuning was locked down and registry alterations were no longer accessible. Window size, scaling etc completely off limits.

Just raises a concern 

Thanks for the assistance much appreciated.

Mark.


--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.

Web: http://groups.google.com/group/harbour-users

--- You received this message because you are subscribed to a topic in the Google Groups "Harbour Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/harbour-users/nPg40CFpLFQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to harbour-user...@googlegroups.com.

Klas Engwall

unread,
Feb 9, 2014, 4:13:55 PM2/9/14
to harbou...@googlegroups.com
Hi Mark,

> Thank you for the guidance / script, I will run it tomorrow, I'm not too
> sure where I
> went wrong but when I attempted to declare the printer map into a static
> var the code would complain about not lpt1 resource in an alert. I think
> the quotes may have been problematic.

Sorry, but I don't follow. Where did lpt1 come into the picture? And
which quotes are you referring to? Is this the original question you are
looking at again?

> I had the same target in the SET PRINTER TO with &variable going on.
>
> I note the #include "set.ch <http://set.ch> "which was not in my code as
> there are no libraries in the original clipper code.

"set.ch" is the header file where the _SET_PRINTER and
_SET_DEFEXTENSIONS #defines live. They are not related to any libraries.

> This should get me into good shape though, thanks for the help.
>
> Going back to the raw issue, I am familiar that the latest Windows
> versions have the heuristic tcp stack which is quite different than the
> earlier versions It was blended in after or during the Vista Rollin and
> also in the server R2 flavours, this could be affecting the network map
> as the stack is very sealed and untenable. Did you run that on Win 7 or
> later Win 8 to see if it might be a factor?
>
> what version did you run my code on ?

I only ran your code on the XP machine I have right here. But my code
snippet is my standard code that runs every day everywhere, including on
XP and Win7 and locally on a Server 2012. *Your* code did *not* work
until I added EJECT before closing the printer.

Regards,
Klas

innerservice .

unread,
Feb 9, 2014, 5:50:35 PM2/9/14
to harbou...@googlegroups.com
Klas,

I believe the LPT1 came up in alert boxes when I was trying to run my version of the macro read from file, I was using old convention fopen fread commands and the file I used also included the network map with the " " delimiters, so after trying various code tests I ran out of ideas. That is when I sent out the SOS. 

More importantly I should say thanks for the samples they worked out excellent, I have coded these into the application throughout and it works great.

Is there a good book or even published text I could pick up and start a fresh study on harbour? I would best focus on a recommendation from you as you probably know the shortest path, if I could get up on this and start GUI code for immersion. This would also save me from asking stupid questions and get me up to speed.

I think I will be in this for the long run as I like the whole package with the extensions and networking added on as well.

As for the raw printing I will go back and check the printer error manager to see if I can get some ideas on what may be at play.

Thank you for all this up to now.

Mark

Klas Engwall

unread,
Feb 9, 2014, 6:45:50 PM2/9/14
to harbou...@googlegroups.com
Hi Mark,

> I believe the LPT1 came up in alert boxes when I was trying to run my
> version of the macro read from file, I was using old convention fopen
> fread commands and the file I used also included the network map with
> the " " delimiters, so after trying various code tests I ran out of
> ideas. That is when I sent out the SOS.

OK, so there was a little too much in the file :-)

BTW, a more straightforward solution from a Clipper/Harbour point of
view than reading those simple configuration settings from a text file
would be to put them in a dbf. You would have a field name to tie them
to, and it would make the whole concept easier for humans to understand.

> More importantly I should say thanks for the samples they worked out
> excellent, I have coded these into the application throughout and it
> works great.

I am glad to hear that

> Is there a good book or even published text I could pick up and start a
> fresh study on harbour? I would best focus on a recommendation from you
> as you probably know the shortest path, if I could get up on this and
> start GUI code for immersion. This would also save me from asking stupid
> questions and get me up to speed.

"The Harbour Book" is something that someone will write in the future
... maybe :-). Most of what we have discussed so far is standard Clipper
stuff - with just a few Harbour twists. The Clipper manuals and the
Norton Guide are invaluable. There is a Norton Guide reader for Windows
and Linux at http://www.davep.org/norton-guides/ (recommended).

The Norton guide is also avaliable online at
http://www.ousob.com/ng/53guide/

Differences between Clipper, Harbour and xHarbour can be found in
doc\xhb-diff.txt, also available at the home page of this newsgroup. The
changelog can be searched for info if you have a good keyword for what
you are looking for. There are also other text files to investigate both
in the root directory and in the doc directory.

This newgroup can also be searched for info, as well as the
harbour-devel group. Everything has already been discussed more than
once :-)

Alexander Kresin has a tutorial for Harbour beginners at
http://kresin.ru/en/index.html

I use the Harbour source tree every day to look up things. Download the
sources today if you have not already done that.

xHarbour has a commercial manual that can be useful for Harbour users
too since most of the basic stuff is identical (from a user's point of
view) between the two. Users say it is a good manual.

For GUI basics, if you want to use HBQT, check out Giovanni's tutorials
at http://www.elektrosoft.it/tutorials.asp

Giovanni also has lists of available functions for easy browsing. But
the docs themselves (in the Harbour tree and in Giovanni's links) are
old and have not been updated in a very long time.

> I think I will be in this for the long run as I like the whole package
> with the extensions and networking added on as well.
>
> As for the raw printing I will go back and check the printer error
> manager to see if I can get some ideas on what may be at play.

OK. Good luck :-)

Regards,
Klas

innerservice .

unread,
Feb 9, 2014, 6:58:18 PM2/9/14
to harbou...@googlegroups.com
Klas,

Thanks, I will read into all this and brush up ... much appreciated.

Thanks for everything,

Best Regards

Mark


On Sunday, February 9, 2014, Klas Engwall <har...@engwall.com> wrote:
Reply all
Reply to author
Forward
0 new messages