Forums > MaxMSP

how do you process a message with js object?

May 04 2014 | 1: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()

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 | 3: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 04 2014 | 5:08 pm

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();

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,’\\\\’)

—code tag isn’t working—

  • This reply was modified 2 years by  argitoth.
May 04 2014 | 5:40 pm

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)

and in each outlet you will get

  • This reply was modified 2 years by  argitoth.
May 04 2014 | 8:38 pm

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,’\\\\’);


Viewing 5 posts - 1 through 5 (of 5 total)

Forums > MaxMSP