Commas between thousands

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
MatthewMunoz
Posts: 15
Joined: Tue Oct 30, 2012 8:33 pm

Commas between thousands

Post 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

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Commas between thousands

Post 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");
		}
    }
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

MatthewMunoz
Posts: 15
Joined: Tue Oct 30, 2012 8:33 pm

Re: Commas between thousands

Post by MatthewMunoz »

Hello Mark,

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

Best Regards,

Matt

Post Reply