Thanks for that-- a little more complex than I need for my purposes, but a useful tip to keep in mind.
The code sample above doesn't really give the clearest indication of what I'm trying to do, or why I really can't give up on using the array structure. In fact, I'm using a two-dimensional array containing scripts of various lengths. For a moment I thought this was going to be a big problem, where I'd have to totally restructure my code, but a simple solution appeared quickly...
Now that I've realised that my array doesn't actually hold any data, but only pointers to the container, I've simply made each array item always point to the start of its script data. I've also added an additional "END" script entry.
When it comes time to run through the script items at a given element of the array, I'll use the array to point me to the start of the script, and stop when I come to the "END" script item. All script data gets loaded in all at once, so scripts are added in their entirety--no need to worry about linking up items in various locations in the container.
The code sample above doesn't really give the clearest indication of what I'm trying to do, or why I really can't give up on using the array structure. In fact, I'm using a two-dimensional array containing scripts of various lengths. For a moment I thought this was going to be a big problem, where I'd have to totally restructure my code, but a simple solution appeared quickly...
Now that I've realised that my array doesn't actually hold any data, but only pointers to the container, I've simply made each array item always point to the start of its script data. I've also added an additional "END" script entry.
When it comes time to run through the script items at a given element of the array, I'll use the array to point me to the start of the script, and stop when I come to the "END" script item. All script data gets loaded in all at once, so scripts are added in their entirety--no need to worry about linking up items in various locations in the container.