Perhaps you can create a private function whose arguments is the 
structure's keys,
For example:

public function foo(required struct myStructVar) {
  // sanitize myStructVar into a correct struct with all default value
   var myPopulatedVar = func_populate(argumentCollection=myStructVar);
  // do something else
}

private function func_populate(string var1="", numeric var2=0, string 
var3="ABC") {
    return arguments;  // return everything that was passed in, plus the 
default value if not exists
}

Peter


On Friday, 23 November 2012 13:45:40 UTC+11, Chris Velevitch wrote:
>
> Let's say I have a cfc I'm using to provide a service to multiple 
> disparate clients. One of the arguments to a function is a struct. 
> That struct is then used to pass values as individual arguments to a 
> stored procedure on a database. 
>
> Now that struct gets a new field, that field is passed as an optional 
> argument to the stored procedure and only one of the many disparate 
> clients is update to add that new field. 
>
> How would you design that function to handle the fact that some 
> clients are NOT passing the new field and there's no need to change 
> the clients as it's optional? 
>
> One idea is pass the value as :- 
>
> value = "#iif(StructKeyExists(struct, 
> 'scheduling_flag'),Evaluate(DE('struct.scheduling_flag')),0)#" 
>
> Is this the best way or there a better way of handling this? 
>
>
>
> Chris 
> -- 
> Chris Velevitch 
> Manager - Adobe Platform Users Group, Sydney 
> m: 0415 469 095 
> www.apugs.org.au 
>
> Adobe Platform Users Group, Sydney 
> Topic: Coldfusion 10 CF Builder and a bit on the Edge 
> Date: Monday, 26th November at 6pm 
> Details and RSVP on 
> http://www.meetup.com/Sydney-Adobe-Platform-User-Group/events/90652722/ 
>

-- 
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/cfaussie/-/OinlJVvcvGsJ.
To post to this group, send email to cfaussie@googlegroups.com.
To unsubscribe from this group, send email to 
cfaussie+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en.

Reply via email to