Can MaxMSP open a rtf in TextEdit or html file in browser?
Dear users,
we can open a url in max.
Max can also launch a favorite browser in order to open a url.
However, how about a file?
Can Max launch an external program (TextEdit) in order to open a rtf file?
best,
prko
You can use [shell] to run terminal commands on a mac. Try something like the patch below. It won't work when there are spaces in the file path, but it will if there are spaces in the filename itself, I imagine that it's fixable though.
lh
is it compatible with max 5?
It doesn't work.
Have you downloaded the [shell] object? It is an external, not part of the regular distribution. If you already have it what is the patch doing? Anything? Try formatting the message manually, it should look something like: "cd ~/; open -a "
lh
Alternatively try this patch which uses applescript and the [shell] or [aka.shell] object. I'm a bit more familiar with escaping characters for applescript so this one should work just fine.
lh
Thanks, there is still one error.
I have corrected it.
Now it works well.
See my correction.
I still don't understand regexp.
I have just experienced your last patch.
Thanks a lot!
I have another problem.
After launching the TextEdit, the application TextEdit is sent back of the MAX5.
Can we have the TextEdit in front of MAX?
Which bit exactly did you change from my example? It should bring the TextEdit window to the front automatically, the "activate" command should take care of that. Do you have anything in max keeping windows in the foreground? Like "front" to [thispatcher] for example?
lh
HM,it is strange.
I added in MAX the message "sendtoback" into thispatcher.
What I altered in your patch is the following:
you connected the second outlet of the second regexp into the sprintf.
It truncate the volume name (partition name) of the harddisk.
I connected the third outlet of the second regexp into the sprintf.
It does not truncate the volume name.
I have not perfectly understood the usage of the symbols in regexp.
But, with this change the patch works now perfectly.
best with lots of thanks,
prko
I have a further question.
Can I also use the default association of the rtf file?
That means, Max use the system information about the association of a file type to a specific program.
Thus, if a system has Acrobat, then a pdf file will be launched with Acrobat.
If a system has just Preview, the a pdf file will be launched with Preview.
best,
prko
You can do that with the shell script I posted before. Remove the "-a TextEdit" bit which tells the terminal which application to use and it will use whichever is the default for the file you specify. If you want to use applescript then I generally find all the information I need using google, perhaps try the "do shell script" command from there.
lh
In your first code, there is an error in sprintf.
There are two inlets for two "%s"s.
However, you connected only one inlet.
Thus, the second code is funtional.
sprintf osascript -e 'tell application \"TextEdit\"' -e 'activate' -e 'open \"%s\"' -e 'end tell'
What I should change?
Thanks a lot!
best,
prko
If you send a list to many max objects it will interpret it as the first item being sent to the first inlet, the second item to the second inlet and so forth. As there are two backreferences (sets of parentheses) in the [regexp] it will output a list of two items and [sprintf] will interpret these as being sent one to each inlet. Just removing the "-a TextEdit" bit should work with the default application. The patch below works for me.
lh
Now I know the problem (but still without solution)!
Your code is only functional, if we open a document inside of the home folder.
However, I want to open a file in another hard disc.
Thus, your patch does not work for me.
I have not found, how to refer another partition in another hard disc.
(IO have four hard disks)
Do you (or does anybody) know the method?
prko wrote on Wed, 21 October 2009 01:22Now I know the problem (but still without solution)!
Your code is only functional, if we open a document inside of the home folder.
However, I want to open a file in another hard disc.
I have not found, how to refer another partition in another hard disc. (I have four hard disks)
Do you (or does anybody) know the method?
Yes, send this message: (ls /Volumes)->[shell].
PG
sorry!
I have tried longer than two days.
I could not find the possibility.
However, I know what I should do.
But, how?
I should e.g. divided the following strings:
"WorkspaceX:/MyDocuments/Compositions/Patches/interactive additive synth/[Version_V]/_sonic_prism_.scd"
This strings should be
WorkspaceX:/MyDocuments/Compositions/Patches/interactive additive synth/[Version_V] _sonic_prism_.scd
I don't kno what I should write in regexp
Dear thereishopeforus and PhiDjee,
here the correct patch!
However, there is still a problem.
The path and filename should not have a space.
prko wrote on Sat, 24 October 2009 04:22The path and filename should not have a space.
philippe
Yes, I did.
However, it also does not work.
See the code revised after your comment.
The %percent% sign is used to recall back-references in [regexp] substitutions, you will need to escape by using two: %%20.
lh
Is the following patch correct?
It does still not work.
Try enclosing your entire filepath in "quotes" this will force it to be interpreted as a string and not a list. The patch below works for me.
lh
Thank you very much!
It is perfect!
sincerely yours,
prko