Ini Files - Read Multi Lines?

后端 未结 8 2208
旧巷少年郎
旧巷少年郎 2020-12-16 03:40

I am aware that Ini Files are meant for single lines of information, needless to say I am trying to read/write multi lines to and from the Ini - without much success (I alwa

8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-16 04:22

    I wanted something similar, to include the body of an automated email in the ini file.
    But I also wanted blank lines in the body. Here is part of the ini file

    [EmailBody]
    This is the weekly Survey Status notification email.
    .
    It lists Survey Reports that may need some attention.
    .
    The purpose of this information is to improve conduct-of-operations in our tracking, 
    recordkeeping, and maintenance of Survey Reports.  This report will also enable 
    us to identify any changes made to electronic Surveys following the normal QA review.
    .
    Please review your information weekly and determine if you need to take corrective action.
    

    Here is what I ended up doing

    var
      Config: TMemIniFile;
      sl: TStringList;
    ...
      sl := TStringList.Create;
      Config.ReadSectionValues('EmailBody', sl);
      for i := 0 to sl.Count - 1 do
        if sl[i] = '.' then
          sl[i] := '';
    

提交回复
热议问题