Have I just re-invented the wheel? Almost certainly, yes! I coudn't find any examples of code that let me manage arrays without going mad, and I wasn't about to try writing a DLL. The script is definitely not perfect, it's a couple-hour-job, but it includes an automated test to prove it works. Run it to make sure I didn't screw up . If I discover any serious problems I'll update.
Here's the function list:
- Array::New -> Register a new array. Specify what NULL should be, and/or a custom name. Return the name.
- Array::Delete -> Delete a registered array.
- Array::Get -> Index accessor
- Array::Insert -> Range-enabled insert
- Array::Fill -> Insert a delimited list of values starting at a given position
- Array::EraseRange -> Null a range of elements. Do nothing else.
- Array::Shrink -> Remove all NULL values and compact the array
- Array::RemoveRange -> EraseRange, and then Shrink
- Array::Valid -> Check if the array was registered with New()
- Array::Copy -> Copy a registered array into destination registered array. Frees the destination first.
- Array::CopyToWorld -> Quick hack for saving arrays in TRPG.
- Array::CopyFromWorld-> Same as CopyToWorld, but in reverse.