|
Joined: Jun 2014
Posts: 248
Fjord artisan
|
OP
Fjord artisan
Joined: Jun 2014
Posts: 248 |
Ok..so its terrible bad, but I'm using that points system thing...you know the one. I'd like to go ahead and use something a little more sophisticated with them fancy hash tables and so forth but I'd like to convert the points.ini I already have into something usable for hash tables. My efforts so far have been in vain.
alias convert {
set %line $lines(points.ini)
echo there are %line lines
while %line > 0 {
var %templine1 $read(points.ini, n, %line)
echo templine1 is %templine1
if ($chr(91) isin %templine1) {
var %templine $remove($read(points.ini, n, %line), $chr(91), $chr(93))
echo running temptoken on %templine
temptoken %templine
echo before temppoints nick is %tempnick channel is %tempchannel and the line %templine
var %temppoints $remove($read(points.ini, n, $calc(%line + 1)),Points=)
echo $mid(%tempchannel,2) $+ .points.ini %tempchannel %tempnick %temppoints
var %tempini $mid(%tempchannel,2) $+ .points.ini %tempchannel %tempnick %temppoints
writeini -n %tempini
}
dec %line
}
}
alias temptoken {
echo using $1 in temptoken
tokenize 46 $1
set %tempnick $2
set %tempchannel $1
echo nick is %tempnick channel is %tempchannel
}
Ok my points file is big, its like 200k lines. This file starts running fine but eventually it just stops running or more accurately mirc just stops responding. Now...I feel like there is something wrong with how I'm writing the new ini...I think I wanted the files to look like this filename: CHANNEL.points.ini file: [ChannelName] Nick1 Points Nick2 Points Nick3 Points(points would be a number) So..not only does it stop running like 1% in..but there are no new files. Obviously I'm doing something wrong..and I suspect its something pretty derpy. If anyone has any input <3
|
|
|
|
Joined: Jul 2006
Posts: 4,211
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,211 |
You should use $readini and $ini to read your ini file. If a nickname is "[test]" you will take it as a section. Also, if you seperate the ini file per channel, no need to use an ini file at all, it's just a waste, INI file are not meant to be used with large data, they are not efficient. If the channel is going to be included in the name of the file, there is no point including it again as the section, which is why a simple text file becomes easier to handle at this point alias convert {
var %a 1,%s,%f points.ini,%b,%nf
while ($ini(%f,%a) != $null) {
%s = $v1
%b = 1
while ($ini(%f,%s,%b) != $null) {
write %s $+ .Points.txt $v1 $readini(%f,%s,$v1)
inc %b
}
inc %a
}
} You now get files like #channel.Points.txt and you can handle them with stuff like /filter for top10 etc You could keep INI structure to load them as hash table but as I said, if you include the channel in the filename, then what do you use for the section? Well you can use an hardcoded "points" value I guess. alias convert {
var %a 1,%s,%f points.ini,%b,%nf
while ($ini(%f,%a) != $null) {
%s = $v1
%b = 1
while ($ini(%f,%s,%b) != $null) {
writeini %s $+ .Points.ini Points $v1 $readini(%f,%s,$v1)
inc %b
}
inc %a
}
} And that makes #channel.Points.ini files, with one section, "Points"
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jun 2014
Posts: 248
Fjord artisan
|
OP
Fjord artisan
Joined: Jun 2014
Posts: 248 |
Ooo ty.. So I copy pasted that and /convert. It started running. About 2 minutes in mirc appears to have stopped responding. Maybe I should just let it run for awhile? I kinda thought that the new files would show up while the script is running but so far I'm not seeing any. Anywho I'll let it run for a bit. Thanks for the help. I guess even if it converted like 100 a second it would still take like 20 minutes. Maybe my first script worked but I didn't give it time. Anyway..I'll let it run.
|
|
|
|
Joined: Jul 2006
Posts: 4,211
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,211 |
That's my bad, I made some typo on variables, I edited.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jun 2014
Posts: 248
Fjord artisan
|
OP
Fjord artisan
Joined: Jun 2014
Posts: 248 |
Okdokie...I'm using the 2nd one..instantly went to not responding I've given it like 30 minutes running now I feel like something has gone terribly wrong. I feel like if it was working properly there would be some new files popping up by now. I think it would help if I understood the script a bit better, I guess I can investigate that.
Last edited by Belhifet; 02/12/14 06:01 PM.
|
|
|
|
Joined: Jul 2006
Posts: 4,211
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,211 |
The code works here. Something, maybe the most important thing, you didn't do is to give the current format of the Points.ini file, eventually upload it so people can test things when helping you.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jun 2014
Posts: 248
Fjord artisan
|
OP
Fjord artisan
Joined: Jun 2014
Posts: 248 |
[#channel1.username1] Points=XX [#channel1.username2] Points=XX [#channel2.username3] Points=XX its like 200k lines of this. I didn't wanna post the file cause I suppose it contains personal information about people. I can't really think of a way to use it to harm someone, but I'd really hate to find out that somehow it was used that way.. I suppose in a way it shows how much time people spend in different places. Oh..Ok so I've been reading and it occurs to me that i might have lucked out on it not working...I think that would have ended up making a shit ton of new files wouldn't it ..I'll work a bit on this.
Last edited by Belhifet; 02/12/14 06:45 PM.
|
|
|
|
Joined: Jun 2014
Posts: 248
Fjord artisan
|
OP
Fjord artisan
Joined: Jun 2014
Posts: 248 |
Ok so I think I've figured out what is happening. I went back to my original
alias convert {
set %line $lines(points.ini)
echo there are %line lines
while %line > 0 {
var %templine1 $read(points.ini, n, %line)
echo templine1 is %templine1
if ($chr(91) isin %templine1) {
var %templine $remove($read(points.ini, n, %line), $chr(91), $chr(93))
echo running temptoken on %templine
temptoken %templine
echo before temppoints nick is %tempnick channel is %tempchannel and the line %templine
var %temppoints $remove($read(points.ini, n, $calc(%line + 1)),Points=)
echo $mid(%tempchannel,2) $+ .points.ini %tempchannel %tempnick %temppoints
var %tempini points. $+ %tempchannel $+ .ini points %tempnick %temppoints
writeini -n %tempini
return
}
dec %line
}
}
alias temptoken {
echo using $1 in temptoken
tokenize 46 $1
set %tempnick $2
set %tempchannel $1
echo nick is %tempnick channel is %tempchannel
}
I added that return on line 16. This script worked it found the last entry and made a points.channel.ini that and filled in the value. I think whats happening without that return is that its trying to write everything into some kinda memory then after it finishes the while loop writing the ini file. But that isn't working because of memory limitations. I'm just guessing maybe I should augment the script a bit so it doesn't try to do it all in a single loop?
|
|
|
|
Joined: Jun 2014
Posts: 248
Fjord artisan
|
OP
Fjord artisan
Joined: Jun 2014
Posts: 248 |
Yes I am using that. But I'm trying to convert the original massive ini file into ini files that can be used by hashtables. I'm not even connected to a server atm, I'm just trying to convert the file into sexier hashtable ready files. It was locking up while it was iterating over the files and never managing to write anything to the files...
alias convert {
set %line $lines(points.ini)
echo there are %line lines
var %b 10
while (%line > 0 && %b > 0) {
var %templine1 $read(points.ini, n, %line)
echo templine1 is %templine1
if ($chr(91) isin %templine1) {
var %templine $remove($read(points.ini, n, %line), $chr(91), $chr(93))
echo running temptoken on %templine
temptoken %templine
echo before temppoints nick is %tempnick channel is %tempchannel and the line %templine
var %temppoints $remove($read(points.ini, n, $calc(%line + 1)),Points=)
echo $mid(%tempchannel,2) $+ .points.ini %tempchannel %tempnick %temppoints
var %tempini points. $+ %tempchannel $+ .ini points %tempnick %temppoints
writeini -n %tempini
}
dec %line
dec %b
}
if (%line > 0) { timercontinue 0 1 keepgoing }
}
alias temptoken {
echo using $1 in temptoken
tokenize 46 $1
set %tempnick $2
set %tempchannel $1
echo nick is %tempnick channel is %tempchannel
}
alias keepgoing {
var %b 10
while (%line > 0 && %b > 0) {
var %templine1 $read(points.ini, n, %line)
echo templine1 is %templine1
if ($chr(91) isin %templine1) {
var %templine $remove($read(points.ini, n, %line), $chr(91), $chr(93))
echo running temptoken on %templine
temptoken %templine
echo before temppoints nick is %tempnick channel is %tempchannel and the line %templine
var %temppoints $remove($read(points.ini, n, $calc(%line + 1)),Points=)
echo $mid(%tempchannel,2) $+ .points.ini %tempchannel %tempnick %temppoints
var %tempini points. $+ %tempchannel $+ .ini points %tempnick %temppoints
writeini -n %tempini
}
dec %line
dec %b
}
if (%line > 0) { timercontinue 0 1 keepgoing }
}
This is working and its gonna take awhile but if I had just done this to start with I wouldn't have spent the last several hours chewing on a ceramic coffee mug staring at 25 lines of code.
|
|
|
|
Joined: Jun 2014
Posts: 248
Fjord artisan
|
OP
Fjord artisan
Joined: Jun 2014
Posts: 248 |
Heh Ya...he might have. I learned all about $ini today and although I've opened http://www.mirc.org/mishbox/tutorials/filter.htm#s6 today is not the day for me to learn about filter. That would definitely surpass my coding fatigue limit for the day. I can just stick with the terribly slow thing I have running. I'm sure there is a movie or 3 on Hbo I can watch.
|
|
|
|
|