[INC] Xini v2 - Edit INI files -
boylett - 30.12.2008
Xini v2
Allows you to edit INI files in the following format:
Code:
[header]
key=value
key2=value
[header2]
key=value
key2=value
I'm not sure what happened to the old topic.. I searched on "xini" but nothing came up, so here's a new topic :P
Quote:
Xini version 2
Created by Boylett
Copyright © Boylett.com
All included files are in there alotted folders.
|
Quote:
LICENSE
You may edit and release modified versions of the script, so long as credit is given to the original author, Boylett.
You must have written permission from Boylett, on Boylett.com, before you release a modified version.
Failure to abide by this license means you may not use this include.
|
Re: [INC] Xini v2 - Edit INI files -
Kowalski - 30.12.2008
I cannot test it at the moment, but I've downloaded it. I know you're a good and helpful scripter, thank you for this work!
Ковалски
Re: [INC] Xini v2 - Edit INI files -
Serbish - 30.12.2008
What should this be?
Re: [INC] Xini v2 - Edit INI files -
Donuts - 30.12.2008
I know what is this for but could you post an example plox? (:
this looks interesting.
Re: [INC] Xini v2 - Edit INI files -
Magor - 30.12.2008
[red]Useless[/red]
pawn Code:
xini_remove(filename[])
{
if(!fexist(filename)) return false;
fremove(filename);
return true;
}
[blue]native bool:fremove(const name[]);[/blue] fails if the file doesn't exist.
Basically this does exactly the same as fremove (not thinking about uselessly called fexist...).
[red]Uneffective, bad managed code[/red]
pawn Code:
new File:file, File:file2, line[MAX_STRING], key2[MAX_STRING], header2[MAX_STRING], filename2[MAX_STRING], tmp[MAX_STRING];
format(filename2,MAX_STRING,"%s.xini",filename);
if((file = fopen(filename,io_read)) && (file2 = fopen(filename2,io_write)))
[blue]MAX_STRING = 255[/blue] => you allocate 1275 bytes of memory (what is really a lot for a such simple function) even before checking if the file exists...
Seriously, first learn how to write effective code and JUST then release something.
[red]Doesn't allow you to choose file name[/red]
pawn Code:
format(filename2,MAX_STRING,"%s.xini",filename);
Because it always appends .xini to end of the file name.
[red]Bad written include[/red]
pawn Code:
native xini_get(filename[],header[],key[],bool:ignorecase=true);
native xini_set(filename[],header[],key[],value[],bool:ignorecase=true);
native xini_iskeyset(filename[],header[],key[],bool:ignorecase=true);
native xini_isheaderset(filename[],header[],bool:ignorecase=true);
native xini_setint(filename[],header[],key[],value,bool:ignorecase=true);
native xini_int(filename[],header[],key[],bool:ignorecase=true);
native xini_setfloat(filename[],header[],key[],Float:value,bool:ignorecase=true);
native Float:xini_float(filename[],header[],key[],bool:ignorecase=true);
native xini_create(filename[]);
native xini_remove(filename[]);
native xini_truncreate(filename[]);
native xini_getstore(filename[],value[],refheader[],refkey[],offset=0,bool:ignorecase=true);
xini_set is [blue]bool[/blue], but native is withoud [blue]"bool"[/blue] -> [green]native xini_set(filename[],header[],key[],value[],bool:ignorecase=true);[/green] <- (the same problem with xini_iskeyset, xini_isheaderset, xini_setint, xini_setfloat, xini_getstore, xini_unsetheader)
These functions aren't [blue]stock[/blue]-ed, so compiler compiles entire include even if you don't use any of xini functions.
And also there is [red]"unnatived"[/red] function... so if you don't read entire include (because it is the last function in the include), you won't probably know about xini_unsetheader...
EDIT: Windows already contains similar functions: [green]GetPrivateProfileString WritePrivateProfileString[/green] -> perfect idea for a plugin.
Re: [INC] Xini v2 - Edit INI files -
Magor - 30.12.2008
Quote:
[red]I believe this isn't his latest script[/red] and mistakes happen.
|
[green]Look when was this topic created[/green]
[INC] Xini v2 - Edit INI files
« on: Today at 11:47:45 am »
Re: [INC] Xini v2 - Edit INI files -
boylett - 30.12.2008
Magor: everything you said is true, but the way you said just makes me think of you as someone who decides to go through the internet pissing people off and trying to look smart. For that reason, I don't think I'll bother with any of your "suggestions" until I get round to it myself.
wanker
And at the time of creation, fremove crashed if used on a file which didn't exist.
BTW, I think you mean effecient. The code is effective at what it does.
Quote:
Originally Posted by Magor
Quote:
[red]I believe this isn't his latest script[/red] and mistakes happen.
|
[green]Look when was this topic created[/green]
[INC] Xini v2 - Edit INI files
« on: Today at 11:47:45 am »
|
This script was created months ago, I'm just reposting it.
Re: [INC] Xini v2 - Edit INI files -
Serbish - 30.12.2008
Quote:
Originally Posted by Boylett
wanker
|
Lol'ed at this.
Re: [INC] Xini v2 - Edit INI files -
boylett - 30.12.2008
Quote:
Originally Posted by -=[Serbish
=- ]
Quote:
Originally Posted by Boylett
wanker
|
Lol'ed at this. 
|
You're not supposed to quote out my [size] tags
Re: [INC] Xini v2 - Edit INI files -
Magor - 30.12.2008
Quote:
Magor: everything you said is true, but the way you said just makes me think of you as someone who decides to go through the internet pissing people off and trying to look smart. For that reason, I don't think I'll bother with any of your "suggestions" until I get round to it myself. [red]wanker[/red]
|
Code:
<span style="font-size: 3pt; line-height: 1.3em;">wanker</span>
HAHA, nice way how to show what are you thinking about
Re: [INC] Xini v2 - Edit INI files -
boylett - 30.12.2008
Quote:
Originally Posted by Magor
Quote:
Magor: everything you said is true, but the way you said just makes me think of you as someone who decides to go through the internet pissing people off and trying to look smart. For that reason, I don't think I'll bother with any of your "suggestions" until I get round to it myself. [red]wanker[/red]
|
Code:
<span style="font-size: 3pt; line-height: 1.3em;">wanker</span>
HAHA, nice way how to show what are you thinking about 
|
Please just leave this topic.
Re: [INC] Xini v2 - Edit INI files -
ғαιιοцт - 02.01.2009
nice include boylett
but I have 2 questions,
Code:
native xini_iskeyset(filename[],header[],key[],bool:ignorecase=true);
native xini_isheaderset(filename[],header[],bool:ignorecase=true);
do they check if a key/header "exists" ? or does it do something else?
and
Code:
native xini_set(filename[],header[],key[],value[],bool:ignorecase=true);
if ignorecase is set to true, will all characters you set there, be 'small letters'? (don't know how they say it in english 'small letters' :P)
Re: [INC] Xini v2 - Edit INI files -
boylett - 02.01.2009
Quote:
Originally Posted by °ғαιιοцт°
nice include boylett
but I have 2 questions,
Code:
native xini_iskeyset(filename[],header[],key[],bool:ignorecase=true);
native xini_isheaderset(filename[],header[],bool:ignorecase=true);
do they check if a key/header "exists" ? or does it do something else?
|
they check if a key/header exists
Quote:
Originally Posted by °ғαιιοцт°
Code:
native xini_set(filename[],header[],key[],value[],bool:ignorecase=true);
if ignorecase is set to true, will all characters you set there, be 'small letters'? (don't know how they say it in english 'small letters' :P)
|
No, ignorecase is to with searching through the keys and headers. If its true then having this:
KEY=blah
and changing it use xini_set(file,header,"key",value,true)
will change KEY=blah to key=value
but changing it using xini_set(file,header,"key",value,false)
will leave KEY=blah and add key=value, resulting in:
KEY=blah
key=value
Re: [INC] Xini v2 - Edit INI files -
ғαιιοцт - 02.01.2009
ok thanks Boylett, I'll now test it with my mode
Re: [INC] Xini v2 - Edit INI files -
ғαιιοцт - 03.01.2009
I have a problem with xini
after registering, the userfile looks like this:
Code:
[Info]
Name=[WWG]Fallout
Password
IP=127.0.0.1
Online=Yes
Logged=No
[Vars]
Money=2000
Score=0
HealthPacks=0
[Weapons]
Slot0=0
AmmoSlot0=65535
Slot1=0
AmmoSlot1=0
Slot2=0
AmmoSlot2=0
Slot3=0
AmmoSlot3=0
Slot4=0
AmmoSlot4=0
Slot5=0
AmmoSlot5=0
Slot6=0
AmmoSlot6=0
Slot7=0
AmmoSlot7=0
Slot8=0
AmmoSlot8=0
Slot9=0
AmmoSlot9=0
Slot10=0
AmmoSlot10=0
Slot11=0
AmmoSlot11=0
and when I log in, "Logged" should change to "Yes"... it does, but than this happens:
Code:
[Info]
Name=[WWG]Fallout
Password
IP=127.0.0.1
Online=Yes
Logged=Yes[Vars]
Money=2000
Score=0
HealthPacks=0
[Weapons]
Slot0=0
AmmoSlot0=65535
Slot1=0
AmmoSlot1=0
Slot2=0
AmmoSlot2=0
Slot3=0
AmmoSlot3=0
Slot4=0
AmmoSlot4=0
Slot5=0
AmmoSlot5=0
Slot6=0
AmmoSlot6=0
Slot7=0
AmmoSlot7=0
Slot8=0
AmmoSlot8=0
Slot9=0
AmmoSlot9=0
Slot10=0
AmmoSlot10=0
Slot11=0
AmmoSlot11=0
This only happens when "Logged" changes, and not when something else (like HealthPacks) changes

I've also tried to use 0 and 1 instead of Yes and No but than it's still the same
Is there something wrong with xini or with my code?
ps there is nothing wrong with "Password" (I just deleted it myself, it works fine)
Re: [INC] Xini v2 - Edit INI files -
boylett - 03.01.2009
Open the file with Wordpad, and not notepad
Re: [INC] Xini v2 - Edit INI files -
ғαιιοцт - 03.01.2009
ok

but... why does it use another type of 'newline' than in the beginning?
and thx for fast reply
Re: [INC] Xini v2 - Edit INI files -
boylett - 03.01.2009
Quote:
Originally Posted by °ғαιιοцт°
ok 
but... why does it use another type of 'newline' than in the beginning?
and thx for fast reply 
|
It uses just \n
Re: [INC] Xini v2 - Edit INI files -
[DrM]spatrik - 13.07.2010
Where I can download it?
Re: [INC] Xini v2 - Edit INI files -
Patchwerk - 17.07.2011
please reuplad ! very thx