I am trying to figure out why I am getting some odd results and I'm sure its a lack of understanding with what's going on at certain points so I was wondering if someone could maybe explain the following which Im sure will lead me in the right direction.
To help undertsand: I am loading a text file which contains lines of data, some have 500/600 lines and some might have 3000+ lines. What I ORIGINALLY did was create a loop to go through each line, read it, token it up, process some of the data (run the lines data though some calcs and functions) and then display it in a nice way at the end. The issue with this though was the "hang time" caused from all of the above happening in one tick.
To solve this I did the following (which maybe the start of the issue)
I crated a function with a line index parameter, which did all the reading and processing of a line at n index. At the end of the function I would simply call the function again with the next line index, until at the last line. This "function loop" works with some of the SMALLER files (upto around 500 lines) but what I found was anything over that and the function loop seemed to break... So I tried putting a "wait for previous action to complete" just before I call the function again with the next line index. Whilst this slowed the whole read process down, it seemed to work, read all lines just fine and does not hang the project. However, it is the start of some strange results from the data.
In each function call, I grab the line of data (just comma delimited numbers and string's) (and sometimes the previous line) and I run them through various EVENT functions AND some JavaScript functions. But I'm finding some data to not be quite right, and its almost like its processing some lines at the wrong time in the function call, but they all use the same index var as the line ref.
Here is a photo which shows the function loop I describe above.
So is this because some of the functions I am calling are not finishing before it gets called again? Is there anything I need to do to these functions (both event funcs and JS funcs) to make sure they finish before continuing? The Event functions are NOT set to async nor are the JS functions.
What I find strange is, nothing inside the function call actually has the little "wait" symbol (indicating a wait is required), yet putting the "wait for previous action to complete" before calling the function again does slow the loop down and loads all the lines, as apposed to if its not there only smaller files get loaded and big ones seem to break half way through reading the lines (500+)
Thanks.