relative paths
Hey guys,
does anyone know how to set up relative paths that aren't within the max application folder? i want to select a folder that is in the same level as my patch and read the relative path, so i just get the folder name rather than the absolute path?
please help.
cheers
dave
path-> [thispatcher]
use [sprintf %ssubfolder/subsubfolder] to concat the rest of the folderpath.
best, thijs
ok i might missunderstand something and in that case please excuse me in
advance.
Did you have a look at the objects relativepath absolutepath and filepath ?
Sorry if my answer if too simple, maybe i got something wrong.
HTH.
Seb.T
yeh i have,
but the object relativepath only works for within the max application program. so im having a bit of difficulty trying to just get a relative path from the main folder.
any ideas?
dave
hi thijs,
here is what i have...sorry i couldn't figure out how/where to put in your suggested object
Im trying just to get the relative path.
hope you can help?
cheers,
dave
javascript is good for sorting this kind of thing out:
appFilePath = "";
post("path: " +this.patcher.filepath);
var tmp = this.patcher.filepath.split("/");
post("Filepath: "+ this.patcher.filepath + "n");
if (tmp[tmp.length-1] != "MacOS") tmp.pop(); //remove patcher name
for(var c=0; c
{
appFilePath += tmp[c] + "/";
}
newFilePath = appFilePath + "yourDirectory/";
you cant get relative paths that way.
if you have
/harddisk/maxmsp/searchpath/
and
/harddisk/file.txt
there is no relative path between max runtime
and the file because it would include going
2 levels up.
if you want to build an app which uses a "samples"
folder relative beside the app, you could
incluide a "samples" folder in your search path
during programming.
That javascript is missing a bit:
appFilePath = "";
//post("path: " +this.patcher.filepath);
var tmp = this.patcher.filepath.split("/");
//post("Filepath: "+ this.patcher.filepath + "n");
if (tmp[tmp.length-1] != "MacOS") tmp.pop(); //remove patcher name
for(var c=0; c<tmp.length-1; c++)
{
appFilePath += tmp[c] + "/";
}
newFilePath = appFilePath + "data/";
Here's an example in situ:
function makepath(fname)
{
appFilePath = "";
//post("path: " +this.patcher.filepath);
var tmp = this.patcher.filepath.split("/");
//post("Filepath: "+ this.patcher.filepath + "n");
if (tmp[tmp.length-1] != "MacOS") tmp.pop(); //remove patcher name
for(var c=0; c<tmp.length-1; c++)
{
appFilePath += tmp[c] + "/";
}
newFilePath = appFilePath + "data/" + fname;
outlet (0,newFilePath);
}