GEOSoft Posted July 24, 2007 Share Posted July 24, 2007 (edited) I've been looking through one of my Backup CD's while I'm on the Road and I came across an INI UDF that I use.It has_INISort (which is really INI sort all)_INISortSections (sort by section name)_INISortValues (sort by key name)_INIAddSection (allows you to add an empty section into an INI file for future use then sort it into place)_IniCopySection (allows you to copy a complete section from one ini file to another)_IniSortSectionByValue (sorts a section based on the data in the key value)I use it to clean up some really long and messy INI files. The reason I haven't posted it before is because I want to modify _INISortValues to return a 2 dimension array. I'm not going to do that soon.I had a request for it so here it is.Ini.au3EDIT: 01/19/2008 Code and demo replaced with a link and added a couple of functions. Edited January 19, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
ResNullius Posted July 25, 2007 Share Posted July 25, 2007 If anyone is interested then I'll post the code(it's all very short).I'm interested. I work with ini files quite a bit and like them in an easy human readable format. I'd done an ini sort before, then started using a modification of one SmOke_N had written http://www.autoitscript.com/forum/index.ph...st&p=352917 I was going to get around to doing some more functions like you've mentioned, but hey, if they're already done (and probably better then I could do at this point) then "show me the code!" Link to comment Share on other sites More sharing options...
GEOSoft Posted July 25, 2007 Author Share Posted July 25, 2007 I'm interested. I work with ini files quite a bit and like them in an easy human readable format. I'd done an ini sort before, then started using a modification of one SmOke_N had written http://www.autoitscript.com/forum/index.ph...st&p=352917 I was going to get around to doing some more functions like you've mentioned, but hey, if they're already done (and probably better then I could do at this point) then "show me the code!" OK, I added it to Post #1Enjoy George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
martin Posted July 25, 2007 Share Posted July 25, 2007 (edited) OK, I added it to Post #1EnjoyGreat, thanks GEOSoft. I will definitely use this; I've often wished ini files were sorted but I never did anything about it. Edited July 25, 2007 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
GEOSoft Posted July 25, 2007 Author Share Posted July 25, 2007 Great, thanks GEOSoft. I will definitely use this; I've often wished ini files were sorted but I never did anything about it.Thanks martinI wrote it because one of my INI files was getting to be about the same size as the old win.ini file and I like to find things easily when I'm looking. I also added it as a tool in Project Express. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
ResNullius Posted July 25, 2007 Share Posted July 25, 2007 OK, I added it to Post #1EnjoyThanks from me too! These will definitely come in handy and I always appreciate seeing how others have tackled problems I too was looking to solve. Link to comment Share on other sites More sharing options...
GEOSoft Posted July 25, 2007 Author Share Posted July 25, 2007 Thanks from me too! These will definitely come in handy and I always appreciate seeing how others have tackled problems I too was looking to solve.Thank youI just added a Demo script to the first post, primarily to show the usage of _IniSortValues() but all the functions except _IniAdd() are used. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Zephir Posted July 25, 2007 Share Posted July 25, 2007 simple and awesome.... simply awesome Link to comment Share on other sites More sharing options...
GEOSoft Posted July 25, 2007 Author Share Posted July 25, 2007 simple and awesome.... simply awesome Thank you.I was just editing the first post when you replied so you might want to re-read it George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
ResNullius Posted July 25, 2007 Share Posted July 25, 2007 (edited) Thank you I just added a Demo script to the first post, primarily to show the usage of _IniSortValues() but all the functions except _IniAdd() are used.Oh-Oh... Just to be a pain-in-the-*** I took the following (admittedly slightly non-standard) sample ini file and ran it thru your demo. [EMPTY] EMPTY = Nothing [@EMPTY2] EMPTY2 = Nothing2 [.EMPTY3] EMPTY3 = Nothing3 [-EMPTY4] EMPTY4 = Nothing4 [YIKES] A = ABCD C = ABCDE B = ABCDEF [XYLOPHONE] 1 = ABCD 3 = ABCDEF 2 = ABCDE [ZEBRA] 4 = Set to 3 5 = Set to 1 Choosing "ALL" produces this [@EMPTY2] EMPTY2=Nothing2 [7] [EMPTY] EMPTY=Nothing [-EMPTY4] EMPTY4=Nothing4 [XYLOPHONE] 2=ABCDE [YIKES] A=ABCD B=ABCDEF C=ABCDE [ZEBRA] 4=Set to 3 5=Set to 1 As you can see, the "[.EMPTY"] section is dropped entirely and replaced by the mysterious "[7]". Some other Characters at the start of section names seem to be a problem too (like "#"). Also the "[XYLOPHONE]' section whose key names are all numbers drops all but one entry. I'd have a go at seeing if I could fix it, but I thought maybe you should get first go GEOSoft Edit: fixed punctuation Edited July 25, 2007 by ResNullius Link to comment Share on other sites More sharing options...
GEOSoft Posted July 25, 2007 Author Share Posted July 25, 2007 (edited) Oh-Oh... Just to be a pain-in-the-*** I took the following (admittedly slightly non-standard) sample ini file and ran it thru your demo. [EMPTY] EMPTY = Nothing [@EMPTY2] EMPTY2 = Nothing2 [.EMPTY3] EMPTY3 = Nothing3 [-EMPTY4] EMPTY4 = Nothing4 [YIKES] A = ABCD C = ABCDE B = ABCDEF [XYLOPHONE] 1 = ABCD 3 = ABCDEF 2 = ABCDE [ZEBRA] 4 = Set to 3 5 = Set to 1 Choosing "ALL" produces this [@EMPTY2] EMPTY2=Nothing2 [7] [EMPTY] EMPTY=Nothing [-EMPTY4] EMPTY4=Nothing4 [XYLOPHONE] 2=ABCDE [YIKES] A=ABCD B=ABCDEF C=ABCDE [ZEBRA] 4=Set to 3 5=Set to 1 As you can see, the "[.EMPTY"] section is dropped entirely and replaced by the mysterious "[7]". Some other Characters at the start of section names seem to be a problem too (like "#"). Also the "[XYLOPHONE]' section whose key names are all numbers drops all but one entry. I'd have a go at seeing if I could fix it, but I thought maybe you should get first go GEOSoft Edit: fixed punctuationThanks I'll look at it again. Was that running the Demo script or calling the functions individually. The demo was pulled from one of my apps that uses the functions so I may have screwed up the conversion of the Demo. I ran it this morning against a long ini file and it was fine. If it had screwed up that file I would have been choked except that it does create a backup. Edit Backup a second here. The Ini file that you sent to it has spaces before and after the "=". That won't work. Any Ini function will fail then. After the "=" should be ok Though. I'll take a look anyway Edited July 25, 2007 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 25, 2007 Moderators Share Posted July 25, 2007 (edited) Nice work GeoSoft... I find making the functions I use to follow AutoIt's standards is most helpful if I'm going to share my work (or I just keep making Res keep editing my work )... the Ini* functions do catch the information if there is a space before or after the = sign though ... Edited July 25, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
GEOSoft Posted July 25, 2007 Author Share Posted July 25, 2007 Nice work GeoSoft... I find making the functions I use to follow AutoIt's standards is most helpful if I'm going to share my work (or I just keep making Res keep editing my work )... the Ini* functions do catch the information if there is a space before or after the = sign though ...Thanks SmokeI thought that a space before was taboo. Oh well I'm looking to mod it now. It hasn't failed me at all, and these are not new functions, but my Ini files never have the spaces. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 26, 2007 Moderators Share Posted July 26, 2007 Thanks SmokeI thought that a space before was taboo. Oh well I'm looking to mod it now. It hasn't failed me at all, and these are not new functions, but my Ini files never have the spaces.Yeah, mine don't either... but you have to "idiot" proof it sometimes ... keep up the good work. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
GEOSoft Posted July 26, 2007 Author Share Posted July 26, 2007 As you can see, the "[.EMPTY"] section is dropped entirely and replaced by the mysterious "[7]". That 7 is being caused by _ArraySort I can solve that. I think The same may apply to the rest I'm just not sure why it runs my files OK. That error should persist throughout. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted July 26, 2007 Author Share Posted July 26, 2007 @ResNullius I know the answer and I know the why so now I'm happy and I will post the modifications in a while and notify @everyone when it's done. I just want tho look at that Demo again first. The problem was this The Array.au3 file that I #include for my self is not the standard Array.au3 file. Some of the functions have been modified to suit me and one of those is _ArraySort(). That's why it works for me and why It failed For you. The 7 was actually Array[0] which in the code you posted was the number of elements. My _ArraySort already has $i_Descending = 0 AND $i_Base = 1 So the proper call to _ArraySort() using the standard UDF is _ArraySort(<Array>, 0, 1) George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted July 26, 2007 Author Share Posted July 26, 2007 Yeah, mine don't either... but you have to "idiot" proof it sometimes ... keep up the good work.I agree but it would be a real bummer if I had to add error handleing for a simple INIRead(). I've got the problem now anyway. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
ResNullius Posted July 26, 2007 Share Posted July 26, 2007 Yeah, mine don't either... but you have to "idiot" proof it sometimes ... keep up the good work."idiot" proof it sometimes... we wouldn't be implying anything now would we? Link to comment Share on other sites More sharing options...
GEOSoft Posted July 26, 2007 Author Share Posted July 26, 2007 "idiot" proof it sometimes... we wouldn't be implying anything now would we? Never!!!Do you really think that Smoke or I would single out an individual as an "IDIOT"? Well we probably would but we would never mention names. We're smarter than that.Give me 5 minutes and the new code will be up. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted July 26, 2007 Author Share Posted July 26, 2007 (edited) Post #1 has been updated to reflect the corrections in the _ArraySort() calls I also now have a sample on that page thanks to ResNullius. Next time I'll just let him fix it too. BTW @ResNullius That ini code wasn't mixed up enough for a good test so I modified it a bit so at least you can see some sorting by comparing to the result. But thanks for noticing the problem. I might have gone on thinking that because it worked for me that it was fine. Edited July 26, 2007 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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