SRL Archive - Help

Repeating a Function


sm321

2012-03-14 06:34:04

Hello. I'm looking to create a very simple script. I have the script:

program Script;

procedure Right;
begin

KeyDown(27);
Wait(10);
end;

begin

Right;
until

end.

How would I make it do the procedure a certain amount of times? E.g. 10 times, 20 times etc. Thankyou :)

Bonfield

2012-03-14 06:57:53

you need a new variable, lets call it counter, just call counter := 0; at the start of the script, and have a repeat loop like

repeat
inc(counter);
Right;
until (Counter >= 10); //can be any number

sm321

2012-03-14 07:21:15

From: Bonfield
you need a new variable, lets call it counter, just call counter := 0; at the start of the script, and have a repeat loop like

repeat
inc(counter);
Right;
until (Counter >= 10); //can be any number


Ok, so me being an absolute beginner, have put:

program Script;

counter := 0

begin;

KeyDown(27);
Wait(10);
end;
repeat

Move(counter);
Right;
until (Counter >=10);
end.

and it obviously wasn't going to work :p I get this:

[Error] (4:1): 'BEGIN' expected at line 3
Compiling failed.

Janilabo

2012-03-14 07:57:38

Your code should look like this:

program Script;

var
counter: Integer;

procedure Right;
begin
KeyDown(27);
Wait(10);
KeyUp(27);
end;

begin
repeat
Right;
Inc(Counter);
until Counter >= 10;
end.

sm321

2012-03-14 08:37:27

From: Janilabo
Your code should look like this:

program Script;

var
counter: Integer;

procedure Right;
begin
KeyDown(27);
Wait(10);
KeyUp(27);
end;

begin
repeat
Right;
Inc(Counter);
until Counter >= 10;
end.


Thanks :) I had a mind black for a bit. EDIT: This is supposed to move the writing "curser" that looks like this | to the right but it doesn't for some reason.

weequ

2012-03-14 09:05:13

Try KeyDown(VK_RIGHT) instead of 27.

Also do you start the script by pressing ctrl+alt+r so that the cursor is still there?

sm321

2012-03-14 09:14:35

From: weequ
Try KeyDown(VK_RIGHT) instead of 27.

Also do you start the script by pressing ctrl+alt+r so that the cursor is still there?


I've edited it to (VK_RIGHT) and tried pressing Ctrl + Alt + R but it just rotated my screen. However, if I press F9 it works, thankyou :)