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

Just starting out? Need help? Post your questions and find answers here.
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

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

Post 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
Last edited by TerryHough on Mon Jul 31, 2006 3:54 pm, edited 1 time in total.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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 :(
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

I cann't test it, but i think is a buffer problem.
check this: FileBuffersSize(8, 0)
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post 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.
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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 ?
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

Can't open LPT1 on my computer when using PB4 either.
Jan Vooijs
Enthusiast
Enthusiast
Posts: 196
Joined: Tue Sep 30, 2003 4:32 pm
Location: The Netherlands

Post 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.
Life goes to Fast, Enjoy!!

PB 4 is to good to be true, wake up man it is NOT a dream THIS is a reality!!!

AMD Athlon on 1.75G, 1Gb ram, 160Gb HD, NVidia FX5200, NEC ND-3500AG DVD+RW and CD+RW, in a Qbic EO3702A and Win XP Pro SP2 (registered)
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post 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.
Last edited by TerryHough on Wed Aug 02, 2006 2:58 pm, edited 1 time in total.
Jan Vooijs
Enthusiast
Enthusiast
Posts: 196
Joined: Tue Sep 30, 2003 4:32 pm
Location: The Netherlands

Post by Jan Vooijs »

Sorry,

oops does not work, removed...

Jan V.
Life goes to Fast, Enjoy!!

PB 4 is to good to be true, wake up man it is NOT a dream THIS is a reality!!!

AMD Athlon on 1.75G, 1Gb ram, 160Gb HD, NVidia FX5200, NEC ND-3500AG DVD+RW and CD+RW, in a Qbic EO3702A and Win XP Pro SP2 (registered)
Post Reply