Terminate Cicode Function

Hi everyone, Using Cicode programming ...
I'm try to make a function empressed Button's input command that still running forever until the user press the Button again .. so if i press the Button at first the function inside Button will be running , But i wonder to terminate that function by press same button second time or don't mind if you suppose other Button for stop running the function ... plz help to make a code or something else to stop running of my function.
 
Lot's of ways to do this.

An easy way is to have a variable called functionRunning which can be either 0 or 1. When you push the button the first time - check the value of functionRunning. If it is 0, set functionRunning to 1, create a task that loops while functionRunning = 1 (remember to include a sleep in there somewhere).

When the button is pushed again check the value of functionRunning. if it is 1, then simply set it to 0. This will end your while loop in your task as it will stop when the loop condition isnt true.
 
Lot's of ways to do this.

An easy way is to have a variable called functionRunning which can be either 0 or 1. When you push the button the first time - check the value of functionRunning. If it is 0, set functionRunning to 1, create a task that loops while functionRunning = 1 (remember to include a sleep in there somewhere).

When the button is pushed again check the value of functionRunning. if it is 1, then simply set it to 0. This will end your while loop in your task as it will stop when the loop condition isnt true.

Thank you mp91 ..
I need to understand how can make a cicode code for create aTask between a variable tag called (Tag01) and my function that called (Surg) , I'm really need you to help me how can i made this relation to stop & start function by Toggle (Tag01).
 

Similar Topics

I have recently installed RSLinx Single-Node and I'm writing an Excel macro to read some recipe data from some PLCs. The macro is pretty straight...
2
Replies
3,050
Views
Hello, I inherited a project where the "designer" decided to run cat6 (perhaps 7?) network cable all the way to the switch inside a Rittal...
16
Replies
8,905
Views
Hi there, I M a newbie to PLC. I M working on a project with connection of multiples Inputs & outputs from Sunx S-link terminate to Nias PLC. What...
1
Replies
2,631
Views
Hey Guys, I am thinking of having the alarm timer in cicode instead of in PLC. The alarm would be generated to citect after say 30 secs. Any...
12
Replies
981
Views
I have an array with more than 500 tags and I need to get values from each tag. The problem is that using the TAGREAD function, the program runs...
3
Replies
1,051
Views
Top