Android Question Using Msgbox2Async to replace Msgbox2 [Solved]

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

I have struck a problem converting from Msgbox2 to Msgbox2Async.

In the two subs below what is supposed to happen when a list item is "clicked" [Sub"FNumView_ItemClick"] SUB"CheckSelectionPGM" is called to check if this item has an existing function. If it has, Msgbox2(Async) gives the user 3 choices and FLAGS are set. These FLAGS are then used by SUB"Formula_click".

It appears that with Msgbox2Async the program continues to SUB"Formula_click" without waiting for the user response to correctly set the FLAGS. [Asynchronous behaviour?]

A question in two parts:
Is my reading of the problem correct?
How do I get the program flow to wait for the user response. to set the flags? I thought this line already did this. "Wait For Msgbox_Result (Result As Int)"


Regards Roger


Msgbox2Async:
Sub FNumView_ItemClick (Position As Int, Value As Object)
'Completes/Saves the selection of F0-F15 to be the assigned function.
'Returns to Formula_click
    FNum = Position
    FNumV = "F"&FNum
    FNum_flag = 1
    ListFlag = 0
    
    FNumView.SingleLineLayout.Label.RemoveView
    FNumView.RemoveView                        'Exit ListView.   
    lblTitle.SendToBack
    ListBack.SendToBack
    listclear.SendToBack
        
        'Check if existing function.  Bring up options
    CheckSelectionPGM
Log("FNumView_ItemClick EditPGMflag = "&EditPGMflag)                                    'This shows the flag as not set.
    Formula_click
End Sub

Sub CheckSelectionPGM
'Check if chosen Fnn is already programmed.  Called by CheckSelectionPGM
    'Private Response As String
    NotAFunction_flag = 1
    FNum_flag = 1
    EditPGMflag = False
    
    For Each v As View In Activity.GetAllViewsRecursive
        If v Is Label Then
            Private lbl As Label = v
            If lbl.Tag = FNumV And lbl.TextColor = lblMOD.TextColor Then   
                NotAFunction_flag = 0
                Exit
               End If
        End If
    Next
    If NotAFunction_flag = 0 Then
        Msgbox2Async("","Existing Function","Overwrite?","Delete?","Edit?",Null,False)       
        Wait For Msgbox_Result (Result As Int)
        
        If Result = DialogResponse.CANCEL Then                                        'DELETE selected
            EditPGMflag = False       
            Idisplay.Text = ""
            For Each v As View In Activity.GetAllViewsRecursive
                If v Is Label Then
                Private lbl As Label = v
                    If lbl.Tag = FNumV Then
                        lbl.Text = "F" & FNum
                        lbl.TextColor = Colors.Gray
                        Rdisplay.Text = 0
                        dummytext.RequestFocus
                        kb.HideKeyboard
                        RFocus = 0
                        FMask.SendToBack
                        BtnFLabel.SendToBack
                        FNum_flag = 0
                        For j = 0 To 999                                    'Clean "Recording" array for FNum
                            For M = 0 To 1
                                Recording(FNum,j,M) = ""
                            Next
                        Next
                        RstrFromStandardSettings
                        'Return
                    End If
                End If
            Next   
        Else if Result = DialogResponse.NEGATIVE Then           'EDIT selected
            FLabel_flag = 1
            EditPGMflag = True
Log("EDIT EditPGMflag = "&EditPGMflag)                                   'This shows the flags are set here
        End If
    End If
End Sub
 
Top