<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=US-ASCII">
<meta name="author" content="mailto:webmaster@zap.tartarus.org">
<meta name="description" content="Zap is a configurable programmers' editor for Acorn RISC OS">
<title>Advanced use</title>
</head>
<body background='/img/background.png' text="#000000" bgcolor="#DCDCDC" link="#20209F" vlink="#008000" alink="#FF2020">
<p align='center'><a href="Chapter8">Previous</a> | <a href="Contents">Contents</a> | <a href="IndexPage">Index</a> | <a href="Chapter10">Next</a></p>

<ul>
<li><a href="#C9">Chapter 9: Advanced use</a>
<ul>
<li><a href="#S9.1">9.1 Setting and using marks</a></li>
<li><a href="#S9.2">9.2 Working with read only files</a></li>
<li><a href="#S9.3">9.3 Zap's help system</a></li>
<li><a href="#S9.4">9.4 Zap's command language</a>
<ul>
<li><a href="#S9.4.1">9.4.1 Command syntax</a></li>
</ul></li>
<li><a href="#S9.5">9.5 Learning and playing back actions</a></li>
<li><a href="#S9.6">9.6 The universal argument: repeating actions</a></li>
<li><a href="#S9.7">9.7 Object Linking and Embedding, and External Edit</a></li>
</ul></li>
</ul>
<h1><a name="C9"></a>Chapter 9: Advanced use</h1>
<p>
Here we look at a final set of advanced functions, before moving on to modes. These features are all 'convenience' features, rather than being important things that you can't do without.
</p>
<h2><a name="S9.1"></a>9.1 Setting and using <a name="i0"></a>marks</h2>
<p>
Often it is useful to be able to remember where you are in a file at a specific time, so that you can return to it later. Zap allows you to do this by using <em>marks</em>, which are controlled from the <code>Misc-&gt;Marking</code> menu or from keystrokes.
</p>
<p>
To toggle a mark - set if there isn't one there, clear if there is - use <code>TOGGLEMARK</code>, on <code>sF11</code>. To set a mark, use <code>DROPMARK</code> (<code>F6</code>). To move to the next mark, use <code>NEXTMARK</code> (<code>sF9</code>), and to move to the previous mark, use <code>LASTMARK</code> (<code>sF6</code>). For instance, if you set a mark, then move and set another one, <code>sF6</code> will move you back to the second mark, <code>sF6</code> again to the first, and then <code>sF9</code> back to the second mark again.
</p>
<p>
Marks can't be seen when they are set; they can be set to any depth.
</p>
<h2><a name="S9.2"></a>9.2 Working with <a name="i1"></a>read only files</h2>
<p>
Zap has two types of read only files: firstly there are permanent read only files. These tend to be internal documentation files. You can't set these to be writable.
</p>
<p>
Secondly, there are temporary read only files; you can set these up yourself by the <code>File-&gt;Read only</code> menu option - the same option turns off the read only aspect again. This means that you can temporarily write-protect a file to stop yourself from doing anything stupid to it. Zap also loads any file that it won't be able to save changes to as temporary read only.
</p>
<p>
If you try to edit a read only file, Zap beeps at you and prints a warning in the minibuffer.
</p>
<h2><a name="S9.3"></a>9.3 Zap's <a name="i2"></a>help system</h2>
<p>
Zap can provide help on the current mode you are using, as well as any keystroke, command or function. Pressing <code>c\</code> brings up a small menu in the <a name="i3"></a>minibuffer. You can press:
</p>
<ul><li>
<code>K</code> - Keystroke help - press the keystroke you want help on.
</li>
<li>
<code>M</code> - Help on the current mode (see <a href="Chapter10#C10">chapter 10</a>).
</li>
<li>
<code>F</code> - Function help - type the function name (see <a href="Chapter11#S11.3">section 11.3</a>).
</li>
<li>
<code>C</code> - Command help - type the command name (see <a href="#S9.4">section 9.4</a>).
</li>
<li>
<code>V</code> - Variable help - type the variable name (see <a href="Chapter12#S12.3.6">section 12.3.6</a>).
</li>
<li>
<code>D</code> - Documentation (opens the documentation directory for the current country).
</li>
<li>
<code>Z</code> - Help on Zap (opens the manual for the current country).
</li>
</ul>
<p>
To get help on a keystroke in anything other than the base keymap, first change into that keymap, and then run the <code>HELP</code> command (either through the minibuffer, or through whatever it's bound to in that keymap).
</p>
<p>
Zap can also display help on its menus and dialogues in Acorn's <a name="i4"></a><em>Help</em>; it also displays help for the relevant mode if the cursor is over an editing window.
</p>
<p>
Note that the <a name="i5"></a><em>ZapText</em> extension also gives Zap the ability to look up help on whatever is at the cursor using <a name="i6"></a><em>StrongHelp</em>. To do this, press <code>cH</code> (you'll need both ZapText and StrongHelp installed to do this - <a name="i7"></a><em>StrongHelp</em> is available from <a href="http://sudden.recoil.org/stronghelp/">http://sudden.recoil.org/stronghelp/</a>).
</p>
<h2><a name="S9.4"></a>9.4 Zap's command language</h2>
<p>
Pressing <code>cEscape</code> brings up the <a name="i8"></a>minibuffer and allows you to enter commands directly into Zap. This is very useful, because Zap has lots of commands (and you can get extensions to provide additional ones), and there simply aren't enough keystrokes or menu items to go round.
</p>
<p>
If you don't know how to use a command, you can type <code>c\ c</code> (help on commands) and then type in the command name for a brief description.
</p>
<h3><a name="S9.4.1"></a>9.4.1 Command syntax</h3>
<p>
Commands can take a parameter; there are four different types. If you request help on a command, the parameter type will be shown as:
</p>
<ul><li>
<code>WIBBLE</code> - Command Wibble takes no parameter.
</li>
<li>
<code>WIBBLE &lt;byte&gt;</code> - Command Wibble takes a single byte.
</li>
<li>
<code>WIBBLE &lt;word&gt;</code> - Command Wibble takes a word (4 bytes).
</li>
<li>
<code>WIBBLE &lt;string&gt;</code> - Command Wibble takes a string argument.
</li>
</ul>
<p>
Byte and word parameters must be preceded by an <code>&amp;</code> if in hex, and may be surrounded by brackets or quotes; string parameters must be either in double quotes <code>"</code> or in brackets <code>(</code> and <code>)</code>. Within a double-quoted string, double quotes themselves can be included by doubling them up (eg: <code>INSERT "Suddenly, Jonathon said ""Hey""."</code>). For byte and word parameters, <code>'x'</code> is evaluated to the ASCII value of the character x (eg: <code>CHAR 'n'</code> inserts the letter <code>n</code>).
</p>
<p>
An error is given if the parameter you place after the command does not match the type of the command, except that if you omit a string parameter, the minibuffer will be opened for you to type the string into. (This is exactly what happens when you press <code>cEscape</code>, in fact - <code>cEscape</code> executes the command <code>COMMAND</code> without any parameters, allowing you to specify your own command.)
</p>
<p>
Commands can be chained together by using colon as a separator <code>:</code> as in BASIC. You <em>cannot</em> chain together commands which use the minibuffer (ie: commands which take a string as a parameter but with the string unspecified).
</p>
<p>
You can put a comment after a command by using <code>;</code> (eg: <code>COMMAND ; comment</code>). The comment terminates at the first <code>:</code> (so you can put comments between commands when you chain multiple commands together).
</p>
<p>
This section has provided only a basic introduction to using simple commands. See <a href="Chapter11#C11">chapter 11</a> for a complete description of Zap's command language, including functions, variables, and conditional and looping constructs.
</p>
<h2><a name="S9.5"></a>9.5 <a name="i9"></a>Learning and playing back actions</h2>
<p>
This feature of Zap is very simple to use, and very useful. To start 'learning' a key sequence, simply press <code>cL</code>. Type the sequence you wish to learn and then press <code>cL</code> again. Press <code>F1</code> to execute the learnt sequence. (<code>EXECUTE</code>, bound to <code>F1</code>, also stops the learning process.)
</p>
<p>
Note firstly that Zap will beep after every keypress you make to remind you that it is being stored. Secondly note that the <code>Escape</code> key will <em>not</em> stop the learning process. Only <code>cL</code> will stop it. Thus you can learn sequences which use incremental search, or keyboard selection of regions; both these actions involve the <code>Escape</code> key.
</p>
<p>
Once you have learnt a sequence, you may 'bind' that sequence to a key so that pressing that key in future causes the same series of actions to take place. To do this press <code>cF8</code> and then press the key you want to bind the sequence to (or <code>Escape</code> if it was a mistake - <code>Escape</code> won't be bound).
</p>
<p>
Examples:
</p>
<ul><li>
Suppose you wanted to insert a tab at the beginning of a group of lines. One way would be to use the indent option (see <a href="Chapter4#S4.4.1">section 4.4.1</a>); another would be to learn the sequence <code>TAB,DOWN,CLEFT</code> and then to press <code>F1</code> a number of times. As a slightly more sophisticated example of this, it is often useful to insert an extra tab before the last word on the line. You can do this by binding <code>TAB,UP,CRIGHT,SLEFT</code> and pressing <code>F1</code> repeatedly.
</li>
<li>
Suppose you wanted to go to the next match of <code>cat</code> and switch the case of the letters. You could learn and then execute the sequence <code>cS cat Return Escape Left Left Left scS scS scS</code> (<code>scS</code> swaps the case of the character at the cursor).
</li>
</ul>
<h2><a name="S9.6"></a>9.6 The <a name="i10"></a>universal argument: repeating actions</h2>
<p>
The universal argument feature enables you to execute a keypress an arbitrary number of times. Suppose for example you wanted to insert 100 spaces. The quick way to do this is to type <code>cU 100 Space</code>.
</p>
<p>
In general you type <code>cU</code> then the number of times you want the key to be executed, then press <code>Return</code>, then press the key to execute. The 'pressing <code>Return</code>' step can be omitted if the key you want to repeat is not delete or a digit or another valid key for editing the number you are typing (as in the example above).
</p>
<p>
Some commands (and therefore the keystrokes they are bound to) can't be sensibly executed more than once (for instance <code>OPENPARENT</code>, which opens the directory containing the current file); in these cases the universal argument simply won't affect the command or keystroke.
</p>
<h2><a name="S9.7"></a>9.7 <a name="i11"></a>Object Linking and Embedding, and <a name="i12"></a>External Edit</h2>
<p>
Zap supports both OLE and EE for editing files. These are used by a large number of other programs that wish to have data edited for them, but don't know how to do it themselves. External Edit is primarily used for editing text, and Zap will edit all Text files (&amp;FFF) for EE. Object Linking and Embedding allows non-textual files to be edited as well; Zap will claim both BASIC (&amp;FFB) and Text (&amp;FFF) files for OLE.
</p>
<p>
Note that these file types, as well as those that Zap claims for running from the Filer, can be configured - you need to edit <code>ZapUser:Config.!ZapBoot</code> and <code>ZapUser:Config.!ZapRun</code>.
</p>
<hr>
<p>
The next section in the manual is <a href="Chapter10#C10">chapter 10</a>, which explains Zap's different editing and displaying modes, and looks at some of the most useful ones. Modes form the key to many of Zap's most useful features, and since they've been occasionally mentioned in the manual up till now you probably want to learn more about them.
</p>
<p>
Alternatively, you could move on to <a href="Chapter11#C11">chapter 11</a>, which explains in more detail Zap's command language, including a look a functions, variables, and conditional and looping constructs.
</p>

<hr><address><a href='/copyright'>&copy; Copyright Zap Developers 1992-2004</a>. All Rights Reserved.
</address></body>
</html>
