prestored.commands Article/Article

prestored.commands

Command prestored.commands Article/Article
Applicable release versions: AP
Category Article (24)
Description short tutorial on using Update processor prestored commands.

contributed by Terri Hale. Original article ran in PickWorld Magazine.

A "prestore command" defines a series of Update processor (UP) commands and embedded text which can be saved and recalled for later use. Once defined and saved, prestore commands can be used during the current update session or recalled and used in subsequent update sessions.

Prestore commands provide the user with a new programming language and are used to add, delete or modify items in files. Prestores can be performed on data files, against select lists, correspondence, documentation, programming and other text files.

Prestore commands may appear cryptic to anyone except the author of the commands. This is because there is a logic based on a step-by-step definition of each prestore which must be determined before the prestore is written.

There is one active prestore buffer available for each update session. This buffer can be re-used as many times as necessary. Prestore commands can be loaded into the buffer and modified using UP commands. The following table contains a list of UP edit commands.

<ctrl>+e Deletes text from the current cursor position to the end of the command.

<ctrl>+g Positions the cursor at the end of the current command.

<ctrl>+h Backs up the cursor one position and is equivalent to the backspace key on most terminals.

<ctrl>+i Moves the cursor to the next tab position.

<ctrl>+k Positions the cursor right one character.

<ctrl>+l Deletes one character from the current cursor position.

<ctrl>+m Terminates the prestore command.

<ctrl>+o Deletes a word beginning with the current cursor position.

<ctrl>+t Positions the cursor at the beginning of the prestore.

<ctrl>+u Moves the cursor forward one word.

<ctrl>+w Inserts a blank at the current cursor position.

<ctrl>+x Clears the command line.

<ctrl>+y Moves the cursor backward one word.

<ctrl>+zz Will undo the last delete or data change.

The default prestore buffer contains the command "zn", which advances the cursor to the next page. Note: the default buffer contents do not display when editing the prestore buffer.

There is no limit to the number of prestore commands that are available, because prestore commands are saved like all other items in the Pick System. Each prestore command is saved as an item in a file. The items remain in the file until they are deleted or overwritten. "md" is the default file used for saving pre store commands, but any legal file.reference may be used. The following table illustrates valid file.references:

"file.reference" refers to the data section of file dict filename refers to dictionary level of the file.

"dict.filename,data.filename" refers to an alternate data section of file.

"account.name,," refers to another md (account).

"account.name,filename," refers to the data section of a file in another account.

"account.name,dict,filename" refers to the dict section of a file in another account

Prestore commands may contain both UP commands and literal text. When literal text is included as part of the command, the text must be enclosed in single or double quote marks. When UP commands are designated in the prestore command, the UP commands are typed in WITHOUT depressing the control key. The Update processor will interpret anything in the command that is NOT in quote marks as a UP command. Figure B summarizes the UP commands used with to create, save, write and execute prestore commands.

UP COMMANDS ACTION

<ctrl>+zl Edit prestore command

