sense talk
TRANSCRIPT
-
8/10/2019 Sense Talk
1/44
SenseTalkLanguage Features
Overview
The following list provides a very brief overview of some of the moresignicant features of the SenseTalk scripting language provided inHyperSense:
Very nglish!like language" making scripts unusually easy forprogrammers and non!programmers alike to read" write" andunderstand #see e$ample scripts below%&
Highly modular" ob'ect! and message!based language&
ach ob'ect in a HyperSense document #including the (ocumentitself% can be assigned its own script&
ach ob'ects) script can include one or more message handlersfor
-
8/10/2019 Sense Talk
2/44
responding to specic messages&
vent!driven: *essages are sent automatically when certainevents occur" such as when a user clicks a mouse button" or opensa document&
*essage!passing hierarchy: + message which is not handled by theob'ect which receives it may be handled by an enclosing ob'ect&This arrangement allows scripts at an outer level #such as a(ocument script% to provide common functionality for allcontained ob'ects" while enabling specic ob'ects to override thatbehavior when desired&
Similar to HyperTalk" making it very easy for Hyper,ard users tomake the transition to HyperSense& Hyper,ard Stacks can evenbe imported and modied to take advantage of HyperSense)s
superior environment&
$ample SenseTalk Scripts
-
8/10/2019 Sense Talk
3/44
The e$ample scripts presented here are intended to convey thegeneral -avor of the SenseTalk language& .o attempt is made todescribe the commands used in detail& /or the most part they areself!e$planatory" or their meaning can be guessed at from the briefe$planation preceding each script& ,omments within scripts arepreceded by a double dash #!!%&
These e$amples are all complete" working scripts& However" they donot even begin to illustrate the range of possible applications of thelanguage& /or additional e$amples of the types of things that arepossible in SenseTalk" see the sample documents which are included
with the HyperSense package&00000000000000000000000000000000000000000000
Script of a button that displays the ne$t page in a stack when it isclicked #a 1mouse2p1 message is sent to an ob'ect that is clicked onwith the mouse%:
on mouseUp -- (when the mouse button is released over the button)
go to the next page
end mouseUp -- (the end of the handler for the mouseUp message)
-
8/10/2019 Sense Talk
4/44
00000000000000000000000000000000000000000000
Script of a button that sorts all of the pages in a stack into ascendingorder based on the last word in the te$t of the 1.ame1 eld on eachpage:
on mouseUp
sort pages by the last word of field "Name"
end mouseUp
00000000000000000000000000000000000000000000
Script of a eld which redisplays its contents in a long date formatwhenever it is edited #a 1close/ield1 message is sent to a eldwhenever a user has changed the te$t in the eld%:
on closeField
convert me to long date
end closeField
00000000000000000000000000000000000000000000
-
8/10/2019 Sense Talk
5/44
Script of a eld which checks that the contents of the eld are a datewhenever the eld is edited& 3f the new contents are not a validdate" the script beeps and reselects the te$t of the eld:
on closeField
if me is not a date then
beep
select the text of me
end if
end closeField00000000000000000000000000000000000000000000
Script of a page which does some initiali4ation each time a usernavigates to that page :
on openPage
-- hide our overlays, leaving only the skeleton showing
hide layer "Organs"
hide layer "Muscle"
hide layer "Skin"
-
8/10/2019 Sense Talk
6/44
-- enable and disable the appropriate buttons
disable button "Reveal Skeleton"
enable button "Show Organs"
enable button "Show Muscle"
enable button "Show Skin"
end openPage
00000000000000000000000000000000000000000000
Script of a button that calculates the total of the amounts entered inthe 1.et (ue1 eld on each page of a stack" when the shift key is not
being pressed& 3f the shift key is held down while the button isclicked" it calculates the average instead of the total& 3n either case"the result of the calculation is presented in a small modal panel onthe screen&
This somewhat contrived e$ample shows the use of multiplemessage handlers within a single script" and also shows how ahandler can send a message to e$ecute another handler :
on mouseUp
-
8/10/2019 Sense Talk
7/44
if the shiftKey is not down then
calculateTotal -- send a "calculateTotal" message
else -- (the shiftKey IS down, so calculate the average)
calculateAverage
end if
end mouseUp
-- the next handler is activated by the "calculateTotal" message:
on calculateTotal
put zero into total -- start our sum at zero
-- now, step through all of the pages in our stack...
repeat with n = 1 to the number of pages
add field "Net Due" of page n to total
end repeat -- (marks the end of the repeated commands)
-- finally, display the result:
answer "The total due is " & total
-
8/10/2019 Sense Talk
8/44
end calculateTotal
on calculateAverage -- handle the "calculateAverage" message
put zero into total
repeat with n=1 to the number of pages
add field "Net Due" of page n to total
end repeat
divide total by the number of pages
answer "The average amount due is " & total
end calculateAverage
00000000000000000000000000000000000000000000
lements of the 5anguageThe list below presents most of the predened elements ofSenseTalk& This list is presented to provide an at!a!glance overviewof the range of capabilities inherent in the language& 3t is notintended as a working reference&
-
8/10/2019 Sense Talk
9/44
ST6rowser&ti7 8
The language elements listed here are presented in more depth"including brief descriptions and code templates" in the SenseTalk6rowser panel within HyperSense& /or further reference it is
suggested you browse there" as well as in the on!line manual&
System Messages
System *essages are the messages which are sent automatically byHyperSense to various ob'ects to notify them of events which haveoccurred& Handlers for these event messages form the starting pointfor all SenseTalk scripts&
sent to All ElementsfirstMouseDown
mouseDown
mouseStillDown
mouseDragged
mouseUp
-
8/10/2019 Sense Talk
10/44
mouseRelease
mouseEnter
mouseWithin
mouseLeave
contextHelp
newElement
deleteElement
sent to Buttons
newButton
deleteButton
sent to Fields
newField
deleteField
enterInField
returnInField
openField
closeField
exitField
tabKey
keyDown
sent to Sliders
-
8/10/2019 Sense Talk
11/44
newSlider
deleteSlider
mouseDragged
mouseUp
valueChanged
sent to Browsers
newBrowser
deleteBrowser
mouseUp
mouseDoubleClick
sent to Graphics
newGraphic
deleteGraphic
sent to StackViewers
newStackViewer
deleteStackViewer
stackViewerWillOpen
stackViewerWillClose
sent to Layers
newSharedLayer
deleteSharedLayer
-
8/10/2019 Sense Talk
12/44
newUniqueLayer
deleteUniqueLayer
newWindowFrameLayer
deleteWindowFrameLayer
openSharedLayer
closeSharedLayer
openUniqueLayer
closeUniqueLayer
openWindowFrameLayer
closeWindowFrameLayer
hideLayer
showLayer
sent to a Page
openPage
closePage
newPage
deletePage
sent to Current Page
startUp
idle
returnKey
-
8/10/2019 Sense Talk
13/44
enterKey
tabKey
arrowKey
keyDown
modifierKeysChanged
doMenu
newStack
deleteStack
openStack
closeStack
help
contextHelp
scriptHelp
senseTalkHelp
systemHelp
becomeCurrentStack
resignCurrentStack
showAlignmentPanel
showLinker
showTools
showDocTools
-
8/10/2019 Sense Talk
14/44
sent to Stacks
openStackInDocument
closeStackInDocument
sent to Documents
documentWillOpen
openDocument
closeDocument
openDocumentAsResource
closeDocumentAsResource
sent to WindowFrames
newWindowFrame
deleteWindowFrame
openWindowFrame
closeWindowFrame
openWindow
becomeMainWindow
resignMainWindowsent to Any object
notifyOnPort
timer
-
8/10/2019 Sense Talk
15/44
Keywords
9eywords provide the basic framework of message handlers within ascript& 9eywords and ,onstants are the only SenseTalk words whichare 1reserved1 and may not be used as variable names&
on...end
function...end
global
pass
returndo
send
[ ] (send a "function" message to a specific object)
if...then
if...then...elserepeat n times...end
repeat with...end
repeat until...end
repeat while...end
-
8/10/2019 Sense Talk
16/44
next repeat
exit repeat
exit handlerName
exit to HyperSense
Commands
,ommands are the action words of the SenseTalk language& This listpresents the commands which are built into HyperSense itself"arranged in functional groups& ou can also create your own
commands" written either in SenseTalk or in Ob'ective , #throughHyperSense)s dynamically!loaded ;*odule capability%&
Sending Messages
message
send[ ]
Arithmetic
add
subtract
-
8/10/2019 Sense Talk
17/44
multiply
divide
User Interaction
answer
answer from list
answer multiple from list
ask
beep
play
put
Navigation
go
go to document
go back
go forth
pop page
pushhelp
find
find in field
open application
-
8/10/2019 Sense Talk
18/44
open file with application
Data
get
put
delete text
pop page into container
convert
convert expression
convertLoc
convertLoc from
Action
add layer to page
create document
create minimal document
create page
create page in stack
create unique layercreate shared layer
create element
create element in layer
delete text
-
8/10/2019 Sense Talk
19/44
delete object
delete variable
doShell (execute Unix shell commands)
doShell into container
hide object
lock screen
print page
print page to device
remove
reorder
reorder layer
reorder to position
select text of a field
select part of a field
select position in a field
select position within a field
show objectshow element at location
sort items of a container
sort lines of a container
sort pages of a stack
-
8/10/2019 Sense Talk
20/44
unlock screen
File Input & Output
answer file
answer file (with panel title)
answer directory
ask file
ask file (with panel title)
close file
close all
open file
open file for a purpose
read for length
read at location for length
read until char
read until end
read at location until char
seekseek relative
write
write at location
Serial Port Input & Output
-
8/10/2019 Sense Talk
21/44
open port
close port
read from port for max
read from port until char
write to port
Events & Simulation
arrowKey
choose
choose tool
click at
click multiple at point
click in context
doMenu
drag
drag in context
edit script
enterInFieldenterKey
hide panel
keyDown
returnInField
-
8/10/2019 Sense Talk
22/44
returnKey
select element
select layer
show panel
scriptHelp
senseTalkHelp
systemHelp
tabKey
type
wait
wait until
wait while
Menu
create menu
put into menu
put after menuItem
delete menudelete menu item
disable
enable
reset menus
-
8/10/2019 Sense Talk
23/44
Timer
start timer
stop timer
Functions
/unctions return values stored or calculated by the system& This listpresents the functions which are built into HyperSense" arranged infunctional groups& ou can also create your own functions" writteneither in SenseTalk or in Ob'ective , #through HyperSense)s
dynamically!loaded ;*odule capability%&
Arithmetic
abs
annuity
atanaverage
compound
cos
exp
-
8/10/2019 Sense Talk
24/44
exp1
exp2
ln
ln1
log2
max
min
random
round
round to multiple
sin
sqrttan
trunc
String
charToNum
lengthnumToChar
offset
offset beyond position
Date & Time
-
8/10/2019 Sense Talk
25/44
date
localToGMOffset
seconds
ticks
time
Object
backList
forthList
menus
number
pushList
selectedElementsstacks
Event-related
alternateKey
clickChunk
clickHclickLine
clickLoc
clickLoc in context
clickText
-
8/10/2019 Sense Talk
26/44
clickV
commandKey
controlKey
foundChunk
foundField
foundLine
foundText
mouse
mouseClick
mouseH
mouseLoc
mouseLoc in contextmouseV
optionKey
selectedChunk
selectedField
selectedLineselectedText
shiftKey
sound
target
-
8/10/2019 Sense Talk
27/44
tool
Miscellaneous
openDocumentList
openFileList
param
paramCount
params
result
screenRect
value
Operators
Operators compute the result of some operation on one or twooperands& The operators available in SenseTalk are listed here&
+ (addition)
- (subtraction)
* (multiplication)
/ (division)
-
8/10/2019 Sense Talk
28/44
^ (exponentiation)
div (integer division)
mod (modulo)
= (test for equality)
(test for inequality)
< (test for less than)
> (test for greater than)
= (test for greater than or equal to)
is (test for equality)
is not (test for inequality)
and (logical and)or (logical or)
not (logical not)
& (string concatenation)
&& (string concatenation)
is in (test for substring presence)contains(test for substring presence)
is not in (test for substring absence)
( ) (operator grouping)
is within (test whether a point is within a rectangle)
-
8/10/2019 Sense Talk
29/44
is not within (test whether a point is not within a rectangle)
is a (test whether object or data is of a certain type)
is not a (test whether object or data is not of a certain type)
there is a (test for existence of an object or file)
there is not a (test for existence of an object or file)
there is no (test for existence of an object or file)
Chunk Expressions
,hunk $pressions make it easy to work with the lines" items
#separated by commas or other specied delimiter%" words" andindividual characters within a piece of te$t&
line chunk
line
ordinal lineline range
item chunk
item
ordinal item
-
8/10/2019 Sense Talk
30/44
item range
word chunk
word
ordinal word
word range
character chunk
character
ordinal character
character range
Sources of Value
Sources of value are the basic building blocks of e$pressions& 3naddition to properties of ob'ects #listed later% and functions #listedearlier%" SenseTalk recogni4es these sources of values&
Literals
Numbers
Quoted Strings
Unquoted Strings
-
8/10/2019 Sense Talk
31/44
Constants
empty
return
tab
quote
space
comma
colon
formfeed
linefeed
pi
zeroone
two
three
four
fivesix
seven
eight
nine
-
8/10/2019 Sense Talk
32/44
ten
up
down
true
false
Containers
local variablesglobal variables
owned variables
fields
the selection
chunks
Properties
very ob'ect in a HyperSense document has various properties whichcan be accessed or changed from within a script& 3n addition" thereare a number of
-
8/10/2019 Sense Talk
33/44
add your own custom properties of ob'ects in the form of 1owned
variables1 which contain data that is stored permanently with eachob'ect&
Global
numberFormat
colorFormatcursor
dragSpeed
editShared
editBkgnd
hideHandlesidleDelay
itemDelimiter
lockMessages
multiSelect
blindTyping
version
long version
showMessages
hideIdle
-
8/10/2019 Sense Talk
34/44
hideUnused
All Objects
name
long name
short name
abbreviated name
idlong id
short id
abbreviated id
local id
variableListWindowFrame
allowClones
autoHide
canBeClosed
canMiniaturizecanResize
resizable
floating
fullSize
-
8/10/2019 Sense Talk
35/44
isPanel
rememberLocation
showName
maxSize
minSize
maxWidth
minWidthmaxHeight
minHeight
miniatureIcon
grid
showGridgridColor
gridSize
gridX
gridY
gridIsSquaregridOnTop
StackViewer
borderStyle
scrollStyle
-
8/10/2019 Sense Talk
36/44
assignedStack
assignedPage
Stack
newPagesAtEnd
rememberOpenPage
sameSizePages
standardPageSizeshowFoundFields
protoPage
useProtoPage
grid
showGridgridColor
gridSize
gridX
gridY
gridIsSquaregridOnTop
Page
dontSearch
marked
-
8/10/2019 Sense Talk
37/44
paperColor
top
bottom
left
right
topLeft
topRightbottomLeft
bottomRight
location
rectangle
widthheight
size
Layers and Elements
dontPrint
autosizing (WindowFrame Elements only)hidden
ignoreMouseAlways
ignoreMouseWhenHidden
visible
-
8/10/2019 Sense Talk
38/44
top
bottom
left
right
topLeft
topRight
bottomLeftbottomRight
location
rectangle
width
heightsize
Tool Elements
isTool
toolType
Graphicscolor
lineColor
textColor
bgColor
-
8/10/2019 Sense Talk
39/44
fillColor
filled
framed
lineArrow
lineCap
lineDash
lineJoinlineSize
lineWidth
startPoint (Line Graphics)
endPoint (Line Graphics)
startAngle (Ovals)endAngle (Ovals)
closed (Polygons & Freehands)
points (Polygons & Freehands)
ImageElement
imagescrollX
scrollY
scaleX
scaleY
-
8/10/2019 Sense Talk
40/44
autoScale
borderStyle
bgColor
color
sharedImage
Field
returnAdvanceautoTab
tabAdvance
dontSearch
dontWrap
editableselectable
lockText
monofont
rtf
scrollable (horizontally)scroll
sharedText
style
textAlign
-
8/10/2019 Sense Talk
41/44
textFont
textHeighttextSize
wideMargins
Button
state
highlighttoggleState
sharedState
showPress
borderStyle
showNamestyle
title
altTitle
pressesBy
changesByradioMode
icon
altIcon
iconPosition
-
8/10/2019 Sense Talk
42/44
textAlign
textFonttextSize
Browser
allowEmptySelect
allowMultiSelect
multiBranchSelectcontents
enabled
maxColumns
minColumnWidth
pathSeparatorselectedPath
selectedPathData
selectedItems
separateColumns
showNametitle
titled
horizontalButtons
horizontalScroller
-
8/10/2019 Sense Talk
43/44
verticalButtons
verticalScrollersSlider
currentValue
minValue
maxValue
stepValuealternateStep
knobSize
enabled
reversed
sharedValueshowName
title
Document
userModeOnly
readOnlyMenu
enabled
name
MenuItem
-
8/10/2019 Sense Talk
44/44
commandChar
enabledmenuMessage
name
subMenu
Serial Port
baudRatedevice
notify
notifyCount
notifyTarget
paritystatus
Timer
period
target
status