Page 1 of 1

First day at the 'office' for this LiveCode Newbie

Posted: Wed Jan 09, 2013 10:33 am
by Traxgeek
Hi !
Wondered if someone could help ?

I'm new to LiveCode (come from years of VB, PCS, Corona and various others) and am following the various tutorials to 'port' an existing PCS app into LiveCode.

I fell at the first hurdle !! I'm trying to create a 'Global' variable. One which will be available to all handlers on all cards within a stack. Currently I have the line :

Code: Select all

global gbABC
and have placed it both within various handlers ('on startup', 'on stack open' etc) and as the first line of code (before and outwith any handlers) in my 'Stack' code page.

Each time I try to 'Apply' the use of the variable to any handler on a Card within the Stack I receive the error message :
button "chkMaintenance": compilation error at line 4 (Chunk: can't create a variable with that name (explicitVariables?)) near "gbABC", char 16
or very similar !

Can someone nudge me in the right direction please ?

Is there any basic help on how to declare variables and assign them 'types' (numeric, floating, string, boolean etc). I have read (and think I understand) the variable 'scope' logic within LiveCode - all makes sense but can't find how to declare a type and for the life of me (all day yesterday) can't work out why I can't access my global accross various Cards within my Stack.

Any and all kicks in generally the right direction would be welcome.

Thanks in advance.

Re: First day at the 'office' for this LiveCode Newbie

Posted: Wed Jan 09, 2013 11:23 am
by Traxgeek
Ooops - Sorry to bother you all !

Found a great explanation in the Help file (which of course I only have working as a pdf at the moment !)

Sorry about that.

Bizarre having to re-declare a Global after having declared it (Stack level). Never heard of this - but it works for me !

Thanks anyway.

Re: First day at the 'office' for this LiveCode Newbie

Posted: Wed Jan 09, 2013 11:35 am
by Dixie
Instead of using a global variable.. look at using a custom property to hold your values.. page 222 in the user guide.. You then will not have to declare the global in the script of the stack or on each card where it will be used...

Dixie

Re: First day at the 'office' for this LiveCode Newbie

Posted: Wed Jan 09, 2013 12:24 pm
by Traxgeek
Thanks a million Dixie.