Hi All.
Does someone know how to save/set and use global Containers of script, and how to call these when needed?
fx 10 buttons that do different things. but 5 lines of code is the same.
How do I put these 5LineOfCode into a variable container?
So I can do something like this:
on MouseUp
Call 5LinesOfCode
End MouseUp
Shall I use a MainScript or the Script of MainStack or hte actual Card?
Or does I only need to declare it on any card, as long as I call it "Global".
Script Containers
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Script Containers
Hi.
What you are asking, and you still have to manage this carefully, is to isolate a segment of code that might be common to many objects, so that segment can be called from any of those objects.
Make five buttons. Give each one a unique name. In the script of each, put:
In the stack script:
Now for two pieces of homework, which you simply must do.
1- read up on the message path in the user guide and the lessons.
2- Rewrite the five button handlers so that a single handler, located in the card script, can do exactly what those five do. You will need to look up "the target" in the dictionary.
You will be tested on this.
Craig Newman
What you are asking, and you still have to manage this carefully, is to isolate a segment of code that might be common to many objects, so that segment can be called from any of those objects.
Make five buttons. Give each one a unique name. In the script of each, put:
Code: Select all
on mouseUp
put the short name of me && random(99) into temp
get massageThatNumber(temp)
answer it
end mouseUp
Code: Select all
function massageThatNumber var
put any char of "ABCDEF" after var
return var
end massageThatNumber
1- read up on the message path in the user guide and the lessons.
2- Rewrite the five button handlers so that a single handler, located in the card script, can do exactly what those five do. You will need to look up "the target" in the dictionary.
You will be tested on this.
Craig Newman