This is part of a deserializer, so I get a file of data from our servers, tokenize it into 10 strings, each a sequence of records for a different table. So say line 7 is a list of 500 movies (id, name, year, release date, rating, so on), I tokenize it into 500 lines, one movie per line. Then my routine comes in. I call it with that pre-initialized array, and it splits line 1 into the fields, which are then named and saved into an associative array, then I call the same routine with line 2, as line 1 is now processed and gone, so I clear the array to return the fields from line 2, and so on through the 500. The reason for the reused array was just to avoid creating the array 500 times (actually 5,000+ over the 10 tables) as a result return variable, with the associated GC operations.
I don't really need to return it as it comes from the caller anyway, but doing so allows me to use the function as a return value -
for each Item in Values
Record = Table.Deserializer(roStringSplit(Result,Item,Delimiter))
if (Record.Valid) List.AddReplace(Record.ID.ToStr(), Record)
end for
I hope my explaination is making some sense.
On the delimeter length, that's what I meant when I said a small adjustment to the Value.Mid calls would fix that. For my use I just needed char delimiters to match my existing C# and PHP code that creates/uses the same serialized file.