mIRC Homepage
Posted By: I_like_pie Trouble with return and $result - 26/01/05 07:16 AM
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?
Posted By: DaveC Re: Trouble with return and $result - 26/01/05 10:20 AM
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.
Posted By: Mpdreamz Re: Trouble with return and $result - 26/01/05 10:24 AM
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)
Posted By: DaveC Re: Trouble with return and $result - 26/01/05 10:34 AM
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.
Posted By: Mpdreamz Re: Trouble with return and $result - 26/01/05 10:43 AM
LOL how did i miss that, tnxs for the correction.
Posted By: I_like_pie Re: Trouble with return and $result - 26/01/05 07:54 PM
ah, that explains it.

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