[Gambas-user] How to call a function in a startup loaded module from a plugin loaded at runtime?

Brian G brian at westwoodsvcs.com
Mon May 25 07:33:54 CEST 2020



(inline) 



OK! A couple of points: 
1) In you main project the classes you want visible in the plugin must 
be exported and 




I understand these things 


BQ_BEGIN


2) (Obviously) the methods you want to expose to the plugin must be public. 

BQ_END

I understand this too. 

BQ_BEGIN



Here's what I think you are trying: 
MAIN PROGRAM "Main" module 

BQ_END


I am trying to access data and structures 


BQ_BEGIN


-------------------------- 
' Gambas module file 

Export 

BQ_END


'these are what I am trying to figure out how to access from the plugin 

Public struct aaa ' this I have no idea how to reference 
bbb as string 
ccc as integer 
end struct 

Public SymTable as collection ' this I can get thru a getSymTable() function i can add 

BQ_BEGIN


Public Sub Main() 

Dim hXXX As Object 

Component.Load("ph.plugin") 
' Print Class.IsLoaded("PluginA") 

hXXX = Object.New("PluginA") 

Catch 
Error Subst("&1\nERR: &2 (&3)\n&4\n&1\n", String$(40, "-"), 
Error.Text, Error.Code, Error.Backtrace.Join("\n")) 

End 

Public Function Addup(...) As Integer 
Dim iTot As Integer = 0 
For each idx As Integer in param 
iTot += idx 
Next 
Return iTot 
End 

PLUGIN COMPONENT "PluginA" class 
-------------------------------- 
' Gambas class file 

Export 

Public Sub _new() 

Dim cxx As Class = classes["Main"] 
Print object.call(cxx, "Addup", [1, 5, 2, 5, 9]) 

End 

b 

----[ [ http://gambaswiki.org/wiki/doc/netiquette | http://gambaswiki.org/wiki/doc/netiquette ] ]---- 

BQ_END

Do you have any thoughts on this part of problem 

----[ http://gambaswiki.org/wiki/doc/netiquette ]---- 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200524/990b1ac6/attachment.html>


More information about the User mailing list