Hitachi

JP1 Version 13 JP1/Script Description and Reference (For Windows Systems)


8.3.20 Format (convert a value to a formatted string)

Purpose

Returns a specified value as a formatted string.

Syntax
Format (Form, Arg1 [, Arg2, ...])
Arguments
Form

Specify the format into which Arg1 to Arg32 are to be converted. Write a character string or a variable that stores this value.

Each character specified in Form is represented as is, and the % symbol shows where the formatting specification starts.

Form can be any combination of the following:

Designation

Meaning

%d

Represent numbers as decimals.

%x

Represent numbers as hexadecimals (lowercase).

%X

Represent numbers as hexadecimals (uppercase).

%o

Represent numbers as octals.

%s

Represent strings as is.

%c

Represent a single character as it is.

If any of the values in Arg1 to Arg32 consist of two or more characters, the first character is represented.

%5d, %10s, etc.

Specify the number of characters output by the value to be formatted.

Pad the value with spaces to the left if the number of characters of the value has less than the specified number of characters. If the number of characters of the value exceeds the specified number of characters, the value is not truncated, and all the characters are output.

%05d

Specify the number of characters output by the value to be formatted.

Pad the value with leading zeros if the number of characters of the value has less than the specified number of characters. If the number of characters of the value exceeds the specified number of characters, the value is not truncated, and all the characters are output.

%-5d, %-10s, etc.

Left-justify the value.

To enter % as the character itself, not as the formatting indicator, type %%.

Arg1 to Arg32

Specify each value to be formatted as a string, number, or as a variable that stores this value. You can specify multiple values in the same order as the format designations in Form.

Description

The Format command returns a specified value as a string.

Example
' Convert the value of global variable seqNo to a five-digit
' decimal number padded with leading zeros, and pass it to
' executable file ABC.EXE as a parameter.
' For example, if the value seqNo is "1", pass parameter
' "00001".
Dim numID, strID
numID = GetGV ("seqNo")
If IsEmpty (numID) Then
  numID = 1
End If
strID = Format ("%05d", numID)
Exec (_SCF_+"ABC.EXE", True, strID)
JP1/Script version

Supported from JP1/Script 05-20.