Home
The HyperCard Center
HyperTalk Reference
Home » HyperTalk Reference » repeat for

Note: This is a work in progress and many formatting issues have been fixed. Read more about the project on the home page.

repeat for

repeat [for] posInteger [times]
statements
end repeat

The statements in a repeat for structure repeat for a specified number of times.

If HyperCard executes an exit repeat statement in the loop, it continues running the handler starting from the first statement after end repeat.

If HyperCard executes a next repeat statement, it returns immediately to the beginning of the repeat loop.

Demo Script

on mouseUp
show bkgnd field "demo field"
put return & " The count will stop at 10:" ¬
into bkgnd field "demo field"
put 0 into theCount
put space & space & theCount after bkgnd field "demo field"
repeat for 10 times
add 1 to theCount
put theCount into last word of bkgnd field "demo field"
end repeat
wait 30
hide bkgnd field "demo field"
put empty into bkgnd field "demo field"
end mouseUp

Related Topics

Placeholders

posInteger

An expression that evaluates to a positive integer.

For example:

3
67 mod 13
the number of bg fields
the number of backgrounds
the number of cards div 2

See also: background, bkgnd, button, card, chunk, field, menu, and menuItem

statements

Any return-separated list of built-in commands, user-defined handlers, or keywords that are part of a message or function handler.

put "Hello world" -- built-in command
get total(field 1) -- function call
global HelpInfo -- keyword

HyperTalk Reference

Version 0.8b4 (July 4, 2025)

Made with Macintosh

Switch to Retro View