LoadString bug

Monkey Forums/Monkey Programming/LoadString bug

ziggy(Posted 2012) [#1]
This one has been driving me crazy. If you make something as simple as this:
[monkeycode]Import mojo
Function Main()
New MyGame(LoadString("level1.txt"))
End
Class MyGame Extends App
Method New(level:String)
'Do stuff...
End
End[/monkeycode]
You'll see LoadString failing. If the LoadString is executed after the App class is created (instead of before as a parameter in this case) it works as always. It's very weird. It fails in glfw, xna and html5.


jpoag(Posted 2012) [#2]
It's not weird, when the App class is created, it creates the device interface.

LoadString() is just a quick method that returns Device->LoadString()

I think the most that would happen with this bug is a check to see if the device is NULL or not. Maybe in Debug Mode the function can throw an Error?


ziggy(Posted 2012) [#3]
well, in this case, it is not documented.


marksibly(Posted 2012) [#4]
Hi,

From the mojo module docs...


Mojo functions should not be called until your application's OnCreate method is called.




ziggy(Posted 2012) [#5]
Aaaah I see, I think it was part of the os module.. sorry


jpoag(Posted 2012) [#6]
Yeah, the OS module has it's own LoadString that doesn't use a device. Maybe you were confusing the two.