Accessing Subs from another Activity

WZSun

Member
Licensed User
Longtime User
Hi,
This may sounds simple for the experienced ones...

How do I access a function/subroutine from another Activity?

For example, I have a sub called GetJulianDate in "Page1" activity. Let's say I need to access the same GetJulianDate statement in current "Page5". How do I call the GetJulianDate that is in "Page1"?

I tried calling GetJulianDate in Page5 but it doesn't work. It doesn't recognise there was a GetJulianDate in Page1. If i inserted identical GetJulianDate sub in Page5, then it works. But this creates duplicated subs in all activities.

Thanks!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You cannot access subs of other activities. The reason is that while one activity is active the other activities are paused and can be even destroyed. Accessing code of a destroyed activity will fail.
A static code module will probably be available in the next version and will allow sharing code.
 
Upvote 0

WZSun

Member
Licensed User
Longtime User
Hi Erel,
Thanks for adding that into the static code module.. that'd save lots of duplicated subs.

Rgds
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…