|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
i have a question regarding ADDING items to INI
i would ask, is it possible to make mirc add sections to ini file BUT to keep specifited section always last (on bottom)
so like i have:
someini.ini
[section 1] bla=bla
[section 2] bleh=bleh
[section 4] 4=4
[section 3] last=last
in other words i ask someone to make alias or script that can do this :P
ofc if you have time !
IceCapped
|
|
|
|
Joined: Mar 2003
Posts: 612
Fjord artisan
|
Fjord artisan
Joined: Mar 2003
Posts: 612 |
you can use a /write -a for the section name then /writeini for the rest.
btk
billythekid
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Not sure why you want this, but then again I don't use ini files much, but this should do what you're asking for alias lastini {
if $ini($1,$2) != $ini($1,0) {
if !$hget(lastini) { .hmake lastini 10 }
.hload -i lastini $1 $2
.remini $1 $2
.hsave -i lastini $1 $2
}
} Usage: /lastini <inifile> <section> Note: <inifile> must be the full filename including the ini extension
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
thanks for code ^^ but unfortunately it doesnt work for me (6.2)
i type: //lastini $mircdirsystem\filename.ini section
and nothing writes down. btw would it be too hard for you to make it write values as well ?
IceCapped
|
|
|
|
Joined: Jun 2006
Posts: 508
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 508 |
There isn't a need for it to write, writeini does that just fine Use this after you edit the file. ; [color:green]/lastini <file.ini> <sectiontobelast>[/color]
alias lastini {
if !$ini($1,$$2) { return }
window -h @@lastini
loadbuf -t $+ $2 @@lastini $1
remini $1 $2
write $1 $+([,$2,])
savebuf -a @@lastini $1
window -c @@lastini
}
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
this doesnt work either :S
IceCapped
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
I don't think the code will work with an entry of $mircdirsystem\filename.ini section Try it as /lastini filename.ini section Here's the code again, but with comments on what happens where alias lastini {
if $ini($1,$2) != $ini($1,0) {
;obtains section number for the specified section and compares it to the total number of sections in the ini file
;if it the two do not match
if !$hget(lastini) { .hmake lastini 10 }
;checks if hash table exists and if not, then creates it
.hload -i lastini $1 $2
;loads the specified section into the hash table
;data is saved in the hash table using the same format as
;/hadd -m lastini item data
.remini $1 $2
;removes specified section from the ini file
.hsave -i lastini $1 $2
;saves specified section to the hash table
}
}
I just performed a quick test, using a copy of the mirc.ini file, and it worked exactly as it should. Note: this script is silent, there is no display at all, unless you alter the code.
|
|
|
|
Joined: Jun 2006
Posts: 508
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 508 |
It works here, make sure you don't still have the other one (same alias name) loaded before it.
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
this is very odd...
now i tried /lastini mirc.ini new-section and mirc.ini doesnt have it O_o
and no i dont have 2 of same aliases....
IceCapped
|
|
|
|
Joined: Jun 2006
Posts: 508
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 508 |
Does mirc.ini have a section named "new-section" beforehand? The section you want to be last must exist before it can be moved to the end of the file.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
You aren't using this to *add* sections. You should already have all sections written to the ini file before using it.
Example INI:
[Section1] Item=Data [Section2] Item=Data [Section3] Item=Data
Now, if you did /lastini file.ini Section1, it should move Section1 to the end. As they said, do all you normal /writeini's first, then use the alias to move whatever section you want to the end of the ini file.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Apr 2005
Posts: 1,009
Hoopy frood
|
OP
Hoopy frood
Joined: Apr 2005
Posts: 1,009 |
aaaah thats the case okay works now ! thanks both of you !
IceCapped
|
|
|
|
Joined: Mar 2003
Posts: 612
Fjord artisan
|
Fjord artisan
Joined: Mar 2003
Posts: 612 |
alias lastini {
if !$ini($1,$$2)[color:red] {
write $1 $+([,$$2,])
return
} [/color]
window -h @@lastini
loadbuf -t $+ $2 @@lastini $1
remini $1 $2
write $1 $+([,$2,])
savebuf -a @@lastini $1
window -c @@lastini
}
that'd fix that problem I think.
billythekid
|
|
|
|
Joined: Jun 2006
Posts: 508
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 508 |
There is no problem, if the section doesn't exist there isn't a point in 'moving' it to the end of the file. /writeini would already add it to the end if it doesn't already exist
|
|
|
|
|