Variable Declaration (save)
tl;dr Here is a code snippet showing variables in Handel
You can declare Variables in Handel. Variables store three builtin types in Handel: Notelists, Notegroups, Durations, Playables.
A Digit is a positive or negative integer.
A Notelist is a single note name, or a list of note names separated by commas.
For example:
A Notegroup is a group of notelists (or conceptually an array of notelists). Each notelist is separated by a vertical line.
For example:
A Duration is the keyword for followed by a beat.
Here are some example durations:
Lastly, we've already seen Playables above. Playables are a note or notelist (chord) followed by a duration. Here are some example playables.
no promises that the above chord sounds pleasing to the ear :p
Finally variables!
To store a notelist, playable or a duration use the save keyword, followed by a variable name, an equal sign and a notelist, playable, duration (or another variable which stores on of these values).
Variable names must contain only lowercase letters, and no numbers. Variable names must also not be any of the reserved keywords in Handel. eSee the Reserved Keywords).
Below is an example program using variables.
When saving variables, Handel now also provides expressions for generating random numbers and for evaluating expressions.
To generate a random number when setting a variable, use the randint
keyword, followed by a range start to end
To evaluate an expression use the eval
keyword followed by a mathematical expression (note division is integer division).
Here is an example of the syntax:
OK! So far so good!