at least using sub folder easily

Mar 25, 2011 at 9:53pm

at least using sub folder easily

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

#55813
Mar 26, 2011 at 12:04am

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 ) )
}
————–

#200669
Mar 26, 2011 at 3:13am

Maa,

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

– Pasted Max Patch, click to expand. –
#200670
Mar 26, 2011 at 6:06am

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

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

– Pasted Max Patch, click to expand. –

Ben one more time Thanks

#200671
Mar 28, 2011 at 4:32pm

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

#200672
Mar 30, 2011 at 1:07am

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

Thanks Maa

– Pasted Max Patch, click to expand. –
#200673
Mar 30, 2011 at 5:36am

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….
}

léo

– Pasted Max Patch, click to expand. –
#200674

You must be logged in to reply to this topic.