.cfg file question

Archive of posts related to former distro versions. Be aware that posts here do not refer to the current distro and may not work.

Moderators: POL Developer, Distro Developer

Locked
coltain
Grandmaster Poster
Posts: 159
Joined: Tue Mar 20, 2007 7:17 am
Location: Poland

.cfg file question

Post by coltain »

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)???
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm
Location: Nederland, Texas

Post by tekproxy »

You don't have to but it's good practice to.

If you do not unload it it should be unloaded for you when it's no longer referenced.
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Post by Austin »

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.
coltain
Grandmaster Poster
Posts: 159
Joined: Tue Mar 20, 2007 7:17 am
Location: Poland

Post by coltain »

So what is better???

for eg.

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?
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Post by Austin »

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.
Locked