Monday, January 24, 2011

How to Create and Run a Script

Overview

Sometimes you'll find instructions in a HowTo that tell you to create a script and run it -- so it's important to know how to do that, even if you don't plan on writing your own scripts.

This isn't an introduction to scripting, but a practical guide to running a script when a HowTo calls for it.

Quick Script Window

For one-line scripts, the Quick Script window is convenient.

To open it, type ctrl-; (cmd-; on Macintosh).

quickScript.gif:

In the text area, type a script, then click the Run button. In the space below the text area appears the result.

Here's an example which counts the number of Manila sites installed on your server.

quickScriptExample1.gif:

The result is 4 in the above example -- the number will most likely be different on your machine.

Longer scripts

If the script to run is more than one line, it's easier to create a new script window. Type ctrl-N (cmd-N on Macintosh) to open a new untitled script window.

untitledScriptWindow.gif:

Tip: often you can copy and paste a script from your browser into the window.

Here's an example multi-line script:

untitledExample1.gif:

Note the indentation -- if you're copying a script from a HowTo, the indentation that appears in the Web page should be followed in the script. Usually, doing a copy-and-paste will do the right thing. You can indent and un-indent using Tab and shift-Tab. You can also use the mouse -- click on a wedge and drag it.

To run a script in a script window, click the Run button. If the script has anything to tell you, it will often present it in a dialog box. (As the above example does.)

Most of the time, any script that a HowTo tells you to run is something you need to do only once. So, once you've created it and run it, you can close the window without saving changes.

But you can of course save the script on disk. You might want to create a folder in your Frontier folder named My Scripts and save scripts there. Then, if you later want to open the script again in Frontier, you can use Frontier's Open command, or double-click on it in the Macintosh Finder or Windows Explorer.

See Also

If you're interested in writing Frontier scripts, see Writing Frontier Scripts in the Frontier Users Guide.

No comments:

Post a Comment