-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfor-stmt.html
More file actions
69 lines (67 loc) · 3.25 KB
/
for-stmt.html
File metadata and controls
69 lines (67 loc) · 3.25 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>FOR Statement - SQL Notebook</title>
<link rel="stylesheet" href="sqlnotebook.css">
</head>
<body>
<header>
<table class="nav">
<tr>
<td>
<a href="index.html"><img src="art/SqlNotebookIcon.png" alt="SQL Notebook (logo)" style="width: 58px; height: 58px; float: left; margin-right: 20px;"></a>
</td>
<td>
<a href="index.html" id="title">SQL Notebook</a><br>
<nav>
<ul class="nav">
<li><a href="https://github.com/brianluft/sqlnotebook/releases">Download</a></li>
<li><a href="doc.html"><span id="header-doc-long">Documentation</span><span id="header-doc-short">Docs</span></a></li>
<li><a href="https://github.com/brianluft/sqlnotebook">GitHub</a></li>
</ul>
</nav>
</td>
</tr>
</table>
<hr style="margin-top: 15px; margin-bottom: 15px;">
</header>
<article><div id="article">
<h1><code>FOR</code> Statement</h1>Executes the provided statements while incrementing or decrementing a counter
variable at each iteration.<br>
<br>
The loop may be terminated without regard to the counter by using the <a href=
"break-stmt.html"><code>BREAK</code></a> statement. The current iteration of the loop can be abandoned and the next
iteration of the loop started by using the <a href="continue-stmt.html"><code>CONTINUE</code></a> statement.
<h2>Syntax</h2><img src="art/for-stmt-syntax.svg" alt="" class="railroad" moz-do-not-send="true" width="666" height=
"243"><br>
<h2>Parameters</h2>
<ul class="args">
<li><i>variable-name</i>: variable name<br>
The name of the counter variable. The variable name must begin with an at sign (<code>@</code>), dollar sign
(<code>$</code>), or colon (<code>:</code>). The variable need not be previously declared; the <code>FOR</code>
statement acts as a variable declaration if needed. This variable will receive an integer value that changes with
each iteration of the loop.</li>
<li><i>first-number</i>: integer<br>
The value of the counter variable on the first iteration of the loop.</li>
<li><i>last-number</i>: integer<br>
The loop stops if the counter steps past this value.</li>
<li><i>step</i>: integer (optional)<br>
The number to add to the counter variable on each iteration. If <span style=
"font-style: italic;">first-number</span> ≤ <span style="font-style: italic;">last-number</span> then the default
step is 1, otherwise the default step is -1.</li>
<li><i>statement</i>: statement<br>
The statements to execute on each iteration of the loop. If more than one <span style=
"font-style: italic;">statement</span> is desired, the <code>BEGIN</code> and <code>END</code> keywords must be
used.<br></li>
</ul>
<h2>Example</h2>
<pre><i>-- Prints the numbers: 1, 2, 3, 4, 5.</i><br>FOR @i = 1 TO 5<br> PRINT @i;<br><br><i>-- Prints the numbers: 5, 4, 3, 2, 1.</i><br>FOR @i = 5 TO 1<br> PRINT @i;<br><br><i>-- Prints the numbers: 1, 3, 5, 9.</i><br>FOR @i = 1 TO 10 STEP 2<br> PRINT @i;</pre>
</div></article>
<footer><div id="footer">
<hr>
© 2016-2025 <a href="https://github.com/electroly">Brian Luft</a>
</div></footer>
</body>
</html>