[Table of Contents]

Templates and Template Files

Using Templates

Templates describe to ALL how fields of an input record and optional literal text should be used to create a command or an output string. They also prescribe the formatting of the output.

A template may be a string specified on the command line as a parameter, or one or more lines supplied in a template file. Such template file can be as large as about 1 KB under DOS and more than 16 KB under Windows 32 bit systems. Thus you can easily fill in variables in longer texts as well.

Template files are especially useful on operating systems like DOS where command line length is somewhat limited. A drawback of template files is that variable parameters like %1 under DOS cannot easily be passed to the template. A suitable workaround in this situation is to use a batch editor to replace placeholders in the original template file with the actual run time values creating a new throwaway template file to be used by ALL.

Lines read from a template file are concatenated to form a single long template string for ALL to work with. Thus, a line end in the template file will not result in a line break in the output. Line breaks in the output can be achieved by using the ~n symbolic sequence or an ampersand (&). The difference between these two methods is explained later in this chapter. The maximum length of the template string that can be constructed is 1024 characters under DOS and 16.384 characters under Windows 32 bit systems.

Templates may contain

Fields and field names are described in more detail in the previous chapter. Symbolic sequences are listed below.

The following table lists all symbolic sequences known to ALL.

Symbolic Sequences
Sequence Function
~aSound the computers bell (a(larm)).
~bInsert a backspace character.
~d{nnn}Insert the character denominated by the 3-digit decimal character value following the ~d sequence. The sequence ~d124, for example, would output the vertical bar (|) used in piping. See also ~o and ~x.
~eInsert an escape (decimal 27, hex 1b) character. This character is often used for output to printers or the screen under DOS. It could also be inserted using the ~d, ~o, or ~x symbolic sequences.
~fInsert a form feed character.
~nInsert an end of line character. The character(s) inserted are the correct ones for the target operating system, e.g. for DOS a CRLF combination is inserted.
~o{nnn}Insert the character denominated by the 3-digit octal character value following the ~o sequence. The sequence ~o174, for example, would output the vertical bar (|) used in piping. Please note: to use octal notation in prefix or append files or strings please drop the 'o' character following the introducer character. There is no such difference for the ~d and ~x symbolic sequences. See also ~d and ~x.
~t{nn}Insert a tab character.
~x{nn}Insert the character denominated by the 2-digit hexadecimal character value following the ~x sequence. The sequence ~x7c, for example, would output the vertical bar (|) used in piping. See also ~d and ~o.

Note

When using a template file the exact syntax of your template string may vary because, unlike a template string, the contents of a template file are not processed by the operating system's command processor. For example, in template files there is no need to escape double apostrophes with a backslash (\).

The following example shows a template string and its template file version.

Template string:

all *.zip "md !fn!&cd !fn!&unzip -l !fs!&echo Unzipping !fn!&unzip !fs!&cd .."

The corresponding ALL command and template file would look like this:

Command:

all *.zip /Tunzip.tpl

Template file (unzip.tpl):

md !fn!&
cd !fn!&
unzip -l !fs!&
echo Unzipping !fn!&
unzip !fs!&
cd ..

[Table of Contents]