File: Treating_Variables_as_Booleans.html

package info (click to toggle)
sludge 2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,820 kB
  • sloc: cpp: 31,960; sh: 1,037; xml: 874; makefile: 672
file content (110 lines) | stat: -rwxr-xr-x 1,621 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<TITLE>Treating Variables as Booleans</TITLE>
  <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<BODY>
<HR>
<div align="center"><img id="headerGraphic" src="images/sludge300.png" alt="SLUDGE"/></div>
<h2>Treating Variables as Booleans</h2>
<HR>


<P>
You can treat all variables as boolean values... that is, you can say:
</P>

<P>
<pre>if (myVariable)</pre>
</P>

<P>
...no matter what data type is actually in the variable. Here's how they're all treated.
</P>

<P>
<B>Undefined:</B>
</P>

<P>
Always equates to FALSE..
</P>

<P>
<B>Numbers:</B>
</P>

<P>
Equates to FALSE if it contains the value 0; TRUE for everything else.
</P>

<P>
<B>Strings:</B>
</P>

<P>
Always equates to TRUE.
</P>

<P>
<B>File handles:</B>
</P>

<P>
Always equates to TRUE.
</P>

<P>
<B>Object types:</B>
</P>

<P>
Always equates to TRUE.
</P>

<P>
<B>Stacks:</B>
</P>

<P>
Equates to FALSE if the stack is empty; TRUE for everything else.
</P>

<P>
<B>Function handles:</B>
</P>

<P>
Always equates to TRUE.
</P>

<P>
<B>Animations:</B>
</P>

<P>
Always equates to TRUE.
</P>

<P>
<B>Costumes:</B>
</P>

<P>
Always equates to TRUE.
</P>


<H3>See also:</H3>

<P>
<a href="Variable_Operations.html">Variable Operations</a>
</P>

<P class="copyright-notice">SLUDGE and this SLUDGE documentation are <A HREF="Copyright.html">copyright</A> Hungry Software and contributors 2000-2012
</P>

<HR>
</BODY>
</html>