Block
Top  Previous  Next

Definition

B block number{ commands }[[,]occurs]

B
Block command
block number
A number ranging from 0 to 9. The block number must be unique between both N and B type blocks and can only be used once across all shapes in a program.
commands
Any commands in combination.
occurs
Default 1.
The number of times the block of commands enclosed in braces will be repeated. The occurs is ignored when the block number is referenced by the repeat command.


Usage

The block and procedure are identical with one minor difference. The block (B) has a default occurrence of 1 while the procedure (N) has a default occurrence of 0. This allows the procedure to define a shape without that shape being represented in the shape until referenced by a repeat (R) command.

The Block command along with its occurs option is used to enclose a series of commands and have those commands used in the shape. Repeating a Block or Procedure is the function of the Repeat command.

The following are all equivalent:

b1{d1,90}

n1{d1,90}
r1


n1{d1,90}1

b1{d1,90}0
r1


r{
d1,90}

In the last example above, the repeat uses the inline block specification.

The difference to using a numbered block vs an inline block, is that the numbered block can be repeated later in the same shape definition with a reference to it by the Repeat command.

The block number is referenced by the Repeat command to repeat the commands enclosed by the { }. The Repeat may optionally specify a number of occurrences the commands are to be repeated.

Repeat block one, four times would be written:

r1,4


Example

Defining a few shape elements in blocks and then repeating the blocks in an inline block of the repeat command can be quite useful. The blocks are referenceable anywhere in the code and is how the long arm of the cross is made.
 

clip0025

r{
b1{d.5 a-90,.1 d.5}
b2{a90,.1 d.3 a90,.1}
}3
r1d1r2d1


Shape produced by block 1
clip0026

Shape produced by block 2
clip0027