Page 1 of 1
Access to global MAP into module [Resolved]
Posted: Sat Jan 03, 2026 8:03 pm
by Kwai chang caine
Hello at all
Is it possible to access to the global MAP created in the main code ?
Code: Select all
Global NewMap MyMap()
DeclareModule Module1
Declare.s Function(Text.s)
EndDeclareModule
Module Module1
Procedure.s Function(Text.s)
ProcedureReturn Text
EndProcedure
MyMap("Module1") = @Function() ; <==== Can't access to the global MAP
EndModule
Debug Module1::Function("Hello")
Repeat : Delay(1) :Until GetAsyncKeyState_(#VK_ESCAPE)
Have a good day
Re: Access to global MAP into module
Posted: Sat Jan 03, 2026 8:18 pm
by mk-soft
Create an Common Module
Code: Select all
;-TOP
DeclareModule Common
Global NewMap MyMap()
EndDeclareModule
Module Common
EndModule
DeclareModule Module1
Declare.s Function(Text.s)
EndDeclareModule
Module Module1
UseModule Common
Procedure.s Function(Text.s)
ProcedureReturn Text
EndProcedure
MyMap("Module1") = @Function() ; <==== Can't access to the global MAP
EndModule
Debug Module1::Function("Hello")
; Public Common to MainScope
UseModule Common
;Repeat : Delay(1) :Until GetAsyncKeyState_(#VK_ESCAPE)
Re: Access to global MAP into module
Posted: Sat Jan 03, 2026 8:26 pm
by Kwai chang caine
Thanks a lot MASTER...that works ..
"Normal", like always... you can say to me
Well... Fred, who always takes the easy way out, didn't take the easy way out this time.
I would never have figured it out on my own
Again thanks

Re: Access to global MAP into module [Resolved]
Posted: Sat Jan 03, 2026 8:29 pm
by Little John
Kwai chang caine wrote: Sat Jan 03, 2026 8:03 pm
Is it possible to access to the global MAP created in the main code ?
Accessing a global map in the main code from inside a module would contradict the purpose and intent of modules.
Re: Access to global MAP into module [Resolved]
Posted: Sat Jan 03, 2026 8:33 pm
by mk-soft
Or also because of your question CallFunctionFast...
Code: Select all
;-TOP
DeclareModule Common
Global NewMap MyMap()
EndDeclareModule
Module Common
EndModule
DeclareModule Module1
Declare Function(*Text)
EndDeclareModule
Module Module1
UseModule Common
Procedure Function(*Text)
ProcedureReturn *Text
EndProcedure
MyMap(#PB_Compiler_Module + ".Function") = @Function() ; <==== Can't access to the global MAP
EndModule
; Public Common to MainScope
UseModule Common
*ptr = CallFunctionFast(MyMap("Module1.Function"), @"Hello")
If *ptr
Debug PeekS(*ptr)
EndIf
;Repeat : Delay(1) :Until GetAsyncKeyState_(#VK_ESCAPE)
Re: Access to global MAP into module [Resolved]
Posted: Sat Jan 03, 2026 9:20 pm
by Kwai chang caine
Yes you have guessed ...too strong
After becoming a grand master of PB, you also become a fortune teller.
Thanks a lot MASTER have a good night