mIRC Homepage
Posted By: darkfire Possible $ini() and $readin() bug - 23/02/04 04:18 AM
$ini() and $readini() will fail when using a temporary variable (set by /var) that stores a number. For example:

var %users.total $ini(users.ini, 0)
var %users.current 0
while (%users.total > %users.current) {
inc %users.current
var %nick $ini(users.ini, %users.current)
...
}

The script here will halt on line 5 "var %nick $ini(users.ini, %users.current)" with the error "* Invalid format: $ini (line 5, script.ini)"

The script will not halt if using a global variable (defined with /set) or if the %users.current variable returns anything other than a number. In this scenario, I simply changed the /vars to /sets and everything worked fine.

-- [email]darkfire@dalnet[/email]
Posted By: Nobodi Re: Possible $ini() and $readin() bug - 23/02/04 06:37 AM
Try using the correct format for the var command.

/var %x = hello , not /var %x hello

/help /var
Posted By: darkfire Re: Possible $ini() and $readin() bug - 23/02/04 06:48 AM
Perhaps it is you that should look up /help /var. It is not necessary to use an = sign when defining a local variable, nor a global one. Thanks anyway.
Posted By: Nobodi Re: Possible $ini() and $readin() bug - 23/02/04 06:58 AM
Straight from the help file.

Quote:

Local Variables
Local variables are variables that exist only for the duration of the script in which they are created and can only be accessed from within that script. They can be created with the /var command:

/var %x

This creates the local variable %x in the current routine and can only be referenced from inside this routine.

/var %x = hello

This creates a local variable %x and assigns it the value hello.

You can create multiple local variables by separating them with commas:

/var %x = hello, %y, %z = $me

loop {
var %x = 1
:next
echo item %x
inc %x
if (%x < 10) goto next
}

Note: You can use /var -s to make a variable show the result when a value is set.




Posted By: darkfire Re: Possible $ini() and $readin() bug - 23/02/04 07:00 AM
That's nice. Now go try it yourself.

alias testing {
var %x blah
echo -a %x
}

You'll be amazed.
Posted By: Nobodi Re: Possible $ini() and $readin() bug - 23/02/04 07:08 AM
I know that works sometimes but tends to break when using identifiers.
Posted By: darkfire Re: Possible $ini() and $readin() bug - 23/02/04 07:11 AM
It's never broken before. Regardless, I modified my /var statements to use the /var <variable> = <value> method and I resulted in the same error. It only happens when using $ini() and $readini() and when using a local variable that stores a numeric value; this is a bug in mIRC.
Posted By: tidy_trax Re: Possible $ini() and $readin() bug - 23/02/04 07:41 AM
it does not break, the only time you have to specify an = sign is when you use:
%x = hello
without a /var or /set command
No. Nobodi is correct. The /var command should have an = sign. Although it will work sometimes without it, it has some unpredictable behaviour and causes seemingly random bugs, such as the one darkfire is experiencing.

Having just tested the code it shows it is a bug caused by the missing = signs.
Posted By: tidy_trax Re: Possible $ini() and $readin() bug - 23/02/04 11:04 AM
never caused me any problems, not once.
Lucky you then.
Posted By: PastMaster Re: Possible $ini() and $readin() bug - 23/02/04 01:09 PM
Quote:
never caused me any problems, not once.


Heh... that's what I used to say about the = in the /var as well... and then, one day... things went wrong... crazy

PM
Posted By: qwerty Re: Possible $ini() and $readin() bug - 23/02/04 01:17 PM
As much as you don't want to admit it, it's /var without = that causes the problem. I'll give you an example of using $ini with mirc.ini to see what I mean.

//var %one = 1 | var %two = $ini($mircini,%one) | echo -a %two
echoes "files" , which is the 1st section in mirc.ini


//var %one = 1 | var %two $ini($mircini,%one) | echo -a %two
echoes * Invalid format: $ini

It spits out the same error as in your script.

The help file says /var should be used with a =. The fact that it works without = in some cases doesn't make it right.
© mIRC Discussion Forums