Specifications

BASIC Stamp II
Parallax, Inc. • BASIC Stamp Programming Manual 1.8 • Page 263
2
capacity of a 16-bit number. When the value rolls over to 464, it passes
the test “Is w1 > 65500?” used by Next to determine when to end the
loop.
Demo Program
Here’s an example that uses a For...Next loop to churn out a series of
sequential squares (numbers 1, 2, 3, 4... raised to the second power) by
using a variable to set the For...Next stepVal, and incrementing stepVal
within the loop. Sir Isaac Newton is generally credited with the discov-
ery of this technique.
square var byte ' For/Next counter and series of squares.
stepSize var byte ' Step size, which will increase by 2 each
loop.
stepSize = 1: square = 1
for square = 1 to 250 step stepSize ' Show squares up to 250.
debug dec ? square ' Display on screen.
stepSize = stepSize +2 ' Add 2 to stepSize
next ' Loop til square > 250.