New topic: dictionary of dictionary
<http://forums.realsoftware.com/viewtopic.php?t=32218> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message phillS Post subject: dictionary of dictionaryPosted: Wed Jan 27, 2010 6:09 pm Joined: Wed Jan 27, 2010 5:10 pm Posts: 1 I am trying to access a dictionary that is a value for a key in a dictionary eg dim dict1, dict2 as dictionary dict1 = new Dictionary dict2 = new Dictionary dim mycatchcolour as string dict2.Value("fish") = "blue" dict1.Value("catch") = dict2 //mycatchcolour = dict1.value("catch").value("fish") in the debugger I can drill down and see the value for fish. Hower the commented out code gives an error. i can't see any way to access dictionaries within dictionaries. I have tried setting dict1.value("catch") to a new dictionary but then I can't seem to set a key value pair for that either. Any ideas (running 2009 5.1 on 10.6.2) Top tomsi Post subject: Re: dictionary of dictionaryPosted: Wed Jan 27, 2010 6:17 pm Joined: Wed Nov 16, 2005 4:58 pm Posts: 50 Location: Sandvika, Norway I think you have to break that expression into two statements. Code:Dim tmpdict As Dictionary dim mycatchcolour as string tmpdict = dict1.value("catch") mycatchcolour = tmpdict.value("fish") Top timhare Post subject: Re: dictionary of dictionaryPosted: Wed Jan 27, 2010 6:19 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 7177 Location: Portland, OR USA dict1.value("catch") returns a Variant. Variant doesn't have a Value property. You have to tell the compiler that it is really a dictionary. The easiest way is just to unload it in the reverse of how you loaded it - use an intermediate dictionary. Code:dict2 = dict1.value("catch") mycatchcolour = dict2.value("fish") You might also be able to cast the intermediate value as dictionary and do it in one line. Code:mycatchcolour = Dictionary(dict1.value("catch")).value("fish") Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
