[Gambas-user] How to extend the String[] class ??

Martín mbelmonte at belmotek.net
Fri Nov 24 16:28:51 CET 2023


El 23/11/23 a las 14:02, Benoît Minisini escribió:
> You can't create a class in the IDE with the "[]" characters in the 
> name, so you can't extend the "String[]" class. 

ok, I understand.

So I try to extend the Class "Array" but String[] didn't "see" the new 
property. String[] inherits Array class right?

Export

Property Filled As Boolean
Private bFilled As Boolean

Private Function Filled_Read() As Boolean

   Return bFilled

End

Private Sub Filled_Write(Value As Boolean)

   Dim v As Variant
   Dim s As String
   Dim a As String[]
   Dim ai As Integer[]
   Dim i As Integer

   bFilled = Value

   If bFilled Then
     Select Object.Type(Me)
       Case "String[]"
         For Each v In Me
           If v <> "" Then
             a.Add()
           Endif
         Next
         Me.Clear
         For Each s In a
           Me.Add(s)
         Next

       Case "Integer[]"
         For Each v In Me
           If v <> 0 Then
             ai.Add()
           Endif
         Next
         Me.Clear
         For Each i In ai
           Me.Add(i)
         Next
     End Select
   Endif

End



More information about the User mailing list