Log in

View Full Version : Getting Functions To Work?



groog
08-05-2010, 04:32 AM
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
08-05-2010, 04:34 AM
function findGTM(mon: TStringArray): Boolean;

TStringArray is Array of String.

i luffs yeww
08-05-2010, 04:45 AM
Also, s/return/Result/.

Frement
08-05-2010, 04:48 AM
Also, s/return/Result/.

Yeah that too.

Result := True;
or
Result := False;

groog
08-05-2010, 04:54 AM
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
08-05-2010, 04:56 AM
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
08-05-2010, 05:00 AM
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
08-05-2010, 05:02 AM
If you need more help, you can add me on MSN. panic._@live.com.