I have 3 functions to backup, restore, and trim arrays, but at the moment, they all only work with a single array.
Here's my TrimArray function...
Code: Select all
void TrimArray()
{
for(int i=(ArrayRange(MyTf,0)-1); i>=0; i--)
{
EmptyElements=MyTf[i,0];
if(EmptyElements==0) a++;
}
ArraySort(MyTf,WHOLE_ARRAY,0,MODE_DESCEND);
int CurrentArrayRange=ArrayRange(MyTf,0);
Alert("Array Size is now ", CurrentArrayRange);
int NewArrayRange=CurrentArrayRange-a;
ArrayResize(MyTf, NewArrayRange);
CurrentArrayRange=ArrayRange(MyTf,0);
Alert("Array Size is now ", CurrentArrayRange);
ArraySort(MyTf);
} // End TrimArray
I've tried changing the function to accept the array name as a string, (void TrimArray(string ArrayToTrim)), but execution never gets past the for(int i=(ArrayRange(ArrayToTrim,0)-1); i>=0; i--) line of code
So, as the title says, is there any way to pass the array name to the function, and replace the instances of MyTf with variable names so that one set of code suits all, or do I have to repeat the code for each array that I want to trim, (or backup/restore, as the case may be)?
I'm most definitely at the limit of my knowledge with this, and really need an example of how to do it, if it's possible to do at all.
Thanks in advance
Have fun!
Radar =8^)
