Post by Drake™ on Jul 26, 2010 5:00:28 GMT -6
Array Functions v1.1
Scripting Level: Advanced
Dynamically manage multi-level variables (aka arrays - $array[0]) using functions! No longer have to keep track of how many variables are all in a file - have the functions do it for you.
Version 1.1, suggestions are welcome.
UPDATES TO THE FILE FOR THOSE WHO DO USE IT:
The file has been updated with some (to me) major fixes.
- The functions now store string data perfectly. Before they wouldn't read string data right, but now they do.
-- Example use of the string data arrays:
- deleteArray(); now actually deletes information properly. Before the loop never finished and information was never actually cleared which proved to be unsafe for the other functions. This is now fixed.
Suggestions/notes/critique accepted.
Scripting Level: Advanced
//---------------------------------------------------------------------
//
// Author's Note:
// Purpose: Store and retrieve mass amounts of similar information
// quickly and easily through the use of arrays. These functions
// allow for MUCH easier use of these arrays. Also, each array is
// setup as a GLOBAL variable due to local variables not being
// permanent outside of a function.
//
// Remember:
// Arrays start at 0. So all information you put into a new array
// will start out at $array[0].
//
//---------------------------------------------------------------------
//
// Includes:
// - createArray(%array);
// - grabData(%array, %slot);
// - getArraySize(%array);
// - addToArray(%array, %info);
// - checkArray(%array, %info);
// - mergeArray(%array, %start, %end);
// - removeFromArray(%array, %info);
// - deleteArray(%array);
//
//---------------------------------------------------------------------
//
// Author's Note:
// Purpose: Store and retrieve mass amounts of similar information
// quickly and easily through the use of arrays. These functions
// allow for MUCH easier use of these arrays. Also, each array is
// setup as a GLOBAL variable due to local variables not being
// permanent outside of a function.
//
// Remember:
// Arrays start at 0. So all information you put into a new array
// will start out at $array[0].
//
//---------------------------------------------------------------------
//
// Includes:
// - createArray(%array);
// - grabData(%array, %slot);
// - getArraySize(%array);
// - addToArray(%array, %info);
// - checkArray(%array, %info);
// - mergeArray(%array, %start, %end);
// - removeFromArray(%array, %info);
// - deleteArray(%array);
//
//---------------------------------------------------------------------
Dynamically manage multi-level variables (aka arrays - $array[0]) using functions! No longer have to keep track of how many variables are all in a file - have the functions do it for you.
Version 1.1, suggestions are welcome.
UPDATES TO THE FILE FOR THOSE WHO DO USE IT:
The file has been updated with some (to me) major fixes.
- The functions now store string data perfectly. Before they wouldn't read string data right, but now they do.
-- Example use of the string data arrays:
function altString(%char1, %char2)
{
%rand = randomInt(2,12);
createArray(altString);
addToArray(altString, %char1);
for(%i = 0; %i < %rand; %i++)
{
addToArray(altString, %char2);
}
mergeArray(altString, 0, %rand);
%result = grabData(altString, 0);
deleteArray(altString);
return %result;
}
- deleteArray(); now actually deletes information properly. Before the loop never finished and information was never actually cleared which proved to be unsafe for the other functions. This is now fixed.
Suggestions/notes/critique accepted.