Command Files

If you often need to give the same sequence of commands or type in the same text, there are two ways to do this without having to laboriously type in the same items over and over again;

A command file is simply a list of commands. It is stored on disc and you call it up when you want to carry out the commands. A simple example is as follows:

Give the Record Command File command:

Menu Command Ctrl-sequence Key
Files Record Command File FY

When the dialogue box appears, type in the name you want the command file to have. Click the OK button or press Enter.

A tick will appear on the left of the Record command file option on the Caret menu to show that you are recording a command file. A command file will be opened with the name you have typed in.

PipeDream will create the file in the directory from which the current document was loaded. If the current file does not have a directory, PipeDream will create the file in <Choices$Write>.PipeDream.CmdFiles.

Now use the keyboard keys to move down a line. Many mouse movements cannot be recorded in a command file so you should use the keyboard to move around. Type your name into the slot and then press Enter.

Give the Record Command File command again. The tick to the left of the Record command file option will disappear to show that you are no longer recording a command file. The commands that you gave and the text will be saved into the file.

To run the command file, drag its icon into the PipeDream window upon which you want it to operate.

Alternatively, give the Do Command File command:

Menu Command Ctrl-sequence Key
Files Do Command File FZ

You should see PipeDream the caret move down a line, enter your name and then move down another line. It is exactly as if you had entered the commands and the formulae at the keyboard.

If you wish, you can make the command file run by assigning it to a function key.

Give the Define Function Key command:

Menu Command Ctrl-sequence Key
Caret Define function key CDF

Set the Function key to define option to Shift-Ctrl F2.

In the Definition field, type

\FZ|i"name of command file"|m

and click the OK button or press Enter.

When you press Shift-Ctrl-F2, the command file will be called up and the sequence of commands you typed into it will be carried out in the current window.

To run the command file in another file's window, drag the command file's icon into the window.

To load the command file into a window to examine it or edit it, drag the file's icon to the PipeDream icon on the icon bar.

Both for defining function keys and making command files, PipeDream uses the Ctrl-key sequences to specify commands. Drag the command file's icon to the PipeDream icon to load it into a new window and examine it. You will see a number of commands, each on a separate line and you will see your name.

\ is used to introduce a command. The command itself is specified by using its sequence (FZ in the case of Do Command File).

|i is used to introduce a dialogue box parameter. If the parameter is a text string, it must be enclosed in double quotation marks.

|m is used to terminate the command. Anything on a line after the |m is treated as a comment. PipeDream automatically puts in the name of the command when it builds command files with the recorder.

Each command must be on a new line.

Most of the Ctrl-key sequences are specified on the sub-menus and you have probably learnt some of them already. Some only appear on long menus. The Ctrl-key sequences which do not appear on the sub-menus are all listed in the table of commands at the beginning of this Reference Guide. Many of these are caret movements. There are some extra commands which are particularly useful in command files. One is Ctrl-CCP which carries out the Pause command. This can be useful if you are using a command file to set up a demonstration. For example, \CCP |i 5 |m makes PipeDream pause in the command file for 5 seconds or until the user tells PipeDream to continue.

Another extra command is Ctrl-ESC which instructs PipeDream to replace the slot contents of a number slot with a new formula.

For example,

\ESC|i"A1+7"|m

means "replace the slot contents with the formula A1+7".

Other useful extra commands are Ctrl-FGF (Full Screen) and Ctrl-FGS (Save With No Box).

Command Files and Startup

A special command file called PipeDream:key can be created. When PipeDream starts up it automatically looks for PipeDream:key (NB see Paths for where this could be stored) and, if it is found, it is invoked as a command file. (This happens after the choices file PipeDream:Choices is loaded.) PipeDream:key is most useful when it contains a set of key definitions. You have seen that both function keys and other keys can be redefined to other commands. You can use these facilities to create a different command key layout. One example of this is the file !PipeDream.Resources.CmdFiles.PD3keys which contains definitions for redefining the function keys to the PipeDream 3 settings. If you copy this file to <Choices$Write>.PipeDream.key, for example, and restart PipeDream, it will use the PipeDream 3 function key settings (NB we do not recommend that you actually use this example file).

Alternatively, consider the following command file:

\CDK|i35|i"¢"|m
\CDF|i"F1"|i"\R|m"|m
\CDF|i"Shift F2"|i"\CGS |i|"C3|"|m"|m
\CDF|i"Ctrl F3"|i"\Q|m\Z|m"|m
\CDF|i"Ctrl-Shift F11"|i"\FH|m"|m

Note the different way in which the function keys are specified. It is always easiest to generate command files using the command Record Command File (Ctrl-FY) on the long Caret menu. If you need to know the syntax of command files precisely, use the command file recorder and then load the resulting file by dragging it to the PipeDream icon on the icon bar.

This command file uses the two commands Define Key and Define Function Key to redefine the # key, F1, Shift-F2, Ctrl-F3 and Shift-Ctrl-F11 respectively. The # key is redefined to produce the ¢ character. The other four commands each redefine a function key to give commands.

Note that we have on each of the last four lines a command describing a command. The command being invoked in each case is Define Function Key. Each parameter to the command is introduced by |i. If the parameter is a string it is enclosed within double quotation marks. Notice that inside the second parameter of the definition for Shift-F2 is a string which itself contains double quotation marks. To tell PipeDream that each of these characters is inside the parameter string they are preceded by a solidus |.

F1 is given the definition string \R|m which redefines it to Format Paragraph.

Shift-F2 is given the definition string \CGS|i"C3"|m which redefines it to the command Go to Slot with parameter C3.

Ctrl-F3 is given the definition string \Q|m\Z|m which redefines it to clear a marked block and then mark the current slot.

Finally Shift-Ctrl-F11 is given the definition string \FH|m which redefines it to give Help, now that F1 no longer does.

| Characters and Strings

Characters introduced with the | (solidus) indicate a special action. The actions are as follows:

|m  terminate the command

|i  introduce a parameter to the field

|"  include the " character.

||  include the | character

Note that spaces are allowed between parameters in a command but not before commands as they will be inserted into your window as spaces.

If you wish you can create a command file which redefines all of the 48 function keys (used by themselves and with Shift and Ctrl) and also the printable characters. In this way, you can create your own keyboard definitions. If you save your definitions in the command file PipeDream:key, PipeDream will automatically load them when it starts up, thereby redefining your keyboard.

For information on See
Redefining single keys or function keys Keyboard Definition