Text IDs feature

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
ladin79
Posts: 19
Joined: Tue Nov 13, 2012 12:25 pm

Text IDs feature

Post by ladin79 »

Hi,
I am using the new version of iX (iX 2.1).
I noticed that there is an interesting new feature "Text IDs" on multiple languages section, my question is:
it is possible to assign texts through script?

Example:

TextBox1.Text = Globals.Multiplelanguages.TextID(7);

or something like that?

Thanks!

mmarks
Posts: 4
Joined: Fri Jan 15, 2016 2:39 am

Re: Text IDs feature

Post by mmarks »

Did you ever figured out how to do this?
I need it too :)

gsavary
Posts: 5
Joined: Fri Feb 24, 2017 7:06 am

Re: Text IDs feature

Post by gsavary »

I have the same question...

AMitchneck
Posts: 137
Joined: Mon Jun 11, 2012 2:10 pm

Re: Text IDs feature

Post by AMitchneck »

There is a way to set an object's text to a text ID via script. To do this you need 3 things: the ID of the text you want, its default value, and the following code.

Code: Select all

public string GetTextID(uint textId, string defaultValue)
{
	Neo.ApplicationFramework.Tools.MultiLanguage.MultiLanguageResourceManager resources = new Neo.ApplicationFramework.Tools.MultiLanguage.MultiLanguageResourceManager(typeof(Neo.ApplicationFramework.Controls.Controls.Form));
	return resources.GetText(textId, defaultValue);
}
Just in case you were interested, you can also get text from library groups:

Code: Select all

public string GetTextFromLibrary(Neo.ApplicationFramework.Tools.MessageLibrary.MessageGroup libraryGroup, int value)
{
	for (int i = 0; i < libraryGroup.Messages.Count; i++)
	{
		if ((libraryGroup.Messages[i].StartValue <= value) && (libraryGroup.Messages[i].EndValue >= value))
		{
			return libraryGroup.Messages[i].Message;
		}
	}
	return "";
}
For example, to get text from Group1 you could then use the following function:

Code: Select all

public string GetTextFromGroup1(int value)
{
	return GetTextFromLibrary(Globals.TextLibrary.Group1, value);
}
Just to note, if you change the display's language you will need to call the above function again to update the text to the new language.
Adam M.
Controls Engineer
FlexEnergy

Post Reply