What is your best practice for setting a script in a script?
alex at tweedly.net
Sat Jul 15 20:23:18 EDT 2023
On 15/07/2023 21:29, Paul Dupuis via use-livecode wrote:
> All good suggestions so far, but not what I was after, which was
> whether there is any better way to have the script you are setting the
> newly created object to, readable, in the script that setup of the new
> object. If a behavior script is used or properties or objects then I
> can not read (and potentially revise) the script right in the script
> that is making the object. I have to open something else if I want to
> revise the script. Of course I can have a comment that says "look here
> for the script" and it is generally obvious from "set the script of
> button "Sample" to <some property and/or object reference>.
OK, how about this ?
> on mouseUp
> -- using special comments to set script of another object
> local tmp
> put the script of me into tmp
> filter tmp with "*--1 *"
> replace "--1 " with empty in tmp
> set the script of btn "B" to tmp
> --1 on mouseup
> --1 put "hello world"
> --1 end mouseup
> end mouseUp
of course, you could have multiple of them --1, --2, etc.
and you could have metadata, say the first line of each "special
comment" has the object name
--1 -- script for button "abc"
--1 on mouseup
--1 end mouseup
More information about the use-livecode