Return Result

Parent Previous Next

Return Result.

If a function is defined to return a result, you use the keyword Return as presented here:


 Function Foo() : Integer

 {

   Return 10;

 }


It is your responsibility as the programmer to ensure that the function will always return a value for every logical path of the code. The compiler will not discover this, but the VM execution will report a runtime error in case of a missing return value.


When a function returns a value, it is okay to ignore the value.


 Function Foo1() : Integer

 {

   Return 10;

 }


 Function Foo2()

 {

   Integer i := Foo1();

   Foo1(); //This is okay. The returned result is ignored.

   Foo3();

 }


 Function Foo3() : Integer

 {

   If False Then { Return 0; } //This path never returns a value. A runtime error will occur!

 }