Syntax and Semantics of the Packager Scripting Language

Contents
cla140
Contents
A script for use by the Packager for Windows comprises instructions in a Packager-specific scripting language. In general, these scripts are evaluated on a line-by-line basis.
The features of the Packager scripting language are as follows:
Comments and Blank Lines
Lines that begin with a # character, are comments and ignored when the script is evaluated. To improve legilibility, blank lines can be inserted in the script, if needed. Blank lines are also ignored during script evaluation.
Keywords
Every script line begins with a keyword that is used to describe a command.
The following table lists the supported commands (keywords):
Keyword
Function
if
else
elseif
endif
Flow control
exit
Termination
setpos
insert
append
delete
modify
File editing
 
Parameter Evaluation
Parameters are introduced by a dollar sign. If dollar sign ($), is required in the text, you must use two $ signs in succession.
The name of the parameter follows the dollar sign in round brackets. The parameter name can be a predefined name (for example, $(ERROR)) or a freely defined name.
Before a command is executed, the parameter names contained in the command are replaced by the corresponding values. If the name does not exist in the list of variables, it is replaced with a blank string. Parameter substitution is also carried out within strings enclosed in quotation marks.
Flow Control
Editing a script can be controlled by inserting an if command with the result that some lines are only edited under special circumstances.
Conditions that may be queried include content, existence, or modification of a parameter.
The condition is formulated following the if or elseif keyword. The following table lists the possible queries:
Query
The query is true if
exist Par1
the parameter Par1 exists
equal Par1 Par2
parameters Par1 and Par2 match
greater Par1 Par2
parameter Par1 is larger than parameter Par2
Par1 == Par2
parameters Par1 and Par2 match
Par1 > Par2
parameter Par1 is larger than parameter Par2
Par1 < Par2
parameter Par2 is larger than parameter Par1
not
condition
the condition is not fulfilled
Any strings (constants) or real parameters can be used for Par1 and Par2. Uppercase and lowercase are not differentiated when comparing Par1 and Par2. A larger than or smaller than comparison is possible with numeric values; nonnumeric values are interpreted as zero.
The commands used for flow control and their syntax are as follows:
  • if
    condition
    The subsequent lines of the script are executed only, if the condition is fulfilled. The if commands can be nested. Every if command must be followed by an endif command later in the script.
  • else
    The subsequent lines of the script are executed only, if all of the conditions of the associated if and elseif conditions are not fulfilled. No text must follow the else keyword.
  • elseif
    condition
    The subsequent lines of the script are executed only, if the condition is fulfilled and the conditions of all preceding if and elseif conditions were not fulfilled.
  • endif
    Terminates conditional editing. No text must follow the endif keyword.
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.
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"
    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.
    The replace command is reserved for future enhancements. In the current implementation, the replace command is rejected with an error message.
Ending Script Editing
The command used to terminate editing and its syntax is as follows:
  • exit
    Terminates editing of the script at this point. No text must follow the exit keyword.