Why does my TodoList.Size show 0 in the log?
See Line 64 of the code below.
The whole project is attached if you need to see it.
Thank you in advance!
See Line 64 of the code below.
The whole project is attached if you need to see it.
Thank you in advance!
My B4A Code:
Sub Globals
'These global variables will be redeclared each time the activity is created.
Type Todo(ID As Short, Name As String, Status As Byte, Context As Byte, Category As Byte, Priority As Int, Note As String)
Dim table1 As Table
Dim Statuses(12,2) As String
Dim Categories(40,2) As String
Dim TodoList As List
Dim HeaderRow(7) As String
Dim Categories(40,2) As String
Dim n As Notification = CreateNotification("Tap to Proceed.")
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Activity.AddMenuItem("Load Table", "LoadTable")
'Activity.AddMenuItem("Save Table", "SaveTable")
Activity.AddMenuItem("Allow Context Notification", "AllowContextNotification")
Activity.AddMenuItem("Clear Context Notification", "ClearContextNotification")
Activity.AddMenuItem("Exit Program", "ExitProgram")
LoadArrays(File.DirAssets, "Todo List.xls")
ContextCheck
End Sub
Sub LoadArrays(Dir As String, FileName As String)
Dim row As Long
Dim workbook1 As ReadableWorkbook
Dim TodoSheet As ReadableSheet
TodoList.Initialize
workbook1.Initialize(Dir, FileName)
TodoSheet = workbook1.GetSheet(0)
'Get the header row.
row = 0
HeaderRow(0) = TodoSheet.GetCellValue(0,row)
HeaderRow(1) = TodoSheet.GetCellValue(1,row)
HeaderRow(2) = TodoSheet.GetCellValue(2,row)
HeaderRow(3) = TodoSheet.GetCellValue(5,row)
HeaderRow(4) = TodoSheet.GetCellValue(6,row)
HeaderRow(5) = TodoSheet.GetCellValue(9,row)
HeaderRow(6) = TodoSheet.GetCellValue(17,row)
'Load the main sheet of the spreadsheet into a list of type Todo. See here for an example under SortType: https://www.b4x.com/android/help/collections.html#list_sorttype
'Log(TodoSheet.RowsCount)
For row = 0 To TodoSheet.RowsCount - 1
If IsNumber(TodoSheet.GetCellValue(2,row)) Then
If TodoSheet.GetCellValue(2,row) > 0 And TodoSheet.GetCellValue(2,row) < 5 Then
Dim TempTodo As Todo
TempTodo.Initialize
TempTodo.ID = TodoSheet.GetCellValue(0,row)
TempTodo.Name = TodoSheet.GetCellValue(1,row)
TempTodo.Status = TodoSheet.GetCellValue(2,row)
TempTodo.Context = TodoSheet.GetCellValue(5,row)
TempTodo.Category = TodoSheet.GetCellValue(6,row)
TempTodo.Priority = TodoSheet.GetCellValue(9,row)
TempTodo.Note = TodoSheet.GetCellValue(17,row)
TodoList.Add(TempTodo)
ExitFlag = 0
End If
Else
ExitFlag = 1 'Found the first blank cell.
End If
If ExitFlag = 1 Then Exit
Next
Log("Todo List Size = "&TodoList.Size)
For row = 1 To TodoList.Size
Log("Todo " & row & " = " & TodoList.Get(row))
Next
End Sub