Image Does Not Exist error

Blitz3D Forums/Blitz3D Beginners Area/Image Does Not Exist error

Ross C(Posted 2005) [#1]
Now, this is very odd... There's no reason why this should work. It's afunction that creates a new type object, and create a new image and assigns it to a type field:

Function create_new_furniture()

	f.furniture = New furniture
		
	Locate 0,0
		f\name$ = Input("Name: ")
		f\length = Input("Length: ")
		f\width = Input("Width: ")
		
		f\x = 400
		f\y = 300
		f\length = f\length*scale
		f\width = f\width*scale
		
		f\rotation = 0
		f\image = CreateImage(f\length,f\width)
		SetBuffer ImageBuffer(f\image)  ; <<<< ERROR!!
		Color 200,100,100
		Rect 0,0,f\length,f\width
		Color 255,255,255
		Rect 0,0,f\length,f\width,0
		SetBuffer BackBuffer()
		
		MidHandle f\image
		
		f_handle(f_number) = Handle(f.furniture)
		
End Function


As I have highlighted:

		SetBuffer ImageBuffer(f\image)  ; <<<< ERROR!!


Produces an image does not exist error. I'm using IBJECT and HANDLE commands to jump to a certain type ojbect, but, that shouldn't matter here, as i'm creating a new object in the function. Anyone got any idea?


Ross C(Posted 2005) [#2]
It seems i got it to work, by updating to the newest version of blitz :o) I was also making a stupid error by constantly rewriting my handle in the array for every new item created :o)

f_handle(f_number) = Handle(f.furniture)


should have been
f_number = f_number + 1
f_handle(f_number) = Handle(f.furniture)


YIPEEEEE!


big10p(Posted 2005) [#3]
I can only see the top code failing if for some reason your f\width or f\length fields are being assigned zero. CreateImage doesn't cause an error if it's given a zero value for length/width, but obviously no image is actually created. Thus, 'SetBuffer ImageBuffer(f\image)' would fail.


Ross C(Posted 2005) [#4]
Just posted that in general discussion. I wasn't aware of that :D