at least using sub folder easily

Maa's icon

Ben gave me this

save as myLocation.js:
---------------------------
autowatch = 1;

function bang()
{
outlet(0, this.patcher.filepath)
}
---------------------------

which help me a lot
but i want to strip the file name

I don't want to learn Java or Java script now (Max is enough)
I am sure this is simple for somebody who know

Thanks Maa

Maa's icon

this is auto answer too

save as myLocation.js:
______________________
autowatch = 1;

function getFileDirectory( str )
{
    if( str.toString().indexOf("/") != -1 )
    {
        return str.substring( 0, str.toString().lastIndexOf( '/' ) );
    }
    return str;
}

function bang()
{
outlet( 0, getFileDirectory( this.patcher.filepath ) )
}
--------------

Ben Bracken's icon

Maa,

Max Patch
Copy patch and select New From Clipboard in Max.

If you don't want the file name, and want to avoid JS, then the 'path' message to [thispatcher] will do the trick:

Maa's icon

what the best one in your opinion js or [thispatcher] ?
does it work (in both case) in case of runtime ?

Max Patch
Copy patch and select New From Clipboard in Max.

in fact U am trying to understand this patch triggered at init

Ben one more time Thanks

Ben Bracken's icon

I think either strategy would be fine in runtime. I guess if you can get away without using JS, then that is one less dependency to have to worry about.

-Ben

Maa's icon

here a solution to strip folder or file name with no JS
I am sure it could be better ( I just adapted a post )

but Ben could you comment the previous one
I am sure it would be very useful to others

Max Patch
Copy patch and select New From Clipboard in Max.

Thanks Maa

Léopold Frey's icon

Hello Maa,

I've simplified the previous patch.
I use it to test wether we're in "MaxMSP", in "MaxMSP Runtime" or in a standalone application.

It just asks for "apppath",
if this apppath startstwith "Max5"
{
we're in Max or in Max Runtime,
so we ask for the patcher path,
} else {
this apppath is a good place to start looking for soundfiles, presets....
}

Max Patch
Copy patch and select New From Clipboard in Max.

léo