PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
cfgfile::GetConfigValue()

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> Feature Suggestions
Display posts from previous:   

Author Message
ncrsn



Joined: 10 Feb 2006
Posts: 165

PostPosted: Sun May 18, 2008 9:08 am    Post subject: cfgfile::GetConfigValue() Reply with quote

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.

Post new topic   Reply to topic    PenUltima Online Forum Index -> Feature Suggestions All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty