Luigi Posted November 17, 2012 Share Posted November 17, 2012 (edited) A simple script to save an Array in ini file and load one or more sectionkey's ini file to array.IniToArray.au3 Read this, >FRED is script to code (string, number, array, Scripting.Dictionary) into string. This string can be save in file, and read/load again, rebuild the structure's data with your values. Edited April 13, 2014 by Detefon JScript 1 Visit my repository Link to comment Share on other sites More sharing options...
BrewManNH Posted November 17, 2012 Share Posted November 17, 2012 Nice idea, but you should include some error checking in it. Check to see if they passed an array, check to see that the array is only a 1 or 2D array, for example. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Luigi Posted November 17, 2012 Author Share Posted November 17, 2012 (edited) BrewManNH thanks for you replay, already exist a way to check is an array is 1D or 2D, its present in _arrayToIni, the first [switch Ubound($aName,2)], this is correct way to check this or exist a better option to this? About error cheking is a very good idea, but I dont have none idea at this moment, will try later. Best regards. Edited November 17, 2012 by detefon Visit my repository Link to comment Share on other sites More sharing options...
JScript Posted November 17, 2012 Share Posted November 17, 2012 Detefon swap your nickname for Luigi!About the UDF, is a great idea, thanks for sharing here too!JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
BrewManNH Posted November 17, 2012 Share Posted November 17, 2012 BrewManNH thanks for you replay, already exist a way to check is an array is 1D or 2D, its present in _arrayToIni, the first [switch Ubound($aName,2)], this is correct way to check this or exist a better option to this? About error cheking is a very good idea, but I dont have none idea at this moment, will try later. Best regards. You aren't checking for an incoming array at all. You need to use IsArray() to check to see if it's an array. Your Ubound statement is also looking at the wrong thing. You need to use Ubound($array, 0) to find out how many dimensions it has, Using Ubound($array,2) is only checking the second dimension to see how many "columns" the array has, if any dimension 2 exists that is. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Bowmore Posted November 18, 2012 Share Posted November 18, 2012 @BrewManNH I find that the use IsArray() is not necessary in AutoIt since we now have UBound() which can also do the job of checking if a variable is a valid array. Since we are usually using UBound() to check this size of the array before processing it, it seems superfluous to be to also check it with IsArray(). Example: expandcollapse popupGlobal $array1[2] = ["one","two"] Global $array2[2][3] = [["one","A","B"],["two","C","D"]] Global $array3 = 0 $Result = Ubound($array1,0) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Result = ' & $Result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $Result = Ubound($array1,1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Result = ' & $Result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $Result = Ubound($array1,2) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Result = ' & $Result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $Result = Ubound($array2,0) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Result = ' & $Result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $Result = Ubound($array2,1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Result = ' & $Result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $Result = Ubound($array2,2) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Result = ' & $Result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $Result = Ubound($array3,0) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Result = ' & $Result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $Result = Ubound($array3,1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Result = ' & $Result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $Result = Ubound($array3,2) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Result = ' & $Result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console For $i = 0 To UBound($array1) - 1 For $J = 0 To UBound($array1,2) - 1 ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $array1[$i][$j] = ' & $array1[$i][$j] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Next Next For $i = 0 To UBound($array2) - 1 For $J = 0 To UBound($array2,2) - 1 ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $array2[$i][$j] = ' & $array2[$i][$j] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Next Next For $i = 0 To UBound($array3) - 1 For $J = 0 To UBound($array3,2) - 1 ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $array3[$i][$j] = ' & $array3[$i][$j] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Next Next "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
BrewManNH Posted November 18, 2012 Share Posted November 18, 2012 Still, there's no check to see if the result of Ubound is returning any valid results in the script. Whether you use Ubound or IsArray, you still need to check for an array being sent to the function. Either way will work, the script just needs to do it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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