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

#65107
Nov 7, 2012 at 11:38am

Here is a way:

http://cycling74.com/toolbox/mxj-filesys-v0-2-3/
but it’s also possible to do this in pure Max (it’s more fun to compute).

p

#234722
Nov 7, 2012 at 1:08pm

Here’s a simple Javascript approach that I use.

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

there is no need of java or javascript.

plain max version:

– Pasted Max Patch, click to expand. –
#234724
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?
E.g.,

– Pasted Max Patch, click to expand. –
#234725
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.

#234726
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

#234727
Nov 7, 2012 at 2:22pm

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

#234728
Nov 7, 2012 at 2:24pm

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

http://cycling74.com/forums/topic.php?id=38141

#234729
Nov 7, 2012 at 2:30pm

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

#234730
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?

#286951

You must be logged in to reply to this topic.