P pcbtmr Member Licensed User Longtime User Oct 3, 2012 #1 Have this bit of code Sub Globals Dim List1,List2 as List End Sub Sub Activity_Create(FirstTime as boolean) List1=SU.LoadCSV().... End Sub Sub Button_Click List2.Add("text") end sub Compiler is flagging List2 should be initialized but is not flagging List1. Why is this? Thanks.
Have this bit of code Sub Globals Dim List1,List2 as List End Sub Sub Activity_Create(FirstTime as boolean) List1=SU.LoadCSV().... End Sub Sub Button_Click List2.Add("text") end sub Compiler is flagging List2 should be initialized but is not flagging List1. Why is this? Thanks.
U ukimiku Active Member Licensed User Longtime User Oct 3, 2012 #2 Maybe .LoadCSV implicitly initializes the list, while .Add does not. Regards, Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Oct 4, 2012 #3 Please use [ code ] [ /code ] tags (without spaces) when posting code. SU.LoadCSV returns a list. This means that this line actually assigns a new list to List1: B4X: List1=SU.LoadCSV() In the second case you are adding an item to an uninitialized list. Upvote 0
Please use [ code ] [ /code ] tags (without spaces) when posting code. SU.LoadCSV returns a list. This means that this line actually assigns a new list to List1: B4X: List1=SU.LoadCSV() In the second case you are adding an item to an uninitialized list.