OpenSTA logo OpenSTA SCL Reference
FORMAT Command

FORMAT Command

This command translates data from one format into another. This makes it easier to manipulate character strings that have been output from the system under test, or which are to be input into that system.

In all translations, the command requires three elements:

  • The target variable that will receive the translated value. This may be either a character or integer variable.
  • A format string defining the type of translation required. For an integer target variable, the format string must only contain a single format identifier; for a character variable, the format string may contain multiple identifiers and/or ordinary characters that are to be copied unchanged to the target variable.
  • One or more values to be translated; these may be specified as variables or as quoted character strings. A single value must be specified for each of the format identifiers in the format string; the data type of each must agree with the associated format identifier and the data type of the target variable, as discussed below. Note that any discrepancies in this respect are detected at run-time and are not picked up by the cpompiler.

The following types of translation are supported:

  • %U - Translate each alphabetic character in the input string into its uppercase equivalent. Both source and target variables must be character variables. The source string if necessary is truncated to fit the target variable.
  • %L - Translate each alphabetic character in the input string into its lowercase equivalent. Both source and target variables must be character variables. The source string if necessary is truncated to fit the target variable.
  • %D - Convert a character string date value into numeric format (representing the number of days since the Smithsonian base date of 17-Nov-1858). The target variable must be an integer variable, and the source variable a character string containing a valid date; this can be either in the default style for the platform on which the Script is running or in the fixed format DD-MMM-CCYY (where CC is optional).

    This format identifier may also be used to convert a numeric date value (representing the number of days since the Smithsonian base date of 17-Nov-1858) into a character string in the fixed format DD-MMM-CCYY. The source must be an integer variable and the target character variable, which will be truncated if necessary.
  • %T - Convert a character string time value into a numeric format (representing the number of 10 milli-second 'ticks' since midnight). The target variable must be an integer variable, and the source variable a character string containing a valid time; this can be either in the default style for the platform on which the Script is running or in the form HH:MM:SS.MMM (where .MMM is optional).

    This format identifier may also be used to convert a numeric time value (representing the number of 10 millisecond ticks since midnight) into a character string in the fixed format HH:MM:SS.MMM. The source must be an integer variable and the target character variable, which will be truncated if necessary.

Command Definition:

FORMAT(target-variable, format-string, variable {,variable ...})
	 {{,}ON ERROR GOTO err-label}

target-variable

The name of an integer or character variable into which the result of the operation is placed.

format-string

A quoted character string containing the string to be formatted and containing a number of format identifiers. The format identifiers must be compatible with the data types of the variables that follow.

variable

One or more integer or character variables or literals to be translated. The number of variables must correspond with the number of format identifiers in the format string. The data type of each variable must match the corresponding format identifier and the target variable.

err-label

A label defined within the current scope of the Script to which control branches if an error occurs.

Examples:

FORMAT(Date-Str, &
	 "The date is %D today, and the time is %T", &
	 Int-Date, Int-Time), ON ERROR GOTO THE_END
FORMAT(Date-Value, "%D", Char-Date), ON ERROR GOTO FRM_ERR
FORMAT(UC-String, "Name in uppercase is %U", LC-String)

<<<
prev page
^^^
section start
>>>
next page