Hamilton LaboratoriesHamilton C shell 2012User guideLanguage reference

foreach, for, while and repeat

Oregon Coast

foreach, for, while and repeat
Previous | Next

Topics

Syntax
Usage
See also

Syntax

foreach name ( wordlist ) statement_list end for name = expr [ to expr ] [ by expr ] do statement_list end while ( expr ) statement_list end repeat number statement repeat statement_list until ( expr )

Usage

The foreach statement allows iteration over a list of words, often specified by wildcarding. Each time through the loop, the control variable name is given the value of the next word in the list.

The for statement offers the more conventional numeric iteration. Multiple iteration ranges, separated by commas, can be specified on the for statement.

The while statement iterates so long as expr continues to evaluate as true.

The repeat statement has two variations. The first provides for the iteration of a single statement an integer number of times. The second form iterates until expr evaluates as true.

See also

Statement relationships
Expression operators
Wildcard characters
Tutorial: foreach, for, while and repeat
Tutorial: Programming constructs
Tutorial: Expressions
Tutorial: Wildcarding

Previous | Next

Getting started with Hamilton C shell

Hamilton C shell, as it first wakes up.

Getting started with Hamilton C shell

A first few commands.

You can set the screen colors to your taste.

You can set the screen colors to your taste.