mIRC Homepage
Posted By: Tzar469 /writeini with [ ] - 23/12/07 07:24 AM
When using /writeini, why does mIRC replace the "[" and "]" characters with "~"? Is there a way to stop this?

For example:

Code:
/writeini myscript.ini ToDo [Homework]Math 50%


Will write as:

[ToDo]
~Homework~Math=50%


I need it to stop doing that.
Posted By: DJ_Sol Re: /writeini with [ ] - 23/12/07 09:58 AM
Im guessing because the sections are surrounded by the same characters? I made an alias that replaces the ['s with the ~ mirc replaces them with anyways. Same alias changes them back as well.
Posted By: Riamus2 Re: /writeini with [ ] - 23/12/07 09:44 PM
It does that because, as mentioned, the Section names in an INI file have []'s around them. If you have []'s around an item name, then as far as the INI is concerned, the item becomes a topic instead, which is obviously undesirable. The best thing to do is either use an alias as mentioned or else decide *why* you need []'s in the item name and decide if there's some other character(s) that you can use instead such as ()'s or {}'s.
Posted By: Tzar469 Re: /writeini with [ ] - 24/12/07 07:51 AM
I see. Unfortunately, I have no choice; I have to use the "[" and "]" symbols. If I can't store it with those symbols, I want to be able to change "~" back into [ ] when it's being read from the ini file. Can you point me to the right direction of the code that's needed for the alias? I tried using $reptok but it didn't work frown

Any help is greatly appreciated.
Posted By: Riamus2 Re: /writeini with [ ] - 24/12/07 11:10 AM
I'd just use an alias as mentioned...

Code:
alias RepB {
  return $replacex($1-,[,ÿ,],Ö,ÿ,[,Ö,])
}


Then, when writing to reading from the INI file, use:

writeini file.ini section $RepB(item) data
$RepB($readini(file.ini,section,$RepB(item)))

Example:
writeini file.ini section $RepB([my_item]) data
$RepB($readini(file.ini,section,$RepB([my_item])))

Note that you can change the characters that are being replaced to something else if you like. I just picked a couple random characters that probably won't be used in your INI files.
© mIRC Discussion Forums