Maybe keep the script in a custom property ? Or in a “prefs” file ? Or ….. any number of ways of avoiding the exact question you asked ;-)
And yes, there’s been a request for “block” text constants for about as long as I’ve used RR/LC - say 20 years. Alex Sent from my iPad > On 15 Jul 2023, at 16:06, Paul Dupuis via use-livecode > <use-livecode@lists.runrev.com> wrote: > > So in the instances where you have a script that creates an object and then > sets the script of that object (example below), what is you best practice for > having the script in a script and still be readable? > > Example: > BUTTON "Make" > on mouseUp > local tScript > create button "Sample" > put "on mouseUp"&cr into tScript > put " ask 'Please enter a number between 1 and 100'" &cr after tScript > put " if it is not a number then exit mouseUp" &cr after tScript > put " if it < 1 OR it > 100 then exit mouseUp" &cr after tScript > put " put it into field 'Number'" &cr after tScript > put "end mouseUp" after tScript > replace "'" with quote in tScript > set the script of button "Sample" to tScript > end mouseUp > > This create a button "Sample" with the script > on mouseUp > ask "Please enter a number between 1 and 100" > if it is not a number then exit mouseUp > if it < 1 OR it > 100 then exit mouseUp > put it into field "Number" > end mouseUp > > However, I reading the script for button Sample in button Make with the "pu" > statements and quotes (double and single) and cr and so one cumbersome to > read. Yes there are behavior scripts, but this is about the best practice of > placing a script in a script (to set the script of an object) and having it > as clear as possible. > > I wish there was a command like "put begin block" where you could follow it > any number of lines and then "end block into tVar". i.e. > > put begin block > on mouseUp > ask "Please enter a number between 1 and 100" > if it is not a number then exit mouseUp > if it < 1 OR it > 100 then exit mouseUp > put it into field "Number" > end mouseUp > end block into tScript > > Is there a better way to have a script written in a script? > > > _______________________________________________ > 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 _______________________________________________ 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