Hardware Dev Center

Standard Variable Expressions

When you specify arguments in a command string, you can specify the argument value as an expression. This expression can perform operations using the current values of the standard variables. Each standard variable expression within a command string is delimited by braces ( {, } ).

A standard variable expression can consist of a combination of the following components:

A standard variable expression cannot contain embedded macro references.

The expression operators are included in the following table.

OperatorDefinitions

Val1+Val2

Addition.

Val1-Val2

Subtraction.

Val1/Val2

Division.

Val1*Val2

Multiplication.

Val1MODVal2

Modulus. Value is the remainder of dividing Val1 by Val2.

max ( Val1 , Val2 )

Maximum. Value is the maximum of Val1 and Val2.

max_repeat ( Val1 )

See the Using max_repeat section.

min ( Val1 , Val2 )

Minimum. Value is the minimum of Val1 and Val2.

( )

Precedence operators. If not used, C-language precedence is used.

 

Standard variable expressions do not modify the values assigned to the standard variables. The calculated value is placed in the escape sequence, using the format specified by the command string argument type specifier.

Using max_repeat

The use of max_repeat is best explained with an example. Suppose a GPD file contains the following entry:


*Command:CmdXMoveRelRight{*Cmd:"<1B>["%d[0,9600]{max_repeat((DestXRel/4))}"a"}

This command contains a single argument, of type %d. It also contains an argument range specification. Whenever Unidrv sends this command to the printer, it first calculates DestXRel/4 and determines if it is within the specified range. If the calculated value is greater than 9600, Unidrv sends the command repeatedly, with a maximum value of 9600, until the specified value has been sent. Thus if DestXRel/4 equals 20,000, Unidrv sends the following commands:


<1B>[9600
<1B>[9600
<1B>[800

The max_repeat operator can be used only if the following conditions are met:

  • A command string includes only a single argument.

  • The argument includes a range specification.

 

 

Send comments about this topic to Microsoft

Show:
© 2015 Microsoft