[Gambas-user] List al the classes and symbols

Martin mbelmonte at belmotek.net
Tue Jun 28 09:56:16 CEST 2022


El 27/6/22 a las 22:06, Benoit Minisini escribió:
> The syntax is not documented, because it's not a public API (I may have 
> to change it unexpectedly for something different or better).
> But it can easily be guessed.

I use this code for that:

Public Function GInfo() As Collection

   Dim sInfoPath As String = "/usr/share/gambas3/info"
   Dim sFile As String
   Dim sComponent As String
   Dim cData As New Collection
   Dim aParts As String[]
   Dim aRaw As String[]
   Dim aLines As New String[]
   Dim sClass As String
   Dim sClass2 As String
   Dim sClass3 As String
   Dim i As Integer
   Dim x As Integer
   Dim cProp As New Collection
   Dim cTmp As New Collection
   Dim sLine As String
   Dim aRaw2 As String[]
   Dim sRaw As String

   aFiles = Dir(sInfoPath, "*.info").Sort()

   For Each sFile In aFiles
     sComponent = Left(sFile, -5)
     aRaw = Split(File.Load(sInfoPath &/ sFile), "\n")
     For Each sLine In aRaw
       If Left(sLine) <> "'" Then
         aLines.Add(sLine)
       Endif
     Next
     sRaw = aLines.Join("\n")
     aRaw.Clear
     aParts = Split(sRaw, "#")
     For i = 0 To aParts.Max
       If aParts[i] <> "" Then
         aRaw2 = Split(aParts[i], "\n")
         aLines.Clear
         For Each sLine In aRaw2
           If Left(sLine) <> "'" Then
             aLines.Add(sLine)
           Endif
         Next
         sClass = aLines[0]
         sClass2 = aLines[1]
         sClass3 = aLines[2]
         For x = 3 To aLines.Max - 4 Step 4
           If aLines[x] <> "" Then
             cProp.Add(aLines[x], "Name")
             cProp.Add(aLines[x + 1], "Kind")
             cProp.Add(aLines[x + 2], "Type")
             cTmp.Add(cProp.Copy(), aLines[x])
             cProp.Clear
           Endif
         Next
         cData.Add(["Name": sClass, "Component": sComponent, "Symbols": 
cTmp.Copy()], sComponent & "#" & sClass)
         cTmp.Clear
       Endif
     Next

   Next

   Return cData

End

> But at the moment I don't know why listing all Gambas classes is needed 
> by Martin.

I can think of two ways, one is that the loaded components can be 
"unloaded" and the other is to make a program with minimal components 
that through an external list and an external log also, load a single 
component each time it is executed and then finished, cron or another 
gambas program can run the script every so often.
I'm going to try the second idea.
Martin.



More information about the User mailing list