Convert Text To Number
Converts a number in a text according to the specified language.
Command availability: IBM RPA SaaS and IBM RPA on premises
Description
This command is used to convert number in text to a number format, following the attributes of the specified language.
Script syntax
IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.
convertStringToNumber --text(String) [--allowleadingsign(Boolean)] [--allowdecimalpoint(Boolean)] [--allowthousands(Boolean)] [--allowexponent(Boolean)] [--allowcurrencysymbol(Boolean)] --culture(Culture) (Numeric)=value
Input parameters
The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.
Designer mode label | Script mode name | Required | Accepted variable types | Description |
---|---|---|---|---|
Text | text |
Required |
Text |
Text variable to be converted into a numeric variable. The value to be converted must include numbers in a text variable. For example the text values: "1", "1.2", "12.2" can be converted to a numeric variable, but the text values: "one", "minus one", "one and one decimal", cannot be converted to a numeric variable. |
Allow Sign | allowleadingsign |
Optional |
Boolean |
Enable to allow the use of mathematical signs in the text to be converted ("+" for positive or "-" for negative) |
Allow Decimal Point | allowdecimalpoint |
Optional |
Boolean |
Enable to allow the use of decimal places. Depending on the Language parameter, the command might use "." and "," to separate thousands and decimals. |
Allow Thousands | allowthousands |
Optional |
Boolean |
Enable to use the thousands separator. Depending on the Language parameter, the command might use "." and "," to separate thousands and decimals. |
Allow Exponent | allowexponent |
Optional |
Boolean |
Enable to convert to a number using scientific notation. |
Allow Currency | allowcurrencysymbol |
Optional |
Boolean |
Enable to convert a number that has a dollar symbol in the text. |
Language | culture |
Required |
Culture |
Language used to convert the text. See the culture parameter options for details. |
culture
parameter options
The following table displays the options available for the culture
input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.
Designer mode label | Script mode name | Description |
---|---|---|
de-DE |
de-DE |
German |
en-US |
en-US |
English |
es-ES |
es-ES |
Spanish |
ko-KR |
ko-KR |
Korean |
pt-BR |
pt-BR |
Portuguese (Brazil) |
pt-PT |
pt-PT |
Portuguese (Portugal) |
zh-CN |
zh-CN |
Chinese (Simplified) |
zh-TW |
zh-TW |
Chinese (Traditional) |
Output parameter
Designer mode label | Script mode name | Accepted variable types | Description |
---|---|---|---|
Number | value |
Number |
Returns a numeric value extracted from the text. |
Example
Converts the text value "1,000.00" to the number 1000.00, using the Allow Thousands and Allow Decimal Point to keep the decimal points and to interpret the comma (,
) as the thousand separator.
defVar --name textToConvert --type String --value "1,000.00"
defVar --name convertedNumber --type Numeric
convertStringToNumber --text "${textToConvert}" --allowdecimalpoint --allowthousands --culture en-US convertedNumber=value
logMessage --message "${convertedNumber}" --type "Info"