Script - InstanceName

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
Lukas0204
Posts: 7
Joined: Fri Jun 15, 2018 4:45 am

Script - InstanceName

Post by Lukas0204 »

Hi,

this is the code that I am using for showing Alias tags in trend. My problem is 'this.InstanceName'! Sometimes I can choose 'InstanceName', and sometimes i can't (it doesn't exist). Why is that so?


Code: Select all

namespace Neo.ApplicationFramework.Generated
{
	using System.Windows.Forms;
	using System;
	using System.Drawing;
	using Neo.ApplicationFramework.Tools;
	using Neo.ApplicationFramework.Common.Graphics.Logic;
	using Neo.ApplicationFramework.Controls;
	using Neo.ApplicationFramework.Interfaces;
    
	public partial class Screen30
	{
		
		void Screen30_Opened(System.Object sender, System.EventArgs e)
		{
			string CurrentAlias = this.InstanceName;
						
			for (int i = 0; i < 5; i++)
			{
				TrendViewer.Curves[i].IsVisible = false;
			}

			if (CurrentAlias == "PT_101")
			{TrendViewer.Curves[0].IsVisible = true;}
			else if (CurrentAlias == "PT_102")
			{TrendViewer.Curves[1].IsVisible = true;}
			else if (CurrentAlias == "PT_103")
			{TrendViewer.Curves[2].IsVisible = true;}
			else if (CurrentAlias == "PT_104")
			{TrendViewer.Curves[3].IsVisible = true;}
			else if (CurrentAlias == "PT_105")
			{TrendViewer.Curves[4].IsVisible = true;}
		
		}
	}
}

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

Re: Script - InstanceName

Post by AMitchneck »

Question: When does 'InstanceName' not exist? During compile or runtime (when you hit build or when you run your project)? If it's the later, are you getting an object null exception? My guess in this case is the window is being shown without being given a value for the alias (i.e. screen is just being shown without being told which instance to show) and thus 'InstanceName' is being left null.
Adam M.
Controls Engineer
FlexEnergy

Post Reply