# !while(4)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

!while, !continue, !done - Conditional loop

## SYNOPSIS

!while condition

... loop body ...
[!continue]

!done

## DESCRIPTION

The !while directive allows statements only to be executed if a condition specified in the directive is met. Every line following the !while directive, until the first !done directive, is only executed if the expression following the !while directive evaluates to a `TRUE` value.

A !continue may be used in the loop, this immediately returns control to the !while statement and skips the rest of the section.

!while statement may not be nested. That is, only one !while statement may be outstanding at a time, a !repeat(4) statement may be used within the !while to create an inner loop if required. Alternatively the !goto(4) used in conjunction with the !if(4) statement may be used to construct loops.

## EXAMPLE

For example, the following macro segment fills to the fill column with spaces.

    !while &less $curcol $buffer-fill-col
        insert-string " "
        !if &equal %example "1"     ; Silly to show continue
            !continue               ; Goto !while
        !endif
        ml-write "You wont see me if %example = 1"
    !done

## SEE ALSO

!if(4), !goto(4), !repeat(4).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>