- page 5 of book "MAMMALS.TBK""""""""""""""""""""""""
Examples of unique names
- button ID 5
- background ID 0
- book "c:\books\newmath.tbk"round ID 0
- book "c:\books\newmath.tbk"
Examples of names you assign
- field "helphint"
- group "red car"
- page "Alaska"
ced exercise"
Examples of objects in other books
- page "Cats" of books "PETS.TBK"
- background "Exercise" of book \
"C:\BOOKS\MATHBOOK.TBK"
- group "Telephone" of page \
"Office Equipment" of book \
"D:\OFFICE\PLANS\FACILITIES.TBK"""""""""""""
Object references - useful terms
* Use this with page, background, or
book to refer to the current page,
background or book
* Use my and self to refer to the
object whose script is currently
executing
More useful terms in references
* Use target to refer to the object
that initially receives a message
(as opposed to the one whose script
is executing)
* Use selection to refer to the currently
selected object or objects
Still more useful terms
* Use focus to refer to the object that
receives keyboard messages
* Use parent to refer to the object
next higher in the object hierarchy
* Use objects to refer to the objects
next lower in the object hierarchy
Referring to record fields
* To refer to a record field as an object,
specify the background:
- recordField "data" of this background
* to refer to the text of a record field,
specify the page:
- text of recordField "data" of this page
"Special terms"
* "Special terms" is a loose category
for OpenScript terms that are not
commands, messages, properties,
functions, constants, or operators
* Where and how you use a special
term depends on context
Common special terms - a few examples
* Ordinals: first through tenth
* Relationals: first, last, middle, next,
previous
* Prepositions: of, by, after, before,
* Articles (optional): a, an, the o f,
by, the, after, before, into
Mouse and pointer messages
mouseEnter rightButtonDown
mouseLeave rightButtonUp
buttonDown rightButtonDoubleClick
buttonStillDown
buttonUp
buttonDoubleClick
Parameters: location, isShift, isCtrlShift, and isCtrl
Control structures - special-purpose
start spooler
statements
end spooler
linkDLL dllname
return type declarations
end linkDLL
Commands
* Commands are the verbs of
OpenScript
* Almost every statement starts with
a command
* Most commands have parameterste
the object to be acted upon or
provides more detail
Notes on command syntax
* Capitalization is not required
* Use \ to break up long statements
* Use ; to continue short statements
* Use -- to start a comment
Types of commands
* Data and object manipulation
* Navigation
* Script control
* Variable declaration
* User interface control
* Menu control
* File manipulation and printing
* DDE, DLL, and data exchangeeeeeee
Data and object commands
draw, move, align
select, select all, extend select, unselect
show, hide
set, get, put
push, pop
clear
increment, decrement
format
return, sort, seed
"So, where should I put a handler?""
* If a handler defines behavior unique
to an object, put the handler in that
object's script
* If a handler defines more general
behavior, put the handler in the
script of an object higher in the
hierarchy
Variables
Containers
Variables
Properties
Command Window
Declaring and using
variables
Parameters
Parameters
Expressions
Special Terms
Object References
Messages
A closer look at command parameters
Containers
Containers
Variables
Properties
Command Window
Referring to data
in containersto
arameters
Parameterssameters
* A command's parameters provide
more detail for the command's action
* Command parameters can be:
- Expressions
- Special terms
- Object references
- Messages
ssages
F l
Command Window
Properties
Variables
Control Structures
Parameters
Script
Handlers
Statements
Commands
Expressions
Special Terms
Object References
Messages
Value References
Functions
Operators
String Specifiers
Literals
Constants
Containers
Parts
parts
buttonUp
buttonUp
parts
Parts
Script
Control Structures
Script
Handlers
Statements
Commands
Parameters
Building scripts
Expressions - in detail
* An expression in OpenScript can
consist of:
- A simple reference to a value
- A function with its parameters
- Values combined with operators
- A reference to part of a string
* More details latere covered in more
detail later specifiers
Literals
Literals - literally
* A number
* A string
* If the string contains spaces or
special characters, enclose it in
quotes
Constants
Constants
black CR null
blue CRLF pi
cyan formfeed quote
green LF space
magenta
white
yellow
Expressions - brieflysss
* An expression describes a value,
character, or string in OpenScript
* An expression can be:
- Arithmetic (yields a value)
- Logical (yields true or false)
- String (yields a character string))gggggggggggggggggg
Still more eventss
* Making the window active
* Receiving a DDE request from
another application
* Pressing F1 for help
* Toggling the status box
Where other messages get sent
* Keyboard messages are sent to the
current page at Reader level
* Messages sent with the send
command go to the object specified
* All other messages are sent to the
current page
Then what?
* If the object's script has a handler for
the message, the handler runs
* If not, the message "floats" up the
object hierarchy
* If it reaches the top (ToolBook, or
"the system") default behavior results
Default behavior for messages
* For menu commands, default
behavior is to carry out the command
* For other messages, default behavior
is to do nothing
* You can write handlers to intercept
and block default behavior for
menu command messagesssssssss
Messages: built-in or user-defined
* All the messages mentioned so far
are "built-in" to ToolBook
* You can define your own messages:
- Write a handler for the message
- Send the message with the
send commanddd
The object hierarchy
* All objects have a place in the
object hierarchy
* An object's position in the hierarchy
affects how it receives messages
Object IDs and names
* An object ID is assigned to every
object (except a book) when it is
created
* If you cut and paste an object, the
pasted object gets a new ID
* An object's ID is stored in its
idNumber propertyy
Object types
book angledLine polygon
page arc rectangle
background curve roundedRectangle
field ellipse
recordField irregularPolygon
button line
hotword paintObject
group pie
polygon
rectangle
Managing message traffic
* You can handle a message where it
enters the hierarchy or let it "float up"
* You can handle a message and
forward it for more processing
* You can send a message directly
to an object t anywhere in the hierarchy
Control structuresof processing
* Control structures are common
to most programming languages
* You use control structures to
alter the order in which statements
are processed
* OpenScript has five common and
two special control structuresres
How scripts are executed
* A script consists of one or more
handlers
* Handlers are executed as needed,
so they can be in any order
* Statements within a handler are
executed in order unless you use a
control structure to alter processinggprocessinger of
processing
Compared to C, Basic, and Pascal
OpenScript C Basic Pascal
If/then/else If/else If/then If/then/else
Step/by For For/next For/do
While While While/do
Do/until Do/while Repeal/until
Conditions/when Switch/case Case/of
Control structures - if/then/else
if expression
statements
else
statements
end if
Control structures - conditions/
conditions
when expression1
statements
when expression2
statements
when expressionN
statements
else
statements
end conditions
conditions
when expression1
statements
when expression2
statements
when expressionN
statements
else
statements
end conditions
Control structures - do/until, while
statements
until expression
while expression
statements
end while
Control structures - step/by
step var from start to finish by steps
statements
end step
Introduction to OpenScript
:PRINTLAYOUT
`D|D|
`D|D|
`D|D|
`D|D|
`D|D|
`D|D|
`D|D|
`D|D|
enterBook
enterBook
sizeToPage
System
"arrow"
Select IrregularPolygon "
Move the
6097, 4690
B"hotword2"
6097, 4105
/record
B"button2"
B"graphic2"
6127, 3535
B"group2"
5167, 2950
3877, 2545
3862, 2020
3862, 1540
4books"
3922, 1060
B"windows dlls"
3892, 565
B"System"
1897, 7000
B"hotword1"
1897, 4690
B"button1"
B"graphic1"
1882, 3535
B"group1"
1867, 3070
3937, 2500
3922, 2020
3922, 1480
3922, 1090
B"Windows DLLs"
3907, 565
leavepage
enterpage
keychar
buttonUp
enterpage
leavepage
keychar
buttonUp
arrow
arrow
hotword2
field/record field
button2
graphic2
group2
background
system books
windows dlls
System
background
system books
windows dlls
system
hotword2
field/record field
button2
graphic2
group2
hotword1
field
button1
graphic1
group1
background
system books
Windows DLLs
System
arrow
selectall
Background
Background
System books
System books
Windows DLLs
Windows DLLs
System
The system (ToolBook)
Field
Field
Group1
Group
Hotword1
Hotword
Button1
Button
Graphic1
label
Graphic
Graphic
Field/Record field
Field/Record field
Button2
Button
Graphic2
label
Graphic
Graphic
Group2
Group
Hotword2
Hotword
arrow
Object referencessssssssssssss
* An object reference starts with the
object type
* The object type is followed by the
object's name or ID
* Depending on context, you may need
to supply information about the
object's location
Parts
parts
buttonUp
buttonUp
parts
Parts
Scripts
* A script is a property of an object
* Any object can have a script
* Scripts are compiled automatically
without explicit compiling or linkingggatically
without explicit compiling or linking
Handlers
* A handler carries out a specific task
* There are three kinds of handlers:
- message handlers
- to set handlers
- to get handlerssslerss
Parts
parts
buttonUp
buttonUp
parts
Parts
Getting Acquainted
with OpenScript
disclaimer
IMPORTANT: These ToolBook files and Dynamic Link Library files are being made available free of charge exclusively for demonstration purposes to show some approaches programmers are taking for applications using ToolBook. The files have not undergone the rigorous review process which Asymetrix's commercial products undergo. Asymetrix does not intend to provide support for these files. Asymetrix specifically disclaims all warranties including without limitation all warranties of title or non-infringement, warranties of merchantability or fitness for a particular purpose and all other warranties express or implied. The files are made available "as is."
ASYMETRIX SHALL NOT BE LIABLE FOR ANY DAMAGES INCLUDING BUT NOT LIMITED TO DIRECT, INDIRECT, INCIDENTAL, SPECIAL, COVER, RELIANCE, OR CONSEQUENTIAL DAMAGES ARISING FROM ITS MAKING THE FILES AVAILABLE, OR THE USE OR INABILITY TO USE THE FILES. ANY USE OF FILES IS STRICTLY AT YOUR OWN RISK.
Copyright (c) 1990 by Asymetrix Corporation. All rights reserved. Asymetrix, ToolBook, and OpenScript are registered trademarks of Asymetrix Corporation.
Message handlers
* A message handler runs in response
to a message
* Syntax:
to handle messagename
statements
end messagenameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee