Feedback problems.
INI unable to read the following [2]
[2] a [3] a [1] w
Feedback problems.
INI unable to read the following [2]
[2] a [3] a [1] w
Feedback problems.
INI unable to read the following [2][2] a [3] a [1] w
Thank you. Confirmed bug. Not surprisingly, it is a bug related to sorting. It is triggered when using whole numbers in section names and the numbers are not ordered least to greatest. There is no issue If you start with [1], then [2], and [3], or use, say, a decimal number (2.0, 3.0, and 1.0) or use non-numeric keys, there is no issue. For example,
sIni:=" (LTrim [2.0] a [3.0] a [1.0] w )" vIni := class_EasyIni("", sIni) for sec, aData in vIni for k, v in aData Msgbox %sec%`n%k% return
Tracking down this bug will be tricky -- it is in the code I copied from this post and this post. In the meantime, I hope my workaround is sufficient.
Scripts are written and tested using AHK_H 64w (unless otherwise specified).
CFlyout. EasyIni. Dynamic Label Execution (No Reload). Word Lookup.
Feedback problems.
INI unable to read the following [2][2] a [3] a [1] w
Thank you. Confirmed bug. Not surprisingly, it is a bug related to sorting. It is triggered when using whole numbers in section names and the numbers are not ordered least to greatest. There is no issue If you start with [1], then [2], and [3], or use, say, a decimal number ([2.0], [3.0], and [1.0]) or use non-numeric keys. For example,
sIni:=" (LTrim [2.0] a [3.0] a [1.0] w )" vIni := class_EasyIni("", sIni) for sec, aData in vIni for k, v in aData Msgbox %sec%`n%k% return
Tracking down this bug will be tricky -- it is in the code I copied from this post and this post. In the meantime, I hope my workaround is sufficient.
Scripts are written and tested using AHK_H 64w (unless otherwise specified).
CFlyout. EasyIni. Dynamic Label Execution (No Reload). Word Lookup.
Hi Larctic, I think this issue is an AutoHotKey limitation having to do with using numeric keys in arrays. I have duplicated the problem in OrderedArray (EasyIni object is basically built from this object) and am waiting on a response to confirm this bug and to see if there is any workaround/fix.
Scripts are written and tested using AHK_H 64w (unless otherwise specified).
CFlyout. EasyIni. Dynamic Label Execution (No Reload). Word Lookup.
Thanks. This is my temporary solution. Very slowly.
Z_Ini(h,p=""){ If !InStr(h,"`n") FileRead, h, %h% If h:=Trim(h," `t`r`n") { j:=OrderedArray() ;,p ? h:=Replace_Var(h):"" Loop, Parse, h, `r`n, `r `t { (!A_LoopField or (p:=SubStr(i:=A_LoopField,1,1)) = ";") ? "" : ((p = "[" and p:=InStr(i,"]",0,0)) ? n:=j[SubStr(i, 2, p-2)]:=OrderedArray(): ((p:=InStr(i,"=")) ? n[Trim(SubStr(i, 1, p-1))] := Trim(SubStr(i, p+1)) : (n[i]:=""))) } return j } }
Verdlin,
Good work bud. Just a heads up with the .Save() function is a little buggy when it comes to preserving format of the .ini read initially if you throw in comments.
EG:
Original:
; Some fancy comments [Section] key=value ;More fancy comments [Section 2] key=value
Will format as this after it's saved:
; Some fancy comments[Section] key=value ;More fancy comments[Section 2] key=value
I discovered this minor bug when writing a new function. Your read from string function comes in handy for my purpose and I was disapointed when I couldn't find the oposite, so I made my own. I've revised your .Save() and my SaveToVar() to be a little bit more legible (to me). Still not fully there but it works for me for now... Maybe you can write one better and include in your distro?
Oh, and did I say great work? you guys rock.
SaveToVar() { ReturnString :="" ; initialize the return variable (old habit) ; Formatting is preserved in ini object for k, v in this.EasyIni_ReservedFor_TopComments { if NOT (A_Index == 1) ReturnString .= "`n" if NOT (v==Chr(14)) ReturnString .= v } for section, aKeysAndVals in this { ReturnString .= "`n[" . section . "]" ; always a new line at the start of section (just like keys below) bEmptySection := true for key, val in aKeysAndVals { bEmptySection := false ReturnString .= "`n" . key . "=" . val ; Add the comment(s) for this key stComments := this[section].EasyIni_ReservedFor_Comments[key] Loop, Parse, stComments, `n { ReturnString .= "`n" if NOT (A_LoopField == Chr(14)) ReturnString .= A_LoopField } } if (bEmptySection) { ; An empy section may contain comments... stComments := this[section].EasyIni_ReservedFor_Comments["SectionComment"] Loop, Parse, stComments, `n if NOT (A_LoopField == Chr(14)) ReturnString .= A_LoopField } } return ReturnString }
...Save() function is a little buggy when it comes to preserving format of the .ini read initially if you throw in comments.
Thanks for catching that! This has been fixed.
Your read from string function comes in handy for my purpose and I was disapointed when I couldn't find the oposite......Maybe you can write one better and include in your distro?
Oh, and did I say great work? you guys rock.
Wow. That is so obvious I don't even know how I missed it. That's a great idea. I went ahead and added my own version of it, but there are two things I should note:
Scripts are written and tested using AHK_H 64w (unless otherwise specified).
CFlyout. EasyIni. Dynamic Label Execution (No Reload). Word Lookup.
Hello, I'm an ultra newbie, so please bear with me.
How do I actually read the keys exactly as they are into variables? I mean, getting a result of Var1=11 and etc. I read the OP, but obviously I'm doing it wrong.
;This is my ini Test.ini [Test] Var1=11 Var2=33
I'm trying to switch all my files to .ini and this looks like the thing to use, Thanks for the help!
Hello, I'm an ultra newbie, so please bear with me.
How do I actually read the keys exactly as they are into variables? I mean, getting a result of Var1=11 and etc. I read the OP, but obviously I'm doing it wrong.
;This is my ini Test.ini [Test] Var1=11 Var2=33I'm trying to switch all my files to .ini and this looks like the thing to use, Thanks for the help!
Hi Vilkra! Sorry for the late reply -- I have been rather inactive lately. If you have a file named Test.ini, then this is how you would load it...
vTestIni := class_EasyIni("Test.ini") ; this assumes Test.ini is in the same location as AutoHotkey.exe for sec, aData in vTestIni for k, v in aData Msgbox [%sec%]`n%k%=%v% ; To answer you question about getting the result of Var1, the shorthand way of doing that is: Msgbox % vTestIni.Var1 ; Show output "11"
Scripts are written and tested using AHK_H 64w (unless otherwise specified).
CFlyout. EasyIni. Dynamic Label Execution (No Reload). Word Lookup.
Support discontinued here and continued in http://ahkscript.org....php?f=6&t=5522
Scripts are written and tested using AHK_H 64w (unless otherwise specified).
CFlyout. EasyIni. Dynamic Label Execution (No Reload). Word Lookup.