mIRC Homepage

renaming ini sections

Posted By: ovelayer

renaming ini sections - 24/09/19 01:44 AM

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!
Posted By: RoCk

Re: renaming ini sections - 24/09/19 03:04 AM

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
Posted By: Raccoon

Re: renaming ini sections - 24/09/19 06:11 AM

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
Posted By: ovelayer

Re: renaming ini sections - 24/09/19 12:17 PM

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!
Posted By: Wims

Re: renaming ini sections - 24/09/19 08:17 PM

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
Posted By: Raccoon

Re: renaming ini sections - 25/09/19 01:28 AM

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.
Posted By: ovelayer

Re: renaming ini sections - 25/09/19 01:35 PM

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.
Posted By: Wims

Re: renaming ini sections - 25/09/19 02:10 PM

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.
Posted By: Raccoon

Re: renaming ini sections - 27/09/19 01:21 AM

You can write invalid ini files all day long. mIRC is going to treat them no worse than they started off as.
© 2020 mIRC Discussion Forums