Welcome Guest ( Login | Register )



All times are UTC - 7 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: read text ID via script?
PostPosted: Wed Jun 08, 2016 5:44 am 

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

Offline
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:
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 :(


 Profile  
 
 Post subject: Re: read text ID via script?
PostPosted: Wed Jun 08, 2016 8:09 am 

Joined: Mon Jun 11, 2012 2:10 pm
Posts: 89

Offline
I've never extracted text from screens, but to extract text from Text Library you could use something like
Code:
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


 Profile  
 
 Post subject: Re: read text ID via script?
PostPosted: Tue Jul 26, 2016 2:48 am 

Joined: Sun Jun 28, 2015 9:18 pm
Posts: 9

Offline
Thanks for the info
บาคาร่า มือถือ


 Profile  
 
 Post subject: Re: read text ID via script?
PostPosted: Mon Aug 01, 2016 7:22 am 

Joined: Mon Jun 11, 2012 2:10 pm
Posts: 89

Offline
After some digging, I found you can extract text from Text ID using the following
Code:
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


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: