Loading…

Round Trip Ini Writer

Most INI readers parse into a plain key/value map and, when writing changes back, regenerate the whole file grouped by section from that map. That throws away everything a human maintainer put into the file for their own benefit: explanatory comments, blank lines separating logical groups, and the order keys happen to appear in. The next time someone opens that config by hand, it looks like a different file even though only one setting changed. This library keeps each line's ORIGINAL TEXT as the source of truth for anything that is not a key's value. A comment line, a blank line, or a malformed line is stored verbatim and written back unchanged. A key=value line is split into key, value, and any trailing inline comment (";..." or "#..." after the value) - SetString() only ever replaces the value part of an existing line, leaving its inline comment and every other line in the file untouched. Adding a brand-new key inserts it right after the last existing key in its section (or creates the section, with a separating blank line, if it did not exist yet) rather than appending it somewhere arbitrary. Notes and limitations - Sections and inline comments are matched exactly as written - section names and keys are case-sensitive. - Inline comment detection looks for a ';' or '#' preceded by whitespace (or at the very start of the value); a value that genuinely contains one of those characters without surrounding whitespace is not misread, but a value needing a literal " ; " or " # " sequence inside it cannot be represented - use a differently-formatted value in that case. - No quoted-value support (no '"value with = inside"' escaping) - a value containing '=' would be misread past the first '=' in the line. This matches plain INI, not any of its quoted-string dialects. - A newly-added key or section has no inline comment or blank-line spacing of its own beyond what SetString() adds automatically - it will not look hand-styled until a human edits it further.

Script · MT4 · v1.0 · Free

About Round Trip Ini Writer

Round Trip Ini Writer is a script for MetaTrader 4. MQL source code included.

Files in the download: RoundTripIniWriter.mqh, RoundTripIniWriter.txt, RoundTripIniWriterDemo.mq4.

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria