Just because I'm in the mood, I've modified the code I sent to you last and
turned it into a UDF.
<CFSCRIPT>
/*
 Takes a list of structures and searches them for any keys that contain the
value. Returns a list of all keys.

 Value  (required; Text) The value to search the structure for.
 lLocation (required; List/Text) A list of the structures to search (url,
form, etc.)
 Scope  (optional; Text) The scope of the search. Defaults to "One" but can
also be "All".
*/
Function ValuePassed(Value, lLocation)
{
 VAR aTemp="";
 VAR lReturnSet="";
 VAR Scope="One";

 // Set a scope if it is passed or set a default of "one"
 IF (ArrayLen(Arguments) GTE 3)
  Scope=Arguments[3];

 // Loop over the list of locations and search each one
 FOR (nLoopCount=1;nLoopCount LTE
ListLen(lLocation);nLoopCount=nLoopCount+1)
 {
  aTemp=StructFindValue(evaluate(ListGetAt(lLocation, nLoopCount)), Value,
Scope);
  IF (ArrayLen(aTemp))
   lReturnSet=ListAppend(lReturnSet, ListGetAt(lLocation,
nLoopCount)&'.'&StructKeyList(aTemp[1]['owner']));
 }

 Return lReturnSet;
}
</CFSCRIPT>





> Two part question. They are related
>
> Part 1:
>
> Let's say you have a page with lots of URL variables. (I.E. url.search,
> url.lang, url.homepage, url.custscript, url.start, url.end,
url.frontscope,
> etc. etc. etc.)
>
> And you don't want to code a CFIF for each URL seperately for the same
> parameter.
>
> (cfif url.search CONTAINS "goofy")
> do this
> (/cfif)
> (cfif url.lang CONTAINS "goofy")
> do this
> (/cfif)
> (cfif url.hompage CONTAINS "goofy")
> do this
> (/cfif)
> (cfif url.start CONTAINS "goofy")
> do this
> (/cfif)
>
> Is there a way to just say:
>
> (cfif attribute.url CONTAINS "goofy")
> do this
> (/cfif)
>
> Or something similar?
>
>
> Part 2:
>
> Is it possible to also encompass all form.* attributes in one shot?
Similar
> to the question above?
>
> Thanks.
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to