Public Sub Main()
Dim sRow As String
Dim c As Class
Component.Load("gb.util")
If Exist(".../.project") Then
For Each sRow In Split(File.Load(".../.project"), gb.NewLine)
If sRow Begins "Component" Then
Print "============="
Print Mid(sRow, 11);; ":"
Print "============="
For Each c In Classes
Print c.Name
Next
Endif
Next
Endif
EndIntendi qualcosa del genere?No, perché - al di là del Componente presente o comunque richiamato - la lunga lista dei simboli resta invariata.
For Each c In ClassesPublic Sub Form_Open()
Dim c As Class
c = Class.Load("Image")
Print c.Component.Name
Endmostrando numerosissimi simboli.Si può ottenere una gran massa di simboli, anche penetrando in alcune Strutture costitutive dei sorgenti di Gambas:
Public Sub Form_Open()
Dim cp As Component
Dim p1, p2, p3, p4 As Pointer
Dim s As String
cp = Component.Load("gb.image")
p1 = Object.Address(cp)
' Accedo alla Struttura "_CLASS" dichiarata nel file header "gbx_class.h":
p2 = Pointer@(p1)
' Mi dice che l'identificatore "cp" si riferisce a un Componente:
Print String@(Pointer@(p2 + 24))
' Accedo alla Struttura "CLASS_DESC_SYMBOL",dichiarata nel file header "gbx_class_desc.h" e puntata dal membro "*table" della Struttura "_CLASS":
p3 = Pointer@(p2 + 40)
For i As Integer = 0 To 8191
' Legge all'interno della Struttura "CLASS_DESC_SYMBOL":
s = String@(Pointer@(p3 + i))
If Not IsNull(s) Then
If IsAlnum(s) Or (s Begins "_") Then Print i & " " & s
Endif
Next
EndFor Each c In Classes
Print c.Name
NextQualcosa del genere allegato?Qualora vengano caricati manualmente o automaticamente (per dipendenza) due o più Componenti Gambas, il tuo codice non riesce ancora precisamente ad assegnare a ciascun Componente caricato le rispettive Classi, ma comunque le individua.
Public Sub Main()
Dim simboli As String[] = ["Main", "Debug", "^System", "Highlight", "Expression", "Pointer[]", "Long[]", "Object[]",
"Date[]", "Single[]", "Float[]", "Integer[]", "Short[]", "Byte[]", "Boolean[]", ".Array.Bounds",
"Observer", "Timer", "Task", "_BoxedString", "String", "Jit", "User", "System",
"Process", "Application", "Args", "Env", "File", "Stat", "Stat.Perm", ".Stream.Term",
".Stream.Lines", "Error", "Collection", "Object", "Components", "Classes", "Array", "String[]",
".Symbol", "Enum", "Variant[]", "Param", "gb", "Stream", "Component", "Class"]
Dim cp As Component
Dim c As Class
Dim b As Byte
' Carica il Componente:
cp = Component.Load("gb.sdl2.audio")
Print String(Len(cp.Name), "=\e[1m")
Print cp.Name
Print String(Len(cp.Name), "\e[0m=")
For Each c In Classes
If (Not simboli.Exist(c.name)) And (Left(c.name, 1) <> ".") Then
Inc b
If Left(c.name, 1) = "^" Then
Print b;; Right(c.Name, Len(c.Name) - 1)
Else
Print b;; c.Name
Endif
Endif
Next
End
Concludo comunque complimentandomi con te: bravo ! :ok:
Try aComponent = Split(File.Load(sPath &/ sComp &/ ".list"), gb.NewLine)
If Error Then
Print "Componente no Gambas\n"
Continue
EndifSi può ottenere una gran massa di simboli, anche penetrando in alcune Strutture costitutive dei sorgenti di Gambas:Solo per mera curiosità accademica, modificando opportunamente il mio primo codice, è possibile ottenere, sebbene in modo apparentemente confuso: i simboli inseriti nel codice, nonché le Classi e le loro specifiche risorse appartenenti al Componente impostato.
Public Sub Main()
Dim cp As Component
Dim p1, p2, p3 As Pointer
Dim s As String
Dim c As Class
Dim b As Byte
cp = Component.Load("gb.sdl2.audio") ' Il Componente Gambas in questo esempio prescelto per la ricerca delle sua risorse
p1 = Object.Address(cp)
' Accede alla Struttura "_CLASS" dichiarata nel file header "gbx_class.h":
p2 = Pointer@(p1)
' Dichiara che l'identificatore "cp" si riferisce a un "Componente":
Print String@(Pointer@(p2 + (SizeOf(gb.Pointer) * 3)))
' Accede alla Struttura "CLASS_DESC_SYMBOL",dichiarata nel file header "gbx_class_desc.h" e puntata dal membro "*table" della Struttura "_CLASS":
p3 = Pointer@(p2 + (SizeOf(gb.Pointer) * 5))
For i As Integer = 0 To 50000000
' Legge all'interno della Struttura "CLASS_DESC_SYMBOL":
s = String@(Pointer@(p3 + i))
If IsAlnum(s) Then
Select Case b
Case 0
If s = "Main" Then
b = 1
Endif
Case 1
If s <> "Main" Then
Print s
b = 2
Else
b = 1
Endif
Case 2
If s <> "Main" Then
Print s
Else
b = 1
Endif
End Select
Endif
Next
Finally
End