# Thread: How do I restart repeat loop from inside loop

1. Registered User
Join Date
Dec 2018
Posts
3
Mentioned
0 Post(s)
Quoted
1 Post(s)

## How do I restart repeat loop from inside loop

As title says. I made a script and in the main line I have a repeat loop because I want it to do a bunch of procedures over and over again for about 120 repeats. But theres a random chance something will mess up the script so I need it to restart the loop from the top when that happens. Help please.

2. Too vague. Paste some concrete code and it will be easier to give you advice.
By mess up the script do you mean that the entire script terminates, or that this specific loop ends?

3. Registered User
Join Date
Nov 2018
Location
System32
Posts
13
Mentioned
0 Post(s)
Quoted
3 Post(s)
Simba Code:
if messup then  FirstProcedure;
Is that what you mean? Would be hard to give you good advice without at least seeing the loop.
Last edited by Zombified; 12-07-2018 at 05:35 AM.

4. Could look at Label/GoTo, but you need to put in your script a specific way or it can cause issues.

There are many different ways to work with looped stuff, but you need to be more specific in what you are asking. Paste your code, or if you don't want it public, write up a procedure of how your script functions, and what you want to achieve.

5. Registered User
Join Date
Dec 2018
Posts
3
Mentioned
0 Post(s)
Quoted
1 Post(s)
I tried posting some stuff but I got a message saying a mod needs to review it first had code in it

6. Registered User
Join Date
Nov 2018
Location
System32
Posts
13
Mentioned
0 Post(s)
Quoted
3 Post(s)
Originally Posted by Nerdy777
I tried posting some stuff but I got a message saying a mod needs to review it first had code in it
In the meantime, feel free to join the Discord server for help! It may not be instant, but there are a lot of helpful members.
https://discordapp.com/invite/627s6fm

7. Registered User
Join Date
Dec 2018
Posts
3
Mentioned
0 Post(s)
Quoted
1 Post(s)
If the game is running correctly it wouldn't crash and the procedures would be able to go in order from 1 - 5, but if it crashes I need the script to detect the game crashed and reopen the game but when the game opens it doesn't open up to where the game left off. I need the script to essential go 1 - 3 and then back to 1 and repeat procedures 1 - 5 as if nothing ever happened whenever the second FindDTM runs successfully.

The script detects all this in procedure 3. I've shown below 2 if FindDTMs, whenever the script reads up to the end of the second FindDTM I need it to restart the script completely at procedure 1, forgetting everything thats ever happened inside the repeat loop.

------------------------------------------------------------------------------------------------------

procedure 1

begin
end

procedure 2

begin
end

procedure 3

begin

if FindDTM(Example1, v, w, 191, 4, 748, 976) or
FindDTM(Example2, v, w, 191, 4, 748, 976) then
begin
writeLn('--- App Crashed! WAITING 10 seconds for user input OR Going to try and REOPEN...');
wait(10000);
DidWeCrashProcedure;
MoveMouse(317, 791);
GetMousePos(v, w);
ClickMouse(v, w, mouse_Left);
wait(2000);
MoveMouse(405, 220);
GetMousePos(v, w);
ClickMouse(v, w, mouse_Left);
wait(2000);
MoveMouse(326, 627);
GetMousePos(v, w);
ClickMouse(v, w, mouse_Left);
writeLn('WAITING 25 seconds for app to open');
wait(10000);
writeLn('Been 10 seconds');
wait(10000);
writeLn('Been 20 seconds');
wait(5000);
writeLn('FINISHED waiting 25 secconds');
if FindDTM(Example3, v, w, 298, 483, 634, 622) then
begin
MoveMouse(470, 550);
GetMousePos(v, w);
ClickMouse(v, w, mouse_Left);
wait(8000);
MoveMouse(476, 100);
GetMousePos(v, w);
ClickMouse(v, w, mouse_Left);
wait(200);
ClickMouse(v, w, mouse_Left);
HoldMouse(v, w, mouse_Left);
wait(200);
MoveMouse(476, 120);
wait(200);
MoveMouse(476, 220);
wait(200);
MoveMouse(476, 320);
wait(200);
MoveMouse(476, 420);
wait(200);
GetMousePos(v, w);
ReleaseMouse(v, w, mouse_Left);
...
end

procedure 4

begin
end

procedure 5

begin
end

begin

t := 0;
ClearDebug;
repeat
procedure 1
procedure 2
procedure 3
procedure 4
procedure 5
t := t+1;
until(t = 120);
CrashClient;

end

------------------------------------------------------------------------------------------------------
Last edited by Nerdy777; 12-07-2018 at 05:15 PM.

8. Simba Code:
for loop := 1 to 120 dobegin  //proc1();  //proc2();  if problem then    loop := 1;end;