帕斯卡语法错误
我的程序中有以下函数:
function Getrand(rStart,rEnd:Integer): Integer;
var
diff: Integer;
begin
diff := rEnd - rStart;
Getrand := Random(diff) + rStart;
end;
当我尝试编译程序时,出现此错误:
Failed when compiling
Line 27: [Error] (27:9): Invalid number of parameters in script
我做错了什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许您的 Pascal 风格不支持传统的返回值语法。尝试使用
Result := ...
而不是Getrand := ...
。Perhaps your flavour of Pascal doesn't support the traditional return value syntax. Try
Result := …
instead ofGetrand := …
.你可以用
它代替。但请记住,如果这样做,它将在返回值后退出函数。
you can use
instead. But keep in mind that if you do that it will exit from function after returning the value.
你需要写 Getrand(Random(diff),rStart);将变量发送到函数
You need to write Getrand(Random(diff),rStart); to send variables to function