I have a program that I wrote a couple of years ago, it compiled and worked OK at the time, the other day I wanted to make a change, so I loaded up the code and compiled it, it failed! saying the code was too large. There are 4143 integers in each list
So after playing around I found that removing two large lists in Process_Globals allowed it to compile, so here are my questions.
1) has something changed in that stops you using large lists
2) Any idea how to fix this.
Thanks
Steve
P.S. In the altered code (one without the two large lists) I create another activity with just one of the large lists and nothing else to see if I could separate them out, this failed to compile.
are you using 4143 codelines to fill the list? Why not loading the List directly?
B4X:
Dim List1 As List
List1 = File.ReadList(File.DirDefaultExternal, "1.txt") ' List with 50000 Lines...
For i = 0 to List1.Size - 1
Log(List1.Get(i))
Next
I was creating the list this way as I was trying to avoid a separate file with the INT's in them
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim List3 As List
List3.Initialize
List3.AddAll(Array As Int(475,275,700,675,625,375,700,850,50,325,675,525,275,575,250,725, _
875,200,875,475,875,25,100,700,50,350,850,375,150,575,375,300, _
200,525,425,250,350,825,550,100,625,750,500,400,450,425,375,50, _
There are several mistakes here:
1. It is better to put them in a file and load them at runtime. It is a mistake to put data inside the code.
2. You shouldn't initialize or call AddAll in Process_Globals.
3. Unless you plan to modify the list in the future then it is better to initialize it like this:
Will be fixed. File.DirDefaultExternal should not be used anymore. It was replaced with RuntimePermissions.GetSafeDirDefaultExternal.
There are several mistakes here:
1. It is better to put them in a file and load them at runtime. It is a mistake to put data inside the code.
2. You shouldn't initialize or call AddAll in Process_Globals.
3. Unless you plan to modify the list in the future then it is better to initialize it like this:
Thanks Don, the reason I put it in the code is I don't want the user to see the list or access it. any suggestions? also any good simple examples of using external files for lists?
OK, so I will use an external file but firstly I have not used B4A for about two years so totally rusty (not that I was well oiled before ) so I have a few newbie questions.
1) Can the list (data.txt) be created within B4A so it installs as part of the application or is it created in a simple text editor and I place it somewhere?
2) if I create and place it, where do I place it on the device?
This is what a forum / software community should be, OK I'm no coding guru anymore, I used to love coding and was into assembly and C and all the other ones at the time, now my life occasionally meets code but I'm a lot older and have not got the time to understand 80% of modern IDE's / development languages or platforms but with a community like this and the help it provides, especially Erel you personify the word "community" thanks for everything, I am sure I will be back in the future to make you all go but then help out as you do. thanks for helping an old man