If, Else And Else If


Mizan

Recommended Posts

I'm trying to use an 'elseif' statement but I understand DAQFactory doesn't do that. 

 

So I tried doing 'else if', a nested if within the original if statement but the sequence still runs the 'nested if' even if the the first criteria is met

 

   if(Pump2 == 1)
      O_Pump2_Off = 1
      delay(.01)
      O_Pump2_Off = 0
 
      O_Pumps = 1
      delay(.01)
      O_Pumps = 0
 
   else if(Pump1==0)
            O_Pumps = 1
            delay(.01)
            O_Pumps = 0
         else
            O_Pumps_Off = 1
            delay(.01)
            O_Pumps_Off = 0
         endif
 
   endif
   
Link to comment
Share on other sites

You syntax is wrong.  You can't have the else and the if() on the same line.

 

But actually, DAQFactory does have an elseif structure, its the switch/case.  So your script would look like:

 

switch

   case(pump2 == 1)

      ...

   case(pump1== 0)

      ...

   default

      ...

endcase

 

Also, did you want [0] after pump2 and pump1?  If they are channels you probably do.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.