What is an explicit variable?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

What is an explicit variable?

Post by gyroscope » Mon Dec 29, 2008 3:01 pm

Hi, using GLX2 in Rev 2.9, in the GLX2 Script Editor Preferences there is an option to check "Always Use Explict Variables"

Can anyone tell me what an explicit variable is, compared to a good ol', everyday variable, please :?:

Obleo
Posts: 174
Joined: Mon Apr 10, 2006 10:35 pm
Contact:

Post by Obleo » Mon Dec 29, 2008 4:28 pm

Explicit Variables is declaring the variable. using this method you have to declare all variable your going to use before using them. They go before (or above) where write the hander or code that uses them.

If you use an non declared variable in the same code with Explicit Variables declared, it will cause an error at compile time. (basically catching your error and allowing you to debug the code then and there)

You can use Explicit variables to avoid incorrectly typing a variable name all ready in use some where else. misspelling a variable, or to make your code more clear and clean. Which can help in debugging long blocks of code. It also requires you to place all literal strings in quotes.

they look kind like this.

tUserAge = 50
tUserWeight = 200
my3Variable = somethingElse

If you check that you pretty much have to use this method. Unchecked you can use any method. It really up to you what you would prefer.

I hope I explained that clear enough.

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Mon Dec 29, 2008 6:46 pm

Sure have Obleo, thank you for answering my question.

If I've understood you correctly then: explicit variables refers to declaring temporary variables, as opposed to global and local variables which have to be declared anyway...

:)

Post Reply