On 2/21/18 12:58 PM, Graham Samuel via use-livecode wrote:
But if there’s no code in the UI stack, how do the handlers in the SOS know 
what object has invoked them?

A behavior acts as though every object with the assigned behavior has that script copied into itself. That means that "me" always refers to the object with the behavior, and each instance of the behavior keeps its own separate script local variables. Without a behavior, you'd need to put a mouseUp handler that calls "doSomething" into each button, and doSomthing would live in a card or stack script. Then doSomething would have to get the name of the target to know the caller, and also keep track of any local variables independently.

I'm working with a project that uses a lot of script-only stacks. It uses a combination of embedded ("normal") scripts and SOS. Handlers that only apply to a single object or card are usually written into the stack or control as usual. Handlers that are used in more than one place are moved to SOS either as behaviors or libraries. Libraries work like stacks in use, behaviors can be shared among different objects. For example, we have a behavior that creates and manages a native scroller on mobile. Whenever we need a native scroller for a field, we assign that SOS as a behavior of the field. The field itself has no script, the behavior does it all.

From what I've read so far here, you don't actually have to convert everything to script-only stacks. You can convert some, or none, or all. I believe Trevor said that you can use other functions outside of the script management features -- for example, built-in functions that compile the app or do auto-update, etc. Your point about not needing SOS for a single developer is, I think, correct. But even if you're the only one working on a stack, you may still want to track changes and updates in a versioning system. Whatever you want to track, you'd convert to a SOS because versioning systems work only with text files.

I haven't made the move myself either, but I'm interested in what is possible so I've been following this thread. Don't feel bad about asking, some of us are lurking.


--
Jacqueline Landman Gay         |     jac...@hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to