[Include] eXtended INI Processor - Fast & Feature Rich INI Processor
#21

Great job,
but I'm having trouble using eINI.
I'm using this code:
Код:
UserPath(playerid)
{
	new string[50],playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid,playername,sizeof(playername));
	format(string,sizeof(string),"/Users/%s.ini",playername);
	return string;
}

//In my register system dialog I have:
new INI:handle = INI::CreateINI(UserPath(playerid));
INI::WriteString(handle,inputtext,"Password");
INI::CloseINI(handle);
But I keep getting errors in my server that the handle is invalid, the file doesn't exist and etc.
What am I doing wrong?

Thanks in advance
Reply
#22

Add this line

Код:
printf("Handle ID:%d",_:handle);
Compare the handle id with

Код:
#define INI_ERR_FAILED_TO_OPEN -1
#define INI_ERR_FILE_DOES_NOT_EXIST -2
#define INI_ERR_FILE_ALREADY_EXISTS -3
#define INI_ERR_FILE_CREATION_FAILED -4
#define INI_ERR_MAX_FILE_LIMIT -5
#define INI_ERR_INVALID_HANDLE -6
#define INI_ERR_SYNTAX -7
#define INI_ERR_INVALID_ID -8
#define INI_ERR_INVALID_BOOL -9
#define INI_ERR_PARSING_FAILED -17

#define INI_SECTION_NOT_FOUND -10
#define INI_KEY_CREATE_FAILED -11
#define INI_SECTION_CREATED -12
#define INI_SECTION_CREATE_FAILED -13
#define INI_KEY_CREATED -14
#define INI_KEY_NOT_FOUND -15
#define INI_KEY_FOUND -16
Also note that CreateINI fails if the file already exists or you ran out of handles.

By default you can have a maximum of 2 active handles. You need to close the previous handle to make a free handle.

You can increase the number of handles by redefining INI_MAX_MULTI_FILES

Код:
#define INI_MAX_MULTI_FILES 128 //Your number of handles
Note that increasing this number means increasing your heap size (increase the RAM Memory consumption).
Reply
#23

Quote:
Originally Posted by Yashas
Посмотреть сообщение
Add this line

Код:
printf("Handle ID:%d",_:handle);
Compare the handle id with

Код:
#define INI_ERR_FAILED_TO_OPEN -1
#define INI_ERR_FILE_DOES_NOT_EXIST -2
#define INI_ERR_FILE_ALREADY_EXISTS -3
#define INI_ERR_FILE_CREATION_FAILED -4
#define INI_ERR_MAX_FILE_LIMIT -5
#define INI_ERR_INVALID_HANDLE -6
#define INI_ERR_SYNTAX -7
#define INI_ERR_INVALID_ID -8
#define INI_ERR_INVALID_BOOL -9
#define INI_ERR_PARSING_FAILED -17

#define INI_SECTION_NOT_FOUND -10
#define INI_KEY_CREATE_FAILED -11
#define INI_SECTION_CREATED -12
#define INI_SECTION_CREATE_FAILED -13
#define INI_KEY_CREATED -14
#define INI_KEY_NOT_FOUND -15
#define INI_KEY_FOUND -16
Also note that CreateINI fails if the file already exists or you ran out of handles.

By default you can have a maximum of 2 active handles. You need to close the previous handle to make a free handle.

You can increase the number of handles by redefining INI_MAX_MULTI_FILES

