Page 1 of 1

SharedScript [Solved]

Posted: Fri May 16, 2014 3:25 pm
by atout66
Hi to all,

What about SharedScript in LC ? I've seen an old post from 2010 on the forum, but 4 years later, is there a way to assign one script to multi btt or fld, or any object within the project ?

Thanks in advance, Jean-Paul.

Re: SharedScript

Posted: Fri May 16, 2014 5:00 pm
by magice
look in the documentation at the "function" and "on" control structures. I think that is what you are looking for.

Re: SharedScript

Posted: Fri May 16, 2014 5:09 pm
by Klaus
Hi Jean-Paul,

every handler and function that is in the card/stack/library stack script IS in already "shared"!
This is a question of cleverly using the "message path". A good read about this topic:
http://www.fourthworld.com/embassy/arti ... _path.html

And then there are "behaviors", which you can apply to one or more objects.
Or do you mean something else?


Best

Klaus

Re: SharedScript

Posted: Fri May 16, 2014 6:22 pm
by atout66
Thanks to both of you for your help.
From the link provided by Klaus, I realize that in fact, what I was used to call a <sharedScript> in TBK is called <Behaviors> in LC.
However, the logical is the same; so great 8)

Kind regards, Jean-Paul.

Re: SharedScript [Solved]

Posted: Fri May 16, 2014 6:55 pm
by FourthWorld
There are several ways to share code among objects:
- Any mainstack script is accessible by any object in the stack file
- Backscripts and libraries are available to all stacks
- FrontScripts can be used to global preprocess messages
- Behaviors can be used to provide a single script across any number of specific objects

For an overview of how these fit together:

Extending the LiveCode Message Path
An introduction to using Libraries, FrontScripts, BackScripts and Behaviors
in RunRev's LiveCode Programming Language
http://www.fourthworld.com/embassy/arti ... _path.html