Using Execute Function In A Switch Statement


Recommended Posts

Hi There,

 

Do you know if it is possible to use the Execute function with doing a conditional statement within a switch structure like as shown below. Apologies if this is a basic error i'm still relatively new to coding. 

 case ((tempprobe >= 65) && (((Equilibration_start_time + Equilibration_time) - SysTime()) < 0 ) && (Equilibration_complete == 0)) && (execute("Alicat"+pot_letter[0]+"_flow => 0.9*(Alicat"+pot_letter[0]+"_Setpoint)")))

i can't seem to get it to work and i'm wondering if its because of how the execute function is calculated. Do you have any suggestions or useful guidance regarding this problem? The Pot_letter variable (string) changes depending on user input so i would like some way of dynamically adjusting the code?

 

Thanks in advance!

 

Richard

 

Link to comment
Share on other sites

You want evaluate().  Execute() is when you want to do full statements, like execute("y = 13").  Evaluate() is for when you want to evaluate an expression, like evaluate("myFlow[0] > 13")  

 

A good rule is: use evaluate() when you expect a result from the function call, and execute() when you want to do something.  So, in my example, execute is setting y to 13.  It does not return anything.  Evaluate is comparing myFlow[0] to 13 and return 0 or 1 depending on whether its > or not.  Evaluate() works with math too of course: evaluate("3+4") will return 7.  

Link to comment
Share on other sites

Archived

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