Previous Topic: Flow ControlNext Topic: Ending Script Editing


File Editing

The modification of configuration files generally refers to specific positions within the file. The area to be modified can be specified directly with the modification command or indirectly using the setpos command. Modification commands with local positioning do not influence the positioning set with a setpos command.

The positioning works similar to the way text is selected in Microsoft Word, that is, a specific range can be selected with a start and end point. In line-based files, the entire line (at most) can be selected.

If the start and end point of the selection are the same, only one position is selected and not a range. In this scenario, the insert, append, and modify functions have the same effect; the delete function still has no effect.

An example of selecting a range is given with the setpos command description below.

Note: Case sensitivity does not apply for ASCII characters in the range 0x40 to0x7f ("A" to "z"). Country-specific ASCII characters in the right-hand character table between 0x80 and 0xff (for example, umlauts) are in all probability case-sensitive.

You can use wildcards * and ? for positioning. They are interpreted in the same way as with the UNIX shell.

The commands used for file editing and their syntax are as follows:

setpos position

Selects a file area for further editing. Subsequent editing commands can modify the selected area, if they do not include local positioning. The position parameter is interpreted as a search string that is used to calculate the area in the file to be selected.

The following table lists the possible position parameters:

Position Parameter

Marked Area

block

A block of lines

noblock

All lines in a file

line

An individual line

text

A part of a line

next line

The next line

next text

The next part of a line

A block is identified by a start and an end line. When the block is edited, this means what is inside the block; in other words, text is inserted before the end of the line with an append command and after the start of a line with the insert command. A delete command deletes the lines within the block, although the start and end lines are not affected.

If a block or a line is selected, the insert and append commands insert new lines into the file. On the other hand, if part of an area was selected, even if it covers the entire line (text "*"), text is inserted or added within the line.

If the entire file contents are selected with the noblock parameter and this is followed by an insert command, text is inserted at the beginning of the file. If an append command is then issued, text is appended at the end of the file.

Example for selecting an area:

setpos block "rem Start printerconfiguration" "rem end printer*"
...
insert [position] value

The new value is inserted before the currently selected position. If no position is specified explicitly, the newly inserted area is selected following the command.

Example: insert "new text"

append [position] value

The new value can be inserted following the currently selected position. If no position is specified explicitly, the newly inserted area is selected following the command.

Example: append "appended text"

Note: The insertion of a blank line has the following effect:

append " "
modify [position] value

The selected area is replaced with the new value. If the area specified by the position parameter does not exist, no new value is inserted. If no position is specified explicitly, the newly inserted area is selected following the command. The modify command cannot be applied to fully selected blocks in text files.

delete [position]

The selected area is deleted from the file. The next line is selected following the command.

replace [position] value

Every occurrence of the area selected by the position parameter is replaced with the new value.

Note: The replace command is reserved for future enhancements. In the current implementation, the replace command is rejected with an error message.