Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Returning a value in Pascal

For a function to return a value in Pascal the assignment FunctionName := SomeVal; is used. I assume it doesn't stop the function execution in that exact place as return in C does. Is there something similar to C return in Pascal? (I'm using FreePascal compiler)

like image 349
Clueless Avatar asked Mar 09 '12 22:03

Clueless


1 Answers

You can use the Exit procedure.

function Foo (Value : integer) : Integer;
begin      
  Exit(Value*2);
  DoSomethingElse();   // This will never execute
end; 
like image 53
RRUZ Avatar answered Oct 08 '22 20:10

RRUZ