Check if a certain file exists

Nov 7, 2012 at 11:20am

Check if a certain file exists

I spend some time browsing through all the file-related objects and I can’t find any solution for my simple task:

before my patch opens a .xml file at startup (which contains some user default settings), it should check whether the file exists. Is there a quick way to accomplish this?

Thanks in advance

Nov 7, 2012 at 11:38am

Here is a way:
but it’s also possible to do this in pure Max (it’s more fun to compute).


Nov 7, 2012 at 1:08pm

Here’s a simple Javascript approach that I use.

– Pasted Max Patch, click to expand. –
Nov 7, 2012 at 1:44pm

there is no need of java or javascript.

plain max version:

– Pasted Max Patch, click to expand. –
Nov 7, 2012 at 1:58pm

Cool — I never thought about that one. Glad you mentioned it — I suppose the only benefit of my version is that it’s just one object instead of four but putting it in an abstraction addresses that.

I’m curious however as to why you used trigger objects rather than just messages containing 0 and 1 respectively?

– Pasted Max Patch, click to expand. –
Nov 7, 2012 at 2:16pm

1) for backwards compatibility

2) less cpu usage.
a message box is an interface object, trigger object not.
not much in this case, but if you have many of them, it will affect performance.

Nov 7, 2012 at 2:18pm

> why you used trigger objects

Maybe it’s a matter of style; I do it too. Then again, I remember a case in which I didn’t anticipate the message object receiving a set message, breaking functionality. With a trigger it is completely unambiguous.

@dupecom nice indeed

Nov 7, 2012 at 2:22pm

Thanks for the explanation — I have a lot of message objects in my patchers for such things. Sounds like it will be worth my while to replace them with triggers…particularly where I’m dealing with incoming highspeed OSC messages.

Nov 7, 2012 at 2:24pm

its not my solution. copied from 11olsen. thanx !!
he posted it here:

Nov 7, 2012 at 2:30pm

It doesn’t matter if it’s not your solution — the value of teaching is not about originality.

Apr 17, 2014 at 4:27pm

The problem with the [absolutepath] object is that searches everywhere on the hard drive – not just a specific folder – would there be a way to search for the file only in the selected folder?


You must be logged in to reply to this topic.