Unit 'msestat' Package
[Overview][Constants][Types][Classes][Procedures and functions][Index] [#msegui]

tstatwriter

[Properties (by Name)] [Methods (by Name)]

Writes structured, human-readable data (sections, booleans, integers, strings, arrays...) to a text file or stream, using an INI-like format

Declaration

Source position: msestat.pas line 201

type tstatwriter = class(tstatfiler)

public

  constructor create();

  procedure writesection();

  procedure writeboolean();

  procedure writebyte();

  procedure writeword();

  procedure writeinteger();

  procedure writeint64();

  procedure writereal();

  procedure writestring();

  procedure writebinarystring();

  procedure writemsestring();

  procedure writedatalist();

  procedure writearray();

  procedure writelistitem();

  procedure writerecord();

  procedure writerecordarray();

  function beginlist(); override;

  function endlist; override;

  procedure writevalue();

  procedure writestat();

  procedure writememorystatstream();

  procedure streamdata();

  procedure streamtext();

end;

Inheritance

tstatwriter

  

Writes structured, human-readable data (sections, booleans, integers, strings, arrays...) to a text file or stream, using an INI-like format

|

tstatfiler

|

TObject

Description

Writes structured, human-readable data (sections, booleans, integers, strings, arrays...) to a text file or stream, using an INI-like format. The data can be read back with tstatreader.

uses
  sysutils,
  msetypes, // filenamety
  msestat;  // tstatwriter, tstatreader

const
  cfilename: filenamety = 'demo.sta';
  cmsestringarty: msestringarty = ('ein');

var
  lstatwriter: tstatwriter;
  lstatreader: tstatreader;
  lmsestringarty: msestringarty;
  lmsestring: msestring;

begin
  try
    lstatwriter := tstatwriter.create(cfilename);
    with lstatwriter do
    begin
      writesection('options');

      writemsestring('a', 'abracadabra');
      writeboolean('b', TRUE);
      writeinteger('c', 2020);

      writearray('d', ['ein', 'zwei', 'drei']);
    end;
  finally
    lstatwriter.free;
  end;

  try
    lstatreader := tstatreader.create(cfilename);
    with lstatreader do
    begin
      setsection('options');

      WriteLn(readmsestring('a', '?'));
      WriteLn(readboolean('b', FALSE));
      WriteLn(readinteger('c', 0));

      lmsestringarty := readarray('d', cmsestringarty);
      for lmsestring in lmsestringarty do
        WriteLn('* ', lmsestring);
    end;
  finally
    lstatreader.free;
  end;
end.

Documentation generated on: 2026-10-03