SRL Archive - Help

Getting Functions To Work?


groog

2010-08-05 00:32:02

I'm having trouble getting custom functions made. Here is an example function-


function findGTM(mon:Array of String);
begin
k := GetArrayLength(mon) - 1;
k := k/3;

if(findColor(x, y, strToInt(mon[0]), xs, ys, xe, ye))then
begin

...Some stuff

while(found)do
begin

....More stuff

if(i = k)then
begin
return true;
end;

...xxx

end else
begin
return false;
end;
end;
end;
end;

I obviously need it to return the value "true" or "false". But I get this error message-

[Error] (13:38): colon (':') expected at line 12
Compiling failed.


Being the first line-

function findGTM(mon:Array of String);

So what can I do to get my function working? Works A-OK as a procedure (without the returning bit of course).

Frement

2010-08-05 00:34:18

function findGTM(mon: TStringArray): Boolean;

TStringArray is Array of String.

i luffs yeww

2010-08-05 00:45:33

Also, s/return/Result/.

Frement

2010-08-05 00:48:10

From: i luffs yeww
Also, s/return/Result/.


Yeah that too.

Result := True;
or
Result := False;

groog

2010-08-05 00:54:06

I found the problem. While I used your advice I also needed to tell the function I was returning a boolean:

function findGTM(mon:TStringArray):boolean; 

Frement

2010-08-05 00:56:40

From: groog
I found the problem. While I used your advice I also needed to tell the function I was returning a boolean:

function findGTM(mon:TStringArray):boolean; 


I said that in my first post to this thread.

groog

2010-08-05 01:00:02

From: Frement
I said that in my first post to this thread.


Damnit! I didn't look at the code bit; I assumed it was a quote. Thanks though.

:duh:

i luffs yeww

2010-08-05 01:02:19

If you need more help, you can add me on MSN. [email]panic._@live.com[/email].