Page 1 of 1
Nwebie with scripting question
Posted: Thu Jan 21, 2010 6:49 am
by MikeinHawaii
I am just starting out in transcript so please bear with me.. Can somebody please tell me how to script this situation?
I want to populate a card with 3 fields. The goal is to be able get the third field to show the result of the sum of any random numbers put into field one and field two. I have tried all sorts of combinations of script lines but keep getting error messages when I hit compile. Basically, I have given each field a name in the object inspector, and then my script goes something like this
Code: Select all
function "GetSum" of field1+field2. Put result of Sum into field3
. Please forgive my ignorance of how to perform this, I never wrote any code in my life yet.
Re: Nwebie with scripting question
Posted: Thu Jan 21, 2010 7:11 am
by FourthWorld
I appreciate your posting that, Mike. Those of us who teach RevTalk for a living benefit tremendously from learning how newcomers envision how it works, where they guess right and where they guess not so right.
In your program, assuming you want to have the third field anytime the user exits either of the first two, put this in your card script:
Code: Select all
on closeField
put fld 1 + fld 2 into fld 3
end closeField
Re: Nwebie with scripting question
Posted: Thu Jan 21, 2010 8:21 am
by MikeinHawaii
Perfect. Thank you very much. It never dawned on me that it would be a card script I needed to use. I kept trying to assign my scripts to the fields.
Re: Nwebie with scripting question
Posted: Thu Jan 21, 2010 12:46 pm
by FourthWorld
The good thing about Rev is that there are so many ways to do things. The bad thing about Rev is that there are so many ways to do things.
Here, the advantage of putting the script at the card level is that you can affect two objects with one script. If you need a specific behavior for just once object, putting the script in that object is just fine, but when you need a behavior for multiple objects, you can choose any other point along the message path to expand the scope of objects it will affect.
While focused more on the basics of the message path than making effective scoping decisions using it, this article may be helpful:
Extending the Runtime Revolution Message Path:
An introduction to using Libraries, FrontScripts, BackScripts and Behaviors
in Runtime Revolution's RevTalk Programming Language
http://www.fourthworld.com/embassy/arti ... _path.html