toying with arrays - help pls

BlitzMax Forums/BlitzMax Beginners Area/toying with arrays - help pls

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

Hello Blitzers,

i need a little help with the following piece of code.

I am trying to load an image, slice it into 32^2 tiles, store these in an array and then draw the array.
This works on one computer but on another i get a

Unhandled Exception:Attempt to access field or method of Null object

SuperStrict
Global iwidth%,iheight%
Global twidth%=32,theight%=32
Global tilesx%,tilesy%
Global imagemap:TImage[tilesx,tilesy]

'GFX SETUP

SetGraphicsDriver GLMax2DDriver()
'SetGraphicsDriver GLGraphicsDriver()
Graphics 1024,768,32,60

Function iLoad(image_path:String)
	Local image:TImage = LoadImage(image_path)
	iwidth = ImageWidth(image)
	iheight = ImageHeight(image)
	tilesx%=iwidth/twidth
	tilesy%=iheight/theight
	imagemap = New TImage[tilesx,tilesy]
	DebugLog "Variables Set."
End Function

Function iTile(image_path:String)
	Local animimage:TImage = LoadAnimImage(image_path , twidth , theight , 0 , tilesx*tilesy)
	Local counti%=0
	For Local i% = 0 Until tilesy
		For Local j% = 0 Until tilesx
			imagemap[j,i] = LoadImage(animimage.pixmaps[counti])
			counti:+1
		Next
	Next
	DebugLog "Added "+ counti +" images."
End Function

Function Drawtiles()
	'DebugStop()
	For Local i% = 0 Until tilesx
		For Local j% = 0 Until tilesy
			DrawImage (imagemap[i,j],i*twidth,j*theight)
		Next
	Next
	DebugLog "Tiles Drawn"
End Function

iLoad ("tilerender_test1.bmp")
iTile ("tilerender_test1.bmp")
Drawtiles()
'For Local i% = 0 Until tilesx
'	DrawImage (imagemap[i,3],i*32,0)
'Next

Flip
WaitKey

EndGraphics


I put a debugstop in the Drawtiles Function as this seems to be the culprit.

I just don't understand why this works on some computers but not on others..