mIRC Home    About    Download    Register    News    Help

Print Thread
Trouble with return and $result #109167 26/01/05 07:16 AM
Joined: May 2004
Posts: 3
I
I_like_pie Offline OP
Self-satisified door
OP Offline
Self-satisified door
I
Joined: May 2004
Posts: 3
help file says:

Quote:

You can also optionally specify a return value which will be stored in the $result identifier. The $result can then be used in the calling routine.

/return [value]


I try playing with it, by doing this:

Code:
test_one {
  $test_two($1,$2)
  echo -a $result
}
test_two {
  if ($1 isin $2) {
    return true
  }
  else {
    return false
  }
}
 


and typing /test_one i is

and i get:

TRUE Unknown command
-
* /echo: insufficient parameters (line 3, aliases3.ini)

what am i doing wrong here? i should be getting "true" echo'd into my active window, but i'm not. i'm just using it as the help file said, and it doesn't seem to be working

any idea what's going on?

Re: Trouble with return and $result #109168 26/01/05 10:20 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
test_one {
  test_two $1 $2
  echo -a Called as a command $result
  echo -a Called as an identifier $test_two($1,$2)
}
test_two {
  if ($1 isin $2) {
    return true
  }
  else {
    return false
  }
}


If you call it as a command then the return value is stored in $result

If you call the alias as an $identifier it is replaced with the return value
^ this is why you were seeing TRUE unknown command, since $test_two($1,$2) was replaced with "TRUE" and that was attempted as a command in itself.

Re: Trouble with return and $result #109169 26/01/05 10:24 AM
Joined: Apr 2004
Posts: 759
M
Mpdreamz Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
correct me if im wrong on this as im just guessing here
$test_two($1,$2) will be identified into the command true
which doesnt excist.. try it with /test_two($1,$2)


$maybe
Re: Trouble with return and $result #109170 26/01/05 10:34 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
correct me if im wrong on this as im just guessing here
$test_two($1,$2) will be identified into the command true
which doesnt excist.. try it with /test_two($1,$2)


that well fail as well
TEST_TWO($1,$2) Unknown command

you cant bracket the parameters if issuing as a command. It sees "TEST_TWO($1,$2)" as one big command name.

But you are right about it being identified into the command true.

Re: Trouble with return and $result #109171 26/01/05 10:43 AM
Joined: Apr 2004
Posts: 759
M
Mpdreamz Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
LOL how did i miss that, tnxs for the correction.


$maybe
Re: Trouble with return and $result #109172 26/01/05 07:54 PM
Joined: May 2004
Posts: 3
I
I_like_pie Offline OP
Self-satisified door
OP Offline
Self-satisified door
I
Joined: May 2004
Posts: 3
ah, that explains it.

thank you very much, i can now get on with the script i needed that for laugh