Page 1 of 1

Commas between thousands

Posted: Wed Nov 07, 2012 8:10 pm
by MatthewMunoz
Hello,

I have some 32-bit integers which will be be running into the millions and floating point numbers that will be in the tens of thousands. I would like to display them on a iX T12B or T12C HMI, with commas between the groups of thousands. How can I do this?

Best Regards,

Matt

Re: Commas between thousands

Posted: Thu Nov 08, 2012 9:23 am
by mark.monroe
The only way to do that would be to write a script that converts your number into a string, and then you would need to insert the ',' yourself.

Below is example code that will take the OrgNumber, a double, and using C# formating it will convert it into a string that has ',' in it. It is triggered whenever the OrgNumber tag value changes. You place it in the tags tab scripting section, found in the lower left hand corner of the tags tab.

Code: Select all

		void OrgNumber_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
		{
			double rawNumber = Globals.Tags.OrgNumber.Value;
			Globals.Tags.StringNumber.Value = rawNumber.ToString("N");
		}
    }

Re: Commas between thousands

Posted: Thu Nov 08, 2012 5:56 pm
by MatthewMunoz
Hello Mark,

Thank you for the prompt reply and sample code. It works perfectly.

Best Regards,

Matt