What is forward and how is it used? Eg:
SCAR Code:procedure Moo; forward;
procedure Meow;
begin
WriteLn('Meow!');
end;
In the example what would the forward do?![]()
What is forward and how is it used? Eg:
SCAR Code:procedure Moo; forward;
procedure Meow;
begin
WriteLn('Meow!');
end;
In the example what would the forward do?![]()
Ok this is how i understand it:
Let say you have
So you'll need this:SCAR Code:procedure eh;
begin
case randomnumber(1, 2) of
1: bafa;
2: blah;
end;
end;
but in your actual script the function "randomnumber" is below the procedure in which you wish to call it in. So you'll have to forward it:SCAR Code:function randomnumber(min, max: integer): integer;
begin
result := random(max)+1;
end;
make sence?SCAR Code:program new;
function randomnumber(min, max: integer); forward;
procedure eh;
begin
case randomnumber(1, 2) of
1: bafa;
2: blah;
end;
end;
function randomnumber(min, max: integer): integer;
begin
result := random(max)+1;
end;
And in that example it would do jack haha
Ok thanks that makes sense I just don't see why you don't put the function before the procedure but otherwise thanks![]()
If you need it after because you use the one above, it would be impossible to do with just two.
So that is why you use forward. I'll write up an example in a second.
SCAR Code:program New;
procedure Test2; forward;
procedure Test1;
begin
end;
procedure Test2;
begin
Test1;
end;
begin
Test1;
end.
Delete the forward line and see what happens.
Last edited by Da 0wner; 07-16-2009 at 04:15 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)