<ctrl>+zw{(file.reference}item.id<ctrl>+m Saves prestore command

<ctrl>+zr{(file.reference}item.id<ctrl>+m Loads prestore command or <ctrl>+zr{(file.reference}item.id <ctrl>+p

<ctrl>+p Executes command in buffer.

<ctrl>+p Repeat prestore command.

Editing Prestore Commands

The <ctrl>+zl command is used to create or edit a prestore command in the prestore buffer. After typing in the command <ctrl>+zl, the Update processor displays the following prompt at the top left corner of the terminal screen:

:P

The prestore command is typed in immediately following this prompt. The command is terminated by either <enter> or <return> or <ctrl>+m. The UP command <ctrl>+p is used to execute the prestore command. The example below assumes that the Update processor is in overtype mode.

Example:

<ctrl>+zl command to define prestore
P: terminal prompt for command
r'inserting'r<return> actual prestore command

The prestore command above causes the following action:

<ctrl>+r = puts UP in insert mode
'inserting' = literal text
<ctrl>+r = puts UP in overtype mode

Saving Prestore Commands

The <ctrl>+zw command is used to write the contents of the prestore buffer to a file for later use. The command <ctrl>+zw causes the Update processor to prompt with:

Prestore id:

at the top left corner of the terminal screen. At this time an item-id may be specified or a file.reference and item-id may be specified. If only an item-id is entered, the prestore command will be saved in the current master dictionary (md). If the md already has an item with the specified item-id, the following prompt displays at the top left corner of the screen :

'prestore.id' item exists on file, press "y" to overwrite:

If any key other than "y" is typed, the prestore command is NOT saved. If "y" is typed, the md item that was on file is overwritten with the prestore command. If the response to the prompt for Prestore id is a file.reference and item-id, the command is written to the designated file with the specified item-id. The format of the saved item is :

attribute 1 = p
attribute 2 = prestore command

The following example shows a prestore command composed of only a literal string, with no UP commands. Since there is no file.reference specified in response to the Prestore id prompt, the command will be saved in the md.

u document document.id invoke UP to edit document
<ctrl>+zl command to define prestore
P: terminal prompt
'This is text'<return> actual prestore command
<ctrl>+zw command to save prestore
Prestore id: terminal prompt for item-id
id<return> user-defined item-id

The next example shows a prestore command consisting of UP commands and text. The command is saved in the file commands with the id of 'holdit'.

u document document.id invoke UP to edit document
<ctrl>+zl command to define prestore
P: terminal prompt
mmr'This is text'mr<return> actual prestore command
<ctrl>+zw command to save prestore
Prestore id: terminal prompt for item-id
(commands holdit<return> user-defined file and item-id

The command in the above example does the following :

mm issues two carriage returns
r puts UP in insert mode
'This is text' text
r puts UP in overtype mode

Commands 'holdit' now contains the following :

01 P
02 mmr'This is text'mr

Loading Prestore Commands into Prestore Buffer

The <ctrl>+zr command loads a previously saved prestore command into the prestore buffer and, optionally, executes the prestore command. After the <ctrl>+zr command has been entered, the following prompt appears at the top left corner of the screen:

Prestore id:

The response to this prompt can either be an item-id (if the prestore command is stored in the current master dictionary) or a file.reference and item-id (if the prestore command is stored in a file other than the current master dictionary.) The item-id is followed by either <return> or <ctrl>+p.

When the <ctrl>+zr command is followed by <ctrl>+m, the contents of the prestore command are loaded in the prestore buffer but the command is not executed. When the <ctrl>+zr command is followed by a <ctrl>+p, the command is executed.

Once the prestore buffer has been loaded, it can be executed any time during the current update session using <ctrl>+p.

The following example shows how to load the prestore buffer with a saved prestore command from the current master dictionary without executing the prestore command.

<ctrl>+zr command to load prestore buffer
Prestore id: terminal prompt for item-id
id<return> item-id from md

The next example shows how to load the prestore buffer with a saved prestore command from the file commands using the item-id of 'holdit'. The command is immediately executed using <ctrl>+p.

<ctrl>+zr command to load prestore buffer
Prestore id: terminal prompt for item-id
(commands,holdit<ctrl>+p file.reference,item.id, execute

Executing a Prestore Command

The <ctrl>+p UP command is used to execute the prestore command in the prestore buffer. The default command in the prestore buffer is <ctrl>+zn. Operating in default mode, the UP command <ctrl>+p advances the cursor to the next page. <ctrl>+zl or <ctrl>+zr can be used to change the contents of the prestore buffer.

Repeating Prestore Commands using Saved Lists

If the UP command "p" is the last command in a prestore command, the prestore command will be repeated. When a select list is in effect, the "p" command causes the entire prestore command to be repeated for each item in the list. The example below shows how to create a recursive prestore command which will be used to search and replace text from a list of items.

Example:

get-list documents retrieve previously saved list
u document invoke UP on document file
<ctrl>+zl command to define prestore
a'old'r'new'nxfp<return> actual prestore command
<ctrl>+p execute the prestore command

The prestore command used in the example above does the following:

Command:

a UP command to search
'old' text to search for
r UP command to replace
'new' text to replace with
n UP command to replace all occurrences
xf UP command to file an item
p UP command to repeat prestore command
Syntax
Options
Example
Purpose
Related