mIRC Home    About    Download    Register    News    Help

Print Thread
renaming ini sections #266103 24/09/19 01:44 AM
Joined: Apr 2015
Posts: 13
O
ovelayer Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2015
Posts: 13
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!

Re: renaming ini sections [Re: ovelayer] #266104 24/09/19 03:04 AM
Joined: Dec 2002
Posts: 2,014
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,014
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

Re: renaming ini sections [Re: ovelayer] #266105 24/09/19 06:11 AM
Joined: Feb 2003
Posts: 2,669
Raccoon Online
Hoopy frood
Online
Hoopy frood
Joined: Feb 2003
Posts: 2,669
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!
Re: renaming ini sections [Re: Raccoon] #266106 24/09/19 12:17 PM
Joined: Apr 2015
Posts: 13
O
ovelayer Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2015
Posts: 13
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.
Re: renaming ini sections [Re: ovelayer] #266107 24/09/19 08:17 PM
Joined: Jul 2006
Posts: 3,585
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,585
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


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: renaming ini sections [Re: Wims] #266109 25/09/19 01:28 AM
Joined: Feb 2003
Posts: 2,669
Raccoon Online
Hoopy frood
Online
Hoopy frood
Joined: Feb 2003
Posts: 2,669
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!
Re: renaming ini sections [Re: Wims] #266111 25/09/19 01:35 PM
Joined: Apr 2015
Posts: 13
O
ovelayer Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2015
Posts: 13
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.

Re: renaming ini sections [Re: Raccoon] #266112 25/09/19 02:10 PM
Joined: Jul 2006
Posts: 3,585
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,585
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.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: renaming ini sections [Re: Wims] #266118 27/09/19 01:21 AM
Joined: Feb 2003
Posts: 2,669
Raccoon Online
Hoopy frood
Online
Hoopy frood
Joined: Feb 2003
Posts: 2,669
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!