mIRC Home    About    Download    Register    News    Help

Print Thread
#266103 24/09/19 01:44 AM
Joined: Apr 2015
Posts: 19
O
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2015
Posts: 19
i have a script where it write an ini for nicks. the section name is their nick.
so the ini is stored as $+($nick,.,info,.ini) ..
on nick change is where my question and request for help lies..
i know you can use /rename $+(c:/,$+($nick,.,info,.ini)) $+(c:/,$+($newnick,.,info,.ini)) to actually rename the ini back and forth.. but is there a way to
change the section name to match accordingly?
as allways i appreciate any help!

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
Use /writeini to write each item in the old section, to the new section. Use /remini to remove the old section.

/help /writeini
/help /remini

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Note that there are characters in nicknames that cannot be used in filenames or INI sections, and are replaced by an underscore instead. This has the potential to create nickname collisions.

What doesn't make sense to me is the fact that each file is unique to their nickname, so there's no reason to use their nickname again in the ini section. Just use the literal word "nick" instead.

Otherwise, here's a simple method to rename an INI section that seems to work just fine.

Code
/writeini -n test.ini foo bar baz
/run test.ini
/write -s[foo] test.ini [fum]
/run test.ini


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Apr 2015
Posts: 19
O
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2015
Posts: 19
thank you raccoon your help was appreciated! after looking @ what you did i was able to find the solution i was looking for!
changing the -s to -w and replacing the [ ] with $chr(91) $chr(93) seemed to do the trick. ya i do note the char's that an ini vs nick can conflict with, so i have chosen to replace those with appropriate chars for data recall
Help is allways appreciated!

Last edited by ovelayer; 24/09/19 12:22 PM.
Joined: Jul 2006
Posts: 4,144
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
Note that using /write -s or -w like that to replace the section's name is not 'proper' and will not work in some cases, using proper ini commands as suggested will ensure that it works in all cases.

Certainly, doing it properly requires a while loop currently, maybe /writeini could get a new switch which means to replace the section's name: /writeini -r file.ini oldsection newsection


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
I honestly don't believe there are "improper" ways about this. I could be wrong, but mIRC doesn't use native INI windows api anymore. I suspect /writeini is just /write with extra features, so you can use them interchangeably.

Last edited by Raccoon; 25/09/19 01:29 AM.

Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Apr 2015
Posts: 19
O
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2015
Posts: 19
Originally Posted by Wims
Note that using /write -s or -w like that to replace the section's name is not 'proper' and will not work in some cases, using proper ini commands as suggested will ensure that it works in all cases.

Certainly, doing it properly requires a while loop currently, maybe /writeini could get a new switch which means to replace the section's name: /writeini -r file.ini oldsection newsection


the new switch idea would be a great idea and practical.

Joined: Jul 2006
Posts: 4,144
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
I am unsure, but I quickly considered such file:


"abc
[section]

def

[section]
realitem=data"

Your /write won't care about any single thing, it finds a match it's let's go, there are absolutely 0 check done related to an ini structure, I strongly feel like this would create issues over the time.
That being said I quickly thought as well that /writeini wouldn't be a great super hero here and would also use the first occurence of [section] here, which may not be so wrong, still feel like /write should be avoided, /writeini should have a switch to do it.

Last edited by Wims; 25/09/19 02:14 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
You can write invalid ini files all day long. mIRC is going to treat them no worse than they started off as.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Link Copied to Clipboard