Page 1 of 1

Works in V3.94, fails in V4.00. Why?

Posted: Fri Jul 28, 2006 7:49 pm
by TerryHough
The following code works perfectly in Vs 3.94 to open and allow writing
to the parallel port (Win98SE, WinXP).

Code: Select all

If OpenFile(8,"LPT1")
  WriteString("Testing" + Chr(12))
  CloseFile(8)
Else
  MessageRequester("Debug","Can't open printer device",0)
EndIf 
but the code converted to PB4.00 fails.

Code: Select all

If OpenFile(8,"LPT1")
  WriteString(8,"Testing" + Chr(12))
  CloseFile(8)
Else
  MessageRequester("Debug","Can't open printer device",0)
EndIf 
  
Why?

This is causing serious problems converting to PB4. I create PCL code for
laserjet printers and send them directly to the printer in V3.94. The code
has worked perfectly with no data loss for thousands and thousands of
pages.

But, in PB4 the printer will not open! Oddly, COM!, COM2, COM3 all work fine. LPT1, LPT2, LPT3 all fail.

Am I doing something wrong? Is there a work-around? Or is this a PB4
bug?

Thanks,
Terry

Posted: Fri Jul 28, 2006 8:40 pm
by Shannara
First, I want to thank you, as this also seems like a Tip and Trick :) I didnt know you can access COM and LPT ports via OpenFile command :) Thank you! But .. I cannot help either :(

Posted: Fri Jul 28, 2006 9:05 pm
by ts-soft
I cann't test it, but i think is a buffer problem.
check this: FileBuffersSize(8, 0)

Posted: Fri Jul 28, 2006 9:17 pm
by dracflamloc
Shannara wrote:First, I want to thank you, as this also seems like a Tip and Trick :) I didnt know you can access COM and LPT ports via OpenFile command :) Thank you! But .. I cannot help either :(
You would love developing device interfaces in linux ;) EVERY device has a file itnerface in /dev/

But yea its a cool thing oddly not enough programmers know about.

Posted: Sat Jul 29, 2006 10:26 pm
by Fred
That's very weird, why a COM1 port will be opened with an LPT port won't ? You have tested again with PB3.94 on the same computer and it worked ?

Posted: Sun Jul 30, 2006 1:12 pm
by Derek
Can't open LPT1 on my computer when using PB4 either.

Posted: Sun Jul 30, 2006 3:37 pm
by Jan Vooijs
As far as memory serves me (not tested) should there not follow a ':' after LPT1 to designateed it is a 'disk drive'??

Try this one:

Code: Select all

If OpenFile(8,"LPT1:")

Jan V.

Posted: Mon Jul 31, 2006 4:15 pm
by TerryHough
Fred wrote:That's very weird, why a COM1 port will be opened with an LPT port won't ? You have tested again with PB3.94 on the same computer and it worked ?
Yes, Fred. I have tested again PB3.94 vs. PB4.00 on the same computer. In fact, I did a complete reload of PB4.00 from the download just to be sure I didn't have a botched install of PB4.00.

The code shown above for PB3.94 works perfectly.

The code shown above for PB4.00 will not open the "LPT1", "LPT2", or "LPT3" . It will open "COM1", etc.

-----------------------------------
@ts-soft
The OpenFile fails. So the FileBuffersSize(8,0) would fail on an invalid file.

-----------------------------------
@Jan Vooijs
Some DOS commands do require LPT1:, but for this purpose it is not needed and will not work if used in either version of PB.

Posted: Mon Jul 31, 2006 5:19 pm
by Jan Vooijs
Sorry,

oops does not work, removed...

Jan V.