SampleTyping.qtz, Reset the Javascript patch...

mfreakz's picture

Hi, I would like to build a composition using the Freeboard Patch to grab some words an then control my composition using some specific words.

I'm starting to play with the exemple: SampleTyping.qtz In this exemple, the Freeboard Patch is connected to a useful javascript that collect and add all keystroke to build words an output a string. All works fine but i would like to know how to reset this javascript ?

A boolean input to this Javascript Patch, that reset all "memorised" keystrokes could be ideal, but i don't know how to do that in javascript...

Here is the "SampleTyping.qtz" exemple link: http://kineme.net/release/Beta/20090430

Someone could help me ?

cwright's picture
Re: SampleTyping.qtz, Reset the Javascript patch...

var result = new Object();
result.output = "";
function (__string output, __number lastCode) main (__string input, __boolean reset)
{
   if(reset)
      result.output = "";
   if(input != undefined && input.length)
   {
      if(input.charCodeAt(0) == 63272 || input.charCodeAt(0)==127)
         result.output = result.output.substr(0,result.output.length-1);
      else if(input.charCodeAt(0) < 63000)
         result.output += input;
      result.lastCode = 0 + input.charCodeAt(0);
   }
   return result;
}

mfreakz's picture
Re: SampleTyping.qtz, Reset the Javascript patch...

Thank you ! It works fine and i could continue my tests. This FreeBoard Patch could be really useful.