This multiline problem has been visited before, at least here and here.
My primary concern was finding a replacement delimiter that wouldn't come back to haunt me. So far so good, but you never know.
(IniMulti.ahk)
Code: Select all
; ┌───────────────────────────────────────────────────────────────────────────┐
; │ After much frustration trying to include multiline values in │
; │ an .ini file, I came up with this. Much credit to those posts below. │
; │ This still needs work. │
; │ In particular, I'm having trouble coming up with a delimiter that │
; │ won't choke some future input. At first I picked "|n" but decided after │
; │ some consideration that it was an accident waiting to happen. │
; │ Thus ╬ below, whichappears as '╬' in my ini files. │
; │ Probably also an accident waiting to happen. Murphy's Law. │
; │ Change that if you manage to give your │
; │ script indigestion. │
; └───────────────────────────────────────────────────────────────────────────┘
IniMultiRead(IniFileName, Section:="", Key:="" , Default:="") {
Iniread, Value, %IniFileName%, %Section%, %Key%
StringReplace, Value, Value, ╬, `n, All
return Value
}
IniMultiWrite(IniVar, IniFileName, Section:="", Key:="") {
StringReplace, IniVar, IniVar, `n, ╬, All
IniWrite, %IniVar%, %IniFileName%, %Section%, %Key%
}
/*
https://autohotkey.com/board/topic/91849-how-to-save-multi-line-user-input-to-ini/
https://autohotkey.com/board/topic/33601-solved-multi-line-tooltip-from-ini-file/
π is alt+995
╬ is alt+1230
*/
Spoiler
Regards,burque505