Difference between revisions of "$true"

From Scriptwiki
Jump to: navigation, search
 
(tweak)
Line 7: Line 7:
 
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 == 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 < 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.
  
 
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).
 
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) { do_this }
 
  if ($away) { do_this }
 
  if ($away == $true) { do_this }
 
  if ($away == $true) { do_this }
  
 
[[Category:Other Identifiers]]
 
[[Category:Other Identifiers]]

Revision as of 13:47, 10 November 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.

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 }