|
Joined: Feb 2003
Posts: 2,812
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 2,812 |
I've tried everything. $result is broken.
Well. At least I won lunch. Good philosophy, see good in bad, I like!
|
|
|
|
Joined: Jul 2006
Posts: 4,150
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,150 |
//alias tres return 5 | echo -s $tres $result | alias tres Only works for numbers, maybe that's what changed.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Feb 2003
Posts: 2,812
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 2,812 |
Ouims: Your code proves that $result doesn't work, not even for numbers.
Well. At least I won lunch. Good philosophy, see good in bad, I like!
|
|
|
|
Joined: Jul 2006
Posts: 4,150
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,150 |
Oops. Well in any case it was working in the past even for non-numbers
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Dec 2002
Posts: 5,421
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 5,421 |
Thanks for your bug report. $result only has a value when a command is called directly that returns a value. It is a pretty old identifier that has always worked this way. That said, it might be possible to extend it to work in other contexts. However, this would mean that it would start returning values in many situations.
|
|
|
|
Joined: Jul 2006
Posts: 4,150
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,150 |
I wonder why it was implemented.
The only benefit I can see right now is wanting to get "consecutive" spaces trimmed to one space (because otherwise you would just call the alias as an identifier and get the returned value that way, no need for $result in this case), which yeah, seems weird.
I don't think it would break many scripts to extend $result but what would be the point of extending it? Having $result working for aliases called as identifiers as well as commands is not going to magically solve/help with issues
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Dec 2002
Posts: 5,421
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 5,421 |
It probably served a purpose at the time it was implemented but as the scripting language evolved, its usefulness decreased.
|
|
|
|
Joined: Feb 2003
Posts: 2,812
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 2,812 |
Khaled: Could you demonstrate the use of $result as it had or still works?
The times I've tried using it was to avoid repeating a call to a custom identifier where /return was used, where it was inconvenient or impossible to store the result of the previous call to a variable -- such as in $findfile or $regsubex or similar callback. Sort of the same way we use $v1 / $ifmatch.
In absence of $result, I have used $iif($identifier(),$v1) $v1
Well. At least I won lunch. Good philosophy, see good in bad, I like!
|
|
|
|
Joined: Dec 2002
Posts: 5,421
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 5,421 |
Could you demonstrate the use of $result as it had or still works? Sure... t {
t2
echo result: $result
}
t2 return moo
In the current and previous versions of mIRC, the following script: t {
t1
echo A: $result
t2
echo B: $result
t3
echo C: $result
t4
echo D: $result
echo E: $t1 $result : $t2 $result : $t3 $result
echo F: $result $t4 $result
}
t1 return 1
t2 return 2
t3 return 3
t4 return 4
Returns: A: 1
B: 2
C: 3
D: 4
E: 1 4 : 2 4 : 3 4
F: 4 4 4 If I change the next version to allow identifier calls to set the $result value, it would return: A: 1
B: 2
C: 3
D: 4
E: 1 1 : 2 2 : 3 3
F: 3 4 4 So there would be a definite change in $result for existing scripts that do not expect identifiers to set $result.
|
|
|
|
Joined: Feb 2003
Posts: 2,812
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 2,812 |
Got it. Thanks.
//alias /apple return apple | /apple | echo -a $result | alias /apple
Well. At least I won lunch. Good philosophy, see good in bad, I like!
|
|
|
|
|