Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Dec 15, 2018 4:07 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Concatenate Dictionaries - HOW?
PostPosted: Tue Oct 04, 2005 3:10 am 
Offline

Joined: Tue Oct 04, 2005 2:58 am
Posts: 2
Hi folks

I have Dict1 and Dict2. Both have key value pairs, some of the values are strings, some are Dictionaries. Some of the keys in Dict2 are the same as in Dict1.

Two dictionaries, each a random number of levels deep, ultimately storing key value pairs...

How do I just "tack Dict2 onto the end" of Dict1, so any keys that don't exist in Dict1 are created (either with string or dictionary values) and the keys that exist in Dict1 are overwritten by those in Dict2(string values might have to become Dictionaries and vice-versa) - is this even possible???

Any help would really, really be appreciated.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Oct 04, 2005 3:36 am 
Offline
User avatar

Joined: Fri Sep 30, 2005 8:05 am
Posts: 61
Location: Edinburgh, Scotland
This should do the trick. It uses the 'Keys' and 'Values' arrays to loop through the second Dictionary, adding each value into the first.

Beware of duplicate keys. If you have a key in the second dictionary that is the same as the first, the first value will be overwritten.

For x As Integer = 0 to Dict2.Count - 1
Dict1.Value(Dict2.Keys(x)) = Dict2.Values(x)
Next

_________________
Charlie Boisseau
[ My Site | My Blog | Net Tool Box ]


Top
 Profile  
Reply with quote  
 Post subject: Fantastic!
PostPosted: Tue Oct 04, 2005 4:01 am 
Offline

Joined: Tue Oct 04, 2005 2:58 am
Posts: 2
I cut, I paste, and.....

WORKS!

Thanks a ton.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group