Name

StructFindKey — New as of ColdFusion 4.5.1 SP2

Synopsis

StructFindKey(top, key [, scope])

Searches complex structures for keys matching the key parameter. top specifies the starting point to begin the search. key specifies the key you want to perform the search for. scope is optional and may be set as either One or All, specifying the number of matching keys that should be returned. The default scope is One. StructFindKey( ) returns an array that contains one structure for each key matched by the search. Each structure contains the following keys:

Value

The value held by the found key

Path

A string that can be used with other functions to reference the found key

Owner

The parent object containing the found key

The following examples demonstrates the use of this function on an array of nested structures:

<!--- create a structure of nested arrays containing nested structures. ---> <CFSET TEMP = STRUCTGET("Stock")> <CFSET TEMP.COMPANY = "Allaire"> <CFSET TEMP.TICKER = "ALLR"> <CFSET TEMP = STRUCTGET("Stock.TradeInfo[1]")> <CFSET TEMP.PRICE = 60> <CFSET TEMP.TRADEDATE = "6/11/99"> <CFSET TEMP.VOLUME = 750000> <CFSET TEMP.DAY.HIGH.PRICE = 62> <CFSET TEMP.DAY.LOW.PRICE = 59> <CFSET TEMP = STRUCTGET("Stock.TradeInfo[2]")> <CFSET TEMP.PRICE = 63> <CFSET TEMP.TRADEDATE = "6/12/99"> <CFSET TEMP.VOLUME = 737000> <CFSET TEMP.DAY.HIGH.PRICE = 66> <CFSET TEMP.DAY.LOW.PRICE = 60> <CFSET TEMP = STRUCTGET("Stock.TradeInfo[3]")> <CFSET TEMP.PRICE = 67> <CFSET TEMP.TRADEDATE = "6/13/99"> <CFSET ...

Get Programming ColdFusion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.