Read text from one other screen

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

Read text from one other screen

Post 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.

stuartm
Posts: 61
Joined: Thu Jun 06, 2013 9:21 am

Re: Read text from one other screen

Post 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

Post Reply