iOS Question Calling routine in Page that has not been shown needs delay?

Robert Valentino

Well-Known Member
Licensed User
Longtime User
NOTE: My page is created using:
B4X:
            B4XPages.AddPageAndCreate(cBBsGlobals.DEFINE_PageName_UserPreferences,     mUserPreferences)

In B4A I do the following routine
B4X:
#Region Preferences_Click
Private Sub sReports_Options_Preferences_Click
            Dim Preferences As pUserPreferences = B4XPages.GetPage(cBBsGlobals.DEFINE_PageName_UserPreferences)
           
            If  Preferences.IsInitialized Then   
                B4XPages.ShowPage(cBBsGlobals.DEFINE_PageName_UserPreferences)
               
#if B4i               
                Sleep(125)
#end if               
               
                Preferences.Show_Preferences("PDF Print")                           
            End If
End Sub
#end Region

In B4i I needed to add a delay otherwise I crash (don't need delay in B4A)

I tried doing
B4X:
CallSubDelayed2(Preferences, "Show_Preferences", "PDF Print")

But without the Sleep delay still crashed.

Is the delay a B4I requirement?
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
I don't have B4I but...

- I don't think you don't have to do anything special in B4I with B4XPages than you do in B4A
- CallSubDelayed requires TWO parameters, not THREE (the component and the name of the sub)
- Declare your pages in B4XMainPage As public, so you don't need this stuff:
Dim Preferences As pUserPreferences = B4XPages.GetPage(cBBsGlobals.DEFINE_PageName_UserPreferences)
If Preferences.IsInitialized Then
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Sorry type-O on the CallSubDelayed (typed that online)

I've tried it different ways. If I've been to the page before it doesn't need the delay, but if I haven't and call it from another page (maybe the setup takes a while)

Just looked they are declared as public (will make the changes to call directly)
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Maybe the creation (B4XPage_Created) takes some time (but with both b4a and b4i).
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Just looked they are declared as public (will make the changes to call directly)
You can still call the methods indirectly (but also directly, of course) but you can write:
B4X:
CallSubDelayed(B4XPages.MainPage.mUserPreferences, "Show_Preferences")
rather than:
B4X:
Dim Preferences As pUserPreferences = B4XPages.GetPage(cBBsGlobals.DEFINE_PageName_UserPreferences)
CallSubDelayed2(Preferences, "Show_Preferences")

You could also create a "short" and specific code module, "enPages", like:
enPages - code module:
Public Const UserPref As String = "UserPreferences"
Public Const PageTwo As String = "PageTwo"
'...
instead of:
cBBsGlobals.DEFINE_PageName_UserPreferences
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…