Open a file in a standalone

Jan 18, 2006 at 10:34pm

Open a file in a standalone

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.

#23989
Jan 18, 2006 at 11:22pm

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

#68690
Jan 18, 2006 at 11:25pm

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

#68691
Jan 19, 2006 at 12:11am

???
I can’t find this “opened” object anywhere.

Eric L.

#68692
Jan 19, 2006 at 12:44am

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

#68693
Jan 19, 2006 at 12:53am

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))
http://www.cycling74.com/forums/index.php?t=msg&goto=593 53

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

- DL

#68694
Jan 19, 2006 at 12:59am

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.

#68695
Jan 19, 2006 at 1:56am

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

#68696
Jan 19, 2006 at 10:55am

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

#P button 18 106 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 286 153 38 196617 folder;
#P comment 239 138 53 196617 see also:;
#P message 239 153 45 196617 dropfile;
#P message 326 153 45 196617 filepath;
#P message 373 153 48 196617 pcontrol;
#P hidden newex 326 182 64 196617 prepend help;
#P hidden newex 326 205 45 196617 pcontrol;
#P window setfont “Sans Serif” 18.;
#P comment 12 18 106 196626 opened;
#B frgb 21 56 9;
#P window setfont “Sans Serif” 9.;
#P comment 12 43 423 196617 List path , filename and filetype of a file
wich has been dragged onto the Max application;
#P user panel 7 13 428 50;
#X brgb 255 247 207;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P window linecount 2;
#P user com 18 73 407 196617 57;
#K set 0 17522 28528 8289 8294 26988 25888 29807 8308 26725 8269 24952
8289 28784 27753 25441 29801 28526 8289 28260 8311 24948 25448 8308
26725 8269 24952 8311 26990 25711 30510 11822 3439 28773 28261 25632
26995 8309 28275 30064 28783 29300 25956 11296 25205 29728 28271 30496
24948 8300 25953 29556 8292 28515 30061 25966 29797 25646;
#K end;
#P window linecount 1;
#P newex 134 152 55 196617 print type;
#P newex 76 152 50 196617 print file;
#P newex 18 152 55 196617 print path;
#P newex 18 127 127 196617 opened;
#P comment 35 108 212 196617 bang reports opened path , filename and type;
#P hidden connect 10 0 9 0;
#P hidden connect 11 0 10 0;
#P hidden connect 13 0 10 0;
#P hidden connect 12 0 10 0;
#P hidden connect 15 0 10 0;
#P connect 1 2 4 0;
#P connect 1 1 3 0;
#P connect 1 0 2 0;
#P connect 16 0 1 0;
#P window clipboard copycount 17;

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

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

#68697
Jan 19, 2006 at 11:34am

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

#68698
Jan 19, 2006 at 12:17pm

Ouuch!
Chineese, headache.
Sorry,

Eric L.

#68699
Jan 19, 2006 at 3:49pm

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.

#68700
Jan 19, 2006 at 3:51pm

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

#68701
Jan 25, 2006 at 1:45pm

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

#68702
Jan 25, 2006 at 6:48pm

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

Does the application bellow works for you?

http://www.e–j.com/dl/test-opened.zip

Best,
ej

#68703
Jan 25, 2006 at 9:26pm

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

#68704
Jan 25, 2006 at 9:37pm

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

ej

#68705

You must be logged in to reply to this topic.