Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Explicit variable declarations, please!

Author
Message
MobileCreator
12
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
Posted: 22nd Aug 2011 03: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

Paulo
Rampage
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: New Zealand
Posted: 22nd Aug 2011 10:07
Are you referring to types?
If so you can simply set one up using:


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

Regards,

Max
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
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!

MobileCreator
12
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
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

Paulo

Login to post a reply

Server time is: 2024-04-26 18:34:46
Your offset time is: 2024-04-26 18:34:46