Author Topic: Conversion of STRING Type to NUMERIC Type  (Read 2292 times)

Rahul Gera

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 88
    • View Profile
Conversion of STRING Type to NUMERIC Type
« 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.
« Last Edit: March 15, 2017, 10:55:00 AM by Rahul Gera »