Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
HyperTalk
(section)
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!
===Referring to containers=== A key concept in HyperTalk was the way it referred to containers through a navigational system based on the visual hierarchy of the stack. Every container in the stack was given a unique ID number when created and could also be given an optional name. Scripts could refer to objects by using either of these identifiers, along with an object ''type'' specified using the <code>of</code> operator. This operator used a natural language syntax making for easily readable, [[self-documenting code]]. For instance, a script stored in a button on a card might wish to take user-supplied text gathered using a text field and store the text in a variable called ''theValue'': <syntaxhighlight lang="applescript"> put the value of card field "typehere" into theValue </syntaxhighlight> Various contextual aspects of statements could be inferred by the interpreter. In the statement above, for example, because the script would be running in the context of a button on a specific card, the identifier ''card'' was understood to refer to the card the user was interacting with, even though the button itself would normally be on the background. In addition, "''the value''" (the text submitted by the user) was assumed to be the main property and to be the target of operations if not otherwise specified. Likewise, "''card field''" was assumed to be the target of the command, as opposed to the background field, so that information could also be omitted. Even container types had short forms that programmers could use to save typing. Thus the code above is equivalent to the shorter form: <syntaxhighlight lang="applescript"> put fld "typehere" into theValue </syntaxhighlight> Objects within a given context—the card or background, for instance—were also given a runtime number based on their [[z-order]] on the screen. To assist in using their position for navigation, HyperTalk also included a variety of [[ordinal number|ordinal]] and [[cardinal number|cardinal]] referencing systems to simplify the syntax further. Assuming the field "typehere" is the only field on the card, the code above could also be written: <syntaxhighlight lang="applescript"> put the first card field into theValue </syntaxhighlight> or: <syntaxhighlight lang="applescript"> put card field 1 into theValue </syntaxhighlight> The choice of addressing style was left to the programmer; often different styles were used in different statements depending on the style of the surrounding code in order to make the code more readable. HyperTalk included the <code>me</code> container which acted in the same fashion as the <code>self</code> qualifier found in most [[Object-oriented programming|object-oriented languages]], allowing simple access to the current container object. Less common was the <code>it</code> variable, which held the value of the last operation for certain built-in operators. For example: <syntaxhighlight lang="applescript"> ask "What is the value?" put it into card field "display" </syntaxhighlight> This example uses the <code>ask</code> command to display a [[dialog box]] and capture the text typed into an accompanying text field; when the dialog is completed by hitting {{keypress|Return}} or clicking {{keypress|OK}}, the value is assigned to the <code>it</code> pseudo-variable. The second line then copies that value into a card field using the <code>put</code> assignment operator.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)