Terminate Cicode Function

ahmed007

Member
Join Date
Aug 2019
Location
baghdad
Posts
13
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).
 
Last edited:

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...
Replies
0
Views
2,276
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...
Replies
16
Views
6,430
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...
Replies
1
Views
2,160
Hi All, Can anyone advise me on how to determine the AN of a genie instance I writing to. I have created a genie to display a valve and some text...
Replies
0
Views
89
I am trying to display a variable within a cicode function onto a graphics page. This function queries a SQL database. I can get the value onto a...
Replies
3
Views
274
Back
Top Bottom