Category
Function
Formats a string.
Syntax
string = Format(template, value, ...);
Inputs
Name | Type | Default | Description |
---|---|---|---|
template | string | none | format control string |
value | value list or string | no default | value to format |
... | more values to format |
Outputs
Name | Type | Description |
---|---|---|
string | string | formatted string object |
Functional Details
This module uses a format-control string and input values to create a formatted output string. Each insertion is matched to a format-control specification, which always begins with a % symbol. Strings, scalars, integers, and vectors can be formed into output strings.
template | is the format-control string used in creating the formatted output. It resembles a C-language printf format string. Data Explorer copies all characters other than format specifications to the output (see next parameter). | ||||||||||
value | is the value to be placed in the output string. The character following the % controls the type of conversion:
To output a %, use %%. You can insert numbers between the % and the conversion character to control the width of the field and the number of significant digits formatted. A minus sign (-) left-justifies the output in the field; the default is right-justification. A format control string of "%-10.4f"indicates left justification of a floating-point number, minimum of 10 columns total, with 4 places to the right of the decimal point. |
A single call to the Format module can format a maximum of 21 values. In the user interface, the default number of enabled value tabs is two. (Tabs can be added to the module icon and removed with the appropriate ...Input Tab options in the Edit pull-down menu of the VPE.)
Script Language Examples
value1 = 32.567799;
output = Format("number = %f", value1); Echo(output);
output = Format("number = %3.2f", value1); Echo(output);
output = Format("number = %11.2f", value1); Echo(output);
value2 = 134569888; value3 = "New York";
output = Format("number = %f, state = %s", value2, value3); Echo(output);
output = Format("number = %10.0f, state = %s", value2, value3); Echo(output);
output = Format("number = %g, state = %s", value2, value3); Echo(output);
output = Format("number = %g, state = %15s", value2, value3); Echo(output);
Example Visual Programs
ContoursAndCaption.net GeneralImport1.net FormatListMacro.net InvalidData.net PlotTwoLines.net SalesOnStates.net Sealevel.net
See Also
[ OpenDX Home at IBM | OpenDX.org ]