misc

misc

Prefixmisc
Library path/tags/misc
CFImport

<misc:cacheControl ...>

XML StyleYes

Attributes

NameTypeRequiredDefaultOptionsDescription
browserSecondsstringNo-1
proxySecondsstringNo-1

<misc:diff ...>

Loops over differences between one string (or array) and another. If strings are passed in they are stripped of HTML tags and compared word by word. After the tags has finished executing, the complete array of diffs is returned.

XML StyleYes

Attributes

NameTypeRequiredDefaultOptionsDescription
oldstringNoThe old value. This should be a string (will be stripped of HTML tags and compared by word)
newstringNoThe new value. This should be in the same format as old.
diffstringNodiffThe variable that the result is stored in. During execution this variable contains individual diff structs: { diff="+|-|=", oldindex, oldvalue, newindex, newvalue }. After execution this variable contains an array of all diffs. Defaults to "diff"

<misc:map ...>

Loops over a set of values and gathers return values from enclosed code. These new values are collected into an output set.

XML StyleYes
The basic use case is converting between complex data types. The following snippet creates a query from the url struct:
<misc:map values="#url#" resulttype="querynew('key,value')">
 <cfset sendback[1].key = index />
 <cfset sendback[1].value = value />
</misc:map>
<cfdump var="#result#" />
This is a more complex example from core .This snippet loops through the application.stCOAPI struct, then through the qWebskins query. As it goes through it is constructing a struct of webskin paths:
<misc:map values="#application.stCOAPI#" index="thistype" value="metadata" result="stWebskins" resulttype="struct" sendback="typesendback">
 <misc:map values="#metadata.qWebskins#" index="currentrow" value="webskin" result="typesendback.#thistype#" resulttype="struct" sendback="webskinsendback">
  <cfif len(webskin.methodname) and webskin.methodname neq "deniedaccess">
   <cfset webskinsendback[webskin.methodname] = webskin.path />
  </cfif>
 </misc:map>
</misc:map>
<cfdump var="#stWebskins#" />

Attributes

NameTypeRequiredDefaultOptionsDescription
values1stringNo#attributes.values#valuesN can be used to input any number of input sets for processing
values1stringNoThe set of source values. Can be a struct, array, list, or query.
indexstringNoindex The variable that will contain the index of the source item. For structs this is the key.
valuestringNovalue The variable that will contain the value of the source item. For queries this is a struct of the column values. If this value is a non-simple value (e.g. struct) editing it will alter the source set. Defaults to "value"
sendbackstringNosendback The variable that enclosed code will add output items to. The type of this variable depends on the output set type: For structs this is a struct which gets merged into the output set. For arrays this is an array that gets appended to the output set. For lists this is a string that gets appended to the output list. For queries this is an array of row structs (containing one empty struct by default), each of which is appended to the output query. If this variable is "empty" (e.g. empty struct) no items are added to the output set. Defaults to "sendback"
resulttypestringNo Same as values struct, array, list, querynew('col1,col2') The output set type. Defaults to the same type as the source set.
resultstringNoresultThe variable the output set is stored in once this tag has finished execution. Defaults to "result"
delimiterslistNo,Only applies for resulttype="list". Specifies an alternate delimiter.
delimitersinstringNo#attributes.delimiters#Only applies when values is a list. Specifies an alternate delimiter for the input list only.
delimitersoutlistNo#attributes.delimiters#Only applies for resulttype="list". Specifies an alternate delimiter for the output list only.

<misc:sort ...>

This tag provides "anonymous comparison function" sorting functionality using the quick sort algorithm. It is useful for situations where the sort definition is too complex for the native functions. The quick sort algorithm has been abstracted so that the comparisons between items can be performed by the code enclosed by the tag. That code is executed for each comparison. Note: This tag DOES alter array type source sets.

XML StyleYes
This example sorts an array by the maximum of two struct variables:
<cfset values = arraynew(1) />
<cfset values[1] = structnew() />
<cfset values[1].a = 10 />
<cfset values[1].b = 30 />

<cfset values[2] = structnew() />
<cfset values[2].a = 25 />
<cfset values[2].b = 5 />

<cfset values[3] = structnew() />
<cfset values[3].a = 15 />
<cfset values[3].b = 20 />

<misc:sort values="#values#">
 <cfset sendback = max(value2.a,value2.b) - max(value1.a,value1.b) />
</misc:sort>
<cfdump var="#result#" />

Attributes

NameTypeRequiredDefaultOptionsDescription
valuesstringNoThe source set. Can be a list, array, or struct.
value1stringNovalue1The variable that will contain the first value to be compared for an iteration. Defaults to "value1"
value2stringNovalue2The variable that will contain the second value to be compared for an iteration. Defaults to "value2"
sendbackstringNosendbackThe variable that will contain the result of the comparison. Should be set to 0 for "equal" values, less than 0 if the first value is "less" than the second, and more than 0 if the first value is "more" than the second. Defaults to "sendback"
resultstringNoresultThe result of the sort. For lists and arrays this is the sorted set. For structs this is an ordered list of keys.