Yini reading Example
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
Reading

This system differs in use quite significantly from dini, but with good reason. In dini you open a file, search for a single value, read that value, close the file and repeat. Imagine this code:

pawn Код:
gA = dini_Get("myini.ini", "c");
gB = dini_Get("myini.ini", "b");
gC = dini_Get("myini.ini", "a");
And this ini file:

Код:
a = 10
b = 67
c = 42
If you can't tell that will open and close the file 3 times and read 6 lines in, just for 3 values - surely you should just open the file once and read 3 lines? This is the equivalent y_ini code:

pawn Код:
INI:myini[](name[], value[])
{
    INI_String("a", gA);
    INI_String("b", gB);
    INI_String("c", gC);
}
pawn Код:
INI_Load("myini.ini");
The code is a little longer, but it's much faster, only reading the file once. Esentially y_ini uses callbacks to load files instead of explicitly reading individual values, which means files are read in the order they are stored. I intend to add the option to load individual values later, but there's rarely any need if you do things properly - read a file and get the data, it's not going to change unless you change it.
<eight.>
Reply


Messages In This Thread
Yini reading Example - by [SOB]Chris - 18.10.2010, 03:55
Respuesta: Yini reading Example - by [SOB]Chris - 18.10.2010, 14:59
Re: Yini reading Example - by LarzI - 18.10.2010, 15:25
Respuesta: Yini reading Example - by [SOB]Chris - 19.10.2010, 02:23
Respuesta: Yini reading Example - by MrDeath537 - 19.10.2010, 02:26
Respuesta: Yini reading Example - by [SOB]Chris - 19.10.2010, 02:33
Respuesta: Yini reading Example - by [SOB]Chris - 22.10.2010, 03:42
Re: Yini reading Example - by Voldemort - 22.10.2010, 09:24

Forum Jump:


Users browsing this thread: 1 Guest(s)