Код:
#define INI_MAX_MULTI_FILES 128 //Your number of handles
Note that increasing this number means increasing your heap size (increase the RAM Memory consumption).
The ID I get is 0 before the WriteString and is 825516 after it
When I added Section it got working, but then I'm facing another problem:
I'm trying to write some stuff in a file but it keeps duplicating the section which causes problem on loading
Код:
new Path[30];
format(Path,30,"/Bizz/%d.ini",id);
new INI:bizzh = INI::CreateINI(Path);
CreatePickup(1239,1,xxa,yya,zza,0);
INI::WriteFloat(bizzh,xxa,"X","data");
INI::WriteFloat(bizzh,yya,"Y","data");
INI::WriteFloat(bizzh,zza,"Z","data");
INI::WriteInteger(bizzh,type,"Type","data");
INI::CloseINI(bizzh);
And the result is:
Код:
[data]
X=2246.384521
[data]
Y=53.340953
[data]
Z=26.667125
[data]
Type=1
So I'm not sure what I'm doing wrong, I've read your main post over and over but I can't figure it out(Perhaps because my English knowledge is not enough)
I'd be very happy if you could help me out
Thanks in advance.
Reply
#24

I am really sorry. There was a bug in eINI which caused that.

https://github.com/YashasSamaga/eXtended-INI-Processor

Please get the latest copy of eINI.

By the way this is the first bug to be reported
Thanks for reporting
Reply
#25

Hi,

I would like to use this include, but I'm a bit lost and not sure if it's even possible. I want to dynamically load this .ini file:
Код:
[1]
PosX=10.0
[2]
PosX=7.0
[3]
PosX=8.0
I want to do something like this:
Код:
INI::ParseINI(myhandle,"LoadPositions",true, .passSectionParameter = true);
Код:
public LoadPositions(const key[],const value[], extra, section[])
{
    // I would to know which section is the key from
    // In this case, I would like to know if the "PosX" key I'm loading is from section 1, 2 or 3
}
Doing something like the following is not reliable for what I'm building:
Код:
public LoadPositions_Section1(const key[],const value[])
public LoadPositions_Section2(const key[],const value[])
public LoadPositions_Section3(const key[],const value[])
Thanks for the attention, and nice work you have done there! I'm amazed by how huge your documentation is. Btw, do you have any ideia how much time it took to write the include back in 2013?

Edit: I have edited your include to support what I wanted to achieve, here's the link for anyone wanting the same:
https://gist.github.com/Nixtren/c5957fa88da565c8ab70
Reply
#26

Quote:
Originally Posted by Nixtren
Посмотреть сообщение
Hi,

I would like to use this include, but I'm a bit lost and not sure if it's even possible. I want to dynamically load this .ini file:
Код:
[1]
PosX=10.0
[2]
PosX=7.0
[3]
PosX=8.0
I want to do something like this:
Код:
INI::ParseINI(myhandle,"LoadPositions",true, .passSectionParameter = true);
Код:
public LoadPositions(const key[],const value[], extra, section[])
{
    // I would to know which section is the key from
    // In this case, I would like to know if the "PosX" key I'm loading is from section 1, 2 or 3
}
Doing something like the following is not reliable for what I'm building:
Код:
public LoadPositions_Section1(const key[],const value[])
public LoadPositions_Section2(const key[],const value[])
public LoadPositions_Section3(const key[],const value[])
Thanks for the attention, and nice work you have done there! I'm amazed by how huge your documentation is. Btw, do you have any ideia how much time it took to write the include back in 2013?

Edit: I have edited your include to support what I wanted to achieve, here's the link for anyone wanting the same:
https://gist.github.com/Nixtren/c5957fa88da565c8ab70
When I made it back in 2013, it wasn't a complete INI Processor, it just had features which I needed for my gamemode. I recently edited it and added more features to make it a complete INI Reader/Writer. I am guessing if I had written this include in one go, it might have taken around 160 hours.

Currently it is not possible to get eINI do what you want. I will add this feature in the next update.
Next update will be available after 2 days.
Reply
#27

your includes are useful I hope that you will keep updating them and share your things with the community Keep up the good work, Yashas!
Reply
#28

Edit: Problem fixed with last update, thanks.
Reply
#29

^ the sizes do not match in your code
--------------------------------------------------------------------------------------------
eINI 1.1 Pre-Release
This is a pre-release which means it might have new bugs. A stable version will be released after 24 hours.

https://github.com/YashasSamaga/eXte...leases/tag/1.1

EDIT: Stable Version Released
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)