Page 1 of 1

Read text from one other screen

Posted: Mon Apr 07, 2014 12:30 am
by ladin79
Hello,
I noticed that if I try to access a text belonging to another form I can’t return this text as long as the form does not appear at least once, I'll explain,
if from Screen1 I try to read a text in Screen2 using this code:

In Screen1:
AnalogNumeric.Text = Screen2.getTextPageTitle();

In Screen2:
public partial class Screen2
{
static string pagetitle;
void Screen2_Opened(System.Object sender, System.EventArgs e)
{
pagetitle = this.Title.Text;
}
static public string getTextPageTitle()
{
return pagetitle;
}
}

the text will be returned only after screen2 will be opened at least once, there is a way to have the text always available, or is there a way via script to read text directly from the Multiple languages table?
Thank you very much.

Re: Read text from one other screen

Posted: Tue Apr 22, 2014 4:38 pm
by stuartm
Don't use private types because these screens get re-instantiated. Basically, the objects in memory gets cleared. Its unreliable. Use Globals context.

Globals.Tags.Tag1.Value = 5;

This will ensure that your data will survive. As a developer you would choose to develop this way. Unfortunately, the way IX was designed, its not advised to use this way.

Alternately, script modules are next safest way to store data. Encapsulation works better and these scripts modules do not get wiped out. If you have a class like TcpClient, tags cannot support this data type. Use a script module instead.

Best Regards,
Stuart