Docfxit Posted October 30, 2014 Share Posted October 30, 2014 (edited) I have successfully saved a registry key in $a[0]. Because $a is used in a different routine I'd like to save the contents of $a in another array that I chose called $Entries. There will always be one line with a number of columns $a. I need to increment $Entries to put each line of $a into a new line of $Entries so I can write $Entries to a file later. I couldn't figure out how to write each line of $a to a file adding each line to the same file. That's the reason for saving the line into $Entries to be written to the file later. #RequireAdmin #include <Array.au3> #include <File.au3> #include <_RegEnumKeyValEx.au3> ; The above #included script was written by DXRW4E ; and can be found here: http://www.autoitscript.com/forum/topic/144234-regenumkeyvalex-regenumkeyex-regenumvalex/?p=1207033 Global $Entries[5] [5], $a, $t, $i, $Error, $Extended, $KeyName $i += 1 $KeyName = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" $a = _RegEnumValEx($KeyName, 128 + 256 + 32, "AutoAdminLogon") ConsoleWrite("Return = " & $a & " - $Error = " & $Error & " - $Extended = " & $Extended & @LF) _ArrayDisplay($a) $Entries[$i][0] = $a _ArrayDisplay($Entries) ;Does not show anything added What am I doing wrong in saving the line of $a into the array $Entries? Thank you, Docfxit Edited October 30, 2014 by Docfxit Link to comment Share on other sites More sharing options...
Gianni Posted October 30, 2014 Share Posted October 30, 2014 Hi Docfxit you are storing the whole array $a into one element of the array $Entries, and this is ok, doing so you are making an array of arrays, what you are doing wrong is trying to display it with _ArrayDisplay, you can't show with _ArrayDisply an array of arrays. You have to extract back the Array stored in $Entries and then use _ArrayDisplay to display it. Something like this: _ArrayDisplay($a) $Entries[$i][0] = $a ; .... $b = $Entries[$i][0] ; retrieve the array _ArrayDisplay($b) Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Docfxit Posted October 31, 2014 Author Share Posted October 31, 2014 Thank you for the reply... The array of an array is getting too complicated. I found out how to append to a file, so I'd like to figure out what is wrong with this code. I'm getting an error saying: "C:ProgramsAutoIt3IncludeFile.au3" (660) : ==> Error parsing function call.: Func _FileWriteFromArray($sFilePath, Const ByRef $aArray, $iBase = Default, $iUBound = Default, $sDelimeter = "|") Func _FileWriteFromArray($sFilePath, Cons^ ERROR #RequireAdmin #include <Array.au3> #include <File.au3> #include <FileConstants.au3> #include <_RegEnumKeyValEx.au3> ; The above #included script was written by DXRW4E ; and can be found here: http://www.autoitscript.com/forum/topic/144234-regenumkeyvalex-regenumkeyex-regenumvalex/?p=1207033 ;AutoIt_Debugger_Command:Enable_Debug Global $a, $t, $i, $Error, $Extended, $KeyName Local Const $ExtensionsFile = @ScriptDir & "\%OriginalRegistryKeys.txt" Local $hExtensionsFile = FileOpen($ExtensionsFile, $FO_APPEND) FileCreate($hExtensionsFile, "") $i += 1 $KeyName = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" $a = _RegEnumValEx($KeyName, 128 + 256 + 32, "AutoAdminLogon") _FileWriteFromArray($hExtensionsFile, $a & @CRLF) FileClose($hExtensionsFile) ; Create a file. Func FileCreate($hExtensionsFile, $sString) Local $bReturn = True ; Create a variable to store a boolean value. If FileExists($hExtensionsFile) = 0 Then $bReturn = FileWrite($hExtensionsFile, $sString) = 1 ; If FileWrite returned 1 this will be True otherwise False. Return $bReturn ; Return the boolean value of either True of False, depending on the return value of FileWrite. EndFunc ;==>FileCreate Thank you, Docfxit Link to comment Share on other sites More sharing options...
Solution kylomas Posted October 31, 2014 Solution Share Posted October 31, 2014 Change _FileWriteFromArray($hExtensionsFile, $a & @CRLF) to _FileWriteFromArray($hExtensionsFile, $a) You could have referenced your array within an array like this... _ArrayDisplay($Entries[0]) kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Docfxit Posted October 31, 2014 Author Share Posted October 31, 2014 That's great. That fixed the problem. It's really nice of all of you to help resolve these issues. Thanks a bunch, Docfxit 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