If, While, Else and Actions

Conditional statements are used to perform different actions for white and black pixels.

Table of Contents
  1. If
    1. If - Definition and Usage
    2. If - Syntax
    3. If - Fields
    4. If - More Examples
  2. While
    1. While - Definition and Usage
    2. While - Syntax
    3. While - Fields
    4. While - More Examples
  3. Else
    1. Else - Definition and Usage
    2. Else - Syntax
    3. Else - Fields
    4. Else - More Examples
  4. Actions
    1. Actions - Syntax
    2. Actions - Fields

If

Move right if the first pixel is black:

if color right

If - Definition and Usage

Use the if statement to specify a single action to be performed if the read pixel has the specified color.

If - Syntax

if condition action

If - Fields

Field Description
if Required. if.
condition Required. 0/white or 1/color.
action Required. An action.

If - More Examples

Emphasize binary:

if 1 right

While

New (v0.4.0)

Move right until the first white pixel:

while color right

While - Definition and Usage

Use the while statement to specify a single action to be performed as long as the read pixel has the specified color.

While - Syntax

while condition action

While - Fields

Field Description
while Required. while.
condition Required. 0/white or 1/color.
action Required. An action.

While - More Examples

Emphasize binary:

while 1 right

Else

Move right if the first pixel is black else reject the input:

if color right else exit 1

Else - Definition and Usage

Use the else statement to specify a single action to be performed if the read pixel does not have the specified color.

Else - Syntax

(if | while) else action

Else - Fields

Field Description
if or while Required. An if- or while statement.
else Required. else.
action Required. An action.

Else - More Examples

Move right until the last black pixel:

while color right else left

Actions

Write a black pixel and move right:

write black right

Actions - Syntax

[write] [direction] [exit | goto]

Actions - Fields

Field Description
write Optional. A write statement.
direction Optional. up, down, left or right, default precompute action.
exit or goto Optional. An exit- or goto statement, default go to next line.

An action consists out of at least one statement.