It is currently Wed Oct 15, 2008 10:57 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: cfgfile::GetConfigValue()
PostPosted: Sun May 18, 2008 5:08 am 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 223
We already have GetConfigInt, GetConfigReal and GetConfigString. What would GetConfigValue do?

Same thing as configelemref.key - that is, analyze and choose the type of the value before it is copied to variable, instead of converting it into a string.

This is useful when scripter does not know the structure of config file element the script will parse.

Code:
// example.cfg
configelem example
{
    key1    text
    key2    193
    key3    31.1
}


Code:
var elem := ReadConfigFile("example")["example"];

foreach key in ListConfigElemProps(elem)
    // array{ "key1", "key2", "key3" }
    // There's no way to read the correct values (at least, without trial-error).
   // GetConfigString(elem, key); is safe solution but is not suitable if values are later to be used "blindly".
   // elem.key does not work because it is read as elem."key"
   // GetConfigValue(elem, key), if existed, would return
   // "text", 193 and 31.1.
endforeach


I hope this explains it.


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

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