LurchMan Posted August 26, 2010 Share Posted August 26, 2010 (edited) Hey everyone - I'm working on a small function that basically enumerates a section of the registry then stores the info in a 2D array (Key Name, Value) but I can't seem to get it to work right... Func: Func _EnumVals ($sPath) Local $aKeys[1][1] For $n = 1 To 1000 $Temp = RegEnumVal ($sPath, $n) If Not @error = -1 Then If UBound ($aKeys) - 1 < $n Then ReDim $aKeys[$n+1][$n+1] $aKeys[$n][0] = $Temp $aKeys[0][$n] = RegRead ($sPath, $aKeys[$n][0]) ;;;Can't seem to get it to store it right $aKeys[1][0] = Key Name, $aKeys[0][1] should hold value Else ExitLoop EndIf Next Return $aKeys EndFunc Edit - Sorry guys, I looked over the wiki for arrays again and it clicked finally, it needs to be: $aKeys[$n][1] = RegRead ($sPath, $aKeys[$n][0]) Edited August 26, 2010 by LurchMan Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
iamtheky Posted August 26, 2010 Share Posted August 26, 2010 also may want to Then ReDim $aKeys[$n+1][2] so as to not create another column for every row (reg key) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted August 27, 2010 Share Posted August 27, 2010 (edited) An empty array with 2000 elements is so small you could just remove that whole ReDim thing. ReDim is slow. Edit: Open task manager and run this: MsgBox(0, "", "") Local $array[1000][2] MsgBox(0, "", "")Notice how the ram-usage increased by only 12-16 K? Of course, if you do that you should do a ReDim at the end so there isn't any long-term waste lying around. And to make the array easier to handle. Edited August 27, 2010 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
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