mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2006
Posts: 47
C
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Mar 2006
Posts: 47
How does /write corrupt an ini file? I'm using a loop to scan through a bunch of settings stored in an ini file and set certain matching lines to 0. As in "
Code:
 /write -l $+ %loop Misc.ini $gettok(%line,1,61) $+ =0 


But the help file says it could corrupt the file....

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
It means that unless you fully know what you're doing, you may write something that has the wrong format (or write something valid in the wrong place), thus corrupting the ini file. /write itself will not corrupt anything, you just have to use it more carefully than /writeini when writing to ini files.

Why aren't you using /writeini though? It's specifically designed for ini files and will do much of the error checking for you.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Mar 2006
Posts: 47
C
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Mar 2006
Posts: 47
Because I'm scanning through all the lines without regard to what [section] they're under. Like I just want to set any "value2" lines to 0 without touching anything else.

[name1]
value1=4
value2=7
[name2]
whatever=fine
value1=4
value2=7

Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
You can do it like this

Code:
 alias _write {
  var %w = 1, %s, %file = [color:red]YOUR.ini[/color]
  while $ini(%file,%w) {
    %s = $v1
    if ( $readini(%file,%s,$1) != $null ) writeini -n %file %s $1 $2
    inc %w
  }
}

 


Syntax: /_write item N

Sample: /_write value2 0

It will loop to each section then check if value2 exists & write 0.

** Change YOUR.ini


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Joined: Mar 2006
Posts: 47
C
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Mar 2006
Posts: 47
Thanks. I'll do things your way.


Link Copied to Clipboard