Loading an image inside a function will not make it available to the rest of the code, as variables used within functions are local unless set as globals prior to calling the function. I suggest you do something similar to the following code, which will allow you to specify a filename and decide which variable will be the handle of the image.
Also, when making functions, try and make them as flexible as possible so that they can be reused. This will allow you to have less code but maintain usability. Like with the above function, you can use it to load and test as many images you want, but with the code in the top of this thread, you are limited to just loading one image into one variable without any flexibility. Coding with flexibility and reuse in mind will speed up future coding projects as function modules can be reused and doesn't have to be coded from scratch.
[edit: added the above text]
Graphics 640,480,0,2 logopointer = loadlogo( "logo.png" ) SetBuffer BackBuffer() While Not KeyHit(1) Cls DrawBlock logopointer,100,100 Flip Wend End Function loadLogo( filename$ ) temp = LoadImage ( filename$ ) If temp <> 0 Then Return temp RuntimeError "Failed to find&load required image file" End Function
Also, when making functions, try and make them as flexible as possible so that they can be reused. This will allow you to have less code but maintain usability. Like with the above function, you can use it to load and test as many images you want, but with the code in the top of this thread, you are limited to just loading one image into one variable without any flexibility. Coding with flexibility and reuse in mind will speed up future coding projects as function modules can be reused and doesn't have to be coded from scratch.
[edit: added the above text]