Access to global MAP into module [Resolved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5596
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Access to global MAP into module [Resolved]

Post 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
Last edited by Kwai chang caine on Sat Jan 03, 2026 8:26 pm, edited 1 time in total.
ImageThe happiness is a road...
Not a destination
User avatar
mk-soft
Always Here
Always Here
Posts: 6473
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Access to global MAP into module

Post 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)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5596
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Access to global MAP into module

Post by Kwai chang caine »

Thanks a lot MASTER...that works .. 8)
"Normal", like always... you can say to me :lol:

Well... Fred, who always takes the easy way out, didn't take the easy way out this time. :shock:
I would never have figured it out on my own :oops:
Again thanks 8)
ImageThe happiness is a road...
Not a destination
Little John
Addict
Addict
Posts: 4823
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Access to global MAP into module [Resolved]

Post 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.
User avatar
mk-soft
Always Here
Always Here
Posts: 6473
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Access to global MAP into module [Resolved]

Post 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)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5596
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Access to global MAP into module [Resolved]

Post by Kwai chang caine »

Yes you have guessed ...too strong 8)

After becoming a grand master of PB, you also become a fortune teller.

Image

Thanks a lot MASTER have a good night
ImageThe happiness is a road...
Not a destination
Post Reply