Scripting a FieldMake a new field, and type these scripts in it
You can select the lines below and copy and paste them straight into your field
Type the script below into the field script and make sure that the field is locked.
Now try it out. The key to this setup is these lines in the field script
put word 2 of the clickLine into lino lino is a variable (a temporary container in this case)
the clickLine is a function peculiar to fields. It returns the line number and the field name containing the text in a field last clicked on by the user.
do is a keyword that carries out a HyperTalk statement
select the clickLine does the highlighting when the text is clicked on.
Fields that do things when you click on the individual lines are often used in HyperCard for such things as indexes. For instance if you put all the card names of a stack in such a field they can be used to take the user to each card as they select its name from the index field.
Make a button under the field and type this script into it
When it is clicked the do keyword runs through the contents of the field statement by statement. The statements have to be separated by a return i.e they must be on separate lines. The statements can be in any container, a field , or a variable and they act just like script would that was made up of the same lines or statements.
More about AnswerThe statement on line 8 of the field is an example of using Answer with three choices. When the user selects one of the buttons the message passed to hyperCard can then be made use of. Make a button and type this script into it.
Notice that the last choice is a button with double line around it. This is the default button that is activated if the user presses the return key.
In this lesson some of the statements uses HyperCard's play command. This command plays prerecorded sounds as musical notes at varying tempos, pitches and lengths. HyperCard includs harpsichord, boing and flute as already installed sound resources.
Return to Index for more about sound and music |