Yini reading Example
#1

Hi, Every One.
I just want a example for how to use the (Yini Inc) for reading .ini
I have a ini file in the nex path
Код:
scriptfiles/example/test.ini
and the ini contains
Код:
testkey = 1
how i can read the test key and store his value in a varible using yini.
Thanks.
Reply
#2

Someone plz.
Thanks.
Reply
#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
#4

damn here is my code
pawn Код:
new pAKA[128];
        INI_Load("ladmin/config/aka.txt");
        INI:aka[](name[], value[])
        {
            if (!strcmp(name, "tmp3"))
            {
                pAKA = value;
            }
        }
i try this to
pawn Код:
new pAKA[128];
        INI_Load("ladmin/config/aka.txt");
        INI:aka[](name[], value[])
        {

            INI_String("tmp3", pAKA);
        }
but the compiler send me this erros, wtfail im doing wrong? sorry for be to newbie u.u
Код:
.pwn(725) : error 029: invalid expression, assumed zero
.pwn(725) : error 017: undefined symbol "@INI_aka_"
.pwn(725) : error 017: undefined symbol "@INI_aka_"
.pwn(725) : fatal error 107: too many error messages on one line
Reply
#5

Quote:
Originally Posted by [SOB]Chris
Посмотреть сообщение
damn here is my code
pawn Код:
new pAKA[128];
        INI_Load("ladmin/config/aka.txt");
        INI:aka[](name[], value[])
        {
            if (!strcmp(name, "tmp3"))
            {
                pAKA = value;
            }
        }
i try this to
pawn Код:
new pAKA[128];
        INI_Load("ladmin/config/aka.txt");
        INI:aka[](name[], value[])
        {

            INI_String("tmp3", pAKA);
        }
but the compiler send me this erros, wtfail im doing wrong? sorry for be to newbie u.u
Код:
.pwn(725) : error 029: invalid expression, assumed zero
.pwn(725) : error 017: undefined symbol "@INI_aka_"
.pwn(725) : error 017: undefined symbol "@INI_aka_"
.pwn(725) : fatal error 107: too many error messages on one line
Try it:
pawn Код:
new pAKA[128];
                INI:aka[](name[], value[])
        {
                    if (!strcmp(name, "tmp3"))
                    {
                        pAKA = value;
                }
                }

        INI_Load("ladmin/config/aka.txt");
Reply
#6

pawn Код:
new pAKA[128];
        INI:aka[](name[], value[])
        {
            if (!strcmp(name, "tmp3"))
            {
                pAKA = value;
            }
        }
        INI_Load("ladmin/config/aka.txt");
send the same error just in diferent line haha, i missed something?
Код:
.pwn(725) : error 029: invalid expression, assumed zero
.pwn(725) : error 017: undefined symbol "@INI_aka_"
.pwn(725) : error 017: undefined symbol "@INI_aka_"
.pwn(725) : fatal error 107: too many error messages on one line
Reply
#7

i see then i need to use global variables for my sistems =S?
Reply
#8

I dont know how this work, but wasnt be like this
pawn Код:
new pAKA[128];
        INI:aka(name[], value[])
        {
            if (!strcmp(name, "tmp3"))
            {
                pAKA = value;
            }
        }
        INI_Load("ladmin/config/aka.txt");
compare aka[](.. and aka(..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)