-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.html
More file actions
552 lines (515 loc) · 23.6 KB
/
Copy pathindex.html
File metadata and controls
552 lines (515 loc) · 23.6 KB
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-3T65RS9DSM"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-3T65RS9DSM');
</script>
<!-- Primary Meta Tags -->
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Spindle Documentation - Complete AP CSP Language Guide | Variables, Loops, Functions</title>
<meta name="description" content="Master Spindle programming language with our comprehensive documentation. Learn variables, loops, functions, built-in commands, and robot programming for AP CSP exam success. Interactive examples included." />
<meta name="keywords" content="Spindle documentation, Spindle programming language, AP CSP language guide, Spindle variables, Spindle loops, Spindle functions, Spindle built-in functions, robot programming, AP CSP exam prep, pseudocode tutorial" />
<link rel="canonical" href="https://spdl.netlify.app/docs/" />
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website" />
<meta property="og:url" content="https://spdl.netlify.app/docs/" />
<meta property="og:title" content="Spindle Documentation - Complete AP CSP Language Guide" />
<meta property="og:description" content="Master Spindle programming language with our comprehensive documentation. Learn variables, loops, functions, and robot programming for AP CSP exam success." />
<meta property="og:image" content="https://spdl.netlify.app/android-chrome-512x512.png" />
<meta property="og:site_name" content="Spindle" />
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content="https://spdl.netlify.app/docs/" />
<meta property="twitter:title" content="Spindle Documentation - Complete AP CSP Language Guide" />
<meta property="twitter:description" content="Master Spindle programming language with our comprehensive documentation. Learn variables, loops, functions, and robot programming for AP CSP exam success." />
<meta property="twitter:image" content="https://spdl.netlify.app/android-chrome-512x512.png" />
<!-- Structured Data -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "TechArticle",
"headline": "Spindle Documentation - Complete AP CSP Language Guide",
"description": "Master Spindle programming language with our comprehensive documentation. Learn variables, loops, functions, built-in commands, and robot programming for AP CSP exam success.",
"image": "https://spdl.netlify.app/android-chrome-512x512.png",
"author": {
"@type": "Organization",
"name": "Spindle"
},
"publisher": {
"@type": "Organization",
"name": "Spindle",
"logo": {
"@type": "ImageObject",
"url": "https://spdl.netlify.app/android-chrome-512x512.png"
}
},
"datePublished": "2024-01-01",
"dateModified": "2024-12-19",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://spdl.netlify.app/docs/"
},
"about": [
{
"@type": "Thing",
"name": "AP Computer Science Principles"
},
{
"@type": "Thing",
"name": "Programming Language"
},
{
"@type": "Thing",
"name": "Pseudocode"
}
],
"educationalLevel": "High School",
"audience": {
"@type": "EducationalAudience",
"educationalRole": "student"
}
}
</script>
<link
href="https://fonts.googleapis.com/css2?family=Dela+Gothic+One&family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200"
/>
<link rel="stylesheet" href="../../css/modern.css" />
<link rel="stylesheet" href="/Global/style.css" />
<link rel="stylesheet" href="./style.css" />
<link rel="stylesheet" href="../articles/code-container.css" />
<link rel="stylesheet" href="/css/modern.css" />
<script src="../articles/code-container.js" defer></script>
<script src="/Global/navigation.js" defer></script>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
</head>
<body>
<nav id="navBar"></nav>
</div>
<h1 id="welcomeToSpindle">Welcome to ✨ Spindle's User Documentation ✨</h1>
<p>
<strong
>The language used in the AP CSP Exam, now a programming
language!</strong
>
</p>
<main>
<div style="background: var(--card-bg); border-radius: var(--border-radius); padding: 1.5rem; margin: 2rem 0;">
<div style="display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem;">
<span class="material-symbols-rounded" style="color: var(--accent-blue);">tips_and_updates</span>
<p style="margin: 0;">
<strong>Pro Tip:</strong> Spindle's syntax mirrors what you'll see on the AP CSP exam, helping you feel confident on test day.
</p>
</div>
</div>
<h2 id="programmingGuide">Programming Guide</h2>
<div class="guide-content">
<h3 id="variables" style="display: flex; align-items: center; gap: 0.5rem;">
<span class="material-symbols-rounded" style="color: var(--accent-blue);">data_object</span>
Variables
</h3>
<p>
Varibles can be assigned a value using "<--" OR
"<-" For example, the following code sets a to 10 and then to
13 (a's value plus 3).
</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">variables.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>a <- 10
a <-- [1,2,3]</code></pre>
</div>
</div>
<p>Varibles can be assigned to other varibles!</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">assignment.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>b <-- a / 2</code></pre>
</div>
</div>
<p>
If you added this line to the lines above, it would set b to a's value
divided by 2, resulting in 6.5
</p>
</div>
<h3 id="operators" style="display: flex; align-items: center; gap: 0.5rem; margin-top: 3rem;">
<span class="material-symbols-rounded" style="color: var(--accent-blue);">code</span>
Logical Operators
</h3>
<div class="card" style="margin: 1rem 0;">
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem;">
<div class="card" style="background: var(--code-bg);">
<code>NOT</code>
<p style="margin-top: 0.5rem;">Negates the condition</p>
</div>
<div class="card" style="background: var(--code-bg);">
<code>AND</code>
<p style="margin-top: 0.5rem;">Returns TRUE if both conditions are TRUE</p>
</div>
<div class="card" style="background: var(--code-bg);">
<code>OR</code>
<p style="margin-top: 0.5rem;">Returns TRUE if at least one condition is TRUE</p>
</div>
</div>
</div>
<h3 id="comparisonOperators">🆚 Comparison Operators:</h3>
<p>
<b
>In this language: <br />
0 is FALSE <br />
1 is TRUE
</b>
The supported comparison operators are:
</p>
<ol>
<li>< 4. >=</li>
<li><= 5. ==</li>
<li>> 6. !=</li>
</ol>
<h3 id="ifStatements">❔ If Statements:</h3>
<p>
If Statements can be defined with the keyword IF, and then the expression
that must be true. The code that is to be ran when the the condition is
met must be wrapred in brackets. If the condition for the IF statement is
false, you can write an ELSE statement that will be ran instead
</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">if_statement.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>a <-- 5
IF a==5 {
DISPLAY(1)
} ELSE {
DISPLAY(0)
}</code></pre>
</div>
</div>
<h3 id="loops" style="display: flex; align-items: center; gap: 0.5rem; margin-top: 3rem;">
<span class="material-symbols-rounded" style="color: var(--accent-blue);">loop</span>
Loops
</h3>
<div class="card" style="margin: 1rem 0;">
<h4 style="color: var(--accent-blue); margin-bottom: 1rem;">For Loops (REPEAT TIMES)</h4>
<p>
For Loops are defined by the keyword REPEAT, followed by the number of
times you want it to repeat, the keyword TIMES, and finally the code you
want to be repeated.
</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">for_loop.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>a <-- 5
REPEAT 10 TIMES {
a <-- a + 1
}
DISPLAY(a) # Output: 15</code></pre>
</div>
</div>
</div>
<div class="card" style="margin: 1rem 0;">
<h4 style="color: var(--accent-blue); margin-bottom: 1rem;">While Loops (REPEAT UNTIL)</h4>
<p>
While loops use REPEAT UNTIL, followed by a condition in parentheses,
and the code block in curly braces. The loop continues until the condition becomes true.
</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">while_loop.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>a <-- 10
REPEAT UNTIL (a > 30) {
a <-- a + 4
} # Final value: 34</code></pre>
</div>
</div>
</div>
<h3 id="functions" style="display: flex; align-items: center; gap: 0.5rem; margin-top: 3rem;">
<span class="material-symbols-rounded" style="color: var(--accent-blue);">function</span>
Functions
</h3>
<div class="card" style="margin: 1rem 0;">
<h4 style="color: var(--accent-blue); margin-bottom: 1rem;">Procedures (Functions)</h4>
<p>
Functions are defined using the keyword 'PROCEDURE', followed by the
function name and arguments in parentheses, with the code block in curly braces.
</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">function.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>PROCEDURE SAY_HI(excitement) {
REPEAT excitement TIMES {
DISPLAY("Hi!")
}
}
SAY_HI(3) # Outputs: Hi! Hi! Hi!</code></pre>
</div>
</div>
</div>
<!-- Built-in Functions Section -->
<div class="card" style="margin: 2rem 0;">
<h4 style="color: var(--accent-blue); margin-bottom: 1rem;">Built-in Functions</h4>
<div class="code-container">
<div class="code-header">
<span class="code-filename">display.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>DISPLAY(value)</code></pre>
</div>
</div>
<p><b>DISPLAY(value):</b> Outputs the value to the console. You can display numbers, strings, lists, or the result of an expression.</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">input.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>INPUT()</code></pre>
</div>
</div>
<p><b>INPUT():</b> Prompts the user for input and returns the value entered. Useful for interactive programs.</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">is_num.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>IS_NUM(value)</code></pre>
</div>
</div>
<p><b>IS_NUM(value):</b> Returns 1 if the value is a number, 0 otherwise. Useful for checking data types before performing calculations.</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">is_str.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>IS_STR(value)</code></pre>
</div>
</div>
<p><b>IS_STR(value):</b> Returns 1 if the value is a string, 0 otherwise. Use this to check if a variable contains text.</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">is_list.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>IS_LIST(value)</code></pre>
</div>
</div>
<p><b>IS_LIST(value):</b> Returns 1 if the value is a list, 0 otherwise. Use this to check if a variable contains a list/array.</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">is_function.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>IS_FUNCTION(value)</code></pre>
</div>
</div>
<p><b>IS_FUNCTION(value):</b> Returns 1 if the value is a function/procedure, 0 otherwise. Useful for advanced programming and debugging.</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">append.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>APPEND(list, value)</code></pre>
</div>
</div>
<p><b>APPEND(list, value):</b> Adds the value to the end of the list. Use this to grow a list dynamically.</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">pop.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>POP(list, index)</code></pre>
</div>
</div>
<p><b>POP(list, index):</b> Removes and returns the element at the specified index from the list. Indexing starts at 1.</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">extend.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>EXTEND(listA, listB)</code></pre>
</div>
</div>
<p><b>EXTEND(listA, listB):</b> Adds all elements from listB to the end of listA. Useful for combining lists.</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">length.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>LENGTH(list)</code></pre>
</div>
</div>
<p><b>LENGTH(list):</b> Returns the number of elements in the list. Note: List indexing starts at 1, following College Board conventions.</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">clear.spdl</span>
<button class="run-button" disabled title="Only available in Native IDE">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>CLEAR()</code></pre>
</div>
</div>
<p><b>CLEAR():</b> Clears the console. <b>Note:</b> This function is only available in the Native IDE.</p>
<div class="code-container">
<div class="code-header">
<span class="code-filename">run.spdl</span>
<button class="run-button" disabled title="Only available in Native IDE">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code>RUN("filename")</code></pre>
</div>
</div>
<p><b>RUN("filename"):</b> Runs another Spindle file by filename. <b>Note:</b> This function is only available in the Native IDE.</p>
</div>
<!-- Robot IDE Built-in Functions Section -->
<div class="card" style="margin: 2rem 0;">
<h4 style="color: var(--accent-blue); margin-bottom: 1rem;">Robot IDE Built-in Functions</h4>
<ul style="list-style: none; padding: 0;">
<li style="margin-bottom: 0.5rem;"><code>MOVE_FORWARD()</code>: Moves the robot forward by one space</li>
<li style="margin-bottom: 0.5rem;"><code>ROTATE_LEFT()</code>: Rotates the robot 90 degrees to the left</li>
<li style="margin-bottom: 0.5rem;"><code>ROTATE_RIGHT()</code>: Rotates the robot 90 degrees to the right</li>
<li style="margin-bottom: 0.5rem;"><code>CAN_MOVE(direction)</code>: Returns 1 if the robot can move in the specified direction, 0 otherwise</li>
</ul>
<div class="code-container">
<div class="code-header">
<span class="code-filename">robot_example.spdl</span>
<button class="run-button" onclick="runCode(this.nextElementSibling.querySelector('code'))">
<span class="material-symbols-rounded" style="font-size: 1rem;">play_arrow</span>
Run
</button>
</div>
<div class="code-content">
<pre><code># Example: Move forward if possible, then turn left
IF CAN_MOVE("NORTH") {
MOVE_FORWARD()
}
ROTATE_LEFT()
MOVE_FORWARD()</code></pre>
</div>
</div>
</div>
</p>
<h2 id="resources" style="display: flex; align-items: center; gap: 0.5rem; margin-top: 3rem;">
<span class="material-symbols-rounded" style="color: var(--accent-blue);">library_books</span>
Additional Resources
</h2>
<div class="card" style="margin: 2rem 0;">
<div style="display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem;">
<span class="material-symbols-rounded" style="color: var(--accent-blue);">description</span>
<div>
<h4 style="margin-bottom: 0.5rem;">AP CSP Exam Reference Sheet</h4>
<a href="https://apcentral.collegeboard.org/media/pdf/ap-computer-science-principles-exam-reference-sheet.pdf"
style="color: var(--accent-blue); text-decoration: none;">
Download PDF
</a>
</div>
</div>
<div style="display: flex; align-items: center; gap: 1rem;">
<span class="material-symbols-rounded" style="color: var(--accent-blue);">play_circle</span>
<div>
<h4 style="margin-bottom: 0.5rem;">Video Tutorial by CodePulse</h4>
<a href="https://youtu.be/Eythq9848Fg?si=yDuSPkEzG2y1X1cm"
style="color: var(--accent-blue); text-decoration: none;">
Watch on YouTube
</a>
</div>
</div>
</div>
</div> <!-- Close guide-content -->
</div> <!-- Close content-section -->
</main>
</body>
</html>