Difference between revisions of "$true"

From Scriptwiki
Jump to: navigation, search
m (added examples-section due to pressure caused by Z)
(Added an example)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This identifier is the opposite of $false, which are both the result of an [[if|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'.
+
This identifier is the opposite of $false, which are both the result of an [[If-Then-Else|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
 
  $true or $false
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-Then-Else#|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.
  
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).
+
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) { do_this }
 
  if ($away) { do_this }
 
  if ($away == $true) { 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 }
 +
  [[If-Then-Else#|else]] { [[return]] $false }
 +
}
 +
 +
if ($IsMorning) { [[notice]] [[$chan]] It's Morning!!!! }
 
[[Category:Other Identifiers]]
 
[[Category:Other Identifiers]]

Latest revision as of 10:53, 5 December 2005

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!!!! }