This uses a hacked block in a very sneaky way in order to create an associative keyword lookup table. This enables a whole bunch of programming techniques not normally used in scratch. LOGO and Prolog used mechanisms like this in their inference engines to support all sorts of AI algorithms. I look forward to seeing some rule-based systems and expert systems and maybe chatbots using this technique!
BIG thanks to zro716 and his 2D array project http://scratch.mit.edu/projects/26343756/ which gave me the idea for this! Instead of having parallel arrays of keyword/value, or structures like a balanced tree, this dirty hack uses Scratch's internal mechanism that is normally used by the interpreter to look up variable names. It creates a new variable called "Lookup:keyword" (where the actual keyword is used, not the string "keyword") and sets item 1 of that array to the associated value. To look up a keyword/value association, it simply tries to retrieve the first item of the array. If none exists, the global variable "value" is set to the empty string. Although it is possible to write a hacked block to create a simple variable rather than an array (just 'set' it to a value) I'm not sure how to write a hacked block to retrieve the value of a scalar, so for the moment, I'm using 1-item arrays. If anyone can suggest a way to do this without arrays I'll update the code,