Kerros Posted November 8, 2007 Posted November 8, 2007 I'm posting this here first as there is a workaround for the issue, but it still seems like it would be a bug. IniWriteSection will not create a folder when creating a new Ini file. If you manually create the folder IniWriteSection will create the file in the newly created folder. CODEDim $aData2[3][2] = [ [ "FirstKey", "FirstValue" ], [ "SecondKey", "SecondValue" ], [ "ThirdKey", "ThirdValue" ] ] $sIni = @DesktopDir & "\test.ini" $return1 = IniWriteSection($sIni,"SectionA",$adata2,0);<---Creates file correctly ConsoleWrite("DesktopDir: "&$return1&@error&@CRLF) $sIni2 = @DesktopDir & "\temp\test2.ini" $return2 = IniWriteSection($sIni2,"SectionB",$adata2,0);<---Does not create directory and file ConsoleWrite("DesktopDir and another folder: "&$return2&@error&@CRLF) DirCreate( @DesktopDir&"\temp");Manually create directory $return3 = IniWriteSection($sIni2,"SectionB",$adata2,0);<---Creates file ConsoleWrite("DesktopDir and another folder after manually creating folder: "&$return3&@error&@CRLF) Any Ideas or does this need to be moved to the Bug Report Forum? Thanks, Kerros Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.
Nahuel Posted November 8, 2007 Posted November 8, 2007 And why would this be a bug? It doesn't say anywhere that if the directory doesn't exist it is created.If file does not exist, it is created. Keys and/or sections are added to the end and are not sorted in any way.
Kerros Posted November 8, 2007 Author Posted November 8, 2007 (edited) Ok, maybe not so much a bug as a feature request then. While the documentation does state that file will be create, it was my assumption that the path would also be created as well, as you can't create a file without the folder being there. A change in the documentation would also be helpful. If file does not exist, it is created, if the path already exists. Keys and/or sections are added to the end and are not sorted in any way. This may just be a suggestion then, if something similar to the flags for filecopy or filemove flag [optional] this flag determines whether to overwrite files if they already exist: Can be a combination of the following: 0 = (default) do not overwrite existing files 1 = overwrite existing files 8 = Create destination directory structure if it doesn't exist (See Remarks). Edited November 8, 2007 by Kerros Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.
Moderators SmOke_N Posted November 8, 2007 Moderators Posted November 8, 2007 The Ini* functions use standard Microsoft functions currently, if you feel this to be a bug, you'll need to report the issue with them. 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.
Kerros Posted November 8, 2007 Author Posted November 8, 2007 I posted about this being a possible bug because the function didn't work as I had expected it to. Upon finding out that it's not a bug, but this is how it's designed, I posted a suggestion. If there are more important features or things that need to be worked on for the functionality of AutoIt that is fine, and this suggestion can be ignored. I now know how it works and will be able to apply that. Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.
Moderators SmOke_N Posted November 8, 2007 Moderators Posted November 8, 2007 I posted about this being a possible bug because the function didn't work as I had expected it to. Upon finding out that it's not a bug, but this is how it's designed, I posted a suggestion. If there are more important features or things that need to be worked on for the functionality of AutoIt that is fine, and this suggestion can be ignored. I now know how it works and will be able to apply that.Ini questions have been popping up quite a bit lately... You could write a simple/quick wrapper for it I'm sure... Something like:Func _IniWriteSection($sFileName, $sSection, $sData, $iIndex = 1) If FileExists($sFileName) = 0 Then FileClose(FileOpen($sFileName, 10)) Return IniWriteSection($sFileName, $sSection, $sData, $iIndex) EndFuncMaybe... I'm not sure, but by the sound of it, it "looked" like Valik may end up re-writing the Ini functions natively... which may change somethings. 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.
Kerros Posted November 8, 2007 Author Posted November 8, 2007 Thank you SmOke_N that wrapper worked well, I just changed $index = 1 to $index to make it more universal for my script. Kerros Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.
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