PB 5.40 LTS ReadFile

Windows specific forum
Lite
User
User
Posts: 17
Joined: Fri Dec 21, 2012 7:50 am

PB 5.40 LTS ReadFile

Post by Lite »

Hello

The comand Readfile makes problems with the new Version 5.40 LTS.
OS: Win7 Bit
PB: 5.40 LTS
PBEXE: unicode without debugger
TestFile File$: Ansicode.

File = ReadFile(#PB_Any, File$)

The Problem, ReadFile return Value 0, but it does not everytime.
On 10 starts failed 4. start the same source with debugger is the results.
On 10 starts 1 failed.

with the old lts version never have a problem with PB.

Greetings

Lite
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: PB 5.40 LTS ReadFile

Post by ts-soft »

No problems here!
I think, you have to post your code to see, what is wrong.

Here, my Testcode:

Code: Select all

EnableExplicit

OpenWindow(0, #PB_Ignore, #PB_Ignore, 800, 600, "Test")
EditorGadget(0, 5, 5, 790, 590)
Define File = ReadFile(#PB_Any, #PB_Compiler_Home + "SDK\Readme.txt", #PB_Ascii)

If File
  Define *mem = AllocateMemory(Lof(File))
  ReadData(File, *mem, MemorySize(*mem))
  CloseFile(File)
EndIf

SetGadgetText(0, PeekS(*mem, -1, #PB_Ascii))
FreeMemory(*mem)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow : Break
  EndSelect
ForEver
Greetings - Thomas
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
Lite
User
User
Posts: 17
Joined: Fri Dec 21, 2012 7:50 am

Re: PB 5.40 LTS ReadFile

Post by Lite »

Hello

Thank your for the replay.

The sourcecode have 15000 lines.

Now found the error. 2 threads access to ReadFile together. I havent use the parameter
#PB_File_SharedRead. without blocked the other thread and come ReadFile-error.
by chance, it is noticed only in V5.40.
Now work great.

Greetings
Lite
Post Reply