> In CF, based on some testing I did a while back, the
> performance of the case construct versus the conditional
> one was close enough to ignore the difference, so you're
> not going to be taking a performance
> hit by choosing one over the other.

Although that's not why I use switch-case constructs anyway... heh...
I use them because they're easier to read. Although I use the cfscript
switch-case constructs for "cascading" logic -- which isn't really
available with <cfswitch>...

switch (arraylen(arguments)) {
  case "0": { arg1 = "default1"; }
  case "1": { arg2 = "default2"; }
  case "2": { arg3 = "default3"; }
}

Not a great example, but it works... Not a great example because I've
actually stopped using this method lately in favor of an
ArrayToStruct() function...

function ArrayToStruct(ar,keys) {
  var st = structnew();
  var x = 0; var last = 0;

  keys = listtoarray(keys);
  last = max(arraylen(ar),arraylen(keys));
  for (x = 1; x lte last; x = x + 1) {
    st[keys[x]] = ar[x];
  } return st;
}

myargs = ArrayToStruct(somearray,"arg1,arg2,arg3");

then I use <cfparam> or equivalent to create my defaults.

It's not really necessary with <cffunction> but I still like to write
functions with cfscript when I can. Just a quirky syntactical
preference of mine -- I don't have to explicitly state output="false"
among other things. I've gotten into the habbit of creating a var'ed
structure to store local variables in the function also, so I don't
have to var everything I use in the function as long as I'm putting my
local variables in that structure. It's useful for some of the larger
/ more complex functions. Although at this point I'm just rambling. :)


s. isaac dealey   954.522.6080
new epoch : isn't it time for a change?

add features without fixtures with
the onTap open source framework

http://macromedia.breezecentral.com/p49777853/
http://www.sys-con.com/author/?id=4806
http://www.fusiontap.com



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:198859
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to