A few weeks ago I bothered you with my variables which had a dot in their names. I finally solved it (ok, I rewrote my script from scratch in fact :lol: ). I think there was two problems : me calling a function with a paramater like foo.bar or %foo%.%bar% instead of foo "." bar and because I was storing the value for each key of my ini file in a variable named after this key (i.e. description.0.1.2.0.1=kiki)
For the same script, I need to append text in Unicode format. How can I do that ?
I saw Transform, Unicode but this doesn't seem to serve my purpose.
Thanks.
PS: my script which is working now, woot!
It probably has no interest for you but I wanted to post it.
Btw, it lacks a UI.
max=80 source:=A_ScriptDir "\install.ini" out:=A_ScriptDir "\out.ini" Loop, Read, %A_ScriptDir%\sectionlist.txt ;parses sections to sort { section:=A_LoopReadLine Sort() } Sort(oldlevel="", newlevel="") { ;the main function, recursively called Global max, source, out, section Loop, %max% { i:=A_Index - 1 ;WIHU's first index is 0 whereas AHK's one is 1 IniRead, iuv, %source%, %section%, description%oldlevel%.%i%, %A_Space% ;retrieves sections description if (iuv="") ;avoid adding non-existant indexes continue if (Names) ;appends a semi-column and the section name (iuv) with its old index (@i) to the list, except if ... Names:=Names ";" iuv "@" i else ;... except if the list is empty (would bug otherwise) Names:=iuv "@" i } Sort, Names, D`; StringSplit, Names, Names, `; Loop, %Names0% { i:=A_Index - 1 ;same as before : WIHU's first index is 0 whereas AHK's one is 1 Stringsplit, oldrank, Names%A_Index%, `@ ;retrieves old index Write(oldlevel "." oldrank2, newlevel "." i, "description") ;calls the write function for each Write(oldlevel "." oldrank2, newlevel "." i, "command") Write(oldlevel "." oldrank2, newlevel "." i, "selected") Write(oldlevel "." oldrank2, newlevel "." i, "hidden") Write(oldlevel "." oldrank2, newlevel "." i, "collapsed") Write(oldlevel "." oldrank2, newlevel "." i, "locked") Write(oldlevel "." oldrank2, newlevel "." i, "disabled") Write(oldlevel "." oldrank2, newlevel "." i, "group") Write(oldlevel "." oldrank2, newlevel "." i, "flags") Write(oldlevel "." oldrank2, newlevel "." i, "workdir") Write(oldlevel "." oldrank2, newlevel "." i, "helptext") Write(oldlevel "." oldrank2, newlevel "." i, "ext_creator_switchtype") Write(oldlevel "." oldrank2, newlevel "." i, "ext_creator_switchtype") IniRead, iuv, %source%, %section%, description%oldlevel%.%oldrank2%.0, %A_Space% ;is there a deeper level to sort ? if (iuv!="") Sort(oldlevel "." oldrank2, newlevel "." i) ;recursive call because when there is a deeper level } } FileRead, sorted, %out% StringReplace, sorted, sorted, description, `r`ndescription, All StringReplace, sorted, sorted, ]`r`n, ], All FileAppend, %sorted%, %A_ScriptDir%\sorted.ini ExitApp Write(old, new, var) { ;the write function global max, source, out, section IniRead, iuv, %source%, %section%, %var%%old%, %A_Space% ;retrieves the old value if (iuv!="") IniWrite, %iuv%, %out%, %section%, %var%%new% ;writes the new value }
PS2: sometimes a sheet of paper is better than a computer to code something.