mIRC Homepage
Posted By: liftman writeini problems - 27/09/11 04:00 PM
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!
Posted By: FroggieDaFrog Re: writeini problems - 27/09/11 06:01 PM
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.
Posted By: Riamus2 Re: writeini problems - 27/09/11 06:17 PM
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.
Posted By: Wims Re: writeini problems - 27/09/11 06:26 PM
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.
Posted By: liftman Re: writeini problems - 27/09/11 08:45 PM
Originally Posted By: FroggieDaFrog

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


i will try this, thanks!
Posted By: liftman Re: writeini problems - 27/09/11 08:51 PM
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!
Posted By: Wims Re: writeini problems - 27/09/11 10:17 PM
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.
Posted By: Tomao Re: writeini problems - 28/09/11 12:24 AM
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.
© mIRC Discussion Forums