GLBasic forum

Main forum => GLBasic - en => Topic started by: Hotshot on 2012-Aug-15

Title: Functions ?
Post by: Hotshot on 2012-Aug-15
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

Title: Re: Functions ?
Post by: Poetronic on 2012-Aug-15
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.
Title: Re: Functions ?
Post by: Hotshot on 2012-Aug-15
Thanks Poetronic  =D   I love Functions because that where I can break small code down into :)
Title: Re: Functions ?
Post by: Why0Why on 2012-Aug-15
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.
Title: Re: Functions ?
Post by: bigsofty on 2012-Aug-15
Welcome back, dont hesitate to ask any questions if need be.  :)
Title: Re: Functions ?
Post by: Hotshot on 2012-Aug-15
Thanks guys :)