To clarify, arrays in Torque aren't actually arrays, they're substitutions to insert variables into variable names.
When you assign %array[1] you are really making %array1. %array[1,1] is really %array1_1. The variable %array itself is unchanged, and passing it to another function passes none of the data included in the arrayed part (this is a really huge shortcoming of Torquescript).
A solution to this would be using a ScriptObject with values assigned, like
function array(%str)
{
%obj = new ScriptObject();
%str = strReplace(expandEscape(%str),",","\t");
for(%i=0;%i<getFieldCount(%str);%i++)
{
%obj.v[%i] = getField(%str,%i);
}
%obj.length = getFieldCount(%str);
return %obj;
}
echo(array("rooster,balls,3,giraffe").length);
But this drives up object pointers (not too big of an issue), is really weird to work with (%array.v[0] and enclosing the whole value of the array as a string - it's syntactically sugar-free), potentially results in bad memory use (the object will still exist until explicitly deleted, instead of being discarded with the scope it exists in). It's a feasible solution, just takes some different habits to deal with. But you can pass all of that data all at once as a potentially iterable set of values to another function as only one argument, which is really, really handy. So if that's what you're doing with it, send it on and remember to delete it when you're done.