Variable Reassignment (update)

Handel supports variable reassignment. Variables can be reassigned using the update keyword.

For example:

save mynotelist = B3
update mynotelist = Bb3

Reassignment and Shifting values#

All variables in Handel can be shifted using the rshift and lshift keywords. You can think of this as the equivalent of += and -= respectively.

For variables storing digits, this shifting is exactly the equivalent of addition and subtraction.

For variables storing notelists, shifting changes the note, left or right by a number of semitones.

The following example reassigns (or shifts) `mynotelist down/left by one semitone. Then up/right by two semitones.

start
save mynotelist = B3
update mynotelist lshift 1
play mynotelist for 1b
save somenum = randint 1 to 5
update mynotelist rshift somenum
play mynotelist for 1b
finish

Variables storing Durations and Playables can also be shifted.

Shifting a duration increases or decreases its beat value.

Shifting a playable increases or decreass its notelist.

For example:

start
save duration = for 1b
save playable = E3, G3 for 2b
update duration rshift 1
update playable lshift 2
play playable
rest duration
play playable
finish