how do you process a message with js object?

    May 04 2014 | 8:50 pm
    It looks like a message is not a string in Max and so I can't use string functions on the message. How do I convert message to string and process it in Max, then output the message.
    i tried this:
    inlets = 1; outlets = 1;
    function anything() { outlet(0,jsarguments[0]); }
    it outputs nothing :(
    ultimately i want to do a replace function like this: message = this and that string = message to string function goes here string.replace("this and that","nothing") outlet(0,string to message function goes here)

    • May 04 2014 | 10:34 pm
      jsarguments is the array of the js/jsui objects arguments not the function's arguments. You can get those using the arguments array. Have a look at the arrayfromargs method as well if you want to convert the arguments to a real array.
    • May 05 2014 | 12:08 am
      really having trouble locating enough information to help me translate inlet messages into strings. So far I have this, I just want to replace prepend and folder variables with inlet message variables. The first inlet is currently a filepath+name such as C:/test/folder/something. I switch / to ~ to make it easier to work with, then convert ~ to / and \\ at the end for my various path requirements
      ---code tag isn't working--- inlets = 3; outlets = 3;
      prepend = "sine_" folder = "processed"
      function anything() { a = arrayfromargs(messagename, arguments);
      string = a.join(); outlet(0,string);
      string = a.join().replace(/,/g," ").replace(/set/,''); string = string.replace(/\//g,'~');
      open = string.replace(/(.*)/,"open $1").replace(/~/g,'/') save = string.replace(/(.*~)(.*)/,"open $1"+prepend+"$2").replace(/~/g,'/') mkdir = string.replace(/(.*)~.*/,"mkdir $1~"+folder+"~").replace(/~/g,'\\\\')
      outlet(0,open); outlet(1,save); outlet(2,mkdir); } ---code tag isn't working---
    • May 05 2014 | 12:40 am
      ok found my first clue
      if you send a message to js, something like [myMESSAGE]
      then you need this in js
      function myMESSAGE() { do stuff }
      and if you send [myMESSAGE yes maybe no]
      then you need
      function myMESSAGE(a,b,c) { outlet(0,a); outlet(1,b); outlet(2,c); }
      and in each outlet you will get yes maybe no
    • May 05 2014 | 3:38 am
      alright, here's the new code. The only thing left I'd like to do is name the inlets/outlets. Is there any syntax for that?
      inlets = 1; outlets = 3;
      function set(fullpath,prepend,folder) {
      fname = fullpath.replace(/.*\/(.*\.wav)/,"$1"); fpath = fullpath.replace(/(.*\/).*\.wav/,"$1"); newpath = fpath.replace(/\//g,'\\\\') + folder.replace(/\//g,'\\\\');
      outlet(0,fullpath); outlet(1,fpath+folder+prepend+fname); outlet(2,newpath); }