I’m trying to make SuperCollider recognize certain words when i type them (followed by a space) and then post useful messages. So, the idea is to store those words and messages as key/value pairs in a Dictionary/Event and then use a globalKeyUpAction and findRegexp to trigger the posts. There seem to be things happening in the .do function below that i don’t understand though. The matching seems to work but asking for the data at that key in the Event returns nil for some reason.
Can anyone explain what is happening here?
(
x = "^why $|^is $|^this $|^not $|^working $";
e = (\why: "I", \is: "don't", \this: "really", \not: "know", \working: "?");
Document.globalKeyUpAction_({
Document.current.currentLine.findRegexp(x).do{|match|
//match.postln;
e[match[1].asSymbol].postln;
};
});
)
// type these words followed by a space
why
is
this
not
working
e["why".asSymbol]; // works