write and read .ini files

Monkey Forums/Monkey Programming/write and read .ini files

lom(Posted 2014) [#1]
Hello,
Is it possible to write and read .ini files with Monkey?


ImmutableOctet(SKNG)(Posted 2014) [#2]
INI files are really simple, writing a quick reader or writer (Especially with reflection being a thing) would be pretty easy. INI's not really a proper format to begin with, but you could read this as a reference. I'm not sure if someone's made a module for this or not, though.

Generally, you'll want to either use reflection (Which could get a bit complicated at times), or you could just read names and their values as strings, then simply keep them in a 'StringMap<String>'. From there you could write your code to either check names with reflection, or just use string literals/constants to get the proper value of each variable.

It's a pretty basic format, if you even want to call it that, so you shouldn't really have an issue writing a basic system for it. INI files aren't always the best option though, have you looked into XML or writing your own configuration format? Hope this helps, I'm not sure if it has already been done, though. XML modules are already available from several users on here. I currently use SKN3's XML module for some basic menu stuff. More specifically, I write/generate it as XML, then "compile" it into a binary format.


Pharmhaus(Posted 2014) [#3]
*click*


lom(Posted 2014) [#4]
ImmutableOctet(SKNG)
,
Pharmhaus

Thank you very much, I'll try both ways!