mIRC Home    About    Download    Register    News    Help

Print Thread
#162093 15/10/06 12:37 AM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
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
#162094 15/10/06 01:04 AM
Joined: Mar 2003
Posts: 612
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Mar 2003
Posts: 612
you can use a /write -a for the section name then /writeini for the rest.


btk


billythekid
#162095 15/10/06 01:09 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
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
Code:
 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

#162096 15/10/06 11:56 AM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
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
#162097 15/10/06 04:21 PM
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
There isn't a need for it to write, writeini does that just fine laugh
Use this after you edit the file.
Code:
; [color:green]/lastini &lt;file.ini&gt; &lt;sectiontobelast&gt;[/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
}

#162098 15/10/06 04:34 PM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Apr 2005
Posts: 1,009
this doesnt work either :S


IceCapped
#162099 15/10/06 04:42 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
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
Code:
 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.

#162100 15/10/06 04:44 PM
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
It works here, make sure you don't still have the other one (same alias name) loaded before it. wink

#162101 15/10/06 05:30 PM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
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
#162102 15/10/06 05:34 PM
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
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.

#162103 15/10/06 05:36 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
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
#162104 15/10/06 05:37 PM
Joined: Apr 2005
Posts: 1,009
raZOR Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Apr 2005
Posts: 1,009
aaaah thats the case laugh

okay works now !
thanks both of you !


IceCapped
#162105 15/10/06 06:23 PM
Joined: Mar 2003
Posts: 612
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Mar 2003
Posts: 612
Code:
 
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
#162106 15/10/06 06:26 PM
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
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 smile


Link Copied to Clipboard