%d
Full Description
swirl
Syntax
  % format-modifier* d (counter-name)


Purpose

The "%d" format item causes the value of the specified counter item to be formatted in Arabic numerals. By default, the numbers are expressed in decimal (base 10) notation. If the value is negative, a minus sign is output before the number.

For example, the following output action will output the value of the counter "line-number" in Arabic numerals within a quoted string:

  output "The file contains %d(line-number) lines.%n"

The following format modifiers can be used with the "%d" option:

  • "number": This is the decimal point modifier. It consists only of a positive number with no identifying letter after it. The decimal point modifier inserts a decimal point in the string representation of the counter value. The number indicates how many digits must be placed to the right of the decimal point. This allows the counter values to simulate fixed-point numbers.
  • "s": The "s" modifier strips trailing zeros from the result of the decimal point modifier. If there are no non-zero digits after the decimal point in the resulting representation, the decimal point is also removed. The "s" modifier requires that the decimal point modifier be specified as well.
  • "number f": The "f" modifier is the field-width modifier. The "f" modifier requires a preceding positive number. If the specified number is less than the minimum number of characters needed to print the value, the "f" modifier is ignored. If it is greater, space characters are added to the right of the value to fill it out to the field width.
  • "k": "k" is the right justification modifier. It causes padding to be done on the left side of the field. The "k" modifier requires the "f" modifier, and cannot be used with the "z" modifier.
  • "z": This modifier specifies that the number should be padded on the left instead of the right, and it should be padded with zeros rather than spaces. The "z" modifier requires the "f" modifier, and cannot be used with the "k" modifier.
  • "number r": "r" specifies the radix of the string representation of the counter value. This format modifier requires a positive number. It converts the value according to the radix specified by the "number", which must be in the range 2 to 36. The lowercase letters "a" through "z" are used for the digits 10 to 35 when the radix is greater than 10. When the "r" modifier is used, counter values are treated as unsigned numbers, so that negative numbers are represented as large positive numbers. This also means that although the modifier "10r" does not change the representation of non-negative numbers, it does change negative numbers to positive numbers.
  • "l": This is the lowercasing modifier. It is allowed only when the radix modifier is specified, and has a value greater than 10, causing the lowercase letters "a" through "z" to be used when the radix is greater than 10. This is equivalent to the default behavior. The "l" modifier requires the "r" modifier, and cannot be used with the "u" modifier.
  • "u": This is the uppercasing modifier. It is allowed only when the radix modifier is specified, and has a value greater than 10, causing the uppercase letters "A" through "Z" to be used when the radix is greater than 10. The "u" modifier requires the "r" modifier, and cannot be used with the "l" modifier.

For example, in the following output action, two format modifiers are applied to the "%d" format item:

  output "There were %k3fd(item-number) items.%n"

Copyright © OmniMark Technologies Corporation, 1988-1998.