Covert int to string

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
GoranW
Posts: 7
Joined: Mon Apr 29, 2013 7:34 am

Re: Covert int to string

Post by GoranW »

I too need to convert an int to a string. I will also need to convert the other way, i.e. a string to an int. After looking in the forum I have tried this:

void RecipeNumber_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
{

Globals.Tags.RecipeName.Value = Convert.ToString(Globals.Tags.RecipeNumber.Value);
}


I get a compilation error saying it is an ambguity between Convert.ToString(uint) and Convert.ToString(System.DateTime)

If I try this:
Globals.Tags.RecipeName.Value = System.Convert.ToString(5);

a "5" is displayed neatly on the Ix.

What am I doing wrong?

User avatar
Edmund
Posts: 92
Joined: Thu Nov 29, 2012 2:27 pm

Re: Covert int to string

Post by Edmund »

Try

To String:

Globals.Tags.RecipeName.Value = Globals.Tags.RecipeNumber.Value.ToString();

To Int

Globals.Tags.MyIntTag.Value = Convert.ToInt32("123");
Edmund Andersson

AITECH AB

Part of Beijer Integrator Group

GoranW
Posts: 7
Joined: Mon Apr 29, 2013 7:34 am

Re: Covert int to string

Post by GoranW »

Hi Edmund,
Tanks for the quick reply.
I managed to get it to work by using private variables, see screen dump.
But I will try your proposal too.

Thanks
Goran :D
Attachments
Namnlös.jpg
Namnlös.jpg (189.21 KiB) Viewed 6764 times

User avatar
Edmund
Posts: 92
Joined: Thu Nov 29, 2012 2:27 pm

Re: Covert int to string

Post by Edmund »

Great Göran :)

The iX tag class also includes convert/cast functions (if possible), see image below
tag_cast.png
tag_cast.png (14.15 KiB) Viewed 6761 times
Edmund Andersson

AITECH AB

Part of Beijer Integrator Group

Post Reply