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 maximum number of digits to be formatted.
%05d
Pad the value with leading zeros if it has fewer than the specified maximum number of digits to be formatted.
%-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.