# Is there any object that have map/hash/dictionary functionality?

**URL:** https://www.finalbuilder.com/forums/t/is-there-any-object-that-have-map-hash-dictionary-functionality/1322
**Category:** Discussion
**Created:** [September 18, 2009, 3:10am UTC](https://www.finalbuilder.com/forums/t/is-there-any-object-that-have-map-hash-dictionary-functionality/1322 "2009-09-18T03:10:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [September 18, 2009, 3:10am UTC](https://www.finalbuilder.com/forums/t/is-there-any-object-that-have-map-hash-dictionary-functionality/1322/1 "2009-09-18T03:10:51Z")

</div>

Hi,

I'm looking for a way to construct a lookup map (key/value). Is there any such object in FinalBuilder 6 or is there a smart way to constuct one?

//C

---

<div class="post-metadata">

### Author: ![paulsamways](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/p/e8c25b/32.png) [@paulsamways](https://www.finalbuilder.com/forums/u/paulsamways)
#### Post date: [September 21, 2009, 12:11pm UTC](https://www.finalbuilder.com/forums/t/is-there-any-object-that-have-map-hash-dictionary-functionality/1322/2 "2009-09-21T12:11:48Z")

</div>

Hi Charlotte,   
  
 The easiest way would be to use the ‘Run Script’ action and use a VBScript dictionary ([http://www.4guysfromrolla.com/webtech/102898-1.shtml](http://www.4guysfromrolla.com/webtech/102898-1.shtml)). If you need the dictionary available across more then one action you can assign the dictionary object to a FB variable.   
  
 Regards,   
 Paul.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [November 18, 2009, 10:01am UTC](https://www.finalbuilder.com/forums/t/is-there-any-object-that-have-map-hash-dictionary-functionality/1322/3 "2009-11-18T10:01:25Z")

</div>

You could use an xml document.&nbsp; Consider the following XML&nbsp;document.

[table]  
&nbsp; [item]  
&nbsp;&nbsp;&nbsp; [k]a[/k]  
&nbsp;&nbsp;&nbsp; [v]42[/v]  
&nbsp; [/item]  
&nbsp; [item]  
&nbsp;&nbsp;&nbsp; [k]b[/k]  
&nbsp;&nbsp;&nbsp; [v]4[/v]  
&nbsp; [/item]  
&nbsp; [item]  
&nbsp;&nbsp;&nbsp; [k]c[/k]  
&nbsp;&nbsp;&nbsp; [v]2[/v]  
&nbsp; [/item]  
[/table]

Using the "Read XML Value to Variable"&nbsp;action specifying the XPath /table/item[k="a"]/v, will cause 42 to be extracted.&nbsp; Likewise /table/item[k="c"]/v results in 2.&nbsp; You will want to wrap the "Read XML&nbsp;Value to Variable" in a Try / Catch / End block.

Adding values is done by using "Create XML&nbsp;Node".&nbsp; For example to set the key "a"&nbsp;to "3".&nbsp; First try and update the existing value by overwritting the previous "v" node with parent XPath /table/item[k="a"] with "3".&nbsp; In this case it succeeds, but if it fails just create the new "item" node as a child of /table with child XML&nbsp;"[k]a[/k][v]3[/v]".&nbsp; If you can't guarantee that the key is valid XML, you will need to at least escape the &, \<, and \>&nbsp;characters.

(Note:&nbsp;remove the extra space after \<'s ).

Edit:&nbsp;Replaced \<&nbsp;and \>&nbsp;with [and]
