mIRC Home    About    Download    Register    News    Help

Print Thread
#192169 23/12/07 07:24 AM
Joined: Dec 2007
Posts: 24
T
Tzar469 Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Dec 2007
Posts: 24
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.

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
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.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2007
Posts: 24
T
Tzar469 Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Dec 2007
Posts: 24
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.

Last edited by Tzar469; 24/12/07 07:51 AM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard