rootx Posted March 30, 2017 Share Posted March 30, 2017 (edited) The path are cutted! maybe double [] in the path generated the error. Example: [I:\aaa\cc\aa vv vv vv (dd).txt] name=aa vv vv vv (dd).txt [I:\ffff\ffff\ffff ffff ffff ffff [ffff]\ffff\ffff.txt] name=ffff.txt $ini = IniReadSectionNames(@ScriptDir&"\my.ini") _ArrayDisplay($ini) for $x = 1 to UBound($ini)-1 ConsoleWrite($ini[$x]&@CRLF) Next Edited March 30, 2017 by rootx Amended title Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 30, 2017 Moderators Share Posted March 30, 2017 @rootx if you believe you have found a bug, please use the Bug Tracker section to report it. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
rootx Posted March 30, 2017 Author Share Posted March 30, 2017 (edited) 11 minutes ago, JLogan3o13 said: @rootx if you believe you have found a bug, please use the Bug Tracker section to report it. I'm not sure why [] is the standard ... and the solution is to skip the brackets inside the path string. But I'm not sure if you can, or you need to clean the name of the folder or change approach. Edited March 30, 2017 by rootx Link to comment Share on other sites More sharing options...
water Posted March 30, 2017 Share Posted March 30, 2017 Are you sure that square brackets are allowed in a section name? Do INI-files support escape characters or encoded characters? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
rootx Posted March 30, 2017 Author Share Posted March 30, 2017 (edited) for example it can happen that people write of the strange path as C: \ name [IBIS 001] 2017. But ini standard are [C: \ name [IBIS 001] 2017\file.txt] name=IBIS 001 years=2017 etc... Edited March 30, 2017 by rootx Link to comment Share on other sites More sharing options...
TheSaint Posted March 30, 2017 Share Posted March 30, 2017 Just over a month ago, I created a viewer (ASCII Checker) to help with determining INI entry issues. It might be of some help to you, and can be found here. There is also a link in the quoted section, to a Wikipedia article about INI files and escape characters. rootx 1 Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 30, 2017 Moderators Share Posted March 30, 2017 rootx, You will have to do some pre/post-processing of the section names if you think there might be [ ] characters in the section name: #include <Array.au3> $sIniFile = "Test.ini" $sPath = "C: \ name [IBIS 001] 2017\file.txt" $sEscPath = StringReplace(StringReplace($sPath, "[", "\5B"), "]", "\5D") IniWrite($sIniFile, $sEscPath, "Key", "Value") $aSections = IniReadSectionNames($sIniFile) For $i = 1 To $aSections[0] $aSections[$i] = StringReplace(StringReplace($aSections[$i], "\5B", "["), "\5D", "]") Next _ArrayDisplay($aSections, "", Default, 8) And please do not be so quick to declare a bug - best ask first next time. M23 Decibel 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
rootx Posted March 30, 2017 Author Share Posted March 30, 2017 Thx, But the question is... if you have this ini file you are not able to read this file. [C: \ name [5BIBIS 001] 5D 2017\file.txt] Key=Value #include <Array.au3> $sIniFile = "Test.ini" $aSections = IniReadSectionNames($sIniFile) For $i = 1 To $aSections[0] $aSections[$i] = StringReplace(StringReplace($aSections[$i], "\5B", "["), "\5D", "]") ConsoleWrite($aSections[$i]) Next _ArrayDisplay($aSections, "", Default, 8) And how can you open this file C: \ name [5BIBIS 001 with iniread? Link to comment Share on other sites More sharing options...
rootx Posted March 30, 2017 Author Share Posted March 30, 2017 Thx. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 30, 2017 Moderators Share Posted March 30, 2017 (edited) rootx, You will need to read the ini file into an array, preprocess the [ & ] characters which are not bounding the section and then rewrite it - something like this: #include <Array.au3> #include <File.au3> $sPath = "C: \ name [IBIS 001] 2017\file.txt" $sIniFile = "Test.ini" $hFile = FileOpen($sIniFile, $FO_OVERWRITE) FileWrite($hFile, "[" & $sPath & "]" & @CRLF & "Key=Value") FileClose($hFile) Global $aLines _FileReadToArray($sIniFile, $aLines) _ArrayDisplay($aLines, "Original ini content", Default, 8) For $i = 1 To $aLines[0] ; Look for the section names If StringLeft($aLines[$i], 1) = "[" Then ; Extract the sectionname from within the [ & ] $sSectionName = StringTrimLeft(StringtrimRight($aLines[$i], 1), 1) ; Escape any [ & ] and rewrit ewith the external [ & ] $aLines[$i] = "[" & StringReplace(StringReplace($sSectionName, "[", "\5B"), "]", "\5D") & "]" EndIf Next ; Now rewrite the escaped ini file _FileWriteFromArray($sIniFile, $aLines, 1) ; Now read it $aSections = IniReadSectionNames($sIniFile) For $i = 1 To $aSections[0] $aSections[$i] = StringReplace(StringReplace($aSections[$i], "\5B", "["), "\5D", "]") Next _ArrayDisplay($aSections, "Section names from ini", Default, 8) M23 Edited March 30, 2017 by Melba23 Typos rootx 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
rootx Posted March 30, 2017 Author Share Posted March 30, 2017 #include <Array.au3> #include <File.au3> $sIniFile = "Test.ini" DirCreate(@ScriptDir&"\name [5BIBIS 001] 5D 2017") FileWrite(@ScriptDir&"\name [5BIBIS 001] 5D 2017\file.txt","xxxx") $file = _FileListToArrayRec(@ScriptDir,"*.txt",1,1,1,2) For $s = 1 to UBound($file)-1 IniWrite($sIniFile, $file[$s],"name",StringRegExpReplace($file[$s], "^.*\\(.*)$", "$1")) Next $aSections = IniReadSectionNames($sIniFile) For $i = 1 To $aSections[0] $aSections[$i] = StringReplace(StringReplace($aSections[$i], "\5B", "["), "\5D", "]") ConsoleWrite("WRONG "&$aSections[$i] & " WRONG " & $aSections[$i]&@CRLF) Next _ArrayDisplay($aSections, "", Default, 8) Thx, but at the same time i have writted!! I try your script thx again. Link to comment Share on other sites More sharing options...
rootx Posted March 30, 2017 Author Share Posted March 30, 2017 Anyway Thx guys, special thx Melba23 4your time. 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