Page 1 of 1

Script - InstanceName

Posted: Tue Apr 09, 2019 1:32 am
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;}
		
		}
	}
}

Re: Script - InstanceName

Posted: Tue Apr 09, 2019 6:32 am
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.