iamtheky Posted June 28, 2015 Posted June 28, 2015 (edited) I gave this as an answer, because it worked as i was playing. It feels really dirty, just wanted some expert dismantling:Local $mMap[] $mMap['cat'] = mapappend($mMap , 'jack') $mMap['dog'] = mapappend($mMap , 'jeff') $mMap['pig'] = mapappend($mMap , 'john') msgbox(0, '' , $mMap[$mMap.cat]) msgbox(0, '' , $mMap[$mMap.dog]) msgbox(0, '' , $mMap[$mMap.pig]) same thing i guess inspired to mimic the scripting dictionary example below:Local $mMap[] $mMap['cat'] = mapappend($mMap , 'jack') $mMap['dog'] = mapappend($mMap , 'jeff') $mMap['pig'] = mapappend($mMap , 'john') For $each In $mMap If stringlen($mMap[$each]) > 1 Then ConsoleWrite(mapkeys($mMap)[$each * 2] & " = " & $mMap[$each] & @CRLF) Next Edited June 28, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Luigi Posted June 28, 2015 Posted June 28, 2015 Local $oo = ObjCreate("Scripting.Dictionary") $oo.Add("cat", "jack") $oo.Add("dog", "jeff") $oo.Add("pig", "john") For $each In $oo ConsoleWrite($each & " = " & $oo.Item($each) & @LF) Next? Visit my repository
iamtheky Posted June 28, 2015 Author Posted June 28, 2015 (edited) I do need to learn more scripting dictionary, it looks great everytime i see it. However, my curiosity is more about the misuse of map; using the key of one entry to pull the value of another, as best I can describe. Edited June 28, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
iamtheky Posted June 29, 2015 Author Posted June 29, 2015 (edited) How about this? Is there any usefulness to having the value be essentially a stored arrayfindall return of the values related to that key?My thought was that I get to keep an order of updates, but dont know if that is accomplished other ways as well. local $mMap[] $mMap['TestCat'] = MapAppend($mMap , 'Entry 1 about Cat') & "|" & MapAppend($mMap , 'Entry 2 about cat') & "|" & MapAppend($mMap , 'Entry 3 about cat') $mMap['TestDog'] = MapAppend($mMap , 'Entry 1 about Dog') & "|" & MapAppend($mMap , 'Entry 2 about Dog') & "|" & MapAppend($mMap , 'Entry 3 about Dog') _MapAddToKey($mMap , "TestDog" , "An additional entry in the map tied to TestDog") _MapAddToKey($mMap , "TestCat" , "An additional entry in the map tied to TestCat") _MapAddToKey($mMap , "TestDog" , "One last entry tied to TestDog") msgbox(0, '' , _MasterKeyGetValues($mMap.TestDog)) msgbox(0, '' , _MasterKeyGetValues($mMap.TestCat)) Func _MapAddToKey(ByRef $sMap , $sKey , $sValue) $sMap[$sKey] &= "|" & MapAppend($sMap , $sValue) EndFunc Func _MasterKeyGetValues($MasterKey) local $out = "" $aKeys = stringsplit($MasterKey , "|" , 2) For $i = 0 to ubound($aKeys) - 1 $out &= $mMap[number($aKeys[$i])] & @LF Next return $out EndFunc Edited June 29, 2015 by boththose I have somehow dorked the formatting, sorry ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now