Raised This Month: $ Target: $400
 0% 

Load ini [Lines]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 08-22-2010 , 13:38   Load ini [Lines]
Reply With Quote #1

Hello,

Can anybody show me, how to read all lines of a Ini file? Like:

HTML Code:
de_dust2
de_dust
de_train

so i have, as example, all maps in one array? (new file[][])
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-22-2010 , 14:25   Re: Load ini [Lines]
Reply With Quote #2

There are several examples. You can look at my Bot Apology plugin shown in my signature.
__________________
fysiks is offline
Vechta
Veteran Member
Join Date: Jun 2010
Old 08-22-2010 , 14:50   Re: Load ini [Lines]
Reply With Quote #3

Maybe you can make a little tutorial how it exactly work ?
Vechta is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-22-2010 , 15:07   Re: Load ini [Lines]
Reply With Quote #4

Quote:
Originally Posted by Vechta View Post
Maybe you can make a little tutorial how it exactly work ?
It's an extremely simple example already. There is not a whole lot to explain.
__________________
fysiks is offline
Mxnn
Veteran Member
Join Date: Aug 2009
Location: AT MY HOME
Old 08-22-2010 , 17:34   Re: Load ini [Lines]
Reply With Quote #5

You can read this way:
PHP Code:
new linecharcount
new data[128]
while ((
line = (read_file("file.ini"linedatacharsmax(data), charcount))))
    {
        
read_file("file.ini"linedatacharsmax(data), charcount)
        
//Asks
    

The code will read the file until the end of file.
In //Asks you can ask if the line is "de_dust" or that.

Parameters:
line represents the number line
charcount the char count of the line
data, content the line (ej: de_dust2)
Mxnn is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-22-2010 , 17:41   Re: Load ini [Lines]
Reply With Quote #6

Quote:
Originally Posted by Mxnn View Post
You can read this way:
PHP Code:
new linecharcount
new data[128]
while ((
line = (read_file("file.ini"linedatacharsmax(data), charcount))))
    {
        
read_file("file.ini"linedatacharsmax(data), charcount)
        
//Asks
    

The code will read the file until the end of file.
In //Asks you can ask if the line is "de_dust" or that.

Parameters:
line represents the number line
charcount the char count of the line
data, content the line (ej: de_dust2)
Nobody should use this. Use the method shown in my plugin.
__________________
fysiks is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 08-22-2010 , 22:06   Re: Load ini [Lines]
Reply With Quote #7

fysiks i got a question about your plugin? It says in one of the parameters for fgets, sizeof(data)-1. Would it be better to use charsmax? If not, why would you use sizeof there instead of charsmax?

Or, would they both work?
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-22-2010 , 22:42   Re: Load ini [Lines]
Reply With Quote #8

Quote:
Originally Posted by nikhilgupta345 View Post
fysiks i got a question about your plugin? It says in one of the parameters for fgets, sizeof(data)-1. Would it be better to use charsmax? If not, why would you use sizeof there instead of charsmax?

Or, would they both work?
charsmax = sizeof - 1

So, it's the same thing. That was before I knew about charsmax.
__________________
fysiks is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 08-22-2010 , 23:22   Re: Load ini [Lines]
Reply With Quote #9

Ok, thanks, just wondering if there were special cases when u would use one and not the other.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-22-2010 , 23:25   Re: Load ini [Lines]
Reply With Quote #10

Quote:
Originally Posted by nikhilgupta345 View Post
Ok, thanks, just wondering if there were special cases when u would use one and not the other.
I always use charsmax for strings now. Bugsy explained it nicely recently in another thread.
__________________
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode