[Gambas-user] Question on Class.Load

Fabien Bodard gambas.fr at ...626...
Sun Nov 2 09:30:47 CET 2014


Just one question ... have you exported those classes ?

tmpClass is just a class ... not an instanciate object

You need to call Object.New

Or just new


Public Sub Main()
Dim hObj As Object
Dim sSym As String
For Each sSym In Classes["MyClass"].Symbols
  Print sSym
Next

hObj = Object.New("MyClass")

Object.Call(hObj, "CreateFile", ["Hi World"])

End

2014-11-02 5:01 GMT+01:00 Ian <ian.roper at ...1974...>:
> Class.Load allows you to create a reference to a named class.
>
> Dim TempClass as Class
> TmpClass = Class.Load("myclass")
>
> This works and I can get the names of the public instances of variables
> and procedures
>
> For each TmpString in TmpClass.Symbols
> Message(TmpString)
> Next
>
> Is there a way to call a Procedure or Function from the named class and
> pass it any parameters that it requires?
>
> ie: if I have a procedure in a valid class I have created called Public
> Sub DoSomething(InStr as string)
> can I call this function from TmpClass somehow
> (or is this just a 'read only' reference to the loaded class?)
>
>
> I tried Object.Call(TmpClass, "NameOfProcedure", TmpAry)
> with TmpAry[] containing the name of a single string parameter I wish to
> pass.
> This returns the error: "Can't find {NameOfProcedure} in Class 'Class'
>
> Context: In each of my projects created classes, I have a standard
> Procedure to save the applicable database table records to a binary file
> called CreateBinaryFile(InPath as String)
> This is the process I am trying to call for each class that I have created.
>
>
> Cheers,
> Ian Roper.
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user



-- 
Fabien Bodard




More information about the User mailing list