mIRC Home    About    Download    Register    News    Help

Print Thread
$result doesn't do anything. #262027 23/12/17 03:34 AM
Joined: Feb 2003
Posts: 2,702
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,702
I've tried everything. $result is broken.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Re: $result doesn't do anything. [Re: Raccoon] #262032 23/12/17 09:11 AM
Joined: Jul 2006
Posts: 3,723
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,723
Code:
//alias tres return 5 | echo -s $tres $result | alias tres
Only works for numbers, maybe that's what changed.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $result doesn't do anything. [Re: Wims] #262034 23/12/17 10:51 AM
Joined: Feb 2003
Posts: 2,702
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,702
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!
Re: $result doesn't do anything. [Re: Raccoon] #262035 23/12/17 01:00 PM
Joined: Jul 2006
Posts: 3,723
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,723
Oops. Well in any case it was working in the past even for non-numbers


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $result doesn't do anything. [Re: Raccoon] #262036 23/12/17 01:07 PM
Joined: Dec 2002
Posts: 4,830
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,830
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.

Re: $result doesn't do anything. [Re: Khaled] #262037 23/12/17 03:04 PM
Joined: Jul 2006
Posts: 3,723
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,723
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


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $result doesn't do anything. [Re: Wims] #262039 23/12/17 06:35 PM
Joined: Dec 2002
Posts: 4,830
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,830
It probably served a purpose at the time it was implemented but as the scripting language evolved, its usefulness decreased.

Re: $result doesn't do anything. [Re: Khaled] #262043 23/12/17 08:21 PM
Joined: Feb 2003
Posts: 2,702
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,702
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!
Re: $result doesn't do anything. [Re: Raccoon] #262045 23/12/17 11:15 PM
Joined: Dec 2002
Posts: 4,830
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,830
Quote:
Could you demonstrate the use of $result as it had or still works?

Sure...

Code:
t {
  t2
  echo result: $result
}
t2 return moo

In the current and previous versions of mIRC, the following script:

Code:
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:

Code:
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:

Code:
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.

Re: $result doesn't do anything. [Re: Khaled] #262047 24/12/17 01:38 AM
Joined: Feb 2003
Posts: 2,702
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,702
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!