Open a file in a standalone

Eric L.'s icon

Hi List,
How can I do this (looking like a) simple thing:
A user double clic on a file created by MyApp (MyApp is a standalone,
created by maxmsp), and the file opens in MyApp?
Thank you,
--

Eric L.

Mark Pauley's icon

If you're on os x, it's pretty easy.
You have to declare the document types you want to handle in the
Info.plist file in your MyApp's bundle contents directory:

To edit this file, you right-click (or control-click) on your app, and
select "Show Package Contents", open the Contents directory, and edit
Info.plist in TextEdit.

Consider storing a backup of this file so you can just drop it into a
new app each time you build it with Max.

Take a look at preview.app for a good example.

http://developer.apple.com/documentation/Cocoa/Conceptual/Do cuments/index.html?http://developer.apple.com/documentation/ Cocoa/Conceptual/Documents/Concepts/DocTypePList.html

_Mark

dlublin's icon

Check out the "opened" object.

I'm not sure if there is a help file for it, but there have been discussions about it on list/forums - search the archives and you'll find all kinds of useful information on it.

- DL

Eric L.'s icon

???
I can't find this "opened" object anywhere.
--

Eric L.

Mark Pauley's icon

Oh, yeah of course you have to handle the "odoc" apple event and do
the right thing with the path you're given.
There is an "odoc" object written for os 9 on maxobjects.com, anybody
feel like porting this?

_Mark

dlublin's icon

I don't have my iLok handy so I can't try it myself, but I'm pretty sure that's the name of the object.. it's a standard object, but unsupported (hence no help file).

A quick search of the C74 mailing list / forums brings up this thread which mentions the object though:

((sorry for some reason the forums keep displaying this address wrong!! it's adding an extra space))
https://cycling74.com/forums/index.php?t=msg&goto=593 53

I've definitely seen it mentioned further back on the list as well..

- DL

Eric L.'s icon

Well...
I'm on OSX.
I know about info.plist but...
When I double-clic on MyFile created by MyApp, it does open MyApp, but
don't open MyFile in MyApp. Did I missed something?
i.e: MyFile should be opened by MyColl: how do MyApp knows that MyFile
has to be opened by MyColl, and not by MyColl2 ?
Thanks,
--

Eric L.

Mark Pauley's icon

That's what the opened object does according to the other post. So
when you're app gets an 'odoc' apple event, you have to handle it.
I'm guessing that's what 'opened' does. If not, I'd assume it would
be not so hard to write an external object that does something like
this using the carbon event manager api:

http://developer.apple.com/documentation/AppleScript/Concept ual/AppleEvents/index.html?http://developer.apple.com/docume ntation/AppleScript/Conceptual/AppleEvents/responding_aepg/c hapter_6_section_2.html

cheers

_Mark

Stefan Tiedje's icon

lublin wrote:
> I'm pretty sure that's the name of the object..
> it's a standard object, but unsupported (hence no help file).

This is the help file which is on my system, either from the list, or
original...

But it seems to need a bang to report anything, and it seems not to
report what it supposed to do. (OS X 10.4.4, Max 4.5.6)

Stefan

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

--

[][] [][][] [][] [][][] [][] [][][] [][] [][][]
[][][][][][][][][][][][][][][][][][][][][][][][][][][][]

Stefan Tiedje
Klanggestalter
Electronic Composition
&
Improvisation

/~~~~~
\ /|() ()|
))))) )| | |( \
/// _/)/ )))))
___/ ///

-------------------------x---
--_____-----------|----------
--(_|_ ----|-----|-----()---
-- _|_)----|-----()----------
----------()------------x----

14, Av. Pr. Franklin Roosevelt, 94320 Thiais, France
Phone at CCMIX +33-1-49 77 51 72

Emmanuel Jourdan's icon

I just tested it... and it seems to work (same setup). In fact, you
won't need to send a bang: when you opened your application while
double-clicking on your file (or dragging the icon of the file to
your application's icon), the path is automatically sent to the
outlet. The only one problem here is about folder which doesn't work
(while dragging the folder to the application).

Best,
ej

Eric L.'s icon

Ouuch!
Chineese, headache.
Sorry,
--

Eric L.

maxing's icon

as a tangent to the "opened" object, if you are doing something other than
.txt, you may want to create another max filetypes file in the "init"
folder (in the application/support/cycling74/init folder, that is) that
explicitly adds extention -> filetype mappings. This file will be copied
to your standalone automatically. Not doing this caused me many
headaches. Though I don't think they were chinese.
Also, I said "create another" rather than "edit the default" becuase when
you upgrade max, the upgrade will probably replace the default, and you
lose your mappings!

P.

Peter Nyboer's icon

> Ouuch!
> Chineese, headache.

sounds like an MSG, not MSP problem.

as a tangent to the "opened" object, if you are doing something other than
.txt, you may want to create another max filetypes file in the "init"
folder (in the application/support/cycling74/init folder, that is) that
explicitly adds extention -> filetype mappings. This file will be copied
to your standalone automatically. Not doing this caused me many
headaches. Though I don't think they were chinese.
Also, I said "create another" rather than "edit the default" because when
you upgrade max, the upgrade will probably replace the default, and you
lose your mappings!

P.

Stefan Tiedje's icon

I tested again with the help file of opened, it does not put out
anything just by dropping a standard patch on the application.

Emmanuel Jourdan's icon

Strange, this I just tested again too, with success... same setup...

Does the application bellow works for you?

Best,
ej

Stefan Tiedje's icon

Stefan Tiedje wrote:
> I tested again with the help file of opened, it does not put out
> anything just by dropping a standard patch on the application.

Sorry they main part of my last message somehow got cut off:

I wanted to say if I drop a max patch it won't report anything, but if I
drop for example a .XML file onto it it will report properly. It just
seems to ignor native max file types.

Stefan

--

[][] [][][] [][] [][][] [][] [][][] [][] [][][]
[][][][][][][][][][][][][][][][][][][][][][][][][][][][]

Stefan Tiedje
Klanggestalter
Electronic Composition
&
Improvisation

/~~~~~
\ /|() ()|
))))) )| | |( \
/// _/)/ )))))
___/ ///

-------------------------x---
--_____-----------|----------
--(_|_ ----|-----|-----()---
-- _|_)----|-----()----------
----------()------------x----

14, Av. Pr. Franklin Roosevelt, 94320 Thiais, France
Phone at CCMIX +33-1-49 77 51 72

Emmanuel Jourdan's icon

Ok, I get the same behavior. if you drop a patch, the application
will try to open it...

ej