| Maptitude GISDK Help |
Returns a string, formatted and substituted according to the the format and the arguments.
text = GetText(string format, opt array args, opt string context)
| Argument | Contents |
|---|---|
| format | A string format, that uses format specifiers such as %s (string), %d (integers), and %6.2lf(long float), to define the string. |
| args | Optional. An array in which each element is a macro expression in Caliper Script. |
No options are currently supported.
A formatted string, with all format specifiers replaced by the corresponding macro expression, (i.e. the values of array elements in the 2nd argument).
The format string is replaced with the strings defined in the args array.
Format specifiers%1,...,%9 are substituted first; followed by other %* substitutions.
A double %% will appear as a single % in the output and will not use any arguments from the args array.
The expression in the args array must return values that match the type specified by the corresponding %* format specifier in the output string. Currently, only string and numerical data types are supported.
Most of the normal specifiers supported by C function printf(...) can be used, for example, %.2f, %g, etc
set_name = "Selection"
count = GetSetCount(set_name)
text1 = "There are %1 records in set %2"
text2 = "Set %2 has 1% records"
new_text1 = GetText(text1 , {count, set_name}) // new_text1 is "There are 4 records in set Selection"
new_text2 = GetText(text2 , {count, set_name}) // new_text2 is "Set Selection has 4 records"
avg = 124.458894
property = "sale"
text = "The average %s is %.2f"
new_text = GetText(text , { property, avg }) // new_text is The average sale is " 124.46"
| Error Type | Meaning |
|---|---|
| Error | Invalid prototype string for format tags (%s) or mismatch in data type. The order of the format specifiers do not match the order of the args types |
| ©2025 Caliper Corporation | www.caliper.com |