can't repeat function inside while True

Asked by david

hello, i can't get this piece of code working and i have no idea as to why...

def ABC():
    while True:
        some codes
################################
(Mainloop)
while True

    some codes

    ABC()

   some codes

the above code repeats mainloop indefinitely,
and when it arrives at the ABC() function, it should indefinitely repeat ABC(), until the code breaks when it fulfills the condition that requires it

however, what i am experiencing is, the ABC() only goes through once.
it doesn't repeat, it's as if "while True" inside def ACB() is being ignored...
so, it just goes through ABC and continues on with the rest of the codes in main loop...

can somebody help me please T.T...

i can't solve this on my own... please help...

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Alex Lunyov (lunyov-av) said :
#1

At first check the breaking condition of ABC() infinite cycle. Check using of global and local variables in "Mainloop" and ABC loop.

Revision history for this message
david (dovidu) said :
#2

the strange thing is , even if the breaking condition is not included in the ABC() infinite cycle, it still goes through only once, and continues on back to the main loop...

Revision history for this message
RaiMan (raimund-hocke) said :
#3

this simply does what it should.
So just check your code agains this template:

nMax = 3
nMain = 0

def sub():
  nSub = 0
  while True:
    # some additional code here
    # prepare break check
    nSub += 1
    if nSub > nMax: break # check break condition
    print "sub:", nSub
    # some additional code here

while True:
  # some additional code here
  # prepare break check
  nMain += 1
  if nMain > nMax: break # check break condition
  print "main:", nMain
  sub()
  # some additional code here

Can you help with this problem?

Provide an answer of your own, or ask david for more information if necessary.

To post a message you must log in.