5: BASIC Stamp Command Reference – FOR…NEXT
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 117
FOR…NEXT
BS1 BS2 BS2e BS2sx BS2p
FOR
Counter
=
StartValue
TO
EndValue
{STEP {-}
StepValue
} … NEXT {
Counter
}
FOR
Counter
=
StartValue
TO
EndValue
{STEP
StepValue
} … NEXT
Function
Create a repeating loop that executes the program lines between FOR and
NEXT, incrementing or decrementing Counter according to StepValue until
the value of the Counter variable passes the EndValue.
•
Counter
is a variable (usually a byte or a word) used as a counter.
•
StartValue
is a variable/constant/expression (0 – 65535) that
specifies the initial value of the variable (Counter).
•
EndValue
is a variable/constant/expression (0 – 65535) that specifies
the end value of the variable (Counter). When the value of Counter is
outside of the range StartValue to EndValue, the FOR...NEXT loop
stops executing and the program goes on to the instruction after
NEXT.
•
StepValue
is an optional variable/constant/expression (0 – 65535) by
which the Counter increases or decreases with each iteration through
the FOR…NEXT loop. On the BS1, use a minus sign (-) in front of
the StepValue to indicate a negative step. On all other BASIC
Stamps, if StartValue is larger than EndValue, PBASIC understands
StepValue to be negative, even though no minus sign is used.
Quick Facts
BS1
BS2, BS2e, BS2sx and BS2p
Max. nested
commands
8
16
To decrement
counter
variable
Set StartValue > EndValue
and enter negative
StepValue*
Set StartValue > EndValue
Counter
comparison
Exit loop if Counter exceeds
EndValue
Exit loop if Counter outside of range set by
StartValue to EndValue
* Direction (ie: increment/decrement) cannot be changed at runtime.
1
2
e
2
sx
2
p
2
1
NOTE: Expressions are not
allowed as arguments on the BS1.
1
NOTE: Use a minus sign to
indicate negative StepValues on the
BS1.
Table 5.11: FOR…NEXT Quick
Facts.
Содержание BASIC Stamp 2e
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...