After trying several methods to extend some classes like 'String' or 'File' I found a simple way to do it.
I'm going to do the example adding the function 'Words' to the class 'String'.
The first step is to create a class called 'String' in the current project, that is String.class, then inside this file:
' Gambas class file
Export
Static Public Function Words(s As String) As Integer
Dim int As Integer
Dim aString As New String[]
s = String.Trim(s)
If InStr(s, " ") > 0 Then
aString = Split(s, " ")
int = aString.Count
Else
If Len(s) > 0 Then
int = 1
Endif
Endif
Return int
End
Regards