Re: What is your best practice for setting a script in a script?

2023-07-21 Thread Geoff Canyon via use-livecode
Way back when (in the metacard era) I wrote code to create an XML
representation of a stack, and build a copy of the stack from that
XML file.

Oh, I just checked and I still have a copy of the file. It almost certainly
does not address all the nuances that have been added since then --
behaviors, widgets, and more -- but if you want a copy you're welcome to it.

gc

On Fri, Jul 21, 2023 at 9:12 AM Paul Dupuis via use-livecode <
use-livecode@lists.runrev.com> wrote:

> As some people on this list and the forums have explored in the past, I
> have a interest in creating a Livecode application (stack) entirely from
> a (text only) single script. So there are initially no Livecode objects
> to place a behavior script in. There are initially no buttons, fields,
> cards, stacks, or anything else.
>
> Yes, one of the values of Livecode is an interactive IDE for UI design
> (and refinement), but for this specific interest, it is all about
> creating the UI - in fact the whole app - from a single 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


Re: What is your best practice for setting a script in a script?

2023-07-21 Thread Craig Newman via use-livecode
Paul.

I assume you have a blueprint of what will become a stack with at least one 
card? And that stack will possibly contain other cards, controls, scripts and 
behaviors?

But since all objects have properties, including scripts, and since LC has the 
“create” command, whatever you want to do seems straightforward, if not simple.

You must have the IDE open to even start, of course, so you are already “in” 
LC. Why not just do it the old fashioned way? The end result will be a stack, 
correct? What is the advantage of not starting with a stack?


Craig

> On Jul 21, 2023, at 12:10 PM, Paul Dupuis via use-livecode 
>  wrote:
> 
> As some people on this list and the forums have explored in the past, I have 
> a interest in creating a Livecode application (stack) entirely from a (text 
> only) single script. So there are initially no Livecode objects to place a 
> behavior script in. There are initially no buttons, fields, cards, stacks, or 
> anything else.
> 
> Yes, one of the values of Livecode is an interactive IDE for UI design (and 
> refinement), but for this specific interest, it is all about creating the UI 
> - in fact the whole app - from a single 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


Re: What is your best practice for setting a script in a script?

2023-07-21 Thread Paul Dupuis via use-livecode
As some people on this list and the forums have explored in the past, I 
have a interest in creating a Livecode application (stack) entirely from 
a (text only) single script. So there are initially no Livecode objects 
to place a behavior script in. There are initially no buttons, fields, 
cards, stacks, or anything else.


Yes, one of the values of Livecode is an interactive IDE for UI design 
(and refinement), but for this specific interest, it is all about 
creating the UI - in fact the whole app - from a single 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


Re: What is your best practice for setting a script in a script?

2023-07-21 Thread Bob Sneidar via use-livecode
I wanted to ask why as well. You can put all the scripts necessary in a card, 
and if you need to know the actual object the user interacted with use the 
target command. 

Eg.

Local lTargetID

On mouseUp
   Put the long id of the target into lTargetID
   
   /*
   Your script here
   */
End mouseUp

Bob S


> On Jul 20, 2023, at 5:52 PM, Richard Gaskin via use-livecode 
>  wrote:
> 
> Paul Dupuis 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?
>  
> Why?
>  
> Among other concerns (robustness, debugging, maintenance), setting the script 
> of an object requires turning off script encryption.
>  
> Dick Kriesel wrote:
>> 
> 
> Hi, Paul. The best way to set the script may be not to; that is, instead
>> set the new object’s behavior to a button that contains the readable script.
>  
> ^ this.
>  
> Simple, clean, with-the-grain.
>  
> Know the engine.
> Trust the engine.
> Use the engine.
>  
> --  
> Richard Gaskin
> Fourth World System

___
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


Re: What is your best practice for setting a script in a script?

2023-07-20 Thread Richard Gaskin via use-livecode
Paul Dupuis 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?
 
