Posted: Wed Dec 19, 2007 6:17 pm Post subject: .cfg file question
When I read a cfg file (using ReadConfigFile(filename)) do I have to unload this .cfg file??? Or is it unloaded automaticly when script ends (or exits by return)???
If you do not unload it it should be unloaded for you when it's no longer referenced.
Author
Message
Austin POL Developer
Joined: 30 Jan 2006 Posts: 345 Location: San Diego, California
Posted: Thu Dec 20, 2007 8:58 pm Post subject:
When you load a config file with ReadConfigFile() it parses it and stores it internally for faster usage later on when you use it in other scripts (it has to be read in the same way though)
If you unload it in a script, it removes the data from the cache and has to be reparsed again.
I have readconfigfile(something) in my AI script (for setup). This script is used by about 10000 mobiles. Is it better not to unload this config after setup or it is better to unload it?
Author
Message
Austin POL Developer
Joined: 30 Jan 2006 Posts: 345 Location: San Diego, California
Posted: Sat Dec 22, 2007 7:41 pm Post subject:
If you only need a config file once then unload it.
If you write to a config file you must unload it to have it updated in memory.
Most the time you don't want to unload a config file because it will have to be removed/reread.
The config file on the first use is parsed and stored in memory.
Every time after that, it is retrieved from memory for speed.
If you call UnloadConfigFile() then the next time ReadConfigFile() is used, the file must be read from disk and parsed back into memory.