Multiple conditions using IF statement

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
Sarah
Posts: 12
Joined: Tue Dec 11, 2012 12:43 am

Multiple conditions using IF statement

Post 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

User avatar
Edmund
Posts: 92
Joined: Thu Nov 29, 2012 2:27 pm

Re: Multiple conditions using IF statement

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

AITECH AB

Part of Beijer Integrator Group

Sarah
Posts: 12
Joined: Tue Dec 11, 2012 12:43 am

Re: Multiple conditions using IF statement

Post by Sarah »

Thanks Edmund for your help.

Post Reply