sharedscripts
J. Landman Gay
jacque at hyperactivesw.com
Thu Feb 24 15:13:48 EST 2005
On 2/24/05 12:43 AM, Rob Meijer wrote:
> Your suggestion to use "set the script of fld "content" to the script of
> btn "wijzigen"
> was the first statement I tried. I put it as last statment into a
> handler, but got
> the errormessage that a script cannot be altered while running.
> Then I tried "send foo", foo being a handler in de stackscript. Same
> errormessage,
> because what I need is not to execute handler "foo", but to replace the
> script of a field.
> Example.
> 1.
> The listfield is an index. Clicking a line opens a card:
> on mouseup;get selectedtext;go card it
> 2.
> A button is pressed to get a new script into that field.
> Now that field may delete a card.
> Or a button is pressed to get a new script into that field.
> Now that field may change the content of a card.
> 3.
> Here comes the problem:
> The main task of the listfield is being an index to go to a card.
> So I need a statement on the end of each script to reset the script
> of that listfield to "on mouseup;get selectedtext;go card it".
> This is easily done in Toolbook, but I can't find it in Transscript.
This isn't how we usually do it in Revolution. In general, scripts
themselves are rarely changed, and in fact, if you compile a stack into
a standalone there are strict limits on replacing scripts so it isn't a
practical approach.
Instead, the scripts should be unchanging and branch to the correct
behavior instead of trying to replace themselves. This allows one script
to handle all circumstances. It is also much easier than replacing the
script content.
Do something like this instead:
Set up three radio buttons, one for "go card", another for "delete card"
and a third for "change contents". Group them. This ensures that only
one can be hilited at a time. Then your field script should do this:
on mouseUp
put the selectedtext of me into theCd
if the hilite of btn "go card" then
go card theCd
else if the hilite of btn "delete card" then
delete card theCd
else if the hilite of btn "change contents" then
-- do whatever you need here
end if
end mouseUp
One script handles everything. If your actions are lengthy, you can call
another handler instead of putting the commands directly into the
"mouseup" handler, like this:
...
else if the hilite of btn "change contents" then
doCardChanges theCd
end if
...
on doCardChanges theCd
-- do stuff here to card theCd
end doCardChanges
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list