numeric keypad having an Integer output?

Discuss issues and ideas you have to configuring displays with PowerVision
rtackett
Posts: 15
Joined: Tue May 03, 2011 9:58 am

numeric keypad having an Integer output?

Post by rtackett » Fri Jan 31, 2014 1:40 pm

Hello,
I have been using a numeric keypad to enter data into my application. I have to run a script because the data from the keypad is a string variable. Looking at the new v2.7 tool, and activity language, I was hopeful that there could be more simple code for the keypad to eliminate the string output and scripting.

Is there a simple command to convert a string variable to a integer variable that I can execute in Powervision (2.6, 2.7)?

Thanks.
Russell
ecarmen
Murphy Representative
Murphy Representative
Posts: 8
Joined: Mon Sep 13, 2010 10:47 am

Re: numeric keypad having an Integer output?

Post by ecarmen » Tue Feb 11, 2014 10:01 am

The keypads use strings to accomodate alpha characters and special characters like decimal points.
If you would like to convert the string to a integer or a double these features have been added to the script function library in 2.7. Please be aware that in 2.7.10306 the string to integer function has a bug that is being fixed.

Here is some sample code: This script converts then writes the string 12345 to two text gages on the display labeled MyInt and MyDouble.

void $ConvertStringsToNumbers$ ()
{
int TempInt;
double TempDouble;
string TempString = "12345";
uint DoubleHandle = VariableIDs.MyDouble; //get the handles for all the main screen widgets
uint IntHandle = VariableIDs.MyInt;

TempInt = StringToInt(TempString); // take the string and convert to a Integer
smWrite(IntHandle, TempInt); // then write it to the Int text gage

TempDouble = StringToDouble(TempString); // take the same string and convert to a double
smWrite(DoubleHandle, TempDouble); // then write it to the Double text gage

}