1

I'm trying to see if there is a entry in a ini-file with a user's nick as the key or not. If not; make an entry. If it exists; post a error message.

var %previous = $readini(numbers.ini,Number,$nick)

if(%previous != $null) {
  msg $chan $nick , you have already written %previous .
}
else {
  writeini numbers.ini Number $nick $2
  msg $chan $nick has written $2.
}

What's happening with the script above is that it is never $null, and I can't find anywhere what is returned from $readini if a key is not found.

PWL
  • 456
  • 4
  • 27

1 Answers1

0

$ini(numbers.ini, Numbers, $nick) will return number N (indicating that the item is the Nth item in that section) if it exists. If it does not exist, it will return $null.

In your case, you'll want something along the lines of

if ($ini(numbers.ini, Numbers, $nick) != $null) {
  msg $chan $nick , you have already written $readini(numbers.ini, Numbers, $nick)
}
else {
  writeini numbers.ini Numbers $nick $2
  msg $chan $nick has written $2.
}
Patrickdev
  • 2,341
  • 1
  • 21
  • 29
  • 1
    Thanks for the `$ini`-suggestion, but the if still fails. With the code you posted I always get `User has written 30.` – PWL Jun 10 '15 at 16:02
  • Phil, I accidentally included typo's. It wrote to the section `Number` instead of `Numbers`, so it would never detect the new value. Also, the `$readini` read from `$numbers.ini` instead of `numbers.ini`. Both are now fixed. I guess that's what I get for not testing code! Let me know if this works. – Patrickdev Jun 11 '15 at 12:32