Globals Question (was Menu Popup)

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Globals Question (was Menu Popup)

Post by WaltBrown » Sat Sep 17, 2011 2:42 am

Thanks Mark for the comment on globals. I just tested and see that once declared, the globals and their contents persist as long as the LC session is open, even if all other stacks are closed. I closed everything but LC, built a new stack from scratch with a global of the same name, and it had the previous contents.

Which leads to a question - is there a way to make a global of stack (or stack and substack) scope? Are user defined properties the only way?

Thanks, Walt
Walt Brown
Omnis traductor traditor

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Globals Question (was Menu Popup)

Post by Mark » Sat Sep 17, 2011 11:55 am

Hi Walt,

Custom properties are a really convenient way to make data available to all scripts without messing with globals. Additionally, you can define local variables instead of global variables. Local variables (declared outside a handler) are available to that particular script only.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: Globals Question (was Menu Popup)

Post by WaltBrown » Sat Sep 17, 2011 5:22 pm

Thanks.
Walt Brown
Omnis traductor traditor

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: Globals Question (was Menu Popup)

Post by WaltBrown » Wed Sep 28, 2011 10:19 am

Hi Emma!

Global variables are global throughout any stacks open in a session. I was asking if there was a way to make a variable global only to the stack - there's not, I am going to use custom properties instead. That way I can use the same name in scripts used in multiple stacks and they will not have shared contents.
Walt Brown
Omnis traductor traditor

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Globals Question (was Menu Popup)

Post by Mark » Wed Sep 28, 2011 10:30 am

Walt,

Since private messaging has been turned off, I have to do this in public. I have noticed that you replied to spammers several times now. Please understand that by replying to spam, you help the spammers. The more replies they get, the more attention they get for their porn, viagra pills, and casino sites.

Before you reply, please check whether you're replying to a spammer. How can you see this? Here are some possible clues:
- the post may contain a quote from elsewhere in the forum
- the spammer didn't write anything clever about LiveCode (e.g. "Hi, can it do this?")
- the spammer wrote about something that has nothing to do with LiveCode (e.g. shoes)
- there is a link in the signature or in the post
- the spammer has written less than 10 messages
- all messages were written on the same day
- your first impression of the post is "huh?!"
- sometimes you can find the user name here

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: Globals Question (was Menu Popup)

Post by WaltBrown » Thu Sep 29, 2011 6:52 am

Thanks, Mark, that occurred to me belatedly.
Walt Brown
Omnis traductor traditor

Post Reply