forked from mit-cml/appinventor-sources
/
logic.html
305 lines (277 loc) · 14.6 KB
/
logic.html
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="/static/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="/static/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
<link href="/static/css/fonts.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/static/css/mit_app_inventor.css">
<script type="text/javascript">
<!--//--><![CDATA[// ><!--
var gotoappinventor = function() {
var referrer = document.location.pathname;
var patt = /.*hour-of-code.*/;
if (referrer.match(patt)) {
window.open("http://code.appinventor.mit.edu/", "new");
} else {
window.open("http://ai2.appinventor.mit.edu/", "new");
}
}
//--><!]]>
</script>
<title>MIT App Inventor Logic Blocks</title></head>
<body class="mit_app_inventor"><nav class="navbar navbar-expand-xl navbar-light">
<a class="navbar-brand" href="http://appinventor.mit.edu/">
<img src="/static/images/logo2.png" alt="Logo">
</a>
<button type="button" class="btn create-btn" style="margin-right: 20px;" onclick="gotoappinventor();">Create Apps!</button>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarContent"
aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle Navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarContent">
<ul class="navbar-nav" style="margin-left: auto;">
<li class="nav-item dropdown">
<a class="nav-link" href="http://appinventor.mit.edu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
About
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="http://appinventor.mit.edu/about-us">About App Inventor</a>
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/our-team">Our Team</a>
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/master-trainers">Master Trainers</a>
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/app-month-gallery">App of the Month</a>
<a class="dropdown-item"
href="http://appinventor.mit.edu/ai2/ReleaseNotes">Release Notes</a>
<a class="dropdown-item" href="http://appinventor.mit.edu/about/termsofservice" target="_blank">Terms of Service</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="http://appinventor.mit.edu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Educators
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/teach" target="_blank">Teach</a>
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/ai2/tutorials">Tutorials</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="http://appinventor.mit.edu/news" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
News
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/news">In the news</a>
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/events">Events</a>
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/stories">Stories from the field</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="http://appinventor.mit.edu/explore/resources" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Resources
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/get-started">Get Started</a>
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/library">Documentation</a>
<a class="dropdown-item" href="https://community.appinventor.mit.edu"
target="_blank">Forums</a>
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/ai2/tutorials">Tutorials</a>
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/books">App Inventor Books</a>
<a class="dropdown-item"
href="https://github.com/mit-cml/appinventor-sources"
target="_blank">Open Source Information</a>
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/research">Research</a>
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/hour-of-code">Hour of Code</a>
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/resources">Additional Resources</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="http://appinventor.mit.edu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Blogs
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="http://appinventor.mit.edu/explore/blog">App Inventor Blog</a>
</div>
</li>
</ul>
<div style="display: inline-flex;margin-left:auto;margin-right:0">
<a href="https://giving.mit.edu/give/to?fundId=3832320" target="_blank">
<button type="button" class="btn donate-btn" style="margin-right: 20px;">Donate</button></a>
<script>
(function() {
var cx = '005719495929270354943:tlvxrelje-e';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:searchbox-only></gcse:searchbox-only>
</div>
<!-- <form class="form-inline" action="/action_page.php">
<div class="form-group has-search">
<span class="fa fa-search form-control-feedback"></span>
<input type="text" class="form-control" placeholder="Search">
</div>
</form> -->
</div>
</nav>
<div class="default-page">
<div class="header">
<h1 class="font-weight-bold text-center offset-xl-2 col-xl-8">MIT App Inventor Logic Blocks</h1>
</div>
<div class="container-fluid">
<article class="documentation">
<ul>
<li><a href="#true">true</a></li>
<li><a href="#false">false</a></li>
<li><a href="#not">not</a></li>
<li><a href="#=">=</a></li>
<li><a href="#not=">≠</a></li>
<li><a href="#and">and</a></li>
<li><a href="#or">or</a></li>
</ul>
<h3 id="true">true</h3>
<p><img src="images/logic/true.png" alt="" /></p>
<p>Represents the constant value true. Use it for setting boolean property values of components, or as the value of a variable that represents a condition.</p>
<h3 id="false">false</h3>
<p><img src="images/logic/false.png" alt="" /></p>
<p>Represents the constant value false. Use it for setting boolean property values of components, or as the value of a variable that represents a condition.</p>
<h3 id="not">not</h3>
<p><img src="images/logic/not.png" alt="" /></p>
<p>Performs logical negation, returning false if the input is true, and true if the input is false.</p>
<h3 id="---">= {#=}</h3>
<p><img src="images/logic/equals.png" alt="" /></p>
<p>Tests whether its arguments are equal.</p>
<ul>
<li>Two numbers are equal if they are numerically equal, for example, 1 is equal to 1.0.</li>
<li>Two text blocks are equal if they have the same characters in the same order, with the same case. For example, banana is not equal to Banana.</li>
<li>Numbers and text are equal if the number is numerically equal to a number that would be printed with that text. For example, 12.0 is equal to the result of joining the first character of 1A to the last character of Teafor2.</li>
<li>Two lists are equal if they have the same number of elements and the corresponding elements are equal.</li>
</ul>
<p>Acts exactly the same as the = block found in Math</p>
<h3 id="---not">≠ {#not=}</h3>
<p><img src="images/logic/notequals.png" alt="" /></p>
<p>Tests to see whether two arguments are not equal.</p>
<h3 id="and">and</h3>
<p><img src="images/logic/and.png" alt="" height="36" /></p>
<p>Tests whether all of a set of logical conditions are true. The result is true if and only if all the tested conditions are true. The number of tests can be expanded using the <a href="../concepts/mutators.html">mutator</a>. The conditions are tested left to right, and the testing stops as soon as one of the conditions is false. If there are no conditions to test, then the result is true. You can consider this to be a logician’s joke.</p>
<h3 id="or">or</h3>
<p><img src="images/logic/or.png" alt="" height="36" /></p>
<p>Tests whether any of a set of logical conditions are true. The result is true if one or more of the tested conditions are true. The number of tests can be expanded using the <a href="../concepts/mutators.html">mutator</a>. The conditions are tested left to right, and the testing stops as soon as one of the conditions is true. If there are no conditions to test, then the result is false.</p>
</article>
<script>
// Handle redirection to documentation based on locale query parameter (if specified)
(function() {
var locale = window.location.search.match('[&?]locale=([a-zA-Z-]*)');
if (locale) {
if (locale[1].indexOf('en') === 0) {
// English needs to stay at the top level to not break existing links
var page = window.location.pathname.split('/');
if (page.length === 5) {
page.splice(2, 1);
} else {
// already on english
return;
}
window.location.href = page.join('/');
} else {
var page = window.location.pathname.split('/');
if (page.length === 4) {
page.splice(2, 0, locale[1]);
} else if (page[2].toLowerCase() != locale[1].toLowerCase()) {
page[2] = locale[1];
} else {
return; // already on the desired language
}
// Test that the page exists before redirecting.
var xhr = new XMLHttpRequest();
xhr.open('HEAD', page.join('/'), false);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if ((xhr.status == 200 || xhr.status == 204)) {
window.location.href = page.join('/');
} else if (xhr.status >= 400) {
page.splice(2, 1); // go to english version
window.location.href = page.join('/');
}
}
};
xhr.send();
}
}
})();
// Handle embedded documentation in help by removing website template
if (window.self !== window.top) {
setTimeout(function() {
var videos = document.querySelectorAll('video');
for (var i = 0; i < videos.length; i++) {
if (parseInt(videos[i].getAttribute('width')) > 360) {
var aspect = parseInt(videos[i].getAttribute('height')) / parseInt(videos[i].getAttribute('width'));
videos[i].setAttribute('width', '360');
videos[i].setAttribute('height', '' + (360 * aspect));
}
}
var h1 = document.querySelector('h1');
var article = document.querySelector('article');
article.insertBefore(h1, article.firstElementChild);
document.body.innerHTML = article.outerHTML;
});
}
</script>
</div>
<div class="footer background-green">
<div class="row container">
<div class="col-xl-3">
<h3>MIT App Inventor</h3>
<!-- <form class="form-inline" action="/action_page.php">
<div class="form-group has-search">
<span class="fa fa-search form-control-feedback"></span>
<input type="text" class="form-control" placeholder="Search">
</div>
</form> -->
</div>
<div class="col-xl-6 legal text-center">
<ul>
<li>
<a href="http://web.mit.edu" class="btn btn-link" role="button"
target="_blank">© 2012-2023 Massachusetts Institute of Technology</a>
</li>
<li>
<a href="http://creativecommons.org/licenses/by-sa/3.0/"
target="_blank" class="btn btn-link" role="button">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0</a>
</li>
<li>
<a href="http://appinventor.mit.edu/about/termsofservice"
target="_blank" class="btn btn-link" role="button">Terms of Service and Privacy Policy</a>
</li>
</ul>
</div>
<div class="col-xl-3 links">
<a href="https://community.appinventor.mit.edu" target="_blank">Support / Help</a><br>
<a href="mailto:appinventor@mit.edu">Other Inquiries</a>
<div>
<span>Twitter:</span>
<a href="https://twitter.com/mitappinventor"
target="_blank" class="btn btn-link" role="button">@MITAppInventor</a>
<div>
<div>
<span>GitHub:</span>
<a href="https://github.com/mit-cml" class="btn btn-link" role="button"
target="_blank">mit-cml</a>
<div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="/static/js/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="/static/js/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="/static/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script async src="/static/js/widgets.js" charset="utf-8"></script>
</div>
</body>
</html>