this should have occurred to me before, but I found a good workaround for
the fact that the arguments array in MX is not an array. I realized that
isarray(arguments) returns false in MX or true in CF 5, so a reasonably
simple function allows me to produce consistent results on both CF 5 and MX
with other functions which seek to alter the arguments array using array
functions that don't work on the arguments array directly in MX.

function argstoarray(args) {
        var x = 0; var args2 = false;
        if (not isarray(args)) {
                args2 = arraynew(1);
                for (x = 1; x lte arraylen(args); x = x + 1)
                { arrayappend(args2,args[x]); }
                args = args2;
        } return args;
}

So if I have a function which needs to alter the arguments array with array
functions, I would rewrite something like this:

function myfunction(x,y,z) {
        arguments[1] = blahblah(x,y,z);
        arraydeleteat(arguments,3);
        arraydeleteat(arguments,2);
        request.tapi.js.call("funcname",arguments);
}

which works on CF 5 only to this for CF 5 and MX:

function myfunction(x,y,z) {
        var args = request.tapi.argstoarray(arguments);
        args[1] = blahblah(x,y,z);
        arraydeleteat(args,3);
        arraydeleteat(args,2);
        request.tapi.js.call("funcname",args);
}

Since it only duplicates the arguments array if it's not an array, the only
added overhead for the function on CF 5 is calling the argstoarray()
function which simply returns the unmodified arguments array and this
preserves the efficiency of the original code for CF 5. MX will still suffer
added overhead from having to copy the vars into an array but there's not a
whole lot I can do about that unfortunately.

Figured somebody might find this usefull. :)

s. isaac dealey                954-776-0046

new epoch                      http://www.turnkey.to

lead architect, tapestry cms   http://products.turnkey.to

tapestry api is opensource     http://www.turnkey.to/tapi

certified advanced coldfusion 5 developer
http://www.macromedia.com/v1/handlers/index.cfm?ID=21816

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to