mIRC Home    About    Download    Register    News    Help

Print Thread
writeini problems #233964 27/09/11 04:00 PM
Joined: May 2006
Posts: 15
L
liftman Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: May 2006
Posts: 15
hi!

I've a little (big) problem with writeini command.

mirc 7.1

writing:

writeini -n filename [something] n1 some text

result as:

[[something]]
n1=some text

mirc 6.35

writing:

writeini -n filename [something] n1 some text

result as:

[~something~]
n1=some text

how my script can to work correctly with all versions?
thanks in advance!


Ciao!
Re: writeini problems [Re: liftman] #233965 27/09/11 06:01 PM
Joined: Apr 2010
Posts: 923
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 923
The only work around I see is to write your own /writeini and $readini:


I haven't bug tested it, by try this:
/writeini2 -n filename section item data
$readini2(filename,[np],section,item)
Code:
alias Writeini2 {
  if (!$regex(ini,$1-,^(?|(-\S*)+ |())(?|"([^"])"|([^ ])) (\S+) (\S+) (.+)$)) {
    echo -sc info * /writeini2: Invalid parameters
    halt
  }
  else {
    !writeini $regml(ini,1) $qt($regml(ini,2)) $regsubex($regml(ini,3),/([\\\[\]])/g,\x $+ $base($asc(\t),10,16,2)) $regml(ini,4) $regml(ini,5)
  }
}
alias readini2 {
  if ($0 == 3) var %s, %i = $3, %t = $regsubex($2,/\\x([0-9a-f])/gi,$chr($base(\t,16,10)))
  else var %s = $2, %i = $4, %t = $regsubex($3,/\\x([0-9a-f])/gi,$chr($base(\t,16,10)))
  return $readini($1,%s,%i,%t)
}




You might have to rewrite the ini files using the above commands.

Last edited by FroggieDaFrog; 27/09/11 06:02 PM.

I am SReject
My Stuff
Re: writeini problems [Re: liftman] #233967 27/09/11 06:17 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Your best option would be to just not use []'s as part of the section name.

/writeini -n filename something n1 some text

This would, of course, mean that you'd have to change your current INI file(s) to remove those extra []'s, but it saves you the problem and then it would work regardless of version.

Note that you can also check $version and have your script do something different based on what version is being used.

Last edited by Riamus2; 27/09/11 06:20 PM.

Invision Support
#Invision on irc.irchighway.net
Re: writeini problems [Re: liftman] #233968 27/09/11 06:26 PM
Joined: Jul 2006
Posts: 3,574
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,574
Originally Posted By: versions.txt 7.0
2.mIRC now uses its own custom ini routines to ensure more reliable ini file handling. They should work almost identically to the standard Windows ini routines.
I don't know how but it seems Windows was able to handle [ ] correctly, even though you would see the same character used for both, and it seems that the new routine is unable to handle them, for me it's a bug.

edit: well in fact it's not a problem nor a bug, you don't have to bother about how it's handled as long as it's working correctly, and it is, 7.X use it's own routine but handle this case fine.

Last edited by Wims; 27/09/11 06:30 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: writeini problems [Re: FroggieDaFrog] #233969 27/09/11 08:45 PM
Joined: May 2006
Posts: 15
L
liftman Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: May 2006
Posts: 15
Originally Posted By: FroggieDaFrog

You might have to rewrite the ini files using the above commands.


i will try this, thanks!


Ciao!
Re: writeini problems [Re: Riamus2] #233970 27/09/11 08:51 PM
Joined: May 2006
Posts: 15
L
liftman Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: May 2006
Posts: 15
Originally Posted By: Riamus2
Your best option would be to just not use []'s as part of the section name.


right, i will do some changes in my script!


Ciao!
Re: writeini problems [Re: liftman] #233971 27/09/11 10:17 PM
Joined: Jul 2006
Posts: 3,574
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,574
You seem to have ignored my message but it says that you don't need to change anything in your script or to re-script /writeini and $readini, it works the same under 6.35 and 7.X, it doesn't matter how it's handled, ie: you don't need to bother with what the ini file contains.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: writeini problems [Re: liftman] #233972 28/09/11 12:24 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Right from what I know the [ may look like ~ under 6.35 but mIRC still sees it as [ I'd imagine. Just leave it be.