expanding to multiple cards

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

expanding to multiple cards

Post by adventuresofgreg » Mon Jul 22, 2013 11:28 pm

Hello: I have a LC application that makes use of many handlers and global variables. I would like to expand it by duplicating the main card, but each card must see it's handlers and globals as it's own local (ie: the values inserted into the global variables should NOT be available to scripts running on other cards. I can move the main stack script containing all the handlers over to a card script, but the handler names, and all associated global variables would be duplicated, and SHARED between copies of this card. Any idea how to get around this?

thanks,
Greg

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10356
Joined: Wed May 06, 2009 2:28 pm

Re: expanding to multiple cards

Post by dunbarx » Tue Jul 23, 2013 2:34 am

Hi.

If you want to isolate variable names so that they are not shared among the handlers on various cards, keep them script local. In other words, if you declare the same global variable name in two scripts, you have to share. If you declare them as script locals, you do not. It is even possible to isolate handlers within a script from seeing global declarations if that declaration is made below the handler in question. But that sort of management seems klugy and unruly.

If you intend to use common names in multiple places, and I get that, then why go global at all?

Usually the issue is the opposite, that the user is trying to make these things universal. You will then be able to use globals in your stack script only for those variables that do indeed need to be universal.

Craig Newman

Post Reply