开发者

Pascal Syntax Error

开发者 https://www.devze.com 2023-02-10 08:46 出处:网络
I have the following function in my program:开发者_开发百科 function Getrand(rStart,rEnd:Integer): Integer;

I have the following function in my program:开发者_开发百科

function Getrand(rStart,rEnd:Integer): Integer;
var
diff: Integer;

begin
diff := rEnd - rStart;

Getrand := Random(diff) + rStart;
end;

When I try to compile the program, I get this error:

Failed when compiling
Line 27: [Error] (27:9): Invalid number of parameters in script 

What am I doing wrong?


Perhaps your flavour of Pascal doesn't support the traditional return value syntax. Try Result := … instead of Getrand := ….


you can use

Exit(Random(diff) + rStart)

instead. But keep in mind that if you do that it will exit from function after returning the value.


You need to write Getrand(Random(diff),rStart); to send variables to function

0

精彩评论

暂无评论...
验证码 换一张
取 消