mIRC Home    About    Download    Register    News    Help

Print Thread
create an ini file with default sections? #180309 07/07/07 03:36 PM
Joined: Dec 2002
Posts: 271
N
NightChillz Offline OP
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
hey, can anyone help me with this, i am creating multiple files, ini files, and in these files i want a section for each month of the year, and i want this with no items to be created when the file is created. i cant seem to find a /writeini that would allow me to write all months(as different sections) with one call to the /writeini, i tried /write %file [January] $+ $crlf $+ [February] $+ $crlf $+ etc

and that works but it doest, it puts all the months in the file as expected but when i add an item to a month it doesnt read it( i know its cause i used write instead of writeini), but what other options do i hove?

thanks

Re: create an ini file with default sections? [Re: NightChillz] #180335 07/07/07 08:10 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
You'd have to specify each month, one at a time, and you also need to include something for an item, and some data.

You have to have an item and some data to create the section. Once the section is created, then you can use /remini to remove the item and the data

I suggest you read
/help /writeini
/help /remini

Code:
var %a = 1, %b = 12 
while %a <= %b {
  var %date = $asctime($ctime($($+(1/,%a,/2007),2)),mmmm)
  .writeini -n %file %date <item> <data>
  inc %a
}


Last edited by RusselB; 07/07/07 08:11 PM.
Re: create an ini file with default sections? [Re: RusselB] #180336 07/07/07 08:31 PM
Joined: Dec 2002
Posts: 271
N
NightChillz Offline OP
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
i already know how to do that, i have a loop that does each one at a time, but unfortunately one at a time like that freezes things of if there is a few files to do

Re: create an ini file with default sections? [Re: NightChillz] #180337 07/07/07 08:46 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Why don't you use hashtables for the initial storage of the information, then you can use the -i switch in the /hsave and /hload commands to have the file be ini compatable.

The slow down that you're experiencing isn't due to the loop, but the slow access speed of the hard drive (relative to the access speed of RAM, which is where hash tables are stored).

Re: create an ini file with default sections? [Re: NightChillz] #180338 07/07/07 08:47 PM
Joined: Feb 2005
Posts: 342
R
Rand Offline
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
Unfortunately for you, that's just the way it is. You're using ini files, and ini files aren't that great for storing data or information, every time you /writeini, mIRC has to open and close the /ini file.

Try learning hash tables instead.

Re: create an ini file with default sections? [Re: NightChillz] #180339 07/07/07 08:52 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
INI files use a single linefeed to separate lines instead of the usual (for Windows) carriage-return + linefeed.

Just replace $crlf with $lf in your code and it will work perfectly.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: create an ini file with default sections? [Re: Rand] #180341 07/07/07 09:02 PM
Joined: Dec 2002
Posts: 271
N
NightChillz Offline OP
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
i already know all about hash tables aswell, lol, and hash tables wont do it either, mind you if i HAVE to do them one at a time, then yes hash tables would be faster, but the thing is, if i

/write file.ini [section]

then

/writeini -n file.ini section item1 some data

then

// echo -a $readini(file.ini,section,item1)

all at the command line, i get an echo of "some data"


so it works fine, but when attempting the samething from a script, only adding 12 blank sections, then /writeini to those sections, and $readini from those section, i get nothing, so i look in the file and it writes over and over beside the [section]item1=some data

odd, why?


but ill just make it /writeini to a single default file and /copy the file with the 12months in it as many times as i need, that way i only writeini 1 time, and copy say 12times, instead of /writeini 144 times :|

Re: create an ini file with default sections? [Re: starbucks_mafia] #180342 07/07/07 09:03 PM
Joined: Dec 2002
Posts: 271
N
NightChillz Offline OP
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
Originally Posted By: starbucks_mafia
INI files use a single linefeed to separate lines instead of the usual (for Windows) carriage-return + linefeed.

Just replace $crlf with $lf in your code and it will work perfectly.



THANK YOU, thats what i was looking for, i was actually gonna ask what the "return" character was for ini files, if it was diffeent from text or what, but you posted first, lol.

thanks smile

Re: create an ini file with default sections? [Re: NightChillz] #180357 08/07/07 04:02 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Note also that the /fread and /fwrite commands make file access much faster.


Invision Support
#Invision on irc.irchighway.net