Author Topic: Problems : sub/function return - multiple definitions of same procedures names  (Read 1292 times)

0 Members and 1 Guest are viewing this topic.

Laurent

  • Guest
Code: [Select]
Hi,

My finds of the day :

1/ ftests returns integer but returning a string doesn't throw an error, the result is zero
2/ stests should return nothing as it's a sub but no problem for returning 98
3/ stests without a return instruction returns a random ? value. "Print  stests" should throw an error
4/ stests and ftests are defined twice without any problem

[code=]Function ftests As integer
   Print "inside ftests"
   return "inside ftests"
End Function

Print ftests

Sub stests
   Print "inside stests"
   return 98
End Sub

Function ftests As integer
   Print "inside ftests"
   return 99
End Function

Print stests+" "+ftests

Sub stests
   Print "inside stests"
End Sub

Print stests

Charles Pegge

  • Guest
Thanks, Laurent.

There is very little difference between functions, subs and methods in terms of being able to return values, or not. This is by design.

As with variables, they can also be overridden or overloaded, including most of the core functions.