Getting into something that is over my brain power I think!  In the Detail Module I am downloading some detail transactions and when a new one is downloaded,  I need to do one of two choices that comes from the ChoiceBox.  So I need to wait until one of the two choices or a cancel has been selected before I continue processing.  I need to know if I can base a wait on a Choicebox (cBox) and if so,  where can I find a example. This involves two B4XTables ( a master and a detail).  Also,  am I missing a resource on 'wait for'?   I really have looked and found some information but it all seemed to be referencing jobs rather than standard controls (other than a message box)
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			
			
				B4X:
			
		
		
		'Module Main
Sub B4XTableM_CellLongClicked (ColumnId As String, RowId As Long)
    SelectedVisibleRowID  = B4XTableM.VisibleRowIDs.IndexOf(RowId)
    SelectedRowDataM = B4XTableM.GetRow(RowId)
    Dim SelectedAccount As String = B4XTableM.GetRow(RowId).Get(ColumnId)
    SelectedRow=RowId
    SelectedCol=ColumnId
    cBox.Items.Clear
    cBox.Top = SelectedVisibleRowID * 24.8+120'100
    cBox.Left=210'220'250
    cBox.items.AddAll(Array As String("Go Online", "History", "Calc_bal","Assign transaction to this account","Add New Account and assign transaction"))
    cBox.ShowChoices
    cBox.PrefHeight=B4XTableM.RowHeight
    cBox.Visible=True
End Sub
Sub cBox_SelectedIndexChanged(Index As Int, Value As Object)
    If Index = -1 Then Return
    Log(Index & "  -  " & Value)
    Select Value
        Case "Go Online" 
            fx.ShowExternalDocument(SelectedRowDataM.Get("URL"))
        Case "History"
            Log("test")
            Dim acct As String = SelectedRowDataM.GetValueAt(0)
            Detail.Show(acct)
        Case "Calc_bal"
            CalcBal
        Case "Assign transaction to this account" 
            Log("Assign transaction to this account  - " & Index & " -  " & Value)
        Case "Add new account and assign transaction"
            Log("Add New Account and assign transaction  -  " & Index & " -  " & Value)
        Case Else
    End Select
    cBox.Visible=False
End Sub
			
				B4X:
			
		
		
		'Module Detail
Sub ImportTransactions
    Dim qfxToLoad As String =Main.CashflowINI.get("BankAccountFileName") '"checking1"'todo get this from lost of qfx files
    Dim qfxFile As TextReader
    qfxFile.Initialize(File.OpenInput(Main.dirDownloads, qfxToLoad & ".qfx") )
    qfxData = qfxFile.ReadAll
    Dim ORG As String = ParseQFX(Array As String("/SONRS","/FI","ORG"))
    Dim FID As String = ParseQFX(Array As String("/SONRS","/FI","FID"))
    Dim INTU_BID As String = ParseQFX(Array As String("/SONRS","INTU.BID"))
    Dim INTU_USERID As String = ParseQFX(Array As String("/SONRS","INTU.USERID"))
    Dim BANKID As String = ParseQFX(Array As String("/BANKACCTFROM","BANKID"))
    Dim ACCTID As String = ParseQFX(Array As String("/BANKACCTFROM","ACCTID"))
    Dim DTSTART As String = ParseQFX(Array As String("DTSTART"))
    Dim DTEND As String = ParseQFX(Array As String("DTEND"))
    Dim BALAMT_L As String = ParseQFX(Array As String("/LEDGERBAL","BALAMT"))
    Dim BALAMT_A As String = ParseQFX(Array As String("/AVAILBAL","BALAMT"))
    Dim DTASOF_L As String = ParseQFX(Array As String("/LEDGERBAL","DTASOF"))
    Dim DTASOF_A As String = ParseQFX(Array As String("/AVAILBAL","DTASOF"))
    Dim sI As Int = 1
    Dim bI, eI, LineCount As Int
    Dim eT As Int
    Do While sI=sI
        Dim QD() As String  = Array As String("<STMTTRN><TRNTYPE>","<DTPOSTED>","<TRNAMT>","<FITID>","CHECKNUM>","<NAME>","<MEMO>")
        'some code here to assign values the array QD() to be used in the INSERT command
        If QD(0)="" Then
            Exit
        End If
        Dim rs As ResultSet = B4XTableD.sql1.ExecQuery("Select c4 FROM data WHERE c4 = '" & QD(3) & "'")   
        If rs.NextRow =False Then ' it is not a duplicate transaction that has already been added
            Dim params As List = Array(QD(0), QD(1), QD(2), QD(3), QD(4), QD(5), QD(6))
            B4XTableD.sql1.ExecNonQuery2($"INSERT INTO data VALUES("D", ?, ?, ?, ?, ?, ?, ?)"$,params)
            B4XTableD.Refresh
           
            'Here is my question.  I want to wait here until the Value shows up as = "Assign transaction to this account" or  Add new account and assign transaction".  Note that cBox is in module Main and this sub is in Module Detail
            wait for  Main.cBox_SelectedIndexChanged(Index As Int, Value As Object)
            ' will do some different functions here based on which cBox selection is chosen   
        End If   
    Loop
End Sub 
				 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		