Use of Var in Launch ?

I am using Var in a Drum Sequencer to access a list that contains the rhythm for the drum beat. The procedure works by itself; it does not work when it is placed in a Launch block.

Can the Var block be used in a Launch block?

Sample Var Code

This should work if you use the "with inputs" option of the launch block. But, let me be frank about this: Regardless if others keep telling you that it's okay, if you feel you need to access variables by names that you stitch together from Strings that's a very sure indicator of a fundamental design flaw in your program. It would be a really good idea to rethink you data structures so you don't need meta-programming capabilities just to identify variables. I'm willing to help....

That would be great. I'll put together some documentation describing the goals for the drum sequencer, with background context about the way in which we have approached it so far.


The Word document, Coding Rhythms, describes the type of drum sequencer that we would like to emulate in Snap! / TuneScope:

This Word document, TuneScope Drum Machine (Ver 1.0), describes our initial iteration. In this version, we created a series of checkboxes that controlled the rhythm for each type of drum (Snare, Crash Cymbal, etc.):

In Version 2 of the Drum Sequencer, we wanted to use clones to create the checkboxes, so that students will not need to create a permanent sprite for each checkbox manually.

If there’s a more appropriate way to do this, we would be appreciative for guidance / exemplars on how best to do this.

It doesn't even take much rethinking. Although there are certainly better-tuned solutions for specific cases, a simple dictionary (a/k/a an association list, a list of name-value pairs) always works.