$true

From Scriptwiki
Jump to: navigation, search

This identifier is the opposite of $false, which are both the result of an if-statement and returned by some other identifiers and are both explained in this article. These two identifiers are rarely actually written in a mirc script, but they are always 'working behind the scenes'.

$true or $false

To understand the essence of these identifiers, you should first read about if-statements.

Examples

Every if-statement is either $true or $false, depending on whether the statement is true or not. So, for example:

if (a == b) { blah }  ;in this case, 'blah' doesn't get executed because the if-statement is $false
if (3 < 7) { bleh }  ;in this case, 'bleh' gets executed because the if-statement is $true
if ($true) { bluh }  ;in this case, 'bluh' gets executed as $true is always true.

Alot of identifiers are used just to check whether something is true or not, for example $islower and $away. And to check that, there's an if-sentence even if it doesn't always look much like it. So actually, the following three lines are exactly the same, but the first one is just a 'shortcut' (and should actually never be used, the middle one is the preferred syntax).

if $away do_this 
if ($away) { do_this }
if ($away == $true) { do_this }


Below is an example how you can create your own $true/$false identifier.

alias IsMorning {
  if ($asctime(H) < 12) { return $true }
  else { return $false }
}

if ($IsMorning) { notice $chan It's Morning!!!! }