Send/return an array.

Blitz3D Forums/Blitz3D Beginners Area/Send/return an array.

Amiga(Posted 2006) [#1]
I need to know if there's a way to send an array to, and return an array from an function.
In the function i have an array named hImages(;;).
But i want to send an Dimmed array to the function, and return an array from the function.
I want to rotate different images, but with this function all rotated images will be placed in the hImages array. I hope you can understand what i want.

[CODE]
Function CreateRotatedImages(sImage$,iNumRotation, dimmed parameter here ???)

Local hTemp = LoadImage(sImage$)
If hTemp = 0 Then RuntimeError "Can't find image - load error!!"
MaskImage hTemp,255,0,255
Local iMultiplyer = 360 / iNumRotation

; rotate image to generate all directions
For iLoop = 0 To iNumRotation - 1

; first copy the original image into the current frame
hImages(iLoop)=CopyImage( hTemp )
; rotate the frame the appropriate number of degrees
RotateImage hImages(iLoop), iLoop * iMultiplyer

Next

FreeImage hTemp : hTemp = 0

End Function
[/CODE]


Dreamora(Posted 2006) [#2]
You can't.

You can only send BlitzArrays to functions. Dim arrays are ALWAYS global which makes sending them local completely useless.


Amiga(Posted 2006) [#3]
Thanks for your reply Dreamora.
I changed my array to * Global hImages[iNumRotation]
and the function as follows, and a lot of changes to the rest of my code.
Function CreateRotatedImages(sImage$,iNumRotation,hImages[iNumRotation])
	
	Local hTemp = LoadImage(sImage$)
		If hTemp = 0 Then RuntimeError "Can't find image - load error!!"
	MaskImage hTemp,255,0,255
	Local iMultiplyer = 360 / iNumRotation
	
	; rotate image to generate all directions
	For iLoop = 0 To iNumRotation - 1
	
        ; first copy the original image into the current frame
    	hImages[iLoop]=CopyImage( hTemp )
        ; rotate the frame the appropriate number of degrees
        RotateImage hImages[iLoop], iLoop * iMultiplyer 
    	 
	Next
	
	FreeImage hTemp : hTemp = 0
	
End Function


Remember if anyone else uses "Blitz arrays", if you call the function above, you must call for it like this " Function CreateRotatedImages("bitmap.bmp", iNumRotation, hImages)


octothorpe(Posted 2006) [#4]
if you need to pass around dynamically sized arrays, check out my Vector Containers.