SRL Archive - OSR Help

A little script I am having trouble making :/


Im4everlast

2010-10-13 20:22:44

Hi, I am trying to figure out something, but as I am still new to this im having a hard time… :/

What I wnat to do is to let the script figure out if its on top of a webpage or at the bottom by using some bitmaps so the next procedure would be able to use it.


Something like this (hope it makes some sense :S):


program New;
{$i SRL\SRL.scar}

var
//Bitmaps

procedure LoadBitmaps;
begin

end;

procedure GetPosition(Position : Integer);
begin
if(FindBitmap(A, x, y) and FindBitmap(B, x, y))then
Position := Up;
if(FindBitmap(C, x, y) and FindBitmap(D, x, y))then
Position := Down;
else
begin
Writeln('NotFound');
end;
end;


procedure asdf;
begin
if(Up)then
//DoSomething
if(Down)then
//DoSomething
else
//DoSomething
end;


begin
SetupSRL;
LoadBitmaps;
GetPosition;
asdf;
end.

Any help would be greatly apreciated.
Thank you in advance :)

Feroc1ty

2010-10-13 20:44:12

First of all, position is a parameter, it's given to the procedure, you want it to be a function which takes no parameters and returns a string.

Read some scar tutorials and learn what I just wrote, than fix your errors.

After you're done with that, instead of doing "Position := Up;", replace it with "Result := 'Up';"

As far as I can tell the rest should compile just fine.

Ogre

2010-10-13 20:46:31

Will it always be at the very top or bottom?

Im4everlast

2010-10-14 05:15:32

@Ferocity:
Yah, I was almost certan it had to be a function, but as I didnt realy figure them out I didn't know how to use it properly (Is the only difference between a procedure and a function that a function returnes a result and a procedure doesn't?).

I'll try fixing it when I come back from school..hell I'm gona try fixing it there lol.. Thanks.

@Ogre:
Yah, It should be almost at the very top and the very bottom

Sandstorm

2010-10-14 09:43:07

Yes, that's the only difference:

Procedure Blah;
Begin
RandomDeclaredVarHere := 5000;
End;

Function Blah : RandomVarTypeHere;
Begin
Result := 5000;
End;

Assuming you used the random declared variable in the first one in place of where you used the result in the second one, they would give the same thing. If you didn't really understand it, I'd be happy to try and help. Kinda bored xP.

A little example:

program New;
Var
ARandomVariable : Integer; //Declares ARandomVariable as an integer.

Procedure Blah1;
Begin
ARandomVariable := 5000; //Sets ARandomVariable to 5000.
End;

Function Blah2 : Integer; //Declares that this Function is going to return an integer.
Begin
Result := 5000; //Declares that the result of this Function is now equal to 5000.
End;

begin
Blah1; //Call this to set ARandomVariable.
Writeln(IntToStr(ARandomVariable)); //Call this to write ARandomVariable to the debug box.
Writeln(IntToStr(Blah2)); //Calls Blah2, which returns 5000, and writes the result (5000) to the debug box.
end.

Feroc1ty

2010-10-14 16:15:03

I have a question… so the parameter variables are references to the variables, instead of local variables?

Im4everlast

2010-10-14 17:07:33

Thanks sandstorm! I'look through the code more coosely when I get home (2 days. Im writing from my phone..) but from what I've seen it looks good, thanks :)