Just starting out? Need help? Post your questions and find answers here.
es_91
 
Posts: 32
Joined: Sat Aug 29, 2015 10:25 pm

How to address a function from a different namespace ?

by es_91 Fri Apr 20, 2018 3:00 pm

Hi.

The typical way to address a function in BindEvent () context is to write @functionname ().

Shall a function from a different namespace, say a module, be addressed, this does not work.
The syntax @module::functionname () is simply not valid.

Likewise writing module::functionname () won't return a valid pointer to that function.

What can i do ?
es_91
 
Posts: 32
Joined: Sat Aug 29, 2015 10:25 pm

Re: How to address a function from a different namespace ?

by es_91 Fri Apr 20, 2018 3:28 pm

Code: Select all
DeclareModule first
   
   Declare function ()
   
EndDeclareModule

DeclareModule second
   
   Declare init ()
   
EndDeclareModule

second::init ()

Module first
   
   Procedure function ()
      
      debug 1
      
   EndProcedure
   
EndModule

Module second
   
   Procedure init ()
      
      bg = OpenWindow (#PB_Any, 0, 0, 0, 0, "", #PB_Window_Background)
      
      BindEvent (#PB_Event_SizeWindow, first::function (), bg) ; TODO: doesn't work !!!
      
   EndProcedure
   
EndModule
User avatar
Peter
 
Posts: 497
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: How to address a function from a different namespace ?

by Peter Fri Apr 20, 2018 3:49 pm

Hello es_91,

put the '@' - sign in front of the functionname:

Code: Select all
BindEvent (#PB_Event_SizeWindow, first::@function(), bg)


Greetings ... Peter
es_91
 
Posts: 32
Joined: Sat Aug 29, 2015 10:25 pm

Re: How to address a function from a different namespace ?

by es_91 Sat Apr 21, 2018 7:23 am

oh dear!

Thank you so much. 8-)
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 2 guests