mIRC Homepage
I have 2 ini files of the same format containing names of my viewers and their points.

viewername = points value
viewername = points value
etc...


Is there a way to combine these?
Posted By: Nillen Re: someway to combine values of 2 ini files? - 15/11/14 10:31 AM
If you provide the name of the files and exactly what they look like, yes very much so.

I assume it's something like
File1.ini
[Points]
$nick1=12
$nick2=13
etc.

File2.ini
[Points]
$nick1=15
$nick2=19
etc

But I can't know for sure unless you tell me

https://www.dropbox.com/s/q6xa31hv7ju71vb/new%20coins.ini?dl=0

https://www.dropbox.com/s/y3nn5peqbb01jbl/old%20coins.ini?dl=0
Posted By: Nillen Re: someway to combine values of 2 ini files? - 15/11/14 02:35 PM
Code:
alias copy_coins { 
  echo -a Moving coins initialized
  var %file1 $qt(old coins.ini)
  var %file2 $qt(new coins.ini)
  var %sec #tylersgaming
  var %items $ini(%file1,%sec,0)
  while (%items) {
    var %item $ini(%file1,%sec,%items)
    var %value1 $readini(%file1,%sec,%item)
    var %value2 $readini(%file2,%sec,%item) 
    if (%value2) writeini %file2 %sec %item $calc(%value1 + %value2)
    else writeini %file2 %sec %item %value1
    dec %items
  }
  echo -a Moving coins finished
}
Type /copy_coins
If this freezes your mIRC application, let me know and I'll attempt doing it through an hashtable (never done this before)
By freezing I mean if you don't see the "Moving coins finished" echo and your mIRC stops responding. Give it some time though, you might have it done in 20 seconds if you just don't touch mIRC.
2 questions where do I type /copy_coins

and how does it find my ini files since they're in drop box,

I tried typing /copy_coins in a lot of windows and it didn't create any files or anything. smirk

but yeah, it's not working ;-;
im also getting this - http://puu.sh/cRMZU/c69f9f5a56.png
Posted By: Nillen Re: someway to combine values of 2 ini files? - 15/11/14 03:51 PM
First of all, open your remote scripts editor by pressing alt + r, press file and create a new scriptfile. Paste the code I gave you in there.

After you've done that, change the var %file1 and %file2 to the actual path to the file. I assumed that the path to the file was standard inside your $mircdir, but just open the file's properties and change the filepath to the correct one. Should looks something like this: var %file1 $qt(c:\myuser\dropbox\old coins.ini)
Posted By: Nillen Re: someway to combine values of 2 ini files? - 15/11/14 04:11 PM
From what I can see in your private message, your code is flawed in the way that your last alias (as in the one prior to mine) does not have a closing bracket.
Code:
on *:TEXT:!on*:#:{
if ($nick == tylersgaming) {
if ($read(botstatus.txt,t,1) == on) {

}
if ( $read(botstatus.txt,t,1) == off) {
/write -c botstatus.txt
/timerAward 0 1800 /awardPoints $chan
write botstatus.txt on
msg $chan Points will now be awarded.
}
}
}

on *:TEXT:!off*:#:{
if ($nick == tylersgaming) {
if ($read(botstatus.txt,t,1) == off) {

}
if ( $read(botstatus.txt,t,1) == on) {
/write -c botstatus.txt
write botstatus.txt off
/timerAward off
msg $chan Points will no longer be awarded.
}
}
}

alias awardpoints {
var %chan = $$1, %table = coins. $+ %chan, %file = C:\Users\TylersGaming\Dropbox\coins.ini

if (!$hget(%table)) {
hmake %table
if ($ini(%file,%chan)) hload -i %table %file %chan
}

var %i = 1, %n = $nick(%chan,0)
while (%i <= %n) {
hinc %table $nick(%chan,%i)
inc %i
}

hdel %table nightbot
hdel %table tylerb0t
hdel %table tylersgaming

hsave -i %table %file %chan

alias copy_coins { 
echo -a Moving coins initialized
var %file1 $qt(old coins.ini)
var %file2 $qt(new coins.ini)
var %sec #tylersgaming
var %items $ini(%file1,%sec,0)
while (%items) {
var %item $ini(%file1,%sec,%items)
var %value1 $readini(%file1,%sec,%item)
var %value2 $readini(%file2,%sec,%item) 
if (%value2) writeini %file2 %sec %item $calc(%value1 + %value2)
else writeini %file2 %sec %item %value1
dec %items
}
echo -a Moving coins finished
}
Whenever your awardpoints alias gets triggered, you should have tons of error messages in your log.
As well as the fact that your coins.ini file seems out of place considering that your files you sent me are called "old coins.ini" and "new coins.ini" not "coins.ini" - Might be something to look up.
idk what to do now ;-;
Posted By: Nillen Re: someway to combine values of 2 ini files? - 15/11/14 04:59 PM
Originally Posted By: Nillen
First of all, open your remote scripts editor by pressing alt + r, press file and create a new scriptfile. Paste the code I gave you in there.

After you've done that, change the var %file1 and %file2 to the actual path to the file. I assumed that the path to the file was standard inside your $mircdir, but just open the file's properties and change the filepath to the correct one. Should looks something like this: var %file1 $qt(c:\myuser\dropbox\old coins.ini)


Do that.

After you've done that we're gonna look into adding a closing bracket to your other alias, but one thing at a time.
ok i did this
Posted By: Nillen Re: someway to combine values of 2 ini files? - 18/11/14 02:23 PM
Now, your alias for awarding points is not closed. From what you sent me it looks like this:
Code:
alias awardpoints {
var %chan = $$1, %table = coins. $+ %chan, %file = C:\Users\TylersGaming\Dropbox\coins.ini

if (!$hget(%table)) {
hmake %table
if ($ini(%file,%chan)) hload -i %table %file %chan
}

var %i = 1, %n = $nick(%chan,0)
while (%i <= %n) {
hinc %table $nick(%chan,%i)
inc %i
}

hdel %table nightbot
hdel %table tylerb0t
hdel %table tylersgaming

hsave -i %table %file %chan
It needs to looks like this:
Code:
alias awardpoints {
var %chan = $$1, %table = coins. $+ %chan, %file = C:\Users\TylersGaming\Dropbox\coins.ini

if (!$hget(%table)) {
hmake %table
if ($ini(%file,%chan)) hload -i %table %file %chan
}

var %i = 1, %n = $nick(%chan,0)
while (%i <= %n) {
hinc %table $nick(%chan,%i)
inc %i
}

hdel %table nightbot
hdel %table tylerb0t
hdel %table tylersgaming

hsave -i %table %file %chan
}
Note that the only change was the closing bracket at the end.

Make sure that the path to the file is correct too: %file = C:\Users\TylersGaming\Dropbox\coins.ini
I dunno what file you're currently using, but if you're using newcoins.ini, you need to change that.
Posted By: Wims Re: someway to combine values of 2 ini files? - 18/11/14 09:04 PM
Quote:
Whenever your awardpoints alias gets triggered, you should have tons of error messages in your log.
Just a side note here, because you miss a { or a } doesn't mean everything will blow necessarily. Here, everything is executed as part of the alias:

Code:
alias copy_coins { 
echo -a Moving coins initialized
var %file1 $qt(old coins.ini)
....
This will be executed as a command, /alias is a command so that won't even produce an error, the { is going to be ignored the same way "//echo -a a { b" would
thanks everyone smile
© mIRC Discussion Forums