Scripting
& IOA Objects
Each IOA object serves a
different purpose. Static text is used to inform the user, or prompt for a
specific kind of response. Radio buttons and checkboxes allow users to turn on
and off options. Popup menus make it possible to select one option from a list
of many options.
Objects have lots of
different attributes. Especially important for scripting are the following
attributes which are explained below: names, values, action scripts and recalc
scripts.
Names
Any object can have a name.
You can refer to the value of the object in a script by using its name. For
example, if you have an editable text object whose name is "nick",
you could have a button with an action script:
dialog.alert
(nick)
This script displays
whatever text the user has entered into the editable text object, in a standard
alert dialog.
Values
Checkboxes and radio
buttons generate strings that contain boolean values, either "true"
or "false". For example, if you have a checkbox named "beep"
you can say:
if
beep
speaker.beep ()
Color popups generate
strings which contain rgb values, e.g. "(0,32767,0)".
Action scripts
The action script is the
one that's displayed in the status bar of Card Editor windows. When the user
clicks on the object or otherwise acts on it, the action script runs.
Radio buttons and
checkboxes can have action scripts that enable or disable other objects using the
card.setObjectEnabled verb.
Popup menus can have
action scripts that run when a menu item is selected.
Please don't perform time
consuming operations in the action scripts for popups, checkboxes or radio
buttons. Create a button or icon object instead.
Some object types don't
have action scripts. For example, clicking on a static text object shouldn't do
anything. Such objects can have action scripts, but they are ignored.
Recalc scripts
The recalc script runs
when the card starts up.
Static and editable text
objects display strings. So you can set the recalc script for a text object to
display the user's name, or the number of free bytes on a disk, basically
anything that can be displayed as a string.
Checkboxes and radio
buttons display boolean values. You can put any boolean expression in the
recalc script for one of these objects. Boolean recalc scripts should resolve to
a string whose value is "true" or "false". Examples:
user.organization
contains "Boeing"
color
equals "red"
"true"
age
82
Color popups recalculate
the selected color. Their recalc scripts should resolve to a string in the form
(r,g,b) where r, g and b are numbers indicating values for the red, green and
blue components of the color.
You can set the frequency
of recalculation in the ScriptsÉ dialog in Card Editor's Object menu.
Objects can be set to recalculate only at card startup, or to recalculate every
time another object's value changes. [Note: this eliminates the uniqueness of
formula objects, they are just static text objects that recalculate every time
another object changes. Formulas are gone in 1.0b15.]
Some types don't
recalculate. For example, buttons are action-oriented objects. They're waiting
to be hit to do their thing.
Summary
Here's a summary table of
the information above:
|
OBJECT |
VALUE |
ACTION SCRIPT |
RECALC SCRIPT |
|
Static text |
string |
|
Sets the text to the value of the script. |
|
Editable Text |
string |
|
Sets the text to the value of the script. |
|
Checkbox |
boolean |
Runs when the checkbox is clicked. |
Checks the box if the value of the script is
"true". |
|
Radio button |
boolean |
Runs when the radio button is clicked. |
Highlights the button if the value of the script is
"true". |
|
Button |
none |
Runs when the button is clicked. |
Sets the text displayed inside the button to the value of
the script. |
|
Popup menu |
string[1] |
Runs when a menu item is selected. |
Runs the script, throws away the value.[2] |
|
Icon |
none |
Runs when the icon is double-clicked. |
Sets the text displayed under the icon to the value of
the script. |
|
Picture |
picture |
|
|
|
Rectangle |
none |
Runs when the rectangle is clicked. |
|
|
Color popup |
rgb |
Runs when a menu item is selected. |
Sets the color displayed in the box. |
|
Frame |
none |
|
Sets the text displayed in the frame to the value of the
script. |