The goal is to enhance Schemacode/Mindcode to more easily create (rectangular) areas of blocks. It's a far cry from a fully programmable block creation, but still may be useful for many schemes.
Block arrays
Syntax extension allowing to specify an area, instead of position. The area specification is appended after the position specification like this:
display:
@tile-logic-display at ( 4, 0) .. (9, 8)
Three area operators are be available:
.. inclusive range operator. Specifies the end of the area, inclusive (i.e., tile at the end position will be occupied by the block). Position can be specified as usual (absolute, relative to last block, relative to labeled block).
... exclusive range operator. Specifies the end of the area, exclusive (i.e., tile at the end position will not be occupied by the block).
* size operator. Specifies the size of the area. In this case, the fist position denotes the lower left corner of the array, x and y coordinates specify the size of the array. Positive sizes extend right/up, negative sizes extend down/left. Example @tile-logic-display at (4, 0) * (6, 9)
It is possible to encode an area with zero width or height (or both). In that case, an error is reported.
A label, when specified, denotes the block at the starting position (the anchor block), regardless of the direction the array is extended.
When more than one label is specified for a block array, the labels are assigned to the blocks one by one until the labels run out. If there are more labels than blocks, an error is reported.
For rectangular block arrays, the direction of the processing can be specified using either the horizontal or the vertical keywords. In case of horizontal, all blocks in a row are assigned the label first, then the next row is processed. In case of vertical, all blocks in a column are assigned the label first, then the next column is processed. The row/column of the anchor block is processed first. Example:
a, b, c, d:
@switch at (3, 7) * (2, 2) horizontal
creates buttons in this layout:
A configuration, when specified, is applied to all blocks in the array (for example, all processors in the array can have the same linked blocks and the same code configured). At this moment, it won't be possible to specify different configurations for different blocks in the array.
Label arrays
Block labels may end with a # character, denoting a label array. In this case, Schemacode generates unique label for each new block by replacing the #character with an index starting at 1, in the order they're encountered in the definition file.
When used with a block array, names are generated from the label array for blocks that do not have a singular label assigned. The array label may be used stand-alone or in conjunction with singular labels, but at most one label array can be used per block array.
Block labels may be either symbolic or literal. Literal link names must conform to the naming scheme of the block types they represent. Symbolic names may represent blocks of different types, but they need to be properly resolved to the correct block type in Mindcode source.
Link arrays
Mindcode link arrays can be tied to Schemacode label arrays in the program. There could be two possible ways to declare them:
linked(@switch) var blocks = (block1 .. block12);
linked(@sorter) var block13 .. block20;
In the first case, a constant array of 12 links named blocks would be created. It would contain 12 links (block1 to block12).
In the second case, individual variables named block13 to block20 would be created.
In both cases, the non-numerical prefix of the identifier must be identical. Both inclusive and exclusive range operators will be permitted - in the case of range exclusive iterators, the block denoted by the max range value may not exist.
Both literal and symbolic link names can be used with link arrays.
The goal is to enhance Schemacode/Mindcode to more easily create (rectangular) areas of blocks. It's a far cry from a fully programmable block creation, but still may be useful for many schemes.
Block arrays
Syntax extension allowing to specify an area, instead of position. The area specification is appended after the position specification like this:
Three area operators are be available:
..inclusive range operator. Specifies the end of the area, inclusive (i.e., tile at the end position will be occupied by the block). Position can be specified as usual (absolute, relative to last block, relative to labeled block)....exclusive range operator. Specifies the end of the area, exclusive (i.e., tile at the end position will not be occupied by the block).*size operator. Specifies the size of the area. In this case, the fist position denotes the lower left corner of the array,xandycoordinates specify the size of the array. Positive sizes extend right/up, negative sizes extend down/left. Example@tile-logic-display at (4, 0) * (6, 9)It is possible to encode an area with zero width or height (or both). In that case, an error is reported.
A label, when specified, denotes the block at the starting position (the anchor block), regardless of the direction the array is extended.
When more than one label is specified for a block array, the labels are assigned to the blocks one by one until the labels run out. If there are more labels than blocks, an error is reported.
For rectangular block arrays, the direction of the processing can be specified using either the
horizontalor theverticalkeywords. In case ofhorizontal, all blocks in a row are assigned the label first, then the next row is processed. In case ofvertical, all blocks in a column are assigned the label first, then the next column is processed. The row/column of the anchor block is processed first. Example:creates buttons in this layout:
A configuration, when specified, is applied to all blocks in the array (for example, all processors in the array can have the same linked blocks and the same code configured). At this moment, it won't be possible to specify different configurations for different blocks in the array.
Label arrays
Block labels may end with a
#character, denoting a label array. In this case, Schemacode generates unique label for each new block by replacing the#character with an index starting at1, in the order they're encountered in the definition file.When used with a block array, names are generated from the label array for blocks that do not have a singular label assigned. The array label may be used stand-alone or in conjunction with singular labels, but at most one label array can be used per block array.
Block labels may be either symbolic or literal. Literal link names must conform to the naming scheme of the block types they represent. Symbolic names may represent blocks of different types, but they need to be properly resolved to the correct block type in Mindcode source.
Link arrays
Mindcode link arrays can be tied to Schemacode label arrays in the program. There could be two possible ways to declare them:
In the first case, a constant array of 12 links named
blockswould be created. It would contain 12 links (block1toblock12).In the second case, individual variables named
block13toblock20would be created.In both cases, the non-numerical prefix of the identifier must be identical. Both inclusive and exclusive range operators will be permitted - in the case of range exclusive iterators, the block denoted by the max range value may not exist.
Both literal and symbolic link names can be used with link arrays.