Liquid UI Forum

Using Your Liquid UI Products => WS aka Web Scripts (Attended RPA for SAP) => Topic started by: Rahul Gera on March 13, 2017, 05:04:46 PM

Title: Conversion of STRING Type to NUMERIC Type
Post by: Rahul Gera on March 13, 2017, 05:04:46 PM
This example, is to convert a STRING type to NUMERIC type. This conversion needs to happen on Liquid UI variables with Numerical values assigned using SET command.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Author: Synactive, Inc. [1065 E. Hillsdale Blvd, Foster City, CA, 94404, USA]
// Email: support@guixt.com; sales@guixt.com;
// Contact: 650.341.3310
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

Liquid UI Script:

// Integer
set("V[zstring]", "1000.28");
result = parseInt(zstring);

The value of resultwill be 1000 is a NUMERIC value.

// Float
set("V[zstring]", "1000.28");
result = parseFloat(zstring);

The value of resultwill be 1000.28 is a NUMERIC value.


// Removing COMMA and Converting to Integer
set("V[zstring]", "1,000.28");
result = parseInt(zstring.replace(/,/g,''"));

The value of resultwill be 1000 is a NUMERIC value.


// Removing COMMA and Converting to Float
set("V[zstring]", "1,000.28");
result = parseFloat(zstring.replace(/,/g,''"));

The value of resultwill be 1000.28 is a NUMERIC value.