y_ini - check if entry exists
#6

I looked at the code in github and the function has been removed in the YSI 4 version. That's the way it was used in the older version:

PHP код:
bool:INI_GetEntryName(source[], dest[], &i)
{
    new
        
j;
    while (
source[j] && source[j] <= ' 'j++;
    
j;
    while (
source[i] > ' ' && source[i] != '='i++;
    if (
== j) return false;
    
-= j;
    
memcpy(destsourcej4MAX_INI_ENTRY_NAME);
    
dest[i] = '\0';
    return 
true;

PHP код:
EntryNameExists(const file_name[], const entry_name[])
{
    new 
Filefopen(file_nameio_read);
    
    if (!
f) return 0;
    
    new 
line[MAX_INI_ENTRY_NAME], stringIdent[MAX_INI_ENTRY_NAME], poscomment;
    
    while (
fread(fline))
    {
        
StripNL(line);
        
        if (!
line[0]) continue;
        
        
comment chrfind(';'line);
        
        if (
comment != -1line[comment] = '\0';
        if (
INI_GetEntryName(linestringIdentpos) && !strcmp(entry_namestringIdent)) return fclose(f), 1;
    }
    return 
fclose(f), 0;

You have to read every line of the file and check if the entry returned is the one you want. An example:
pawn Код:
if (!EntryNameExists("some_file.ini", "some_entry")) print("\"some_entry\" does not exist in the INI file.");
Reply


Messages In This Thread
y_ini - check if entry exists - by Brooks1 - 07.07.2016, 11:37
Re: y_ini - check if entry exists - by F1N4L - 07.07.2016, 11:43
Re: y_ini - check if entry exists - by Brooks1 - 07.07.2016, 11:45
Re: y_ini - check if entry exists - by Konstantinos - 07.07.2016, 11:56
Re: y_ini - check if entry exists - by Brooks1 - 07.07.2016, 12:19
Re: y_ini - check if entry exists - by Konstantinos - 07.07.2016, 12:46
Re: y_ini - check if entry exists - by Stinged - 07.07.2016, 13:12

Forum Jump:


Users browsing this thread: 3 Guest(s)