Functions ?

Previous topic - Next topic

Hotshot

Hello Everyone

I going to give GLBASIC Second chance and give a try :)

Code (glbasic) Select

GLOBAL BACKGROUND=0

LOADSPRITE "picture.PNG", BACKGROUND

FUNCTION SHOW_BACKGROUND:

         DRAWSPRITE BACKGROUND, 100, 100


ENDFUNCTION

SHOW_BACKGROUND()

SHOWSCREEN
MOUSEWAIT
END


What wrong with the code as it saying

"MYFIRSTPROGRAM.gbas"(31) error : command not inside function or sub


Poetronic

#1
Hi Hotshot,

try placing the function after the function call:

Code (glbasic) Select
GLOBAL BACKGROUND=0

SETSCREEN 640,480,1

LOADSPRITE "picture.PNG", BACKGROUND

SHOW_BACKGROUND()

SHOWSCREEN

MOUSEWAIT

END

// This is your function
FUNCTION SHOW_BACKGROUND:
         DRAWSPRITE BACKGROUND, 100, 100
ENDFUNCTION


Cheers,
P.
ILI-Blocks, my first game ever - please check it out! http://www.glbasic.com/forum/index.php?topic=8654.0

Hotshot

Thanks Poetronic  =D   I love Functions because that where I can break small code down into :)

Why0Why

Hey Hotshot, guess we were reading the same thread on the Blitz forums ;)  I had bought GL years ago when they first came out with iPhone support and never really used it much.  I moved over to Corona for awhile and then I have been using Monkey.  Like you, just thought I would give it another shake.

bigsofty

Welcome back, dont hesitate to ask any questions if need be.  :)
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Hotshot

Thanks guys :)