messages are sent along the hierarchy. You normally
trigger each demonstration by clicking the yellow
"Show Example" button on that page. Would you like to see the
demo for this page instead of moving on to the next page?
StrShowDemo
&Show Example
StrNoDemo
&No Demo
The Pattern Property
Background Objects
Mouse movement and button messag
To get and To set Handlers
Book Editor
Local versus System Variables
Branching with If/then/else
Branching control structures
User-defined messages 1
Expressions
sectionNumber
startSection
Expressions
An expression is a way of combining or specifying values in OpenScript. For example, the following are expressions:
125 + 77
(text of field "Cost" - 5)
An expression has a result. The result of the first expression is 202. The result of the second expression depends on the contents of a field named "Cost."""eld named "Cost."
Using the debugger to interrupt
sectionNumber
A looping control structure whose ending condition is never met is called an endless loop. If you run a handler that contains an endless loop your computer may appear broken. Fortunately, you can interrupt a running handler so you can edit the script and fix it.
1. Switch to Reader level.
2. Click the "Endless Loop" button.
This button's script contains an endless loop.
3. Hold down both Shift keys until the Debug window appears.
4. To return to ToolBook, choose Exit Debugger from the Options menu.
To find out more about how to use the Debug window, see ToolBook Online Help.g Scripts," in Using OpenScript.
Using Shift+Shift to interrupt an endless loopp
Endless Loop
-- This handler
endless loop. The
_tests
-- i
will
'than
equal
zero. However,
-- i starts
increases so the ending condition
-- never met. Press Shift+
-- running
interrupt
TDebug
ci > 0
buttonUp
buttonUp
Endless Loop
Types of expressions
Types of expressions
There are three types of expressions in OpenScript:
numeric Results in a number (e.g. 10 / 3 = 3.33333333)
string Results in a string
(e.g. "Cat" & "Mouse" = "CatMouse")
logical Results in true or false (e.g. 6 > 11 = false)
The following exercises allow you to explore writing expressions and predicting their results.lts..
sectionNumber
Building expressions
sectionNumber
An expression consists of one or more values separated by operators like +, -, &&,
and so on. For example, "100", "100+5",
and "3>5 or 5>3" are all expressions.
1. Switch to Reader level.
2. Use the lists of values and operators to the right to build an expression. Click the values or operators you want in your expression. They will be added in the order you click them. You can also type directly in the "Expression" field.
3. Predict the result of your expression, then click the "Show Result" button to see your expression's result in the "Result" field."Result" field......... in the "Result" field... the "Result" field....................
Building expressions_
-- If the current expression has already been calculated,
;"Expression"
"Result" fields. In
M, place
pselected value
lineNum
<= 0;
W& " "
buttonUp
buttonUp
Expression
Result
textFromPoint
Expression
lineNum
calculated
1.0e5
false
"Avacado"
"Beet"
"Carrot"
"Eggplant"
"Zucchini"
-- Add the selected operator
expression.
4calculated
"Expression"
"Result"
lineNum
<= 0;
" " &
W& " "
buttonUp
buttonUp
Expression
Result
textFromPoint
Expression
lineNum
calculated
is not
contains
is not in
Value:
Operator:
Result
Expression
Expression:
Test Result
Result:
Show Result
-- Use the
function
expression
"Expression"
. If there
error, display a
message, otherwise, place
|result
"Result"
4calculated
-- The following
Uputs
_succedes
's syntax
handler can
. Trying
invalid
results
"Execution Suspended"
"Test
" &&
"This isn't a correct
. Remember," && \
consists
values separated" && \
Hoperators."
buttonUp
buttonUp
Expression
Test Result
set a to
Result
This isn't a correct expression. Remember,
an expression consists of values separated
by operators.
expression
calculated
Show Result
Specifying parts of strings
sectionNumber
You can refer to parts of strings in OpenScript.
For example, if you want characters two through
five of the string in the field to the
right you would type:
characters 2 to 5 of text of field "String"
If you want just character 10 you
would type:
character 10 of text of field "String"
To specify words use "word" rather
than "character."
1. Switch to Reader level then
specify words 3 through 5 of the
string by typing an expression in the
"String Specifier" field. Click the
"Show Result" button to see the expression's result. Make up some other expressions and try them..
Specifying parts of strings
String
The quick brown fox jumped over the lazy dogs.
String:
Show Result
-- Use the
function
specifier
""String Specifier"
. If there
error display a
message. Otherwise, place
result
"Result"
sSpecifier
-- The following
Uputs
_succedes
's syntax
handler can
. Trying
invalid
results
"Execution Suspended"
"Test
" &&
"This isn't a
buttonUp
buttonUp
String Specifier
Test Result
set a to
Result
This isn't a valid string specifier. Try again.
sSpecifier
Show Result
String Specifier
characters 5 to 15 of text of field "String"
String Specifier:
Result
quick brownnown fox jumped over the lazy dogs.
Test Result
"String"
String
Result:
-- Table
Contents -
-- The
may be entered
8. That
's section
saved
-- s_currentSection
handler.
used
displayed.
-- There
also a
-- marks a completed
chapter
Hplacing
-- asterisk beside its
-- When entering
(entry
-- corresponding
recorded
-- Switch
Reader level
-- Hide
help
-- Highlight
selectedTextLines
J"Chapters"
J"Sections"
-- Place
front
identified
x. If
sections
, place
markSection x
chapterNum
sectionNum
-- Get
list
--
propertyName
commandLine
" &&
5&& "
--
fore
" &&
-- If
chapterDone
chapters
x"*"
enterPage
markSection
enterPage
reader
Chapters
buttonUp
Chapters
Sections
Sections
currentSection
s_currentSection
markSection
Sections
of page "Table of Contents"
of page "Table of Contents" to it
Chapters
Table of Contents
chapters
chapterDone
commandLine
propertyName
sectionNum
chapterNum
Chapter Head
Using the workbook
Basic concepts
Basic concepts
startSection
sectionNumber
Elements of OpenScript
Elements of OpenScript
startSection
sectionNumber
OpenScript commands
OpenScript commands
startSection
sectionNumber
enterPage
enterPage
Lists
Lists
A list contains items which are separated by commas. For example, the following list contains four items:
Oranges, Apples, Star Fruit, Kiwi
Notice that even though "Star Fruit" is two words it is only one item since it is between commas. The following exercise allows you to experiment with lists and items....you to experiment with lists and items.....
startSection
sectionNumber
Lists
Changing an Object's Color Prope
The sysCursor Property
OpenScript Workbook
Listing Objects using Push and P
on a Page
Table of Contents
Close the Workbook
bjects from
Handling Standard Menu Choices
Handlers in Backgrounds
Table of Contents
The OpenScript Workbook
1991 Asymetrix Corporation
All Rights reserved.
Asymetrix OpenScript Workbook Team:
Bob Gallup
Carol Buchmiller
Claude Ostyn
Greg Pearson
Brad Gaub
Tom Arnold
instructional design:
Tec Ed, Ann Arbor, Michigan
ichigan
ructional design:
Tec Ed, Ann Arbor, Michigan
-- Go
the Table
Contents
buttonUp
buttonUp
Table of Contents
Table of Contents
Showing all objects on a page
If you want to show all objects on a page even if they are currently hidden, you can use the page's objects property.
1. To show all objects on a page, type the following command in the Command window:
show objects of this page
This technique can be useful if you know there are hidden objects on the page but you don't know their names or IDs.
How would you hide the objects on this page? How would you show all objects on the background?
Showing all objects on a page
Button
sectionNumber
OpenScript Workbook
January, 1991
(c) Asymetrix Corporation
gives you permission
e, revise
reuse the individual
scripts
your own applications.
--You may
x, however,
Sentire
a substantial part
redistribution
jproduct.
retains
copyright on
original elements
. Include
notice "Portions
are
they contain
copied
-- Special handling
Author
test drive version
-- It does
xstop
clock, but prevents annoying messages
-- due
frequent
cdoing
exercises
myAuthor
"Title"
"Welcome"
-- When entering
8, switch
Reader level,
-- environment,
cbar
status box.
4s_launchedFrom, s_changesDB, s_currentSection
restoreEnvironment
done
"The hierarchy 2"
leaving
-- Restore
_saving
contents
. Also,
asure that
-- ToolBook confirms
user exits
8without
-- System
- Application
workbook
setting
nproperty
--
8was opened
FromAppSampler
oldLaunchedFrom
oldFromAppSampler
sFromAppSampler
oldChangesDB
beginning
a section,
. If
marks
L list.
-- This handler also unlocks
screen, forcing
image,
mouse cursor
hourglass
default shape.
scomplements
, which
effective
notify
flipping
complete.
4s_sectionStarted
sectionNumber
startSection
markSection
/"Table
Contents"
record
Exit
selected
sent
Command
started
. If so,
Tour.
linkDLL "tbkwin.dll"
STRING GetWinIniVar(
OldBook
","AppSampPath")
"Unable
G New
, issue a warning
creating a
8will
-- impossible
"Creating a
Pmean
can't
" && \
unless
directly." \
f"Create"
"Cancel"
opening a
"Opening a
" && \
-- Use
function
asterisk,
strip x
SPACE & TAB & "*" & CR & LF
restoreEnvironment
enterPage
author
leavePage
leaveBook
enterBook
strip
author
myAuthor
Title
Welcome
enterBook
reader
eRrestoreEnvironment
sizeToPage
The hierarchy 2
s_launchedFrom
s_changesDB
s_currentSection
leaveBook
eRrestoreEnvironment
s_changesDB
restoreEnvironment
oldChangesDB
oldFromAppSampler
oldLaunchedFrom
s_launchedFrom
s_changesDB
sFromAppSampler
enterPage
sectionNumber
startSection
sectionNumber
markSection
Table of Contents
default
s_sectionStarted
leavePage
sectionNumber
s_currentSection
tbkwin.dll
GetWinIniVar
ToolBook
AppSampPath
GetWinIniVar
AppSamp.tbk
Unable to return to the Application Sampler.
OldBook
sFromAppSampler
Creating a new book will mean you can't return
to the Application Sampler unless you open it directly.
Create
Cancel
Cancel
sFromAppSampler
Opening a new book will mean you can't return
to the Application Sampler unless you open it directly.
Cancel
Cancel
sFromAppSampler
strip
Popping items from a list
sectionNumber
The objects property of a page, background, or group returns a list of object references. The object property of an object is the object's type (e.g. the object of ellipse id 42 is ellipse). Using the pop command and the objects and object properties, you can write a handler to count the number of objects of a certain type on a page.
1. Create a button called "Count Ellipses"
2. Write a handler that gets the objects property of this page. Then, using the pop command, count the number of objects that are ellipses.
Switch to Reader level and click the "Hint" button for one solution.
3. How could you count all the rectangles on the page?
Popping items from a listttttttttttter o
to handle buttonUp
set numEllipse to 0
get objects of this page
while it is not null
pop it into anObject
if object of anObject is "ellipse"
increment numEllipse
end
end
put "Number of ellipses is" && numEllipse
end buttonUp
-- Show
the hint.
"Hint"
buttonUp
buttonUp
Accessing items in lists
sectionNumber
Many properties are lists. For example, fillColor, strokeColor and bounds are all lists. In this exercise you will see how to change an item in an object's bounds to change the object's height.
1. Look at the script in the button "Shorten Pyramid."
Double-click the button while pressing the Ctrl key. Notice which item of the pyramid's bounds is modified by the script.
2. Switch to Reader level and click several times on the "Shorten Pyramid" button. What happens?
3. Create a new button called "Grow Pyramid" and write a buttonUp handler to make the pyramid taller by moving the bottom of the pyramid down...............
Accessing items in lists
Shorten Pyramid
Pyramid
-- Make the
"e" shorter
units
Hincrementing
=. The
-- corresponds
(y coordinate)
Ledge.
"pyramid"
buttonUp
buttonUp
pyramid
pyramid
Using OpenScript Help
226,280
SetWinHelpDims
-- Adjust
.ini settings
xrunning yet, so that
will come
)a good
OpenScript
Kbar
-- below default
OWorkBk
-- Note: Assumes most common
M,which
standard VGA,
3.0
compatibility.
linkDLL "tbkwin.dll"
WORD SetWinIniVar(STRING,
"Windows
","Xl","27")
","Yu","37")
","Xr","611")
","Yd","475")
","Maximized","0")
enterpage
SetWinHelpDims
enterpage
SetWinHelpDims
SetWinHelpDims
tbkwin.dll
SetWinIniVar
Windows Help
SetWinIniVar
Windows Help
SetWinIniVar
Windows Help
SetWinIniVar
Windows Help
SetWinIniVar
Windows Help
Maximized
SetWinIniVar
sectionNumber
In this exercise you will display and explore OpenScript Help. Follow the steps below. Please read all the instructions before starting.
1. Activate the Command window.
Display the Command window by pressing Shift+F3. You can move the Command window by dragging its caption bar. If the Command window is already visible, click it to activate it.
2. Display OpenScript Help: Press the F1 key.
3. Click "Using this Encyclopedia" in the index and read the text displayed. Return to the index and explore other terms of interest. When you are finished, close OpenScript Help by double-clicking its Control menu.
For information about using Windows help itself, choose "Using Help" from the Help menu in OpenScript Help.
Help.
Using OpenScript Help
What this book contains
What this book contains
This book contains exercises and examples to help you learn to use OpenScript for writing scripts. The book is divided into chapters and sections. Each section covers one topic and contains a mix of explanation and exercises.
Chapter
Explana-
Exercise
Explana-
Exercise
Section
Section
startSection
sectionNumber
User-defined functions 2
ontinue
User-defined functions, continued
sectionNumber
The following OpenScript command uses the isAlpha function to set the variable charType to true or false:
set charType to isAlpha(char 2 of name)
If a function is not defined in the same script as the handler that refers to it, ToolBook follows the object hierarchy looking for a corresponding to get handler.r.ect hierarchy looking for a matching to get handler.ndler..ollows the object hierarchy to find a matching to get handler.
Object Types
OpenScript Help
Clicking a page
Writing a Simple buttonUp handle
Restoring Menus
Listing objects, continued
. Toolbook programming
To set handler continued
ith a
sectionNumber
1. Read about to set handlers in OpenScript help.
2. Write a to set handler to set a property called objectSize of the green ellipse to the right. Place the handler in the ellipse's script.
3. Test the handler from the Command window by typing:
set the objectSize of ellipse "green" to 2000, 500
To see one solution, switch to Reader level and click the "Hint" button.r level and click the "Hint" button..
To set handler, continuedwith a To Set Handler, cont.
green
-- Get and Set handlers for the size property.
-- Place them in an object's script.
to set objectSize to xyList
get my bounds
set item 3 of it to item 1 of it + item 1 of xyList
set item 4 of it to item 2 of it + item 2 of xyList
set my bounds to it
to get objectSize
get my bounds
clear theSize
push item 4 of it - item 2 of it onto theSize
push item 3 of it - item 1 of it onto theSize
return theSize
-- Show
the hint.
"Hint"
buttonUp
buttonUp
Branching control structures
ranching
If/then/else and conditions/when/else are ToolBook's branching control structures. If/then/else provides two-way branching and Conditions/when/else provides many way.....vides many way.....
to handle buttonUp
ask "What's your name?"
if it is not null then
set text of field "Name" to it
else
beep 10
end if
endep 10
end if
to handle buttonUp
request "How Hot?" with "Mild" or \
"Medium" or "Hot"
conditions
when it is "Mild"
set spice to 0
when it is "Medium"
set spice to 5
else
set spice to 10
If/then/else:
Conditions/when/else:
sectionNumber
Branching control structuresgggggggggggg
User-defined functions 1
ntinue
User-defined functions, continued
An example of a user-defined function is:
to get isAlpha testChar
return testChar is in "abcdefghijklmnopqrstuvwxyz"
The name of this function is "isAlpha". It has one parameter, "testChar". The return command sets the function's value to true it testChar is a letter or false if it is not.
tter.
Sets the variable charType to true or false
sectionNumber
Looping control structures
sectionNumber
Looping control structuresgggggggggg
Step, do/until, and while are ToolBook's looping control structures......tep - repeats
to handle buttonUp
step i from 1 to 10
set fieldName to "field " & i
clear the text of field fieldName
end1 seconds
end beep 10
end if
Step:
to handle buttonUp
set giveAccess to false
while not giveAccess
ask "Password"
if it is securityCode of this book then
set giveAccess to true
end if
endndnd
While:
to handle buttonUp
pop objectList
show it
until objectList is null
endd"
if it is securityCode of this book then
put true into giveAccess
end if
Do/until:
The sysCursor property
sectionNumber
The ToolBook system also has properties. They are called system properties. One of many useful system properties is the sysCursor property which can be used to change the shape of the mouse pointer.
1. The "Please Wait" button contains the script displayed at the bottom of the page. Look at the script and try to identify the commands that change the sysCursor property.
2. Switch to Reader level and click the button to see how the cursor shape is changed.
3. Look up sysCursor in OpenScript Help and edit the button's script to try some of the other cursor shapes.....ursor shapes. shapes..es..s.rsor shapes..
The sysCursor property
Please Wait
-- Set the cursor
hourglass
default shape.
buttonUp
buttonUp
Please Wait
-- Shows setting the cursor to a different shape
to handle buttonUp
set sysCursor to 4
pause 3 seconds
set sysCursor to 1
Handlers in backgrounds
sectionNumber
If neither the object nor the page has a buttonDown handler, but the background does, the background handler gets executed and the message stops.tops.
Handlers in backgrounds
Spark
height
height
bkgnd script
to handle buttonDown
beep 10
to handle myMessage
go to page "Test"
arrow
-- Animate the message demo
showMe
moveLSpark "et1"
"bkgnd
showMe
showMe
moveLSpark
moveLSpark
moveLSpark
bkgnd script
bkgnd script
bkgnd script
The special variable It is used
as a default container in
OpenScript. Whenever you
use a get command,
OpenScript places the
result in the variable It.
Ask and request commands
also store their results in It.
For this exercise, each line in the "Commands" field is an OpenScript command that affects or uses the value of the variable It. The field's script executes each line as you click it at Reader level and shows the resulting value of It in the field labeled "Value of It:"
1. Switch to Reader level and click each command. Observe how the command affects the value of It...t.f IT.alue of IT.e value of IT.........
Stuff
T'was brillig and the slithy toves did gyre and ...eeeeeeeeeeeeeeeeee
Field Stuff
h B!
T'was brillig and the slithy toves did gyre and ...bal in the wabe
to handle buttonUp
get the text of field "stuff"
if it contains "brillig" then
end buttonUp
ITCommands
-- Execute a
"itValue"
place the resulting value
special
^"It"
lineNum
buttonUp
buttonUp
itValue
textFromPoint
itValue
lineNum
get the text of field "Stuff"
put it
get (10 * 15)
request it with "OK" or "Cancel"
request it with "Yes" or "No"
itValue
Value of It:
Commands:
T'was brillig and the slithy toves did gyre and ...
sectionNumber
Forwarding a message
sectionNumber
If a handler contains a forward statement, the message is passed on to the next object in the hierarchy.y
Forwarding a message
Spark
height
height
arrow
bkgnd script
to handle buttonDown
beep 10
forward
to handle myMessage
go to page "Test"
forward
-- Animate the message demo
showMe
moveLSpark "et1"
"bkgnd
showMe
showMe
moveLSpark
moveLSpark
moveLSpark
bkgnd script
bkgnd script
forward
moveLSpark
moveLSpark
forward
bkgnd script
More on forward
-- Animate the message demo
showMe
moveLSpark "et1"
"bkgnd
showMe
showMe
moveLSpark
button script
button script
button forward
moveLSpark
moveLSpark
bkgnd script
background forward
moveLSpark
book script
book script
book script
background forward
bkgnd script
bkgnd script
button forward
button script
sectionNumber
Objects further up in the hierarchy will handle a forwarded message if the objects have a handler for the message..
More on forward.
Spark
height
height
bkgnd script
to handle buttonDown
forward
beep 10
to handle myMessage
go to page "Test"
background forward
book script
to handle buttonDown
beep 30
the target to true
set invert of the target to false
to handle myMessage
go to page "Test"
button script
to handle buttonDown
beep 10
forward
endddd myMessage
go to page "Test"
end"Test"
button forward
arrow
Background objects
sectionNumber
If you click an object located on the background, the object gets the message first. If the object doesn't have a handler for the message, the message passes to the background and so on.so on.
Background objectskground
Spark
height
height
arrow
-- Animate the message demo
showMe
moveLSpark "bt1"
showMe
showMe
moveLSpark
moveLSpark
moveLSpark
moveLSpark
Clicking a page
sectionNumber
If you click the page, but away from any object, the message goes directly to the page.oes directly to the page.
Clicking a pageege
Spark
height
height
arrow
-- Animate the message demo
showMe
moveLSpark "pgt"
"et5"
showMe
showMe
moveLSpark
moveLSpark
moveLSpark
moveLSpark
Objects in groups
-- Animate the message demo
showMe
moveLSpark "et1"
showMe
showMe
moveLSpark
moveLSpark
moveLSpark
moveLSpark
moveLSpark
moveLSpark
sectionNumber
If you click an object in a group, the message goes first to the object, then to the group, then to the parent of the group (in this example, the page), and so on until the message is handled or until it reaches the ToolBook system.
Objects in groupss
Spark
height
height
arrow
The UniqueName
Basic concepts
hical Naviga
Objects in Groups
The object hierarchy
User-defined functions continue
Listing objects using push and p
sectionNumber
The objective in this exercise is to write a handler to display the names or IDs of all the objects on a page, even if they are nested in groups. One technique is to use the push and pop commands. The basic steps for listing objects on the page are as follows:
A. Get the value of the objects property for the page (a list of objects).
B. Pop an item from the list:
If the item identifies an object, not a group
display that object's name or ID
otherwise, if the item identifies a group
get the objects of the group
push the objects onto the list of objects
C. Repeat step B until the list is empty.
Continued on the next page.ge. page. page.
Listing objects using push and pop
"Sample1"
Button Indic
group indic
Group
"2 6#
group indic
Group
The objects property of page "sample1" is the list of objects whose parent is the page. page.round.
Chapter Head
Click the right arrow to continue.rrrrrrrrr
Title
Table of Contents
-- Go
the Table
Contents
buttonUp
buttonUp
Table of Contents
Table of Contents
-- If
moved
reposition
on the
-- user-defined property, home,
/graphic covering
-- When
qmouse
pressed,
released,
w. Finally,
-- Move
-- depending on
parameter, x, which can be
H15,15
buttonDown
moved
buttonUp
press
moved
buttonDown
press
buttonUp
press
previous
press
7755,5480
Right
-- If
moved,
a user-defined property, home,
-- the
graphic covering
-- When
Bmouse
pressed,
released,
w. Finally,
-- Move
-- depending on
parameter, x, which can be
H15,15
buttonDown
moved
buttonUp
press
moved
buttonDown
press
buttonUp
press
press
8370,5475
Object types
-- Place the type
{clicked
"Type"
Glocation
objectFromPoint(
"Object
buttonup
buttonup
Object Type
Object Type
location
sectionNumber
This page contains a script that will display the object type of an object you click.
1. Switch to Reader level.
Use F3 or the Reader command from the Edit menu. If you're not at Reader level the script cannot function.
2. Click different objects on the page and observe the type displayed in the
field at the bottom of the page.
Note: this exercise only shows information about objects on the page. It will not show information about background objects.
3. Switch back to Author level and create an object of your own. Switch to Reader level and click your new object.
Was the result what you expected?he result what you expected?
Object types
Object Type
Object Type
User-Defined Messages
Typing multiple commands in the
An Object's Location
Building Expressions
More on forward
Typing multiple commands in the
A user-defined function for sort
Elements of OpenScript
Handler placement
sectionNumber
startSection
Handler placement
Remember, if an object doesn't have a handler for a message, the message continues up the object hierarchy. You can often simplify an application by placing a single handler further up in the hierarchy that handles messages for similar objects. Such a handler can use the target system property to identify the object that first received the message.
The following exercise shows how placing a handler further up in the hierarchy can reduce the number of handlers needed.eded.
User-defined functions
startSection
sectionNumber
OpenScript has numerous built-in functions for calculating arithmetic, statistical, string, and other results. You can create your own functions by writing a special type of handler, called a "to get" handler.
Unlike a message handler, which runs in response to a message, a to
get handler runs only when its name is used in an OpenScript command.
mmand.
to area(self)
Area is a function that returns a the areArea is a function that returns a the arerens a the aren that returns a the are
User-defined functions
A self-correcting object
sectionNumber
This exercise uses the Command window and shows how you can create a user-defined property to store an object's size.
1. Activate the Command window. Create a property called "originalSize" and set it to the bounds of the triangle by typing:
set originalSize of polygon "triangle" to bounds
of polygon "triangle"
2. Select and resize the triangle, then type:
set bounds of polygon "triangle" to originalSize
of polygon "triangle"
3. Display the value of the originalSize property in the Command window.
Type: originalSize of polygon "triangle"""n "triangle"angle"then type:
set bounds of polygon "triangle" to
originalSize of polygon "triangle"
A self-correcting objectc
triangle
Object names
-- Place the
p, type
{clicked
fields on
. If
2mouse
% but
1will be cleared.
Glocation
objectFromPoint(
"Object Name"
Type"
0UniqueName"
buttonup
buttonup
Object Name
Object Type
Object UniqueName
Object Name
Object Type
Object UniqueName
location
sectionNumber
This page contains a script that will put the name, type, and uniqueName of any object you click into the fields at the bottom of the page.
1. Switch to Reader level.
Use F3 or the Reader command from the Edit menu. The script cannot function at Author level.
2. Click each object on the page and observe the name, type, and uniqueName displayed.
Note: this exercise will only show information about objects on the page. It will not show information about background objects.
3. Switch to Author level and create an object of your own. Return to Reader level and click your new object.
Was the result what you expected??????????????
Object names
Object Name
Nameeeeeeee
Object Type
Object UniqueName
Unique Name
Red Square
Diamond
Pie Slice
Button
Hi There!
A user-defined function for chec
sectionNumber
In this exercise, you will write a handler that defines a function that checks a character to see if it is a numeral.
1. Edit the script of this page and create a to get handler for a function called isNumber. The function should check a character supplied as a parameter and return true if the character is a numeral (0-9), or false if the character is not a numeral.
This function is similar to the isAlpha function. For a hint click the "Hint" button.
2. Test the isNumber function by typing the following in the Command window:
isNumber("3")
isNumber("a")
isNumber("a")
isNumber("a")
A user-defined function for checking character type
to get isNumber testChar
return testChar is in "0123456789"
-- Show
the hint.
"Hint"
buttonUp
buttonUp
Local versus system variables
-- When leaving
[the "totalSys"
"totalLocal"
-- fields.
4count
leavePage
leavePage
totalLocal
totalSys
count
sectionNumber
OpenScript has two types of variables: system and local. System variables retain their value when a handler has finished and can be shared between handlers. Local variables are discarded.
In this example the two buttons, "System" and "Local", contain the scripts displayed below them. The scripts are identical except for the system declaration in one compared to the local declaration in the other.
Each time one of the buttons is clicked, the value in the variable count is incremented and displayed in the total field.
1. Switch to Reader level and try clicking the buttons. How do they act differently??y???? do they act differently??????
Local versus system variables
to handle buttonUp
system count
if count is null then
set count to 0
increment count
set the text of field "totalSys" to count
System
-- Increment the
^"count"
display
result
%"totalSys"
. The
^, so its value remains
ghandler
finished
-- running.
buttonUp
buttonUp
totalSys
count
System
totalSys
System Variable:
to handle buttonUp
local count
if count is null then
set count to 0
increment count
set the text of field "totalLocal" to count
Local
-- Increment the
^"count"
display
result
%"totalLocal"
. The
^, so its value
discarded
Fhandler
-- finished running.
buttonUp
buttonUp
totalLocal
count
Local
totalLocal
Local Variable::
Setting an object's size with a
sectionNumber
An object's bounds property is a built-in property that contains coordinates of the upper left and lower right corners of the object's bounding rectangle. The size of the object (width and height) can be calculated by subtracting the left coordinate from the right and the top from the bottom. The size of an object can be set by adding the width and height to the left and top coordinates.
In this exercise you'll write a to set handler to set the size of an ellipse. After adding the handler to the object's script you should be able to type "set the objectSize of ellipse green to 800,300" in the Command window to change the object's size and have its bounds change accordingly.
Continued on the next page.
ext page.
1. Read about to get and to set handlers in the Using OpenScript manual.
2. Following the guidelines above write handlers
Setting an object's size with a to set handler
Verifying data during input with
sectionNumber
In this example you will write a keyChar handler to allow only numerals to be typed in the Number field shown to the right.
1. Look up the keyChar message in OpenScript help.
2. Try to write a keyChar handler in the script of the "Number" field to the right that allows only numerals to be typed.
Hint: If a character from 0 to 9 is typed, the message should be forwarded. Otherwise, the handler should beep and do nothing. Test the handler by switching to Reader level then typing in the field.
To see one solution, switch to Reader level and click the "Hint" button.....el and click the "Hint" button.
Verifying data during input with a keyChar handler
to handle keyChar key
get ansiToChar(key)
if it is in "0123456789" then
forward
else
beep 5
end if
end end if
-- Show
the hint.
"Hint"
buttonUp
buttonUp
Number:
Branching with conditions
The conditions/when/else control structure allows you to accomodate many conditions in one structure.
1. Create a button.
2. Edit the button's script to use the request command to request a color: Light, Medium or Dark. Then, using the conditions control structure, set the button's fillColor to "White", "Cyan", or "Red" according to the chosen value.
For one solution, switch to Reader level and click the "Hint" button.
3. Test your button by clicking it at Reader level.
Branching with conditions
to handle buttonUp
request "Which color?" with "Light" or \
"Medium" or "Dark"
conditions
when it is "Light"
set my fillColor to White
when it is "Medium"
set my fillColor to Cyan
when it is "Dark"
set my fillColor to Red
enddddd
-- Show
the hint.
"Hint"
buttonUp
buttonUp
sectionNumber
Changing an object's bounds
sectionNumber
Another of an object's properties is its bounds. The bounds of an object is a list of four numbers representing the coordinates (x,y) of the upper left corner and lower right corner of a rectangle bounding the object. In this exercise you'll write a handler to change the bounds of the smiley face, which is a group.
1. Look at the script of the "Flat Face" button. Also look at the script of the "Round Face" button.
Select the button and use the Button Properties command or hold down the Ctrl key and double-click the button with the selection arrow. Notice the command that changes the bounds of the "Smiley" group.
2. Switch to Reader level and click each of the buttons.
ttons.
button to try it out.
Changing an object's bounds
Smiley
Round Face
Flat Face
-- Return the
"Smiley"
its original
5776, 837, 7998, 3162
buttonUp
buttonUp
Smiley
-- Change the
"Smiley"
looks flat
5776, 837, 7998, 1500
buttonUp
buttonUp
Smiley
Restoring menus
Adding or deleting menus and menu items from the menu bar changes the menu until you change it back--even if you open another book. You can restore the menu bar to the ToolBook default by using the restore menubar command.
1. Type the following command in the Command window:
restore menubar at both
You can ensure that your menu bar is restored whenever you open a new book by adding a leaveBook handler to the script of any book that changes the menu. See the handler on the right for an example.
xamples.
Restoring menus
-- leaveBook handler to restore the menu
-- bar when going to another book.
to handle leaveBook
restore menuBar at both
-- leavePage handler to restore the menu
-- bar when going to another page.
to handle leavePage
restore menuBar at both
sectionNumber
Topic
Branching with If/then/else
sectionNumber
The if/then/else control structure allows you to test a condition and do different things as a result. In this exercise you will use if/then/else to test the results of an ask command.
1. Edit the "Set Attendance" button's script and create a buttonUp handler. In the handler, ask for the attendance. Check the result to see if it is between 0 and 10. If it isn't, beep. If it is, set the text of field "Attendance" to the value.
To see one solution, switch to Reader level and click the "Hint" button (click again to make the hint disappear).
2. Try the script by clicking the "Set Attendance" button...on.ld's scripts and switch to Reader level. el. l.
Branching with If/then/else
Attendance
Attendance
to handle buttonUp
ask "Attendance?"
if it >=0 and it <= 10 then
set text of field "Attendance" to it
else
beep 20
end if
endddddd
Set Attendance
-- Show
the hint.
"Hint"
buttonUp
buttonUp
Containers
Changing an Object's Bounds
The hierarchy 2
Drawing Objects from a Script
To set handler continued
Listing objects continued
and P
sectionNumber
In this exercise you will write a handler that displays the name or ID of all the objects on a page. To prepare, look at OpenScript Help for information on the objects and object properties.
1. Create a button and write a handler for it that will display the names or IDs of objects on the page in the "Object List" field to the right.
To see one solution, switch to Reader level and click the "Hint" button. You can cut and paste this handler into the field's script and then experiment by making modifications. The handler can be modified in numerous ways such as displaying information about object properties for each object or indenting objects in groups.ps..ng objects in groups.. groups.
Listing objects, continued
blank hint
to handle buttonUp
clear text of field "Object List"
set x to objects of this page
while x is not null
pop x
put object of it && quote&name of it"e\
& CRLF after text of field "Object List"
-- For a group, push its objects back onto
-- the list of objects to display
if object of it is "group"
push objects of it onto x
end
end buttonUp
Object List
-- Show
the hint.
"Hint"
buttonUp
buttonUp
Geometrics
Square
Triangle
Object List:
( used
true
Objects
sectionNumber
startSection
Objectssssssssss
A ToolBook book consists of objects such as buttons, fields, graphics, and pages. An author defines the objects, their properties, and their behavior. The book's reader interacts with the objects.
As an example, this page contains record fields (for text), several buttons, and various graphic objects.page also contains a foreground that could contain objects unique to this page.e to this page.
Objects
Handlers in Objects
Visual Effects
Properties
sectionNumber
startSection
Properties
Objects have properties. You can change an object's appearance or select different built-in ToolBook behaviors by changing the object's properties. You can add to or replace an object's built-in behavior by changing the object's script.
The following exercises show some examples of changing properties.
Properties
continue
A final note ...
Using the Ask Command
A Self-Correcting Object
Typing multiple commands in the
sectionNumber
You can type multiple commands in the Command window at the same time by separating them with semicolons.
1. Type the following commands in the Command window and press Enter when you're finished:
step i from 1 to 100; move ellipse dot by 10,10; end
2. What commands would you type to move the dot back to its starting point?
3. What commands would you type to move the dot back to its starting point?
Typing multiple commands in the Command window
Mouse movement and button messag
-- When leaving
[the "Messages"
leavePage
leavePage
Messages
sectionNumber
Numerous messages are sent to an object as a result of mouse movement and actions. The messages are:
mouseEnter mouseLeave
buttonDown buttonUp
buttonStillDown rightButtonDown
buttonDoubleClick rightButtonUp
rightButtonDoubleClick
1. Switch to Reader level
Press F3. (mouse messages aren't sent at Author level).
2. As you move the mouse over the magenta rectangle and click, the messages sent to the rectangle will be displayed in the "Messages" field. Try to display each of the ones listed above..........
Mouse movement and button messagess
Messages
Messages:
Object drawing and display
Object drawing and display
OpenScript has commands to draw objects as well as to manipulate them in various ways. The following exercises use OpenScript commands to draw, show, hide, and move objects.nScript commands.ds.ving objects.
startSection
sectionNumber
Navigation and visual effects
sectionNumber
startSection
Navigation and visual effects
OpenScript has commands that you can use to navigate between pages and books. It also has commands that you can use to create different visual effects when switching pages.
The following exercise looks at page navigation as well as the three special effects ToolBook provides.
Types of Objects
Branching with Conditions
Setting an Object's Size with a
User-defined functions
FxZoom fxDissolve and fxWipe
A self-sorting field
sectionNumber
startSection
A self-sorting field
One of the powerful things about ToolBook's object-oriented approach is that you can design objects, complete with scripts, that can be cut and pasted into other applications. An example of this is a field that has a script to sort itself. Such a field could be pasted into other applications ready to go.
The following exercise shows how to create a self-sorting field.d.orting field.
A simple object browser
When a page or background has many objects, it can be difficult to keep track of what their names are, which ones have scripts and so on. One tool that can make it easy to inspect objects and their properties is a script that displays information on objects you click.
In the following exercise you will write a script that allows you to quickly see information about objects.jects..cts..bjects...cts.
startSection
sectionNumber
A simple object browser
Structure of a Handler
Another Example of the step cont
User-defined functions 1
Listing all objects on a page
sectionNumber
startSection
Listing all objects on a page
Backgrounds, pages, and groups all have an objects property. Its value is a list of all the objects of the background, page or group. Listing objects from the objects property is simple unless one of the objects is a group. This is because a group contains other objects.
The following exercise shows an example of using the push and pop commands to list objects even if they are within groups.following exercise shows how to write a handler that lists the object type and name of objects on a page.............s on a page.page.n a page.......
Contents
Showing all Objects on a Page
Table of Contents
Using the ask command
sectionNumber
1. Create a button and label it "Get First Name".
Use the button tool from the tool palette.
2. Edit the button's script and type:
to handle buttonUp
ask "Type your first name" with "Sigmund"
set the text of field "First Name" to it
end buttonUp
3. Switch to Reader level and click the button.
What happens when you click the Cancel button? What happens if you remove "with "Sigmund"" from the Ask command in the script??pt? if you remove the "with "Sigmund"" from the Ask command?
Using the ask commanddddd
First Name
First Namest Name
Structure of a handler
Structure of a handler
A handler has a beginning, middle, and end.
In the following exercise you will write a simple handler for a buttonUp message.ritten using OpenScript. The end is a line identifying the end of the handler.
In the following exercise you will
write a simple buttonUp handler.you will write a simple buttonUp handler.
sectionNumber
-- Changes to reader level when
-- page is entered.
to handle enterPage
send Reader
end enterPagerPageeeeee
Beginning: identifies the name of the message to which this handler responds.
Middle: contains instructions in OpenScript saying what to do when the message is received.
End: marks the end of the handler
ToolBook Programming
Name versus ID
Setting and Getting Field Text i
Handlers in Pages
A simple object browser using ri
Table of Contents
Chapters
Sections
-- Turn the
selected section
clicked.
turnToSection
pressed.
--
pkey
default processing
-- Algorithm:
-- Get
currently
. If
named
strip(
oselectedTextLines
Click
buttonDoubleClick
keyChar
turnToSection
buttonDoubleClick
qturnToSection
keyChar
qturnToSection
turnToSection
strip
-- Display
the help
helpObject
buttonUp
buttonUp
helpObject
Close the Workbook
-- Go
same
buttonUp
buttonUp
Close the Workbook
Title
-- Hide
help
clicked.
default
buttonDoubleClick
buttonDoubleClick
default
Click a chapter name on the left to see that chapter's sections on the right.
Double-click a section name on the right to go to that section. As you complete each section or chapter, it will be marked with an asterisk beside its name.
Double-click this text to make it disappear
Chapter Name
Using the workbook
Using the workbook
startSection
sectionNumber
Exercise pages
Exercise pages
On exercise pages, ToolBook
automatically changes to Author
level so you must use
<Ctrl>+arrow keys or commands
from the Page menu to turn pages.
To complete an exercise, follow directions in the field on the left and use the space to the right as your work area.area..............
Instructions
Title
Exercise Page
startSection
sectionNumber
Table of Contents
Sections6
A self-sorting field
Listing all objects on a page
A simple object Browser
Sections5
User-defined properties
User-defined messages
Handler placement
User-defined functions
Handling keystrokes
To get and to set handlers
Sections4
The Command window
Ask and request
Control structures
Object drawing and display
Navigation and visual effects
Push and pop
Menus
Sections3
Object identifiers
Properties
Containers
Lists
Expressions
Sections2
Toolbook programming
Objects
Messages
Handlers
The object hierarchy
Sections1
What this book contains
Navigating in this book
Exercise pages
OpenScript Help
A final note ...
What this book contains
Navigating in this book
Exercise pages
OpenScript Help
A final note ... keystrokes
To get and to set handlersers
Using the workbooktionsic concepts Elements of OpenScript OpenScript commands Advanced topics OpenScript applicatio
ToolBook comes with an extensive online OpenScript encyclopedia called OpenScript Help. To read OpenScript Help, activate the Command window by clicking it or open a Script window, then press <F1>.
OpenScript Help works the same way as standard Windows Help so it is similar to online help in other Windows applications. following exercise you getript Help....
ing [
startSection
sectionNumber
A final note ...
A final note ...
The exercises in this book are just starting points. Feel free to pick and choose topics that seem interesting, explore on your own, and make up your own examples.
Now, click the forward arrow to begin learning about OpenScript or click the Table of Contents button to turn to the table of contents.
ny o%
startSection
sectionNumber
Developing ToolBook Applications
OpenScript applications
User-defined functions 2
The object hierarchy
sectionNumber
startSection
The object hierarchyy
When a message is sent to an
object, it travels up what's called
the object hierarchy until
the message locates
a handler for itself or
until the message
reaches the ToolBook
system.
Object
Button Indic
ToolBook
System
stemstem
Background
Page
Object
Button Indic
group indic
Group
"2 6#
group indic
Group
Object
Button Indic
group indic
Group
Message
Spark
l+height
Spark
,height
Spark
.height
Spark
h/height
Spark
0height
Spark
2height
3used
3true
Using OpenScript Help
Welcome
Exercise Pages
Specifying Parts of Strings
Developing ToolBook applications
Developing ToolBook applications
Developing a ToolBook application usually begins with the user interface. You can lay out the buttons, fields and other objects, then develop scripts to make them behave the way you want. While traditional program development tends to be linear, ToolBook development is more flexible and modifications can be made and tested readily.
to kE
sectionNumber
Handlers
Handler Placement
Object Names
Navigation and Visual Effects
Using the Request Command
ion, cont.
The Command Window
ctures - Looping
fx destination
A buttonUp handler Higher in the
Containers
Containers
A container is anything in OpenScript that can hold a value. Containers can be properties, variables, the special variables It and sysError, or the Command window.
The following exercises demonstrate using local variables versus system variables and the special variable It. Properties are covered in another section..c.topic.
objeE
startSection
sectionNumber
Handling standard menu choices
sectionNumber
In this exercise you will see a script that alters how ToolBook responds to the Author menu item. When you choose a menu item, ToolBook sends a message to the current page. The message name is the same as the menu item, but without spaces or special characters.
1. Switch to Reader level and choose Author from the Edit menu.
Notice what happens.
2. Edit the script of this page and add the handler displayed to the right.
Choose Page Properties from the Object menu.
3. Change to Reader level again and choose Author from the Edit menu.
What's different this time?
Handling standard menu choices
script1
to handle author
request "Switch to Author level?" \
with "Yes" or "No"
if it is "Yes"
forward
end if
end author
end author
e enterBook
--positions the workbook window
set syslevel to author
send sizeToPage
end enterBook
Author Handler
A popup definition using show an
sectionNumber
In this exercise you will write scripts to hide and show a field that contains a hotword definition.
1. Double-click in the green field to begin editing its text. Select the bold word "score" in the text and make it a hotword.
Choose the Create Hotword command from the Text menu or press Ctrl-W. To outline the hotword choose Show Hotwords from the Text menu.
2. Edit the script of the hotword and create a buttonUp handler that shows the field called "definition" (the white field).
3. Edit the script of field "definition" to hide itself when it is clicked (you can use the special term self in the hide command).
4. Switch to Reader level and try your scripts by clicking the fields.
A popup definition using show and hidend Hideddddddddd
hotwords
Four score and seven years ago, our fathers brought forth a new nation, conceived in liberty and dedicated to the proposition that all men are created equal.
Definition
A score is twenty years. "Four score and seven" is eighty-seven years."ight-seven years."
-- Handler for the hotword
to handle buttonUp
show field "definition"
end buttonUp
-- Handler for the popup definition
to handle buttonUp
hide self
end buttonUp
-- Show
the hint.
"Hint"
buttonUp
buttonUp
-- Add the message
ppassed
"msgText" parameter
/"messages"
. If its
overflowing,
A are added. Once 500 lines
_ have accumulated,
[them
logMessage
oldSuspend
& CRLF
) > 500
-- Post
names
mouse
received
buttonDown
mouseEnter
buttonStillDown
buttonUp
logMessage
buttonDoubleClick
rightButtonDown
mouseLeave
rightButtonUp
rightButtonDoubleClick
logMessage
messages
oldSuspend
msgText
mouseEnter
logMessage
mouseEnter
mouseLeave
logMessage
mouseLeave
buttonDown
logMessage
buttonDown
buttonStillDown
logMessage
buttonStillDown
buttonUp
logMessage
buttonUp
buttonDoubleClick
logMessage
buttonDoubleClick
rightButtonDown
logMessage
rightButtonDown
rightButtonUp
logMessage
rightButtonUp
rightButtonDoubleClick
logMessage
rightButtonDoubleClick
Working with objects from the Co
sectionNumber
1. Display the Command window.
Press Shift+F3.
2. Type each of the following commands in the Command window. Press Enter after each command.
select ellipse "dot"
unselect ellipse "dot"
put position of ellipse "dot"
move ellipse "dot" by 100,100
set the fillColor of ellipse "dot" to green
set bounds of ellipse "dot" to 300,300,1300,1300
edit the script of ellipse "dot"
You can find out more about these commands in OpenScript Help.penScript manual.al.n the Using OpenScript manual. information on each command in the Using OpenScript manual."""""""""""""""""""""
Working with objects from the Command window
-- When the mouse
pressed,
released,
buttonDown
buttonUp
buttonDown
240,50,100
buttonUp
60,50,100
Adding menus and menu items
sectionNumber
The script to the right shows an example of adding a custom menu and menu items.
1. Edit the script of this page and type the handler displayed to the right.
An easy way to do this is to type the following in the Command window:
set script of this page to text of field "script1"
2. Install the menus by sending a setupMenu message to this page.
Send the setupMenu message by typing the following in the Command window:
send setupMenu
3. Try the new menu items.
See the next exercise to restore the menu bar.
Switch back to Author level.
Adding menus and menu items
script1
to handle setupMenu
add menu"Script" at both
add menuitem "Object" to menu "Script" at both
add menuitem "Page" to menu "Script" at both
add menuitem "Book" to menu "Script" at both
deactivate menuitem "Object" at Reader
end setupMenu
to handle Object
if the selection is not null
edit the script of the selection
end if
end Object
to handle Page
edit the script of this page
end page
to handle book
edit the script of this book
end book
to handle leavepage
restore menubar at both
end leavepagee
restore menubar at both
end leavepageeeeeeeeenubar at both
end leavepageepage leavepageepageleavepageepageepageepageepageepageeeeee
The uniqueName
sectionNumber
The uniqueName
An object's uniqueName identifies the object. It includes the object's ID, the page it is on and the name of the book it is in.
The following example shows you the name, object type, and uniqueName of several common objects.........ere the object is located.
The following example shows you the name, object type, and uniqueName of several common objects.
Forwarding a Message
age Hierarchy
Object Identifiers
The pattern property
Another of an object's properties is its pattern property. This pattern is used to fill shapes.
1. Look up the pattern property using the Search button in OpenScript Help.
Activate the Command window and press F1.
2. The button, "Watch", contains the script displayed at the bottom of this page. Examine the script and identify the line that sets the pattern property.
3. Switch to Reader level and click the "Watch" button.
4. Edit the button's script and add a line so that the pattern returns to solid after displaying the other patterns..erns.s.
The pattern propertyyyyyyyyyyyyyy of
script1
-- Changes the pattern property of a rectangle
-- to all possible patterns.
to handle buttonUp
step i from 1 to 128
set pattern of rectangle "boob toob" to i
endddddddddddddd
Boob Toob
Watch
-- Change the
property
possible patterns.
"boob toob"
buttonUp
buttonUp
boob toob
Watch
sectionNumber
Topic
ction
-- Switch
Reader level
entering
enterBackground
enterBackground
Reader
Page Leader
Title
Table of Contents
-- Go
the Table
Contents
buttonUp
buttonUp
Table of Contents
Table of Contents
-- If
moved
reposition
on the
-- user-defined property, home,
/graphic covering
-- When
qmouse
pressed,
released,
w. Finally,
-- Move
-- depending on
parameter, x, which can be
H15,15
buttonDown
moved
buttonUp
press
moved
buttonDown
press
buttonUp
press
previous
press
7755,5480
Right
-- If
moved,
a user-defined property, home,
-- the
graphic covering
-- When
Bmouse
pressed,
released,
w. Finally,
-- Move
-- depending on
parameter, x, which can be
H15,15
buttonDown
moved
buttonUp
press
moved
buttonDown
press
buttonUp
press
press
8370,5475
Hiding and showing objects using
User-Defined Properties
Push and Pop
A popup definition using Show an
Handlers
sectionNumber
startSection
Handlerssandlerss
When an object receives a message, it can respond to the message or ignore it. If the object ignores the message, the message gets passed on to the group, page, background, or book that contains the object.
In order to respond to a message, an object must have a "handler" for that message in its script.
ript.
d is a line identifying the end of the handler. In the following exercise you will write a simple buttonUp handler.
Another example of the step cont
sectionNumber
Here's another example of using the step control structure.
1. Edit the script of the "Clear Names" button.
2. Create a buttonUp handler to clear the names of the fields. The fields are called "Name1", "Name2", and so on, through "Name6".
To see one solution, switch to Reader level and click the "Hint" button.
Another example of the step control structure
Name1
Name6
Name5
Frank
Name4
Name3
Henderson
Name2
Bertrand
Clear Names
to handle buttonUp
step i from 1 to 6
set fieldName to "Name" & i
clear the text of field fieldName
endddd1 seconds
end beep 10
end if
-- Show
the hint.
"Hint"
buttonUp
buttonUp
exercise
Introduction
Message Demo
Close the workbook
-- When entering the
label on
8icon
/s_launchedFrom
^. If
Lworkbook
-- Quick Tour,
ewill be "
." Otherwise,
probably be
"returnBook"
enterPage
enterPage
returnBook
s_launchedFrom
Close the workbookk
After completing the exercises
in this workbook, you are
ready to begin writing
scripts and applications
on your own....
Double-click the book icon to close this workbook. If you opened the workbook from the Application Sampler, the Application Sampler will be opened............... to open another book called the OpenScript Work Book. When you are finished
with the Work
Book the
Quick Tour will
resume.
returnBook
-- When
}-clicked,
-- label
d(since
-- become unshaded)
message (which
, be intercepted
handler
a mouse
pressed over
Hchanging its
-- Trap
ignore
}messages
Click
buttonDoubleClick
buttonDown
buttonUp
buttonDoubleClick
0,100,0
buttonDown
0,50,100
buttonUp
:PHYSSIZE
sectionNumber
What this Book Contains
Object Drawing and Display
Menus
Messages
Accessing Items in Lists
A simple object browser
User-defined functions, continue
Cont.
OpenScript Online Help
Control Structures
Ask and Request
Types of objects
sectionNumber
Types of objects
ToolBook has several different types of objects:
Books Record fields
Backgrounds Hotwords
Pages Groups
Buttons Graphic objects (pictures, draw
Fields objects, and paint objects)
Writing a simple buttonUp handle
sectionNumber
1. Create a rectangle on this page.
Use the rectangle tool from the tool palette.
2. Edit the script of the rectangle.
Click the selection tool in the tool palette.
Choose Graphic Properties from the Object menu and click the Script button.
3. Enter and save the following script (use the Exit/Update command in the Script menu):
to handle buttonUp
hide self
pause 2 seconds
show self
end
4. Switch to Reader level and click the rectangle.
What messages did clicking the rectangle send? Which message caused the rectangle to disappear? What about the other message????????????????????????????????????????????????????????????????
Writing a simple buttonUp handler
Please note: Read the instructions on this page carefully before executing them.
Other windows will appear in front of this window. If you need to move these windows to read the instructions, drag their title bar.
Object identifiers
sectionNumber
startSection
Object identifiers
In writing scripts you often have to refer to an object, perhaps to hide or show it, or to change it in some way. To refer to an object you use a combination of the object's type (e.g. field, button) and the object's name or ID. If the object isn't on the current page you may also have to add location information. As an example, to refer to the blue ellipse
on this page you could use ellipse "oval" or
ellipse ID 0....pic".
Hiding and showing objects using
1. Display the Command window.
Press Shift+F3.
2. Type the following commands in the Command window. Press Enter after each command.
hide rectangle "box"
show rectangle "box"
hide menubar
show menubar
hide toolpalette
show toolpalette
move toolpalette to 100,100
3. What commands would you type to hide and show the pattern palette? The color tray?
Hint: If you don't know, try using OpenScript Help.
manual.
Hiding and showing objects using the Command window
sectionNumber
Setting and getting field text i
1. Type the following commands in the Command window. Press Enter after each command:
set text of field "thatfield" to text of field "thisfield"
clear text of field "thisfield"
set text of field "thisfield" to "Hi there!"
put the third word of text of field "thatfield"
put the last word of text of field "thisfield"
put words 4 to 7 of text of field "thatfield"
2. How would you refer to the third through thirteenth characters of field thatfield???ters of field thatfield?"
3. How would you refer to the third through thirteenth characters of field thatfield?
Setting and getting field text in the Command windowow
thisfield
The text of a field is one of its properties just like its border style. and can be set with an OpenScript statement.
thisfield
thatfield
thatfield
sectionNumber
ToolBook programming
ToolBook programminging
In traditional programs, the program controls the user by requesting input and displaying output..
PRINT "What's your name?";
INPUT Name$
PRINT "Hi, "; Name$
PRINT "Enter a number: ";
INPUT Num
PRINT "The square root of "; Num; " is: "; SQRT(Num)
FUNCTION Fact(n)
f = 1
FOR i=2 to n
f = f*i
NEXT i
Fact = f
END FUNCTIONNNNNNNNNNNNNNNN
What's your name? Sue
Hi, Sue
Enter a number: 4
The square root of 4 is 2
startSection
sectionNumber
The hierarchy 2
ontinued
sectionNumber
For example, if you click a page object that does not have a handler for the buttonDown message, the message continues to the page, then to the background, and so on, until it reaches the ToolBook system..m.
The hierarchy, continued....
Spark
height
height
arrow
false
false
The ToolBook difference
sectionNumber
The ToolBook differenceg
In a ToolBook application, the user controls the program. Everything the user does (like clicking a button) sends a message to an object which runs a "handler" to respond.
Try to click the objects for which a script is shown.n.
Number:
number
-- When
clicked,
(the user
place
("What
x"Cancel"
buttonUp
buttonUp
What number?
Cancel
81fdas
to handle buttonUp
get text of self
ask "What number?" with it
if sysError is not "Cancel" then
set the text of self to it
end buttonUpp
Calculate
-- When
clicked, calculate the square root
place results
3"answer"
-- The actual
here
a little more complicated than
{impler
, because
also implement
-- error trapping.
Our testers had so much fund trying
, we
placate them.
-- Don't suspend execution
r -- Clear
P-- Reset
default
y -- If there was
"Cannot take
& n & """!"
buttonUp
buttonUp
number
answer
Cannot take the square root of "
answer
Calculate
to handle buttonUp
get text of field "number"
clear text of field "answer"
if it is not null then
get sqrt(it)
set text of field "answer" to it
end buttonUp ndld "answer"
Answer
Square Root:is:::::
Name versus ID
sectionNumber
Name versus ID
You can refer to an object using its name, if it has one, or its ID. You can name an object using the Properties dialog box or by setting the Name property for the object. The ID is assigned by ToolBook and is unique for each object.
It is usually best to refer to objects by name. When you cut and paste an object, its ID changes, so references to the old ID will be invalid. The name does not change unless you change it...old ID will be invalid. The name does not change unless you change it.ess you change it.
An object's location
An object's locationame
If the object you're referring to isn't on the current page you may have to add location information to refer to it. For example, to refer to a button on the background you might use the following:
button "Next Page" of background "Database"
mple shows you the namess of
sectionNumber
Handlers in objects
sectionNumber
If the script of the object contains a handler for the buttonDown message, the object's handler is executed and the message stops..
Handlers in objectsarchy
Spark
height
height
button script
to handle buttonDown
beep 10
to handle myMessage
go to page "Test"
end"Test"
arrow
-- Animate the message demo
showMe
moveLSpark "et1"
showMe
showMe
moveLSpark
button script
button script
button script
Ask and request
Ask and request Commands
The ask and request commands are useful for getting information or choices from a user. The ask command asks the user to enter some text. Whatever the user types is placed in the special variable, It.
The request command displays a message and asks the user to click a button in response. The text on the button clicked is placed in the special variable, It.
in the container, IT.
startSection
sectionNumber
Handling keystrokes
sectionNumber
startSection
Handling keystrokess
Sometimes you want to respond to a user based on characters he or she types at the keyboard. You can do this with a keyChar handler. One common use of the keyChar handler is to check data as it is typed to make sure it is valid for the field.
The following exercise shows how to write a keyChar handler to make sure data is numeric.ic.numeric.meric.ic.
Handlers in pages
sectionNumber
If the object does not have a buttonDown handler but the page does, the page's handler is executed and the message stops..................
Handlers in pagesarchy, cont.
Spark
height
height
page script
to handle buttonDown
beep 10
to handle myMessage
go to page "Test"
arrow
buttU
-- Animate the message demo
showMe
moveLSpark "et1"
showMe
showMe
moveLSpark
moveLSpark
page script
page script
page script
Using the request command
1. Create a button and label it "Decision".
Use the button tool from the tool palette.
2. Edit the button's script and type:
to handle buttonUp
request "Save humanity or not?" with \
"Save" or "Destroy"
set text of field "fate" to it
end buttonUp
3. Switch to Reader level and click the button.
Try this a couple of times, making different choices. Which choice is the default choice? Try adding a third choice, "Neither" (remember, you can look in OpenScript Help for information on the request command). What's the difference between ask and request?anual).
Using the request command
Fated: fate
sectionNumber
To get and to set handlers
User-defined properties are commonly used to store values. By defining a to get and a to set handler for an object, however, you can create a user-defined property that is much more powerful.
The following exercise shows how to define a size property for an object such that setting the object's size will cause its bounds to change..
ndle=
startSection
sectionNumber
To get and to set handlers
Creating a self-sorting field
sectionNumber
To create a self-sorting field, write a handler in the field's script to handle a user-defined message, such as sortLines. Then, to sort the lines of the field from the Command window, type:
send sortLines to field <fieldname>
where <fieldname> stands for the name of the field.
1. Create a field.
2. Write a sortLines handler for the field that sorts the field's lines.
Remember the terms my and self can be used to refer to the object containing a script. If you want to see one solution, switch to Reader level and click the "Hint" button....Hint button......l and click on the Hint button.....................
Creating a self-sorting field
-- Show
the hint.
"Hint"
buttonUp
buttonUp
-- Handler to sort a field. The handler must be
-- located in the field's script and is activated by
-- sending a sortLines message to the field. This
-- handler uses a Bubble sort algorithm.
to handle sortLines
get my text
set N to textLineCount(it)
clear my text
step i from N to 2 by -1
step k from 1 to i-1
if textLine i of it < textLine k of it as text
set temp to textLine i of it
set textLine i of it to textLine k of it
set textLine k of it to temp
end if
end step
end step
set my text to it
enddd
Working with Objects from the Co
Adding Menus and Menu Items
Creating a Self-Sorting Field
The ToolBook Difference
Types of Expressions
A user-defined function for chec
OpenScript commands
Verifying data during input with
A Self-Sorting Field
Navigation
Listing All Objects on a Page
Moving a Draw Object
Using the debugger to interrupt
Using the debugger to interrupt
Push and pop
sectionNumber
startSection
Push and pop
Lists are a powerful feature of ToolBook. The push and pop commands allow you add items to and remove items from a list. Pushing an item places the item at the beginning of the list. Popping an item removes it from the beginning. Try clicking the two "Show" buttons for a demonstration.a demonstration.
Items
Three
Seven
Show Push
-- When
clicked,
the "
" arrow (
one pointing
Ftake
Mlist"
. Then,
. If there are no lines
, display a message
that effect.
"pushArrow"
"popArrow"
"Items"
. Try popping
"List"
buttonUp
buttonUp
pushArrow
popArrow
Items
No items to push. Try popping items first.
items
items
Show Push
Show Pop
-- Show the "
" arrow (
one pointing
2list"
removes
places
). If there are no
, display a message
that effect.
"pushArrow"
"popArrow"
"List"
. Try pushing
"Items"
buttonUp
buttonUp
pushArrow
popArrow
No items to pop. Try pushing items first.
Items
Show Pop
pushArrow
List:
Item:
popArrow
Navigating in this Book
Advanced topics
Popping items from a List
Handling Key Strokes
Expressions
Moving a draw object using the s
Handling keystrokes
Navigating in this book
Navigating in this book
On explanation pages you can
click on the arrow buttons to turn
pages. Click the Table of
Contents button to return to the
table of contents.
Text on this page explains a topic.cg a topic
Title
Explanation Page
Table of Contents
Table of Contents
8370,5460
7764,5464
startSection
sectionNumber
The Command window
sectionNumber
startSection
The Command windowWindow
Although OpenScript is used most often in writing scripts, it can also be used directly in the Command window to do things that would be difficult or impossible with a menu command or with a mouse.ld be difficult or impossible with a menu. following pages contain exercises using OpenScript and the Command Window...uld be difficult or impossible through a menu. The following pages contain exercises using OpenScript and the Command Window.
:PHYSSIZE
User-defined properties
sectionNumber
startSection
User-defined properties
In addition to an object's built-in properties, you can create your own properties. The following exercise shows an example of creating a user-defined property to store the original bounds of an object so the object can be restored to its original size after its size has been changed.been changed.
User-defined messages
sectionNumber
startSection
User-defined messages
Through the use of custom menus, message handlers, and the send command, you can define your own messages and handlers.
The following exercise shows a simple example of creating a user-defined message and handler. For an example of defining your own menus, see the section on menus.
Menus
ontrol
sectionNumber
startSection
Menuslllllll
You can use OpenScript to customize ToolBook's pull-down menus. You can add or remove menus and menu items as well as change the way ToolBook responds to existing menu items...o existing menu items.
Message Demo
-- When entering
the speed
ark
-- switch
level.
4s_mLSpeed
-- Move
\message hierarchy animations. The
$, "What",
Ualong which
travels.
-- This handler assumes
-- finished moving
displays
large
-- splatting spark, "Bing".
moveLSpark what
"bing"
- height
z" / 2
ackground
enterbackground
moveLSpark
enterbackground
reader
s_mLSpeed
moveLSpark
height
spark
height
spark
spark
spark
spark
spark
s_mLSpeed
Table of Contents
-- Return
the Table
Contents.
buttonUp
buttonUp
Table of Contents
Table of Contents
-- If
moved,
a user-defined property, home,
-- the
graphic covering
-- When
Bmouse
pressed,
released,
w. Finally,
-- Move
-- depending on
parameter, x, which can be
H15,15
buttonDown
moved
buttonUp
press
moved
buttonDown
press
buttonUp
press
previous
press
7755,5480
Right
-- If
moved,
a user-defined property, home,
-- the
graphic covering
-- When
Bmouse
pressed,
released,
w. Finally,
-- Moves
sets
-- depending on
parameter, x, which can be
H15,15
buttonDown
moved
buttonUp
press
moved
buttonDown
press
buttonUp
press
press
8370,5475
ToolBook
Systemmm
Background
MouseButton
Page Leader
Title
Paths
Show Example
-- When the mouse
pressed, turn
-- graphics on
0screen
B"mouseButton"
"Arrow"
released,
showMe message
animated demo
0,75.3125,0
buttonDown
buttonUp
buttonDown
mouseButton
0,0,0
Arrow
0,0,0
buttonUp
showMe
mouseButton
Arrow
0,100,0
Show Example
Looping control structures
Listing objects continued
Messages
Messages
sectionNumber
startSection
Messages Messageslers, Cont.
A user's actions cause
messages to be sent. Each
message has a name. For
example, clicking an object with
the mouse causes two messages
to be sent to the object:
buttonDown and buttonUp.
Button Message Example
-- Animate the two
Bmessages
example.
doMouse
B"mouseClick"
"downMessage"
Move
6435, 2647
6390, 2557
6300, 2467
6210, 2332
6120, 2212
6045, 2122
5910, 1942
5745, 1852
5565, 1687
5430, 1597
"upMessage"
6435, 2647
6390, 2557
6300, 2467
6210, 2332
6120, 2212
6045, 2122
5910, 1942
5745, 1852
5565, 1687
5430, 1597
doMouse
doMouse
mouseClick
downMessage
button
mouseClick
upMessage
button
matte
button
inverse
false
arrow
mouseClick
inverse
upMessage
buttonUp
downMessage
buttonDown
Show Example
-- Send a doMouse message
the grouped
example,"
animate
"Button Message Example"
buttonUp
buttonUp
FdoMouse
Button Message Example
Show Example
arning ToolBook
System
enScript Exercises
s Rmn
`D|D|
-- a
renumbering a
n > 0
enterBook
renumber
enterBook
sizeToPage
renumber
:REPORTDATA
:CONDITIONDATA
Text of RecordField "Instructions" is "null" As Text
Text of RecordField "Instructions" is null
OpenScript Workbook
System
y`D|D|
`D|D|
]D|D|
gD|D|
\D|D|
`D|D|
`D|D|
`D|D|
`D|D|
`D|D|
`D|D|
rminal
`D|D|
`D|D|
`D|D|
fault
9_D|D|
pageNumber is 103 or pageNumber is 104
pageNumber is 103 or pageNumber is 104
pageNumber is 103 or pageNumber is 104
pageobjs
`D|D|
:PRINTLAYOUT
`D|D|
`D|D|
u`D|D|
3^D|D|
\D|D|
\D|D|
\D|D|
Title
Instructions
"QuikTour"
"OSWorkBk"
"~pUnable
Quick
enterBook
previous
author
leaveBook
enterBook
reader
sizeToPage
s_launchedFrom
author
o MmenuPop
previous
o MmenuPop
leaveBook
QuikTour
OSWorkBk
QuikTour.v
~pUnable to return to the Quick Tour.
launchedFrom
s_launchedFrom
exercise
Instructions
Title
To turn the page, press Ctrl+Right Arrow.............................................
-- Make sure ToolBook
)Author level
)the beginning
each exercise.
enterPage
enterPage
Author
author
Control structures
Control structures
OpenScript contains several control structures for both branching and looping within a script. The following pages show some examples of the branching and looping control structures. These are followed by exercises.es.
startSection
sectionNumber
User-defined messages 1
sectionNumber
In this exercise, the button, "Send message," sends a user-defined message to the rectangle. The rectangle has a handler that responds to the message.
1. Type the following two commands in the Command window, pressing Enter after each command:
set script of rectangle "rec" to text of field "script1"
set script of button "send" to text of field "script2"
This copies the scripts into the two objects
2. Switch to Reader level and click the "Send Message" button.
3. Create another user-defined message called "changeColor" that causes the rectangle to turn red then back to white.ar.
User-defined messagess
Send message
script1
to handle hideAndShow
hide self
pause 2 seconds
show self
y fillcolor to white
end blush
script2
to handle buttonUp
send hideAndShow to rectangle "rec"
endUpp
Script11
Script22
ect so t
Drawing objects from a script
sectionNumber
In this exercise you will write a script to draw a rectangle.
1. Edit the script of the button, "Draw Square".
2. Look at the draw command in OpenScript Help.
3. Create a buttonUp handler to draw a rectangle from 6000,900 to 7500,2400.
For a hint, switch to Reader level and click the "Hint" button.
4. Switch to Reader level and try the button.
5. Try drawing an ellipse or polygon.
Drawing objects from a script
Draw Square
Draw Square
to handle buttonUp
draw rectangle from 6000,900 to \
7500,2400
set the fillcolor of the selection to blue
end buttonUpppppppppppppppp
-- Show
the hint.
"Hint"
buttonUp
buttonUp
A simple object browser using ri
sectionNumber
In this exercise you will write a handler that displays information on an object when it is clicked with the right mouse button. To prepare, look at the rightButtonClick message and the objectFromPoint function in OpenScript Help.
1. Write a handler for the page that uses the request command to display an object's ID, name and parent when the object is clicked with the right mouse button.
For a hint, switch to Reader level and click the "Hint" button.
2. Test your script by switching to Reader level and clicking objects on the page with the right mouse button.
Why doesn't clicking background objects work? Try modifying the handler to edit the script of an object when it is clicked with right mouse button.ked with right mouse button.ht mouse button. mouse button..button.
A simple object browser using rightButtonClick
blank hint
to handle rightButtonUp loc, isShift, isCtrl
get objectFromPoint(loc)
if it is not null
clear objInfo
put "Object:" & TAB & it & CRLF after objInfo
put "Name:" & TAB & name of it & CRLF \
after objInfo
put "Parent:" & TAB & parent of it & CRLF \
after objInfo
request objInfo
end rightButtonUpppppppppppppppppppppppt onto x
end
end buttonUpp
-- Show
the hint.
"Hint"
buttonUp
buttonUp
Red Ellipse
Slice of Blueberry
Click Me
-- Move the
B50 steps
S. Each
units (1/1440
inch). When finished,
-starting
which was saved
-- "home" user-defined property.
H-30, 0
buttonUp
buttonUp
Click Me
Square
Moving a draw object
sectionNumber
In this exercise you will write a script to move
the red dot around the screen.
1. Edit the script of the button "Fun With Dot" and create a buttonUp handler to move the dot to the following points:
8000, 100
8000, 4000
6300, 2050
4600, 4000
4600, 100
Use any order you want. For one solution, switch to Reader level and click the "Hint" button.......
Moving a draw object
funbutton
Fun With Dot
to handle buttonUp
move ellipse "dot" to 8000,100
move ellipse "dot" to 8000,4000
move ellipse "dot" to 6300, 2050
move ellipse "dot" to 4600,4000
move ellipse "dot" to 4600,100
end buttonUppttonUppppppppppppnUp
-- Show
the hint.
"Hint"
buttonUp
buttonUp
Changing an object's color prope
sectionNumber
In this exercise there are three ellipses: "scoop", on top of the cone; "Vanilla", on top of the vanilla tub and "Chocolate", on top of the chocolate tub. The script displayed in the white field shows how the color of the scoop ellipse (its fillColor property) can be set to the fillColor of "Chocolate" or "Vanilla".
1. Look at the script. Which lines change the fillColor property of the ellipse, "scoop"?
This is the script of the button labeled "Chocolate or Vanilla?"
2. Switch to Reader level and click the button.
Try again with the other flavor...the other flavor..r..avor..n the button.
Try it again with the other flavor..hen switch back to Author level.
Changing an object's color properties
scoop
vanilla
chocolate
Flavor
-- Use the
a choice
flavor
-- user,
."scoop"
accordingly.
"What
@would you like?"
"Chocolate"
"Vanilla"
buttonUp
buttonUp
What flavor would you like?
Chocolate
Vanilla
Chocolate
scoop
Chocolate
scoop
Vanilla
Chocolate or Vanilla?
Script1
to handle buttonUp
request "What flavor would you like?" with \
"Chocolate" or "Vanilla"
if It is Chocolate
set the fillcolor of ellipse "scoop" to the \
fillcolor of ellipse "Chocolate"
else
set the fillcolor of ellipse "scoop" to the \
fillcolor of ellipse "Vanilla"
end if
end buttonUpttonUptonUpttonUptonUpttonUppppppp
Moving a draw object using the s
sectionNumber
The step control structure can be used for animation. In this exercise it is used for moving the red dot around the screen.
1. Edit the script of the button, "Fun with Dot".
2. Create a buttonUp handler to move the dot to the bottom of the screen and back.
The starting position is 7750, 100 and the ending position is 7750, 5000. One way to write this handler is to use the step control structure and the move command. For information on these, see OpenScript Help. To see one solution, switch to Reader level and click the "Hint" button.
3. How could you move the dot in a square around the screen?en? screen??
Moving a draw object using the step control structure
to handle buttonUp
move ellipse "dot" to 7750, 100
step yPos from 100 to 5000 by 100
move ellipse "dot" to 7750, yPos
end step
step yPos from 5000 to 100 by -100
move ellipse "dot" to 7750, yPos
end step
end buttonUp 0,var2
end step
step var3 from 300 to 1 by -10
move ellipse "dot" by var3,0
end step
end buttonUpW
-- Show
the hint.
"Hint"
buttonUp
buttonUp
Fun with Dot
A buttonUp handler higher in the
One way to handle clicking an object is to
place a handler in the object's script. With
lots of similar objects, this can mean lots
of similar handlers. Using the target property, you can write a single handler on the page that handles clicking all of the similar page objects.
1. Edit the page script and enter the script you see to the right.
2. Switch to Reader level and click one of the states in the map.
The buttonDown message is first sent to the state you click, a draw object. The object is recorded in the target property. The message is passed on to the group ("map"), then to the page. The page has a handler for the message that puts the name of the target (the state you clicked) into the "State Name" field.
sectionNumber
A buttonUp handler higher in the hierarchyyy
State Name
Washington
Montana
Oregon
California
Nevada
Idaho
Wyoming
Arizona
New Mexico
Colorado
Texas
Oklahoma
Kansas
Nebraska
South Dakota
North Dakota
Minnesota
Missouri
Arkansas
Louisiana
Wisconsin
Illinois
Kentucky
Indiana
Tennessee
Mississippi
Alabama
Georgia
Florida
North Carolina
South Carolina
Michigan
Pennsylvania
West Virginia
Virginia
Maryland
Delaware
New York
New Jersey
Vermont
New Hampshire
Maine
Massachusetts
Connecticut
Rhode Island
Alaska
Hawaii
Hawaii
Hawaii
Hawaii
Hawaii
script1
to handle buttonDown
set text of field "State Name" to name of target
end buttonDown
to handle buttonUp
set the text of field "State Name" to null
end buttonUpppppppppp
A user-defined function for sort
sectionNumber
Although lists are a powerful feature in ToolBook, there are no built-in functions for sorting lists. In this exercise, you will write a function to sort a list of text items. The following is one method for sorting a list:
While the original list still has items in it,
Find the largest item in the list
Push that item onto the sorted list
Clear that item from the original list
1. Edit the script of this page and write a handler that sorts a list. Call the function "sortList" and give it one parameter, the list to be sorted.
Click the "Hint" button for one solution.
2. Test the function by clicking the "Sort Test" button.
" button.
e options menu when the debugger is displayed.......
A user-defined function for sorting a listto a dateage
This exercise shows the effect of the different "fx" commands when changing pages. There are three scripts. Clicking on each one at Reader level will install it in the "Effect" button.
1. Switch to Reader level.
Most messages aren't sent at Author level.
2. Click one of the scripts.
This puts the script in the "Effect" button.
3. Click the "Effect" button.
4. Try it with the other scripts.
5. Make up an effect script of your own.
ript2, switch to Reader level and click the button.
5. Switch back to Author level and use the Command window to set the script of the button to the text of samplescript3, then switch to Reader level and click the button.
FxZoom, fxDissolve and fxWipe
Landscape
Effect
Effect
script3
to handle buttonUp
fxDissolve slow to next page
end buttonUputtonUp#
script2
to handle buttonUp
fxZoom to next page at sysmouseposition
end buttonUpppppppppp
script1
to handle buttonUp
fxWipe left to gray
fxWipe right to next page
end buttonUpd buttonUpd buttonUp
buttonUp
buttonUp
fx destination
-- When entering the
, switch
Reader level.
enterPage
enterPage
Reader
sectionNumber
You made it!
Click the "Go Back" button to return to the previous page.