Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: Clyde on May 02, 2006
-
Anyone know what the difference between using a sub or function with or without Private before it is used for please? And Is there any benefit with using it?
For example:
Sub ( ByVal x As Integer, ByVal y As Integer, ByVal c as Integer )
'Dummy Sub
End Sub
Or:
Private Sub ( ByVal x As Integer, ByVal y As Integer, ByVal c as Integer )
'Dummy Sub
End Sub
Cheers and many thanks,
Clyde.
-
Syntax
PRIVATE sub/function name
Description
Explicitly sets an individual sub/function to be private (instead of PUBLIC by default). This means the sub/function is only accessible within the module and is hidden to other modules. This means two subs/functions can have the same name, as long as they are private and are in seperate modules.
Subs/functions are private by default if the command OPTION PRIVATE is used, otherwise they are public by default.
If you have coded 2 librarys (*.bi) and if they use same name for one function/sub you can make those functions private for each separated module (.bi file).
And Is there any benefit with using it?
Maybe, but I never used it until today :(
-
So it's like having a local subroutine / function for seperate includes, so it cant be used by other source listings that are shared.
Cheers Rbraz.