From 7bf98411b6d4dfd203371b5d2ec0a5ef3a2305df Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 14 Mar 2010 01:25:25 +0100 Subject: version 0.8.8 --- examples/parsecfgex.nim | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 examples/parsecfgex.nim (limited to 'examples') diff --git a/examples/parsecfgex.nim b/examples/parsecfgex.nim new file mode 100755 index 000000000..618ecadd6 --- /dev/null +++ b/examples/parsecfgex.nim @@ -0,0 +1,25 @@ + +import + os, parsecfg, strutils, streams + +var f = newFileStream(paramStr(1), fmRead) +if f != nil: + var p: TCfgParser + open(p, f, paramStr(1)) + while true: + var e = next(p) + case e.kind + of cfgEof: + echo("EOF!") + break + of cfgSectionStart: ## a ``[section]`` has been parsed + echo("new section: " & e.section) + of cfgKeyValuePair: + echo("key-value-pair: " & e.key & ": " & e.value) + of cfgOption: + echo("command: " & e.key & ": " & e.value) + of cfgError: + echo(e.msg) + close(p) +else: + echo("cannot open: " & paramStr(1)) -- cgit 1.4.1-2-gfad0