# Editing scripts

## Add comments to a script

In HyperTalk scripts, two hyphens (--) indicate a comment. HyperTalk ignores all commented lines when executing a script.

For example:

```
on mouseUp
   -- Displays a dialog box
   answer "What?" with "No" or "Yes"
   put it -- the user's reply
end mouseUp
```

* To comment several lines at once,        drag to select the lines you want to     comment, and then choose Comment     from the Script menu (or press Command-–).

* To “uncomment” several lines at     once, drag to select the lines you want     to uncomment, and then choose     Uncomment from the Script menu     (or press Command-=).

## Close a script window

There are several ways to close a script window. If you close a window in which you’ve made changes, HyperCard asks you if you want to save the changes before it closes the window.

**To close a script window:**

* Click the window’s close box.

* Choose Close from the Edit menu    (or press Command-W).

* Hold down Command-Option and click.

**To close a script window without saving your changes:**

Press Command-. (period).

**To close a script window and save your changes:**

Press Enter.

## Debug a script

HyperCard provides some useful tools for troubleshooting your scripts. These debugging tools let you step through a handler line by line as it runs, inspect the values of variables, and trace the flow of messages.

To debug a handler, follow these steps:

1. Open the script that contains the     message or function handler you     want to debug.

1. Click to place the insertion point     on the line with the on or function     statement that defines the handler.<br><br>Or, depending on where you want    to start, place the insertion point    on any statement of the handler    that is not a comment.

3. Choose Set Checkpoint from the     Script menu (or press Command-D) to set    a temporary checkpoint.<br><br>    A checkpoint tells HyperTalk where     you want to start watching the script     as it runs.

4. Press Enter to save the script and     close the script editor window.

5. Now, perform the action in     HyperCard that will run the script     (for example, click a button).

When HyperCard hits the checkpoint, it opens the script and puts a box around the current statement. HyperCard also displays the Debugger menu.

HyperCard does not enter the script editor itself: All of HyperCard’s normal menus remain in the menu bar. (Because the script is still running, HyperCard must preserve the current context.) *But only the Debugger menu is active.*

6.  Choose commands  from the Debugger       menu to proceed.<br><br>     Click a command for more      information about it.

## Move between open scripts

In HyperCard, you can have more than one script window open at once.

**To move between the windows that contain scripts:**

* Click to activate the script window   in which you want to work.

* Choose an open script window   from the Go menu.

**To move between all open windows (including windows that contain stacks):**

* Choose Next Window from   the Go menu (or press Command-L).

## Open a script window

Click any object in the list at the left to see how to open its script window.

You can have more than one script window open at a time, and you can leave the script window open while you work on your stack.

As you write handlers in a script window, place each HyperTalk statement on a single line.  Press Option-Return to break a statement across more than one line. Press Tab to reformat the script.

A button
A field
A card
A background
A stack

## Save a script

Once you have made changes to a script, you can save it in two ways:

* To save a script without closing its    script window, choose Save Script    from the File menu (or press Command-S).

* To save a script and close its script     window, press Enter.

When you close an unsaved script's window by any method other than pressing Enter, HyperCard asks if you want to save the changes.

## Set the font and size of a script

Text in the script windows appears in 9-point Monaco as the default.  You can change the default font and size of the text in your script window using two properties:

```
the scriptTextFont
the scriptTextSize
```

These two properties affect all script windows—you can’t set the font and style of each script window separately.

For example, to set the font and size of the script windows to 10-point Geneva, type the following messages into the Message box, and press Return:

```
set the scriptTextFont to "Geneva"
set the scriptTextSize to 10
```
