SharedScript [Solved]

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

SharedScript [Solved]

Post by atout66 » Fri May 16, 2014 3:25 pm

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.
Last edited by atout66 on Fri May 16, 2014 6:23 pm, edited 1 time in total.
Discovering LiveCode Community 6.5.2.

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: SharedScript

Post by magice » Fri May 16, 2014 5:00 pm

look in the documentation at the "function" and "on" control structures. I think that is what you are looking for.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: SharedScript

Post by Klaus » Fri May 16, 2014 5:09 pm

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

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: SharedScript

Post by atout66 » Fri May 16, 2014 6:22 pm

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.
Discovering LiveCode Community 6.5.2.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: SharedScript [Solved]

Post by FourthWorld » Fri May 16, 2014 6:55 pm

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
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply