Crash with ReadBytes + length + Windows GUI Oo

Archives Forums/MaxGUI Bug Reports/Crash with ReadBytes + length + Windows GUI Oo

Klin(Posted 2011) [#1]
ehmm.. Hi...
I'm a little bit confused. Because today i used this code:

Import MaxGui.Drivers
Import MaxGUI.MaxGUI

Local file:TStream=WriteFile("test123.txt")
file.WriteString("TEST12345asdasdasdasd6wqewqeqw7890TEST234567890")
file.close()
file=ReadFile("test123.txt")
Local mop:Byte[]
file.ReadBytes(mop,"TEXT 123 TEXT".length) '<- 3 Spaces with "TEXT NUMBER TEXT" = Crash Oo

Print "Create Window"
Local window:TGadget=CreateWindow("My Canvas",wx,wy,300,300)
Print "OK"
Local canvas:TGadget=CreateCanvas(0,0,320,240,window)


Well.. In Debug Modus the code works fine. But in the Normal Modus (only "Build GUI App") it crashed. The console just displayed: "Create Window" and then it crashed. But! It's JUST the "TEXT 123 TEXT".length Oo I don't understand why. When I change the Text, the app works... And very strange: when I change the text to "TEXT 123 TEXT1", then Bmax sad: "EXCEPTION_ILLEGAL_INSTRUCTION"

I don't know why. Is this maybe my mistake?

THX
Klin

Sorry for my bad english.

System:
Windows 7 32 Bit Ultimate
3 GB Ram
NVidia 8600GS

EDIT: Ok.. It crash only, when the ReadBytes length is over 12. But why?

Last edited 2011


skidracer(Posted 2011) [#2]
You have not allocated any memory for your buffer. Try:

Local mop:Byte[4096]


Klin(Posted 2011) [#3]
Ehm... I restarted my PC today and now it works. Maybe a Memory error? But the error occurs only with the MaxGUI functions.

THX
Klin


skidracer(Posted 2011) [#4]
You cannot read bytes to unallocated memory. If you do it will corrupt other variables in your program.

Please consider using the LoadText command.

Last edited 2011