Android Question Order of executed commands

Mentalist

Member
Licensed User
Longtime User
Hello,

I'm an absolute beginner in this language.
Why is 'yes' or 'no' displayed first and then the first message box with the time?

Sorry, if this has been asaked before.

Thanks!

B4X:
Sub Button1_Click
    Dim FTP As FTP
    Dim ctm As CustomTrustManager
    
    DateTime.DateFormat = "dd-MM-yyyy"
    MsgboxAsync(DateTime.Date(DateTime.now),"")
    FTP.Initialize("ftp", "ftp.server.com", 21, "user", "password")

    If FTP.IsInitialized=True Then'
        MsgboxAsync("yes","")
    else if FTP.IsInitialized=False Then
        MsgboxAsync("no","")
    End If
    FTP.Close
End Sub
 

drgottjr

Expert
Licensed User
Longtime User
async means not coordinated in time. ie, it happens when it happens. one command may be
issued before another, but the results of either - if asynch - may not come back in the same order.

if you want the date to appear first, you need to "wait for" it. the issue has more to do with an
understanding of android and modern applications than to a given programming language.
many operations in android are asychronous in nature. you cannot assume you will have the
result before moving on to the next operation.

B4X:
DateTime.DateFormat = "dd-MM-yyyy"
MsgboxAsync(DateTime.Date(DateTime.now),"")
wait for msgbox_result(result As Int)
FTP.Initialize("ftp", "ftp.server.com", 21, "user", "password")
 
Upvote 0
Top