mIRC Home    About    Download    Register    News    Help

Print Thread
please help. ini file renumber. #254597 19/08/15 09:14 AM
Joined: Aug 2015
Posts: 16
A
acpixel Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Aug 2015
Posts: 16
Ok so i basically have a ini file and it looks somewhat like this

Code:
[#acpixel]
1=test
2=test1
3=test2
4=test3

and so on, and things get added all the time so it is endless.

so what i need is something so that if i have a command that lets people remove #2 it would end up like this,

Code:
[#acpixel]
1=test
3=test2
4=test3


And then the script automaticly fixes it and makes it
Code:
[#acpixel]
1=test
2=test2
3=test3


I dont know if this is possible but if it is i would love some help.

Last edited by acpixel; 19/08/15 09:31 AM.
Re: please help. ini file renumber. [Re: acpixel] #254601 19/08/15 10:59 AM
Joined: Jul 2006
Posts: 3,582
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,582
It's possible but you should work on how not to have to do this, because as you said, if it's endless, mIRC will simply freeze a lot if you have a large amount of data.
Note also that because you used number as the items, you won't be able to use $ini properly, which would be the way to solve that problem. A solution would be to use something else than just numbers, like I<n> where n is the number, but you have a letter before it, making it not just number, then you would be able to do what you asked with:

Code:
alias fixit {
var %a 1
hmake #acpixel
while ($ini(file,#acpixel,%a) != $null) {
hadd #acpixel %a $readini(file,#acpixel,$v1)
inc %a
}
%a = 1
while ($hget(#acpixel,%a) != $null) {
writeini $qt(file) #acpixel I $+ %a $v1
inc %a
}
hfree #acpixel
}
But you shouldn't be doing it like that, use a text file or a @window if you want ordered stuff


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: please help. ini file renumber. [Re: Wims] #254605 19/08/15 03:12 PM
Joined: Aug 2015
Posts: 16
A
acpixel Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Aug 2015
Posts: 16
Thank you @wims


I would do text files but the reason I'm doing this is I'm making a quote system that has a different quote bank for each channel it joins. And I wouldent know how to format or use text files at all. I only ever use ini. So if there's a way you could explain making a numbered system then being able to have a random quote chosen and sent to the channel, or someone types !quote 29 and it would send quote 29. The reason I needed the fix thing was because I needed a way to delete quotes. And if I didn't do a fix. Then it would overlap it's self a whole bunch and break.

Re: please help. ini file renumber. [Re: acpixel] #254609 19/08/15 03:51 PM
Joined: Jul 2006
Posts: 3,582
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,582
You could create a text file for each channel, just like you would have different section for different channel in your INI file.
Note that even in your perfect world where it works as you want, once you delete quote n3, the old quote n4 becomes the n3 and so on, so you can't rely on fixed number unless you don't delete the quote, but rather mark them as deleted (like Nillens mentioned in that other thread, iirc), that would make the file much bigger but one could rely on the number.

Last edited by Wims; 19/08/15 04:00 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: please help. ini file renumber. [Re: Wims] #254610 19/08/15 04:11 PM
Joined: Aug 2015
Posts: 16
A
acpixel Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Aug 2015
Posts: 16
Actually I have a different ini for each channel do to a weird maybe bug that I was running into

Re: please help. ini file renumber. [Re: Wims] #254612 19/08/15 04:14 PM
Joined: Aug 2015
Posts: 16
A
acpixel Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Aug 2015
Posts: 16
I will probably end up marking them as deleted... But when I do I need a way to make it so that when I type !quote to get a random one, the deleted ones don't show up.

Re: please help. ini file renumber. [Re: acpixel] #254613 19/08/15 04:29 PM
Joined: Jul 2006
Posts: 3,582
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,582
Which bug? If you have one INI file per channel with only one section, it's not so great..
To avoid getting the one marked as deleted, it's pretty easy, just mark them with something super strange which is unlikely to be a quote, (like $+($chr(1),$chr(2),$chr(3)) ), and when you find a quote, check that it's different from that, if it's equal, just try another quote, pseudo code:

while ($findquote == $deletedmark) noop
echo -a quote: $v1


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: please help. ini file renumber. [Re: Wims] #254614 19/08/15 04:40 PM
Joined: Aug 2015
Posts: 16
A
acpixel Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Aug 2015
Posts: 16
Thanks. I worked for about 5 hours straight and I found that the ini thing works best if I do one ini per channel. I have them all outputting to a folder called quotes. Thanks to you everything works. Thanks <3

Re: please help. ini file renumber. [Re: Wims] #254620 19/08/15 06:47 PM
Joined: Aug 2015
Posts: 16
A
acpixel Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Aug 2015
Posts: 16
i have one more question. one what exactly is noop
and two what would $findquote and $deletedmark be set to?

here is my code but idk how to make it leave out my delete tag. which is "asdf1234,,"

Code:
on *:TEXT:!quote:#: {
  set %quote $rand(1, $calc($lines(F:\mIRC\quotes\quotes $+ # $+ .ini) - 2))
  msg $chan $readini(F:\mIRC\quotes\quotes $+ # $+ .ini, n, #, %quote)

}

Re: please help. ini file renumber. [Re: acpixel] #254626 20/08/15 12:03 AM
Joined: Jul 2006
Posts: 3,582
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,582
Quote:
and I found that the ini thing works best if I do one ini per channel
This must be because as a single INI file you had a lot of lines, but it's not a bug, it's just that INI handling is slow with mIRC script.

/noop is a commmand for doing nothing with the result, usually used with identifier which are not returning a value, but aren't given as command to preserve spaces in parameters, like $hfind, check /help /noop

Code:
on *:TEXT:!quote:#:get_quote $chan
alias $deletedmark return asdf1234,,
alias get_quote {
;as long as the quote we got is the deleted mark, we keep that loop running evaluating $findquote again to find a new quote, the body of the loop itself doesn't need to do anything
while ($findquote($1) == $deletedmark) noop
  msg $1 $v1
}
alias findquote {
var %file $+(F:\mIRC\quotes\quotes,$1,.ini)
return $readini(%file, n, #, $rand(1, $calc($lines(%file) - 2)))
}


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net