Just a query on the DBUtils implementation.  There is, amongst other very useful routines, this one:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
While this works to fill things like comboboxes, I cant find any way of just filling a list to be used in code. Maybe I'm dense, but the obvious thing of passing a list name as a parameter just returns an empty list. And in thinking about it, I can see why, since objects in B4X ( like Java ) are passed by value, so you cant alter them within the routine and have them retained on the return. I presume it works with a combobox, because you pass an object which contains a list.
However quite often I want a list I can just operate on in code after an SQL query to get a list of data. Yes I know I can do it ( but it takes more work ) to extract the list after doing an ExecuteMap to get the data returned as a Map
I played with changing the ExecuteList routine to this:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
This seems to do just what I want, allowing to fill either a list, or a combobox with the right data by doing it like this:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Or to do it to fill just a list:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
There must have been some good reason to do it the other way, but I cant see one.
Anybody care to comment ?
			
			
			
				DBUitils ExecuteList:
			
		
		
		Public Sub ExecuteList(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, List1 As List)
    'List1.Clear
    Dim Table As List
    Table = ExecuteMemoryTable(SQL, Query, StringArgs, Limit)
    If Table.Size = 0 Then
        Log("Table empty")
        
        Return
    End If
    Log("Table size " & Table.Size)
    
    Dim Cols() As String
    For i = 0 To Table.Size - 1
        
        Cols = Table.Get(i)
        
'        Log("Getting item " & i & " " & Cols)
        List1.Add(Cols(0))
    Next
End SubWhile this works to fill things like comboboxes, I cant find any way of just filling a list to be used in code. Maybe I'm dense, but the obvious thing of passing a list name as a parameter just returns an empty list. And in thinking about it, I can see why, since objects in B4X ( like Java ) are passed by value, so you cant alter them within the routine and have them retained on the return. I presume it works with a combobox, because you pass an object which contains a list.
However quite often I want a list I can just operate on in code after an SQL query to get a list of data. Yes I know I can do it ( but it takes more work ) to extract the list after doing an ExecuteMap to get the data returned as a Map
I played with changing the ExecuteList routine to this:
			
				ExecuteListA:
			
		
		
		Public Sub ExecuteListA(SQL As SQL, Query As String, StringArgs() As String, Limit As Int) As List
    Dim list1 As List
    list1.Initialize
    
    Dim Table As List
    Table = ExecuteMemoryTable(SQL, Query, StringArgs, Limit)
    If Table.Size = 0 Then
        Log("Table empty")
        
        Return
    End If
    Log("Table size " & Table.Size)
    
    Dim Cols() As String
    For i = 0 To Table.Size - 1
        
        Cols = Table.Get(i)
        
'        Log("Getting item " & i & " " & Cols)
        list1.Add(Cols(0))
    Next
    
    Return list1
End SubThis seems to do just what I want, allowing to fill either a list, or a combobox with the right data by doing it like this:
			
				ExecuteLIstA call:
			
		
		
		cmbRating.SetItems(DBUtilsA.ExecuteListA(SQL, "SELECT rating from tblRating ORDER BY rank ", Null, 0 ))Or to do it to fill just a list:
			
				Fill list:
			
		
		
		Dim lstTest As List
    lstTest.Initialize
    lstTest = DBUtilsA.ExecuteListA(SQL, "SELECT rating from tblRating ORDER BY rank ", Null, 0 )There must have been some good reason to do it the other way, but I cant see one.
Anybody care to comment ?
 
				 
 
		 
 
		 
 
		 
 
		 
						
					 
 
		