Pascal syntax error

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 a program, I get this error:

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

What am I doing wrong?

0
pascal
source share
3 answers

Your Pascal flavor may not support the traditional return value syntax. Try Result := … instead of Getrand := …

+5
source share

you can use

 Exit(Random(diff) + rStart) 

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

+3
source share

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

+2
source share

All Articles