-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path1421.html
More file actions
182 lines (182 loc) · 12.1 KB
/
Copy path1421.html
File metadata and controls
182 lines (182 loc) · 12.1 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SmallBASIC | STEP</title>
<meta name="description" content="Specifies the loop counter increment in a FOR loop">
<link rel="canonical" href="1421">
<link rel="keywords" href="FOR t = 1 TO 10 STEP 2">
<link rel="stylesheet" href="/css/style.css">
<link rel="icon" type="image/png" href="/images/sb-desktop-32x32.png">
<script src="/clipboard.js"></script>
</head>
<body>
<button onclick="topFunction()" id="BackToTopBtn" title="Go to top">⯅</button>
<script src="/backtotop.js"></script>
<div class="wrapAll clearfix">
<nav class="navigation">
<div class="logo">
<a href="/"><img src='/images/sb-logo.png?v=2' alt="logo"></a>
</div>
<div class="navlinks">
<a href="/pages/download.html">Download</a>
<a href="/pages/news.html">News</a>
<a href="/pages/community.html">Community</a>
<a href="/pages/articles.html">Resources</a>
<a class='active' href="/pages/reference.html">Language Reference</a>
<a href="/pages/guide.html">SmallBASIC Manual</a>
</div>
</nav>
<div class="mainsection">
<div class="tabs clearfix">
<div class="tabsRight">
<a target="_github" href="https://github.com/smallbasic/smallbasic.github.io/blob/master/_build/reference/1421-language-step.markdown">Edit</a>
<a target="_github" href="https://github.com/smallbasic/smallbasic.github.io/commits/master/_build/reference/1421-language-step.markdown">History</a>
</div>
</div>
<div class="article">
<h1>STEP</h1>
<blockquote>FOR i = a TO b STEP s</blockquote>
<div class="siteSub">
<p>
<a href="/">Home</a> >
<a href="/pages/reference.html">Reference</a> >
<a href="/pages/language.html">Language</a>
</p>
</div>
<p>Specifies the loop counter increment <code>s</code> in a FOR loop.
The variable <code>i</code> will be increased in every loop by amount
<code>s</code>. <code>s</code> can be a positive or negative number.</p>
<p>See FOR for more information.</p>
<h3 id="example-1-positive-step">Example 1: Positive step</h3>
<div class="sourceCode" id="cb1"><pre
class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="kw">for </span>t = <span class="dv">1</span> <span class="kw">to</span> <span class="dv">10</span> step <span class="dv">2</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> <span class="kw">print</span> t</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="kw">next</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="co">' Output: 1 3 5 7 9</span></span></code></pre></div>
<h3 id="example-2-negative-step">Example 2: Negative step</h3>
<div class="sourceCode" id="cb2"><pre
class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="kw">for </span>t = <span class="dv">10</span> <span class="kw">to</span> <span class="dv">1</span> step -<span class="dv">2</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="kw">print</span> t</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="kw">next</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="co">' Output: 10 8 6 4 2</span></span></code></pre></div>
<div class="lavenderBox">
<div class="header">Code samples using STEP</div>
<div class="linklist">
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/getting started/004 loops.bas">004 loops.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 3/2048.bas">2048.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Misc Bpf/3d block lettes.bas">3d block lettes.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 1/3d_palmx.bas">3d_palmx.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 1/3d_torus.bas">3d_torus.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/3dtictac.bas">3dtictac.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 2/3dtorus.bas">3dtorus.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 3/3dttt.bas">3dttt.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/mobile/3dttt.bas">3dttt.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/anball 1.0.bas">anball 1.0.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/mathematics/another look at trig functions.bas">another look at trig functions.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/applications/arc_ui.bas">arc_ui.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 2/autumn scene.bas">autumn scene.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/BestOf Graphics/B+B.bas">B+B.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/mathematics/bairstow.bas">bairstow.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/BestOf Graphics/bb2fork smurf.bas">bb2fork smurf.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/betrayal: crows ii.bas">betrayal: crows ii.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 2/bezier's autograph book.bas">bezier's autograph book.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 1/bezier_pen.bas">bezier_pen.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 1/bezierbounce.bas">bezierbounce.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 1/biorythms.bas">biorythms.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/blackjack.bas">blackjack.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 3/BlackJack.bas">BlackJack.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 2/blushing snowflakes.bas">blushing snowflakes.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 3/bomb.bas">bomb.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/bonkers.bas">bonkers.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 3/bopit.bas">bopit.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/bowling7.bas">bowling7.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Other graphics/bpf1.bas">bpf1.bas </a>
</div>
</div>
<div class="lavenderBox">
<div class="header">Language</div>
<div class="linklist">
<a href="/reference/662.html">AND </a>
<a href="/reference/1424.html">AS </a>
<a href="/reference/663.html">BAND </a>
<a href="/reference/1428.html">BG </a>
<a href="/reference/664.html">BOR </a>
<a href="/reference/639.html">BYREF </a>
<a href="/reference/637.html">CALL </a>
<a href="/reference/640.html">CASE </a>
<a href="/reference/1426.html">CATCH </a>
<a href="/reference/678.html">CONST </a>
<a href="/reference/1419.html">DECLARE </a>
<a href="/reference/641.html">DEF </a>
<a href="/reference/642.html">DO </a>
<a href="/reference/643.html">ELIF </a>
<a href="/reference/644.html">ELSE </a>
<a href="/reference/645.html">ELSEIF </a>
<a href="/reference/679.html">END </a>
<a href="/reference/1427.html">END TRY </a>
<a href="/reference/646.html">ENDIF </a>
<a href="/reference/665.html">EQV </a>
<a href="/reference/648.html">EXIT </a>
<a href="/reference/1457.html">FALSE </a>
<a href="/reference/650.html">FI </a>
<a href="/reference/680.html">FOR </a>
<a href="/reference/651.html">FUNC </a>
<a href="/reference/681.html">GOSUB </a>
<a href="/reference/682.html">GOTO </a>
<a href="/reference/683.html">IF </a>
<a href="/reference/638.html">IFF </a>
<a href="/reference/666.html">IMP </a>
<a href="/reference/667.html">IN </a>
<a href="/reference/684.html">LABEL </a>
<a href="/reference/685.html">LET </a>
<a href="/reference/668.html">LIKE </a>
<a href="/reference/653.html">LOCAL </a>
<a href="/reference/1496.html">LSHIFT </a>
<a href="/reference/669.html">MDL </a>
<a href="/reference/670.html">MOD </a>
<a href="/reference/671.html">NAND </a>
<a href="/reference/654.html">NEXT </a>
<a href="/reference/672.html">NOR </a>
<a href="/reference/673.html">NOT </a>
<a href="/reference/686.html">ON </a>
<a href="/reference/674.html">OR </a>
<a href="/reference/688.html">REM </a>
<a href="/reference/689.html">REPEAT </a>
<a href="/reference/690.html">RETURN </a>
<a href="/reference/1497.html">RSHIFT </a>
<a href="/reference/655.html">SELECT </a>
<a href="/reference/1421.html"><strong>STEP</strong> </a>
<a href="/reference/656.html">STOP </a>
<a href="/reference/657.html">SUB </a>
<a href="/reference/658.html">THEN </a>
<a href="/reference/1437.html">THROW </a>
<a href="/reference/1420.html">TO </a>
<a href="/reference/1455.html">TRUE </a>
<a href="/reference/1425.html">TRY </a>
<a href="/reference/660.html">UNTIL </a>
<a href="/reference/661.html">USE </a>
<a href="/reference/1423.html">USG </a>
<a href="/reference/1422.html">USING </a>
<a href="/reference/691.html">WEND </a>
<a href="/reference/692.html">WHILE </a>
<a href="/reference/675.html">XNOR </a>
<a href="/reference/676.html">XOR </a>
</div>
</div>
</div>
<div class="pagefooter">
This page was last edited on Tue, 15 Aug 2023 11:33:09 +0200
|
<a href="https://en.wikipedia.org/wiki/Markdown" target="_blank" rel="nofollow">Markdown</a>
processed with
<a href="https://pandoc.org/MANUAL.html#pandocs-markdown" target="_blank" rel="nofollow">pandoc 3.1.12.1</a>
</div>
</div>
</div>
</body>
</html>