save filter of a table

manu

Active Member
Licensed User
can you help me?


I am trying to make a filter in a file .csv and save the result in a new file csv , but on having save this table he save the table completes not the filtered results.


A Greeting.

Thank you.
 

davelew1s

Active Member
Licensed User
copy table

Hi!
I am trying to do something similar but cannot work out how to copy the old table to the new table row by row, any help?
Dave.
 

specci48

Well-Known Member
Licensed User
Hi davelew1s,

since you can't copy a complete row directly, you have to copy cell by cell:

B4X:
Sub Globals
End Sub

Sub App_Start
   
   ' defining both tables with the same columns
   Table1.AddCol(cString,"Col1",50,False)
   Table1.AddCol(cString,"Col2",50,False)
   Table2.AddCol(cString,"Col1",50,False)
   Table2.AddCol(cString,"Col2",50,False)
   
   ' adding six rows to table1
   Table1.AddRow("row1","value1")
   Table1.AddRow("row2","value2")
   Table1.AddRow("row3","value1")
   Table1.AddRow("row4","value2")
   Table1.AddRow("row5","value1")
   Table1.AddRow("row6","value2")
   
   ' setting a filter => three rows left
   Table1.Filter("Col2 = 'value2'")
   
   ' copy filtered rows from table1 to table2 (cell by cell)
   Table2.Clear
   For i = 0 To Table1.RowCount - 1
      Table2.AddRow()
      For j = 0 To Table1.ColCount - 1
         Table2.Cell(Table2.ColName(j),i) = Table1.Cell(Table1.ColName(j),i)
      Next
   Next
   
   Form1.Show
End Sub
specci48
 
Top