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
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
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). If you need the dictionary available across more then one action you can assign the dictionary object to a FB variable.
Regards,
Paul.
You could use an xml document. Consider the following XML document.
[table]
[item]
[k]a[/k]
[v]42[/v]
[/item]
[item]
[k]b[/k]
[v]4[/v]
[/item]
[item]
[k]c[/k]
[v]2[/v]
[/item]
[/table]
Using the "Read XML Value to Variable" action specifying the XPath /table/item[k="a"]/v, will cause 42 to be extracted. Likewise /table/item[k="c"]/v results in 2. You will want to wrap the "Read XML Value to Variable" in a Try / Catch / End block.
Adding values is done by using "Create XML Node". For example to set the key "a" to "3". First try and update the existing value by overwritting the previous "v" node with parent XPath /table/item[k="a"] with "3". In this case it succeeds, but if it fails just create the new "item" node as a child of /table with child XML "[k]a[/k][v]3[/v]". If you can't guarantee that the key is valid XML, you will need to at least escape the &, <, and > characters.
(Note: remove the extra space after <'s ).
Edit: Replaced < and > with [ and ]