dynamic scripts at runtime

Phil Davis davis.phil at comcast.net
Fri Jun 18 15:59:27 EDT 2004


Why do you need *any* handlers in the dynamically created objects? As long
as the Master Script is in the message hierarchy of the newly created
objects, it can do ALL the work. Like this:


on createControls
  set the defaultStack to stack "FoodPrep"
  set the loc of the templateButton to 100,100
  create button "boil"
  set the loc of the templateButton to 100,200
  create button "grill"
  set the loc of the templateButton to 100,300
  create button "fry"
end createControls



on mouseDoubleUp
  put (short name of the target) into tObject
  switch tObject
  case "boil"
    heatWater 212
    break
  case "grill"
    fireUpBarbie "medium"
    placeChickenOnGrill
    break
  case "fry"
    heatOil 325
    send "cookCatfish" to this stack in 300 seconds -- let oil get hot!
    break
  end switch

My example performs tasks using custom handlers. Each task is represented in
a 'name of the target' - the names of those dynamically created controls.
You can assign control names when you create them, so this approach should
work fine. This is ONE way to accomplish your goal without having to script
any of the controls.

Food for thought.

Phil Davis




----- Original Message -----
From: <RGould8 at aol.com>
To: <use-revolution at lists.runrev.com>
Sent: Friday, June 18, 2004 12:27 PM
Subject: Re: dynamic scripts at runtime


I was under the impression that it had to be 10 commands or less.   Right
now, my "master" script has these handlers:

1)   On mouseLeave
2)   On mouseDown
3)   On mouseDoubleUp
4)   On mouseMove

So, it's sounding like I could perhaps do a:

on mouseLeave
      stackbasedmouseleaveroutine
end mouseLeave

on mouseDown
     stackbasedmousedownroutine
end mouseDown

that type of thing?   I'll give it a try!    My fear was that the "On
MouseDown", "end MouseDown" and calls inbetween would add up to too much,
but perhaps
it'll just fit.




In a message dated 6/18/04 3:20:52 PM, ambassador at fourthworld.com writes:


> RGould8 at aol.com wrote:
>
> > I've got an app that needs to be able to generate fields dynamically
when
> > compiled as a standalone application. I also need to be able to assign
> scripts
> > to those newly created fields.
> >
> > The emails I've read make it sound like this is not possible, if the
> script
> > exceeds 10 commands (which mine does.) What's the work-around? My
> script is
> > stored in a text field on the card, and I was doing a
> >
> > set the script of field newFieldID to field "masterscript"
>
> Why not put the "masterScript" script in the stack and have a much
> shorter script in the fields that call it?
>
> --
> Richard Gaskin
> Fourth World Media Corporation
> ___________________________________________________
> Rev tools and more: http://www.fourthworld.com/rev
> _______________________________________________



More information about the use-livecode mailing list