Page 1 of 1

Multiple conditions using IF statement

Posted: Thu May 09, 2013 7:23 pm
by Sarah
Hi,

I would like to know how you would go about scripting for the following scenarios:
1. setting tag3 to '1' if tag1 = 0 and tag2 = 0
2. setting tag3 to '1' if tag1 = 0 or tag2 = 0

I attempted scenario #2 by using ValueChange for tag1 and tag2 separately but it did not work.

Thanks

Re: Multiple conditions using IF statement

Posted: Fri May 10, 2013 10:53 am
by Edmund
You could do something like this (example is for both senarios)...

Code: Select all

void Tag1_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
		{
			Update_Tag3();
		}
		
		void Tag2_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
		{
			Update_Tag3();
		}
		
		void Update_Tag3()
		{
			if(Tag1.Value && Tag2.Value)
				Tag3.Value = false;
			else
				Tag3.Value = true;
		}
All three tags has been assigned as bool.

Re: Multiple conditions using IF statement

Posted: Sun May 12, 2013 6:20 pm
by Sarah
Thanks Edmund for your help.