mIRC Home    About    Download    Register    News    Help

Print Thread
R
RusselB
RusselB
R
Normally when you look at an ini file through a text editor it looks something like
Quote:
[section1]
item1=data1
item2=data2
item3=data3
[section2]
item1=data1
item2=data2
item3=data3


I'm trying to use an ini file to store some information for specific nicks, using the nick as the section.
For most nicks this isn't a problem, however, I recently noticed that a couple of the nicks have the [ ] characters in the nick, which is making it difficult to use the ini file format.

While I could use hash tables for this, I'm trying to reduce the number and size of the hash tables in use. This is being used on a bot, and currently the bot has 10 hash tables with between 20 and 10,000 entries (depending on the table).
The larger tables (ie: 5,000+ entries) could easily be transferred over to ini file format, as 99% of the information is just being stored.

Any suggestions as to how I could handle the [ ] characters in the respective nicks?

Joined: Feb 2003
Posts: 3,412
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,412
maybe try use  $chr(91) = [ and $chr(93) = ], don't know if it help, but you can try use $replace for this..

H
Horstl
Horstl
H
Albeit not pretty, I'd replace the square brackets with chars that "may" not be part of a nickname (e.g. round brackets) - and translate these chars back, if needed.
Unfortunately, you cannot use quotes or escapes, $encode won't help either. Of course, there may be networks that extended the "common" set of chars allowed for nicks ( letters, digits, []{}_-|^`\ )...



T
Tomao
Tomao
T
Just out of curiosity, did the [ and ] appear to be ~ when stored in an ini file? As in [~nick~]

R
RusselB
RusselB
R
As a matter of fact, yes.

Joined: Jul 2006
Posts: 4,062
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,062
Then what's the problem ? When you will use $readini(file,[nick],item) it will work.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
R
RusselB
RusselB
R
weird.. it wasn't working, but now it is.. sorry for what has turned out to be an unnecessary question.

H
Horstl
Horstl
H
Uhm, but [ or ] == ~ and therefore ~nick~ = [nick] or [nick[ etc.
I supposed the issue was unambiguously translating a nick with square brackets to an ini section (or item), and vice versa smile

R
RusselB
RusselB
R
That was my thinking too, but (atm) mIRC is recognizing the difference between ~ for [ and ~ for ]

I don't understand it, but until it screws up or I can find a way to guarantee that this can't screw up, I'll just go with it.

or to put it another way.. if it ain't broke, don't fix it.

laugh


Link Copied to Clipboard