$istok

From Scriptwiki
Jump to: navigation, search

Returns $true if token exists, otherwise returns $false.

$istok(text, token, C)

Text is the string where we are looking for the match token. C stands for ascii value of character that is used as delimiter.

Note: $istokcs() is the case-sensitive version.

Ascii value for dot is 46. String where from we are looking is a.b.c.d and we're looking for token b.

$istok(a.b.c.d, b, 46)  ;returns $true

Note that if we'll search the same match from the string a.b c.d with same parameters, $istok(a.b c.d, b, 46) returns $false because now b belongs to token a.b.

text can be anything, figurative constant, $1- or any parameters, or variables.

If you would like to check if you're name is in text the user typed. As separator we use space. Ascii value for it is 32.

on *:text:#help.script:{
  if ($istok($1-, $me, 32)) {
    beep
    notice $me Nick $nick just said your name at $chan
  }
}

See Also

  • $asc to get character's ascii value.
  • If-Then-Else for more information about if-statements.