Why?
 
Among other concerns (robustness, debugging, maintenance), setting the script 
of an object requires turning off script encryption.
 
Dick Kriesel wrote:
>

Hi, Paul. The best way to set the script may be not to; that is, instead
> set the new object’s behavior to a button that contains the readable script.
 
^ this.
 
Simple, clean, with-the-grain.
 
Know the engine.
Trust the engine.
Use the engine.
 
--  
Richard Gaskin
Fourth World System
 

___
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


Re: What is your best practice for setting a script in a script?

2023-07-16 Thread Mark Smith via use-livecode
Not a perfect solution but it does solve the problem of not having to use all 
the put statements and other grammar which as you note is cumbersome to read, 
let alone write. I agree though, a more elegant solution to this problem would 
be useful. 

> On 15 Jul 2023, at 9:29 pm, 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  object reference>.
> 
> 
> 
> On 7/15/2023 11:06 AM, Paul Dupuis via use-livecode 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" into tScript
>>   put "  ask 'Please enter a number between 1 and 100'"  after tScript
>>   put "  if it is not a number then exit mouseUp"  after tScript
>>   put "  if it < 1 OR it > 100 then exit mouseUp"  after tScript
>>   put "  put it into field 'Number'"  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


___
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


Re: What is your best practice for setting a script in a script?

2023-07-15 Thread Paul Dupuis via use-livecode

Oh, another great solutions!

On 7/15/2023 8:23 PM, Alex Tweedly via use-livecode wrote:


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 .



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


Alex.


___
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


Re: What is your best practice for setting a script in a script?

2023-07-15 Thread Alex Tweedly via use-livecode


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 .



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


Alex.


___
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


Re: What is your best practice for setting a script in a script?

2023-07-15 Thread Paul Dupuis via use-livecode

That's pretty good!


On 7/15/2023 7:14 PM, Geoff Canyon via use-livecode wrote:

Custom properties would definitely be my go-to, similar to what others have
said. That said, I think the merge command is your friend here.

This script in a button does what you want:

