Re Iptscrae Python and While

B

Bluexcell

While:
This repeatedly tests the expression and, if it is true, executes the first
suite; if the expression is false (which may be the first time it is tested)
the suite of the else clause, if present, is executed and the loop terminates.

The problem with using While as a scanner loop is the loop cycle is carried out
at the natural cycle rate and is fixed, also one would have to define a
function that contained a while loop in order to control it remotely,?

What i want is a loop in which the the cycle rate is a variable, so it can be
controlled globally from other functions, I also need to set a variable to
start and stop the loop so i can call it and set it globally from other
functions and i can see that is possible, by containing the While loop in a
function.
The purpose of the loop is to scan for events, these are the #body, and the
result of those function calls may require a change in the scan rate or for the
scan to stop and command to pass elswhere.. ie another function. While can be
exited using break i know and it can resume using continue. but it seems an
unwieldy and ugly way to do it.
I will study it further though.. perhaps there is a clean way i havent seen
yet.
Thanks. Incony
 
T

Terry Reedy

Bluexcell said:
What i want is a loop in which the the cycle rate is a variable, so it can be
controlled globally from other functions, I also need to set a variable to
start and stop the loop so i can call it and set it globally from other
functions and i can see that is possible, by containing the While loop in a
function.

I do not quite understand what you want to do. However, when a while loop
inside a function contains a yield statement, then cycling is controlled by
calling .next on the resulting gen-iterator. This can be done from
multiple places, by any function with a reference to the iterator. Hope
this at least gives you more ideas.

Terry J. Reedy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,183
Messages
2,570,967
Members
47,517
Latest member
Andres38A1

Latest Threads

Top