passing a filehandle to a function

Blitz3D Forums/Blitz3D Beginners Area/passing a filehandle to a function

I know in some other laguages I have to explicity declare the type of variable (string, int, float) I'll be passing to a function

In this case I wish to pass a filehandle to a function
eg. in this example "title_screen" is a filehandle

draw (title_screen)
end

;----------------------------------
Function draw (handle)

drawimage handle,0,0

End Function
;----------------------------------

My question is, is this code ok, or in the function do I have to declare handle as being some type of float or long int or something.

well, you'd say in the function the type of variable you want the passed across parameter to be.

Function draw(handle$)


But i think blitz might automatically do this. But you'd be as well doing it anyway, for clarity :)

I think it will be ok, but you should declare it just to be on the safe side..

Function Myfunction(file_name$)
..blabla
End Function

In Blitz, handles are always integers. (There are only a few built-in types in Blitz anyway.)

Also, whenever a variable (or return type) is declared without specifically referencing the type, it is assumed by Blitz to be an integer. In other words, these examples are all the same:
Function draw(img)
    DrawImage img,0,0
End Function

Function draw%(img%)
    DrawImage img,0,0
End Function

Function draw%(img)
    DrawImage img%,0,0
End Function

Function draw(img)
    DrawImage img%,0,0
End Function

...etc

ok great

my code has started to become buggy and I was trying to get to the bottom of it - I guess this isn't the source of the crashes then!