Page 1 of 1

Globals Question (was Menu Popup)

Posted: Sat Sep 17, 2011 2:42 am
by WaltBrown
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

Re: Globals Question (was Menu Popup)

Posted: Sat Sep 17, 2011 11:55 am
by Mark
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

Re: Globals Question (was Menu Popup)

Posted: Sat Sep 17, 2011 5:22 pm
by WaltBrown
Thanks.

Re: Globals Question (was Menu Popup)

Posted: Wed Sep 28, 2011 10:19 am
by WaltBrown
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.

Re: Globals Question (was Menu Popup)

Posted: Wed Sep 28, 2011 10:30 am
by Mark
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

Re: Globals Question (was Menu Popup)

Posted: Thu Sep 29, 2011 6:52 am
by WaltBrown
Thanks, Mark, that occurred to me belatedly.