Configuration Files dll

Posted By: Sinthoras

Configuration Files dll - 05/18/06 13:57

hiho
I wrote a small configfile dll:
It can read values and strings out of a userdefined file. Comments are possible (as shown in the example) with just writing ";" as the first line character.

There are three data levels:
first one: [head topic]
second: #specified topic
third: variable / string

a short example code:
Code:

//load the seconds
temp = DLL_cfgload("Settings.cfg", "GameSettings", "Game Time", "seconds");
//load the start string
DLL_cfgloadS("Settings.cfg", "GameSettings", "GameStarter", str_cpy(Start_str, "start"));



the string access is a bit tricky because the functions cannot have more than 4 parameters.. you have to take a string containing the cfg-value name for reading the user string. But that shouldnt be a problem..

a short example file:
Code:


;----------------------------------------------
[GameSettings]

;time for one run
#Game Time
hours = 0
minutes = 0
seconds = 5

#GameStarter
start = Welcome!
rebirth = We'll start another round..
timeout = Timeout..
end = No lifes left

;settings for the player
#Player
healthpoints = 3
speed = 25
jumpSpeed = 10




Is anyone interested in it?
Posted By: frazzle

Re: Configuration Files dll - 05/18/06 19:34

Well I'm not the plugin man, so abit confused here
I NEED MORE INFORMATION
Posted By: Sinthoras

Re: Configuration Files dll - 05/18/06 20:14

ah, thats the point ^^ just wondered why nobody ansered..

here you are:
with the two functions
var = dll_cfgload(*filename*, *head topic*, *specaliced topic*, *name*);
and
dll_cfgloadS(*filename*, *head topic*, *specaliced topic*, *name&returnstring*);

you can read values and strings out of a .cfg file. The advantage of that is that no wdl files have to be accessed (->it is working in the published version) and you can describe and STRUCTURE your settings/data/.. very well.
Posted By: Michael_Schwarz

Re: Configuration Files dll - 05/18/06 20:19

Why do you want to know if it is useful by comment FIRST, if you have ALREADY finished it? Why not just let the people try and THEN say if it is/was useful?
Posted By: Sinthoras

Re: Configuration Files dll - 05/18/06 20:24

I have already finished it because I need it for my project, and now I just want to share it.
The question was not about the creation, because it is already done.
It was just about any interest in the community, if I should upload the dll etc.
Posted By: Rigoletto

Re: Configuration Files dll - 05/18/06 20:26

Quote:

the string access is a bit tricky because the functions cannot have more than 4 parameters..




You can use one string seprated by a delimiter for access keywords.
Posted By: William

Re: Configuration Files dll - 05/19/06 01:25

I'd be intrested in this, but where would you download it? Thanks.
Posted By: Orange Brat

Re: Configuration Files dll - 05/19/06 07:09

Thanks if you upload it. I think this is the same as Napo's INI DLL, but the more the merrier. I'll have to compare it with that one whenever I find the time.
Posted By: Sinthoras

Re: Configuration Files dll - 05/19/06 15:30

Quote:

You can use one string seprated by a delimiter for access keywords.



An exellent idea, thanks for that! I'll implement it

[EDIT]

-> implemented

here you are
> Download link <

the dll functions are just those two:
Code:


//**********************
//KeyString:
//- head topic
//- group
//- sub group
//- variable/String
// Separator: comma
//returnString:
//string returned from the cfg. The function also returns a pointer to this string

dllfunction DLL_cfgload(KeyString);
dllfunction DLL_cfgloadS(KeyString, returnString);


Posted By: Sinthoras

Re: Configuration Files dll - 05/20/06 13:08

I forgot to add:

the path for the cfg files is

*workdir* \\data\\cfg\\ *filename*
Posted By: LordRathan

Re: Configuration Files dll - 05/21/06 04:02

Zip-file updated. It's the same link as above.
Posted By: Thomas_Nitschke

Re: Configuration Files dll - 05/21/06 12:43

Very nice!
How about having the path for the cfg files adjustable?
Posted By: Sinthoras

Re: Configuration Files dll - 05/21/06 19:07

huh yeeees ^^ would be no problem but takes time as well.. the code is included in the .zip file, feel free to do it on your own

If I make another update, I'll implement it. But this will take some time, cause I don't see any reason for a new one. Maybe time will bring some new needed features, then your idea will be included
Posted By: Thomas_Nitschke

Re: Configuration Files dll - 05/21/06 19:09

Okay, thank you
Unfortunately, I have no real idea about C/C++... got to learn some, I guess
Posted By: Sinthoras

Re: Configuration Files dll - 05/21/06 19:28

Ah! huh well, in this case I could implement it NOW ^^
(my mate will get crazy if I send him the data every day )
Posted By: Thomas_Nitschke

Re: Configuration Files dll - 05/21/06 19:43

Wow, you're being really kind
Thanks in advance!
Posted By: Sinthoras

Re: Configuration Files dll - 05/21/06 20:29

ok, its working now. I've changed the function names to some more comfortable ones, too.

dllfunction cfg(KeyString);
dllfunction cfgS(KeyString, returnString);

//PathString:
//the path to the cfg files, standard = data\\cfg\\
//double slashes!!
dllfunction cfgSetPath(PathString);

the file will be up tomorrow, I think.
Posted By: LordRathan

Re: Configuration Files dll - 05/22/06 03:59

Right, here it is.
Posted By: Thomas_Nitschke

Re: Configuration Files dll - 05/22/06 13:15

Great!
Thank you!
© 2024 lite-C Forums