FORMAT

C Test Script Language

Syntax

FORMAT <variable> = [<new type>[#<display directive> [<size>]]

FORMAT <type> = <new type>[#<display directive> [<size>]]

FORMAT <field> = <new type>[#<display directive> [<size>]]

Description

The FORMAT instruction allows you to modify the type of the tested element, where:

The <new type> is an abstract C type.

The optional <display directive> is one the following suffixes for integers  only:

  1. #h for hexadecimal display,

    #b for binary display,

    #u for unsigned decimal display,

    #d for signed decimal display,

and with the following possibilities for floating variables:

  1. #f to display without an exponent,

    #e to display with an exponent.

For integers, <size> is the number of bits to be displayed. For floating variables, <size> is the number of the number of digits after the decimal point.

Associated Rules

The FORMAT statement is optional and must be located after the BEGIN statement.

The FORMAT definition can be replaced by an optional <format> parameter in a VAR statement.

It is applicable immediately, only in the block in which it is declared.

<variable> follows standard C syntax rules. <type> is a C identifier used in typedef, struct or union instructions. <format> is an abstract C type.

If the change is to be applied to array elements, you can use an abstract C type to describe the new modified variable, field, or type.

A format cannot be empty. It must contain either the abstract C type or the display directive.

In the display directive, the size is optional. The size must be a multiple of 8 for the integers. The default values for this size are the following:

  1. For integers, the number of bits of the abstract type if it is given, or if it is not, the number of bits of the type or the variable whose printing format is modified

    For #f, 6 digits after the decimal point and for #e, 2 digits after the decimal point

Example

#char x;

#char t[10];

FORMAT t = int     -- t is an array of integers

FORMAT x = int#h8  -- display in hexa, only 8 bits

FORMAT y = #b      -- display in binary without modifying the type

FORMAT z = short#u -- display in unsigned decimal

FORMAT f1 = #f     -- displays for example 3.670000

FORMAT f1 = #f4    -- displays for example 3.6700

FORMAT f1 = #e4    -- displays for example 0.36700E1

Related Topics

VAR, ARRAY and STR