Posted: 22nd Aug 2011 3:30
Hi,

I wonder if AppGameKit Basic supports the equivalent to the VisualBasic Option Explicit, making mandatory to declare (or set a value) first before the variable can be used.

I think one error that is pretty common and super hard to fix is set the variable player_width but testing the variable player_widht, for example.

Please, tell me I can set this behavior!

Thanks
Posted: 22nd Aug 2011 10:07
Are you referring to types?
If so you can simply set one up using:
+ Code Snippet
//object type
Type _obj
    img   as integer
    spr   as integer
    x     as float
    y     as float
    sx    as float
    sy    as float
    w     as integer
    h     as integer
    flag  as integer
    point as integer
EndType

//media type
Type _media
    theme as integer
    ball  as integer
EndType

//type identifiers
background  as _obj
logo        as _obj
agk         as _obj
legal       as _obj
tap         as _obj
court       as _obj
pad         as _obj
ball        as _obj
font        as _obj
music       as _media
sound       as _media


Then access the variables through background.img, background.spr etc.

This probably isn't what you are referring too but its what I got from what you said
Posted: 22nd Aug 2011 11:11
I think what he means is that you must declare a variable before usage.

An example:
a as integer
a = screenwidth()
print a

as opposed to:
a = screenwidth()
print a

He would like the second to bring up a warning or compile error because a hasn't been declared. I would also like this because then you know that you haven't accidentally made up a variable on the spot due to a typo and spend hours trying to debug it only to find a typo!
Posted: 22nd Aug 2011 16:44
Thanks for the answers. Yes, it is what Hodgey says. Declaring the variables before using it helps to keep track of them, and avoid typo mistakes.

Rampage, I didn't think this before, but using types is a good way to work around the lack of strong types of simple variables. It is not perfect, but probably enclosing everything that is important in types is a good idea to avoid silly mistakes.

Thanks