mIRC Home    About    Download    Register    News    Help

Topic Options
#261700 - 14/11/17 06:52 PM $timer(N).name
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1146
The way $envvar() has a .name property to treat a numeric property as a variable name instead of the Nth variable, and $bfind() has a .text property to treat a numeric parameter as text instead of an ASCII value, it would be nice if $timer() could have the same thing. My guess is that .name would be the more appropriate property name here.

When a timer is created without assigning a name to it, mIRC assigns it the lowest available positive integer. Yet you can't use the value returned from $ltimer or $ctimer to access characteristics about that timer without looping through all the timers looking for the $timer(N) which returns that particular numeric name. $timer(3).secs is returning info about the 3rd timer, not the timer *named* 3.

The .name property would make it simple to find properties for /timer1 by using the .name property to force the numeric string to be treated as the timer name instead of the Nth timer ID. If /timer1 is the 5th timer in the list, $timer(1).name returns 5 instead of the name of the 1st timer, and you could find properties of /timer1 with $timer($timer(1).name).secs.

Top
#265197 - 15/03/19 03:51 AM Re: $timer(N).name [Re: maroon]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1146
I'm posting this update for the benefit of those searching for keyword $envvar and finding this post.

What I posted above about $envvar().name seems not actually correct, and I'm having trouble finding an older mIRC version having the behavior I described behavior above.

Instead of .name treating a numeric variable name as the name of an environment variable instead of its index in the sequential list of variables, it instead returns the actual case of the variable, regardless of the string used as the parameter.

For example, $envvar(path).name returns 'Path' because that's the literal case of the existing variable name.

I have an environment variable named '7', and instead of returning '7' or the index number where '7' appears in the list of variables, $envvar(7).name and $envvar(7) both return identical string, returning the name of the 7th item in the list of environment variables.

The only way to return the contents of the variable named '7' is to loop through all the variable names looking for the index numer where $envvar(index-number) is '7', then use $envvar(index-number).value

I'm not sure whether it would break compatibility for the .name property in this case to return the index number when the parameter is numeric, or whether it's worth the bother for this edge case.

But it is great to now be able to find the timer index for $timer(12345) without needing to loop through them until finding a string match, and now instead can use $timer(12345).name

Top