IgntionX - iConfig not writing to file

Monkey Forums/Monkey Programming/IgntionX - iConfig not writing to file

ombinar(Posted 2014) [#1]
Hello,

I followed the sample here and debug showing change of value when using c.WriteString("Count", 77)

I checked the config.txt file and it's not updated.

Local c:iConfig=New iConfig("config.txt")

http://docs.playniax.com/html/Modules_playniax.ignitionx.framework.config_iConfig.html#description

config.txt content:

Name=Jack

Count=12
Width=32
Height=32

Alpha=.8
Red=255
Green=160
Blue=80
ScaleX=8
ScaleY=8


Playniax(Posted 2014) [#2]
You can use Monkey SaveString to save data to a file.

To get the config data in memory you can use the Data() method.

For example:

Local c:iConfig=New iConfig("config.txt")
c.WriteString("Count", 77)
Print c.Data()


And to save to file:

SaveString(c.Data(),"myfile.txt")


The iConfig object was originally designed to work for reading settings or skin files.

The write functions only makes changes to the values in memory.

iConfig goes back to the time that monkey was still very young and had limited file access.

Ignition X also has an iStorage class to save the data but it uses the monkey LoadState and SaveState commands but that does not make changes to the loaded text file.


ombinar(Posted 2014) [#3]
Perfect, thanks!