Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
HyperTalk
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Messages and events=== HyperTalk used an object-oriented concept for calling scripts, with objects in the stack sending "events" as ''messages'' that would be processed by ''handlers'' that declared their interest in receiving the events using the <code>on</code> syntax. For instance, most GUI containers would send the <code>mouseDown</code> message when the mouse button was clicked down, and then a <code>mouseUp</code> message when it was released while still on top of that container, and a script could capture these events like this: <syntaxhighlight lang="applescript"> on mouseUp -- place additional code here end mouseUp </syntaxhighlight> Messages for events were first sent to the script in the object that created the event, for instance, if the user clicked on a button the <code>mouseUp</code> message was first sent to that button. If the button's script object did not have a <code>mouseUp</code> handler (or no script at all), it was then passed to the card, the background, the stack, any stacks whose scripts had been explicitly imported using the <code>start using</code> command, the "home stack" (a user-selected always-open HyperCard stack), and finally to the HyperCard application itself. For many simple events like mouse clicks on buttons the script would be placed directly within the object in question, the button itself. For instance, one might use the example code above within a button handler in this fashion: <syntaxhighlight lang="applescript"> on mouseUp repeat with i = 1 to the number of card fields hide field i end repeat end mouseUp </syntaxhighlight> In the case where code was being called from multiple locations, or it was being used as a global handler for an event, the script could determine the original sender of the event using the <code>target</code> function. Likewise, scripts could send events to other containers using the <code>send</code> command and then using the navigational code to refer to the container holding that handler's code: <syntaxhighlight lang="applescript"> send "mouseUp" to card button "OK" of card "Veracity" </syntaxhighlight> Combining HyperTalk's string processing with the <code>do</code> command allowed for the construction of interactive interpreters by placing a text field on a card and then placing this code in the field's script: <syntaxhighlight lang="applescript" highlight="4"> on mouseUp select the clickLine put word 2 of the clickLine into linenum do line linenum of cd fld 1 end mouseUp </syntaxhighlight> <code>clickLine</code> is a global property that returns the name and line number of the last field clicked, in a form like {{code|2=applescript|1=line 10 of card field 4}}. This code first selects all of the text on the clicked line, then extracts the line number into a local variable, then uses <code>do</code> to run the text as a HyperCard script. The <code>mouseDown</code> message was sent to a button when the user clicked it, and <code>mouseUp</code> was sent when the user released the mouse inside it to trigger its action. Similarly, HyperCard sent periodic <code>idle</code> message, <code>mouseEnter</code>, <code>mouseLeave</code>, ... and various other messages related to navigation between different cards in a HyperCard stack, as well as user input (<code>keyDown</code>, <code>functionKey</code>, ...), and system events. As far as the scripters were concerned, there were no main event loops like in other procedural programming languages.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
HyperTalk
(section)
Add topic