read text ID via script?

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
mmarks
Posts: 4
Joined: Fri Jan 15, 2016 2:39 am

read text ID via script?

Post by mmarks »

I'm wondering if there is any way to retrieve a string (in the current language) defined under Multiple Languages/ Text IDs via script?

I saw in another topic that the following line compiles (and I tried it myself too):

Code: Select all

Globals.MultipleLanguages.SetLanguage("Default");
So we have access to the MultipleLanguages object but since there is no autocomplete and I can't find any documentation I'm stuck :(

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

Re: read text ID via script?

Post by AMitchneck »

I've never extracted text from screens, but to extract text from Text Library you could use something like

Code: Select all

using Neo.ApplicationFramework.Tools.MessageLibrary;
public string GetTextFromLibrary(int Value)
{
	for (int i = 0; i < Globals.TextLibrary.Group1.Messages.Count; i++)
	{
		if ((Globals.TextLibrary.Group1.Messages[i].StartValue <= Value) &&
			(Globals.TextLibrary.Group1.Messages[i].EndValue >= Value))
		{
			return Globals.TextLibrary.Group1.Messages[i].Message;
		}
	}
	return "";
}
Adam M.
Controls Engineer
FlexEnergy

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

Re: read text ID via script?

Post by AMitchneck »

After some digging, I found you can extract text from Text ID using the following

Code: Select all

Neo.ApplicationFramework.Tools.MultiLanguage.MultiLanguageResourceManager resources = new Neo.ApplicationFramework.Tools.MultiLanguage.MultiLanguageResourceManager(typeof(Screen1));
button.Text = resources.GetText(ID, "default");
where
Screen1 is the name of the screen
ID is a uint of the desired textID
"default" is the default text to return if ID not found
button.Text is where to put the result

you can obtain specific text to controls on screen by replacing ID with, for example, "Screen1.button.Text". This example would get the text associated with button on Screen1.
Adam M.
Controls Engineer
FlexEnergy

Post Reply