mIRC Homepage
Posted By: moi Modifying number in text file - 21/06/13 11:50 PM
Hey I am new to scripting with mIRC, I want a script that when activated by command would raise a number in a txt file.

I already know I can write and replace the first line with
Code:
on *:TEXT:!add:#: {
  write -l1 number.txt 1
}

But I want that number to rise by 1 every time someone uses the command.
Thanks for the help.
Posted By: Loki12583 Re: Modifying number in text file - 22/06/13 12:39 AM
Code:
on *:TEXT:!add:#: {
  write -l1 number.txt $calc($read(number.txt,1) + 1)
}
Posted By: moi Re: Modifying number in text file - 22/06/13 02:19 AM
Originally Posted By: Loki12583
Code:
on *:TEXT:!add:#: {
  write -l1 number.txt $calc($read(number.txt,1) + 1)
}

This doesn't seem to do anything for me.
Posted By: 5618 Re: Modifying number in text file - 22/06/13 05:51 AM
This fails due to how mIRC handles the first line in a text file when this line is a number. See /help $read
You'll need to circumvent this by using:
Code:
on *:TEXT:!add:#:{
  write -l1 number.txt $calc($read(number.txt,0) +1)
}
Posted By: MarkyO Re: Modifying number in text file - 23/06/13 04:21 AM
Why do this in a text file and not make a variable for it?
© mIRC Discussion Forums