javascriptmax-msp-jitter

String Split not working


I'm having a problem with splitting strings in Javascript in Max/MSP.

outlet is the Max/MSP version of printf etc.

The string splits weirdly, but it seems to only output both words comma seperated.

function sample_callback(args)  // Callback
{
    var keyword=args;
    var trackname=keyword.toString().split(" ");
    var name = trackname[0]; // trackname[1] outputs nothing.
    outlet(0, name);
}

Any help is greatly received.


Solution

  • Big thanks to Aaron Kurtzhals . Hopefully the upvote in the comment counts towards your rep!

    A simple overlooked checking of what the string is helped me out. oops. The working code is now..

    function sample_callback(args)  // Callback
    {
      var keyword=args.toString();
      var trackname=keyword.split(",");
      var name = trackname[0];
      outlet(0, name);
    }
    

    Cheers