Why does this code fail?

Monkey Targets Forums/Windows 8/Why does this code fail?

Damon97(Posted 2014) [#1]
Hi, when I run this code using the html target everything works but when I compile it for the Window 8 target and run it using Visual Studio 2013 I get an Access Violation error. Visual studio shows the error occurs in the writepixel function. Am I doing something wrong?

Import Mojo

Class Emulator8 Extends App
	Field Pixel:Image
	
	Method OnCreate()
		Pixel = CreateImage(10,15)
		Local Pixels:Int[150]
		For Local i:Int = 0 To 150-1
			Pixels[i] = $FFFFFFFF
		Next
		Pixel.WritePixels(Pixels,0,0,10,15)		
	End Method
	
	Method OnUpdate()

	End Method
	
	Method OnRender()
		Cls
		DrawImage Pixel,10,10
	End Method
End Class

Function Main()
	New Emulator8
End Function



ziggy(Posted 2014) [#2]
Out of bounds?


Goodlookinguy(Posted 2014) [#3]
I dunno what your particular issue is because I'm against development for Win8, but this line...

For Local i:Int = 0 To 150-1


In the future instead of adding that extra unnecessary "-1", just change "To" with "Until"

For Local i:Int = 0 Until 150



ziggy(Posted 2014) [#4]
I think it's a WP target bug. Tested in HTML5 and in C++ with MinGW, so I think a bug report should be placed


Damon97(Posted 2014) [#5]
Thank you everyone, I'll try and post a bug report.