Begin/End Blocks
Keywords: mma

Subsections

- Begin
- End

#
Begin/End Blocks

Entering a series of directives for a specific track can get quite tedious. To make the creation of library files a bit easier, you can create a block. For example, the following:

Drum Define X 0 2 100; 50 2 90 Drum Define Y 0 2 100 Drum Sequence X Y

Can be replaced with:

Drum Begin Define X 0 2 100; 50 2 90 Define Y 0 2 100 End Drum Sequence X Y

Or, even more simply, with:

Begin Drum Define X 0 2 100; 50 2 90 Y 0 2 100 End

If you examine some of the library files you will see that this shortcut is used a lot.

# Begin

The BEGIN command requires any number of arguments. Valid examples include:

Begin Drum Begin Chord2 Begin Walk Define

Once a BEGIN block has been entered, all subsequent lines have the words from the BEGIN command prepended to each line of data. There is not much magic here—BEGIN/END is really just some syntactic sugar.

# End

To finish off a BEGIN block, use a single END on a line by itself.

Defining musical data or repeats inside a block (other than COMMENT blocks) will not work.

Nesting is permitted, e.g.,

Scale Begin Begin Define stuff End Sequence stuff End

A BEGIN must be competed with a END before the end of a file, otherwise an error will be generated. The USE and INCLUDE commands are not permitted inside a block.

Caution:

- Be careful when using user defined plugins inside a block. If you were to do something like:

  Begin @myplugin some args End

  and the plugin returns strings back into your source file, you will end up forever loop. The plugin is returning a data line back and MMA will insert “@myplugin” to the new line. However, the block:

  Begin @myplugin ... End

  should work fine.