Difference between revisions of "$true"

From Scriptwiki
Jump to: navigation, search
m (fixed commenting syntax)
m (just added some if-then-else operator references)
Line 9: Line 9:
 
Every if-statement is either $true or $false, depending on whether the statement is true or not. So, for example:
 
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 (a [[If-Then-Else#.3D.3D|==]] 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 (3 [[If-Then-Else#.3C|<]] 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.
 
  if ($true) { bluh }  ;in this case, 'bluh' gets executed as $true is always true.
  

Revision as of 03:54, 5 December 2005

This identifier is the opposite of $false, which are both the result of an If-Then-Else-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.

Quite many 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 }