Run a script non-stop ?

Asked by Laurent

Hello.

I have a script, a short 12 lines script which I would like to run forever (until I stop it, at least).
I'm not very knowledgable with Python, AppleScript or Ruby or wathever (I stopped at Lbl 1 Goto 1 haha)

I tried to def fonction() : and call it at the end of the script.
No result.
I tried repeat 100000 times + end repeat.
No result.

I can't imagine what I have to tell to the script to make it loop from line 12 to line 1 x)

Any idea ?

Thx for your help.

Question information

Language:
French Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
Last query:
Last reply:
Revision history for this message
xyz_User (userseven) said :
#1

do you have your code you can share here? why not just set a simple loop?

eg:

def myScript() #This is your script/program
        your script here
        myLoop() #Calls the loop below

def myLoop(): #This function loops "MyScript"
        myScript()

myScript() #Runs your script

Revision history for this message
Best Manfred Hampl (m-hampl) said :
#2

To repeat forever you can use a construct like this:

while True:
    your_script_actions

If you want the script to terminate at a certain condition, you can extend it with

while True:
    your_script_actions
    if termination_condition_is_True:
        break

This is simple python, to be found in the manuals.

Revision history for this message
Laurent (rakanishu) said :
#3

Oh, thx !
Maybe it is simple knowledge but I didn't manage to dig it myself.
Thx again.

Revision history for this message
Manfred Hampl (m-hampl) said :
#4

Just to add:

You have to be aware that indents are significant in Python!
With "while True:" all statements to be repeated have to be indented to the next level.

Revision history for this message
Laurent (rakanishu) said :
#5

Yes, it's like a def fonction () : i guess.
That at least I know :)