on mouseUp
set the script of button "Sample" to \
  merge("on mouseUp[[cr]]" &\
  "ask [[quote]]Please enter a number between 1 and
100[[quote]][[cr]]" &\
  "if it is not a number then exit mouseUp[[cr]]" &\
  "if it < 1 OR it > 100 then exit mouseUp[[cr]]" &\
  "put it into field [[quote]]Number[[quote]][[cr]]" &\
  "end mouseUp")
end mouseUp

The use of \ to continue, and [[quote]] and [[cr]] results in a pretty
readable script to my eye at least.


___
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


Re: What is your best practice for setting a script in a script?

2023-07-15 Thread Geoff Canyon via use-livecode
Custom properties would definitely be my go-to, similar to what others have
said. That said, I think the merge command is your friend here.

This script in a button does what you want:

on mouseUp
   set the script of button "Sample" to \
 merge("on mouseUp[[cr]]" &\
 "ask [[quote]]Please enter a number between 1 and
100[[quote]][[cr]]" &\
 "if it is not a number then exit mouseUp[[cr]]" &\
 "if it < 1 OR it > 100 then exit mouseUp[[cr]]" &\
 "put it into field [[quote]]Number[[quote]][[cr]]" &\
 "end mouseUp")
end mouseUp

The use of \ to continue, and [[quote]] and [[cr]] results in a pretty
readable script to my eye at least.

gc

On Sat, Jul 15, 2023 at 8:07 AM 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" into tScript
>put "  ask 'Please enter a number between 1 and 100'"  after tScript
>put "  if it is not a number then exit mouseUp"  after tScript
>put "  if it < 1 OR it > 100 then exit mouseUp"  after tScript
>put "  put it into field 'Number'"  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


Re: What is your best practice for setting a script in a script?

2023-07-15 Thread Paul Dupuis via use-livecode
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 .




On 7/15/2023 11:06 AM, Paul Dupuis via use-livecode 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" into tScript
  put "  ask 'Please enter a number between 1 and 100'"  after tScript
  put "  if it is not a number then exit mouseUp"  after tScript
  put "  if it < 1 OR it > 100 then exit mouseUp"  after tScript
  put "  put it into field 'Number'"  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


Re: What is your best practice for setting a script in a script?

2023-07-15 Thread Mark Smith via use-livecode
Another possibility, which is sort of a combination of Alex and Dicks 
suggestions is to create a “scripts” card and store all of the scripts as 
readable custom properties. When I have done this in the past I typically just 
number the scripts (cScript1 … cScriptn) and put some metadata in the first 
line of each. Usually a comment of the form "—cScript1 — button Sample of cd 
X". If you do that, when you list the custom properties of the scripts in the 
property inspector you see the metadata along with each cp field name (so it 
would look like, cScript1 — cScript1 — button Sample of cd X) and you can see a 
whole list of them. In this situation, the code you provided would be replaced 
with:

create button “Sample”
set the script of btn “Sample” to the cScript1 of cd “Scripts"
Mark


> On 15 Jul 2023, at 4:06 pm, Paul Dupuis via use-livecode 
>  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" into tScript
>   put "  ask 'Please enter a number between 1 and 100'"  after tScript
>   put "  if it is not a number then exit mouseUp"  after tScript
>   put "  if it < 1 OR it > 100 then exit mouseUp"  after tScript
>   put "  put it into field 'Number'"  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


Re: What is your best practice for setting a script in a script?

2023-07-15 Thread David Bovill via use-livecode
This is the same type of problem as deleting an object from a user
interaction with the object - but more common use case and I don;t know a
good way of doing that either. I use:

 send "delete_Object" to somewhere in 2 ticks

But it is messy and tends to be a bit unreliable in my experience. I don't
know a way around it other than avoiding any events being trapped within
the object itself - but that is not so easy.

On Sat, 15 Jul 2023 at 20:47, Dick Kriesel via use-livecode <
use-livecode@lists.runrev.com> wrote:

>
> > On Jul 15, 2023, at 8:06 AM, 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?
>
> Hi, Paul. The best way to set the script may be not to; that is, instead
> set the new object’s behavior to a button that contains the readable script.
> — Dick
> ___
> 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


Re: What is your best practice for setting a script in a script?

2023-07-15 Thread J. Landman Gay via use-livecode

On 7/15/23 12:51 PM, Tweedly via use-livecode wrote:

Maybe keep the script in a custom property ?


That's what I usually do. If the variables or references may change, I use placeholders and the 
merge command to replace things before setting the script on the control.


If it's a very short script I sometimes use this method:

set the script of tObj to "on mouseUp;doSomething;end mouseUp"

--
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


Re: What is your best practice for setting a script in a script?

2023-07-15 Thread Dick Kriesel via use-livecode

> On Jul 15, 2023, at 8:06 AM, Paul Dupuis via use-livecode 
>  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?

Hi, Paul. The best way to set the script may be not to; that is, instead set 
the new object’s behavior to a button that contains the readable script.
— Dick
___
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


Re: What is your best practice for setting a script in a script?

2023-07-15 Thread Tweedly via use-livecode
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 
>  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" into tScript
>   put "  ask 'Please enter a number between 1 and 100'"  after tScript
>   put "  if it is not a number then exit mouseUp"  after tScript
>   put "  if it < 1 OR it > 100 then exit mouseUp"  after tScript
>   put "  put it into field 'Number'"  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


What is your best practice for setting a script in a script?

2023-07-15 Thread Paul Dupuis via use-livecode
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" into tScript
  put "  ask 'Please enter a number between 1 and 100'"  after tScript
  put "  if it is not a number then exit mouseUp"  after tScript
  put "  if it < 1 OR it > 100 then exit mouseUp"  after tScript
  put "  put it into field 'Number'"  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