SRL Archive - OSR Help

Calling another function that is below another in a script.


Cage

2014-06-20 15:50:46

Hello :)

This may seem like an obvious one for most, but I am having trouble with this. I am trying to call a function below another in my script and it will not let me as it is classed as a unknown identifier.

How do I go about allowing it to be called? Because all I can think of right now if placing it above said function and I don't think that is likely to be at all an effective solution. Heres a sample of my code to get an idea what I mean.

procedure Protection;
begin

WriteLn('Protecting Player...');
if DetectGas(GASX, GASY) then
begin
WriteLn('We have gas!');
playsound('C:\Simba\gump.wav');
runaway(RandomDirection, False, 1, RandomRange(2000,4000));
OreFinder; // THIS IS WHAT I WANT TO CALL!

end;

if FindNormalRandoms then
begin
playsound('C:\Simba\gump.wav');
end;

CustomAntiBan;
MiniBreaker;

end;


Function OreFinder : boolean;



// REST OF ORE FINDER FUNCTION WOULD BE BELOW: LEFT OUT DUE TO IT NOT BEING REQUIRED.


Thanks for any and all help. :)

KeepBotting

2014-06-20 15:51:32

As far as I know, placing it above the function is the only way.

rj

2014-06-20 16:37:25

Try putting

Function functionnamehere:boolean:foward;
At the top off all the functions and procedures

Kasi

2014-06-20 17:38:37

From: Robert
Try putting

Function functionnamehere:boolean:foward;
At the top off all the functions and procedures


Might wanna spell forward right when you do it though + use semicolon instead of colon?


program new;

function b : boolean; forward;

function a : boolean;
begin
Result := b;
end;

function b : boolean;
begin
Result := True;
end;

begin
Writeln(a);
end.

Cage

2014-06-20 17:42:59

Thanks guys that sorted it. Much appreciated.

The Mayor

2014-06-20 18:33:53

From: Robert
Try putting

Function functionnamehere:boolean:foward;
At the top off all the functions and procedures


Go back to school

rj

2014-06-20 20:41:16

From: The Mayor
Go back to school


Lol I'm on my phone cba to do spell check and simba tags

Nebula

2014-06-20 21:15:34

yea u use forward brah

Dervish

2014-06-20 21:16:23

Is there anything negative in using forward; ?

Edit :

Also why does there have to be this "hierarchy" in a script if the forward; exists ?

Kasi

2014-06-21 05:16:32

From: Dervish
Is there anything negative in using forward; ?

Edit :

Also why does there have to be this "hierarchy" in a script if the forward; exists ?


AFAIK there is nothing negative about it in PS; it does the job required. IMO it doesn't look the best.

Forward(/function prototyping) is generally used to tell the compiler that there is a function which has x return type with n parameters *in specifics*. It also specifies the parameter types. Forward exists during compilation so the program knows what function to use in simple terms.

kriss1993

2015-02-09 09:57:30

Oh shit that just saved me so much trouble ty guys

honeyhoney

2015-02-15 23:08:51

From: Dervish
Is there anything negative in using forward; ?


Using forward; is frowned upon by some developers. This is largely for code readability purposes.
forward; is akin to the goto in assembler languages and can result in some really really messy code.

So long as you're sensible you'll be fine.

I know some developers will aim to rewrite portions of code if the forward; becomes necessary.

The less tightly coupled your code is the better.