ExamplesLoops
Loops
Counters, totals, countdowns, and repeated input implemented with MiniScript+ loops.
On this page
Loops repeat the same operation while a condition holds or across a known interval.
Count upward
counter.msp
counter = 0WHILE counter < 5 PRINT counter counter = counter + 1ENDSum from 1 to N
sum.msp
n = 5total = 0FOR value = 1 TO n total = total + valueENDPRINT totalCountdown
countdown.msp
counter = 5WHILE counter >= 0 PRINT counter counter = counter - 1ENDProcess repeated input
three-values.msp
total = 0FOR index = 1 TO 3 INPUT value total = total + valueENDPRINT totalEvery
WHILEloop must make progress toward a false condition. Otherwise it will run indefinitely.