Not sure this is a true "HashMap" but it would replicate your example. One 
caveat would be that your struct name would always have to be a valid cold 
fusion variable.

If "a" and "b" are more likely to be "http://www.yahoo.com"; then this approach 
won't work. 

I would recommend a two-dimensional array.

~Brad

While your two-dimensional array may very well be a better solution, I just 
wanted to point out that structure keys do not HAVE to be valid ColdFusion 
variables, if they are quote["|'] escaped.

The following test case shows this.

<cfsilent>
        <cfscript>
                map = structNew();
                
                map["http://www.google.com";] = 1;
                map['http://www.yahoo.com'] = 2;
        </cfscript>
        
</cfsilent><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Struct test</title>
</head>

<body>
        <cfoutput>
        <cfloop list="#structKeyList(map)#" index="key">
                <a href="#key#">#map[key]#</a>
        </cfloop>
        </cfoutput>
</body>
</html>


--------------
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA

---------
| 1 |   |
---------  Binary Soduko
|   |   |
---------
 
"C code. C code run. Run code run. Please!"
- Cynthia Dunning



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:231158
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=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to