View Full Version : Repeating a Function
sm321
03-14-2012, 10:34 AM
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
03-14-2012, 10:57 AM
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
03-14-2012, 11:21 AM
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
03-14-2012, 11:57 AM
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
03-14-2012, 12:37 PM
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
03-14-2012, 01:05 PM
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
03-14-2012, 01:14 PM
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 :)
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.