0

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?

2
  • 1
    And this brings back memories from ages past. When last hav a seen some pascal code X-) Commented Feb 11, 2011 at 5:41
  • @Marcelo this line: Getrand := Random(diff) + rStart; Commented Feb 11, 2011 at 5:42

3 Answers 3

5

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

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.