PenUltima Online

It is currently Sat Sep 06, 2008 6:28 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: .cfg file question
PostPosted: Wed Dec 19, 2007 2:17 pm 
Offline

Joined: Tue Mar 20, 2007 7:17 am
Posts: 99
Location: Poland
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)???


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 20, 2007 9:08 am 
Offline
Distro Developer
User avatar

Joined: Thu Apr 06, 2006 5:11 pm
Posts: 350
Location: Nederland, Texas
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 20, 2007 4:58 pm 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 409
Location: San Diego, California
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.

_________________
-Austin


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 22, 2007 3:28 pm 
Offline

Joined: Tue Mar 20, 2007 7:17 am
Posts: 99
Location: Poland
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?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 22, 2007 3:41 pm 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 409
Location: San Diego, California
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.

_________________
-Austin


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl