How to read multiline values in inifile

北城以北 提交于 2019-12-06 09:06:34

The INI file format does not support multiline values. The specification is lines with either a section name in square brackets to start a new section or lines with a keyname followed by an equals sign followed by a value terminated in a line end. Or a comment line.

The tcllib parser splits the file into lines and if the line is not a comment, not a section start and does not contain an equals sign it is discarded.

If you want to include multiple values in an INI file value then you should use some application-specific field separator or multiple keys eg:

[Test.Field]
multi-field = first|second|third
[Test.MultiKey]
multi.1 = first
multi.2 = second
multi.3 = third

The first version could be used as simply as:

set ini [ini::open test.ini r]
set fields [split [ini::value $ini Test.Field multi-field] "|"]
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!