Android Question for loop and callsubdelay

Pantelis Loizou

Member
Licensed User
Longtime User
Hallo everyone. Can i use CallSubDelayed within foreach loop statement? i want to pause main activity until i get a result from calling sub
 

Pantelis Loizou

Member
Licensed User
Longtime User
is there any way to solve my issue? in order to understand what i am really try to do is that i have one table with many rows, a button (named Repeat). each item has some optional items to select. when i press the button i want to pop up for each the activity with the optional items in order to select them
 
Upvote 0

Pantelis Loizou

Member
Licensed User
Longtime User
Sub btnRepeat_Click
If itemSelected=True Then
TableRowsCount=ResultTable.GetTableSize
For i =0 To TableRowsCount-1
selItemDescr = ResultTable.GetValue(0, i)
selQuantitySel = ResultTable.GetValue(1, i)
selItemPrice = ResultTable.GetValue(2, i)
selItemPriority = ResultTable.GetValue(3, i)
selItemCode = ResultTable.GetValue(4, i)
selItemSelected = ResultTable.GetValue(6, i)

If selItemSelected="Y" Then
CursorLite=SQLite.ExecQuery("SELECT ModGroupCode, ModGroupCode1, ModGroupCode2, ModGroupCode3 FROM Inventory WHERE ItemNum='" & selItemCode & "'")
CursorLite.Position=0
ModGroupCode = CursorLite.GetString("ModGroupCode")
ModGroupCode1 = CursorLite.GetString("ModGroupCode1")
ModGroupCode2 = CursorLite.GetString("ModGroupCode2")
ModGroupCode3 = CursorLite.GetString("ModGroupCode3")

If ModGroupCode="" Then
ModGroupCode="*NA*"
End If
If ModGroupCode1="" Then
ModGroupCode1="*NA*"
End If
If ModGroupCode2="" Then
ModGroupCode2="*NA*"
End If
If ModGroupCode3="" Then
ModGroupCode3="*NA*"
End If

ResultTable.AddRow(Array As String(selItemDescr, selQuantitySel, Round2(selQuantitySel*selItemPrice,2), selItemPriority, selItemCode, DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now), "N"), "Item")

refreshGrandTotal

If ModGroupCode<>"*NA*" Or ModGroupCode1<>"*NA*" Or ModGroupCode2<>"*NA*" Or ModGroupCode3<>"*NA*" Then
rowSelected=ResultTable.GetTableSize

Starter.csu.CallSubDelayedPlus2(Modifiers, "callModifiers", 5, Array As Object(ModGroupCode & ":" & ModGroupCode1 & ":" & ModGroupCode2 & ":" & ModGroupCode3 & ":" & selQuantitySel & ":" & ItemPriority, 1))

'STOP HERE UNTIL TO RETURN THE RESULT FROM CALLING SUB
End If
End If
Next
itemSelected=False
End If
End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Please use code tags when posting code in forum!

codetag001.png


codetag002.png


codetag003.png
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
in order to select them

You need to process the whole list and the user has to select options for each item? Or do you mean process all items and add more data?

If yes, just add a Button (like "Save"). Check if all items are "filled". If not, prompt "xxx is missing". To fill an item just let him/her click on the item to enter the value.

Don't mess up with views and data. I have all the data in a List (with maps). The views are "only" used to show the data. So there's often "no" need to process all the views. You can even add the views to a list and work with the list. So maybe there is no need to call SubDelayed just to do "magic" things. Many things are much easier than expected.
 
Upvote 0

Pantelis Loizou

Member
Licensed User
Longtime User
Maybe i didnt make myslef clear of what im trying to do so i will give you an actual example to clarify myslef.

E.G. Imagine that i have a list of items on an invoice on my screen. Some of the items have the so called "modifiers" (extra optionals) i.e. BURGER (item) with modifiers ONE of the following RARE MEDIUM, WELL DONE. Lets say the user chooses Burger and then Well Done. When i use the option Repeat button i want the whole combination to be repeated within the loop.

"You need to process the whole list and the user has to select options for each item?" YES i want to process the selected items on the list and select modifiers for each item.
 
Upvote 0
Top