folder creation in Max

Jul 25, 2006 at 1:22pm

folder creation in Max

#26917
Jul 25, 2006 at 1:41pm

You’re on the right track to use Java. Try this bit of code (be sure
to import java.io.File):

public void anything(String s, Atom[] args) {
f = new File(s);
f.mkdir();
}

The string s represents the path of the folder you want to make.

HTH,
Dan

At 3:22 PM +0200 7/25/06, Pascal Baltazar wrote:
>Hi all,
>
>I need a way to create folders from my patch.
>
>Usually, I was using mkdir from Bill Orcutt…
>But, it hasn’t been ported to UB…
>
>So I’ve tried mxj syscommand for this use
>(by Tim Place, on Topher Lafata’s share page)
>on My Macbook, Max 4.6, it works perfectly well, sending exec mkdir
>(folder adress)
>on a Win PC, Max 4.5.7, it outputs a bunch of error messages (see end
>of mail for those so-inclined…)
>
>If any has a clue for this kind of job (creating a folder somewhere on disk)
>of course, that works on both OSes….
>It would be much appreciated…
>
>Thanks in advance…
>
>pb
>
>___
>
>mxj syscommand errors on PC (sending exec mkdir (folder adress) message) :
>
>str is PATHSEP
>str is TMP
>str is SEP
>* error: Exception in thread “3″
>java.lang.StringIndexOutOfBoundsException: String index out of range:
>1
>* error: at java.lang.String.charAt(Unknown Source)
>* error: at java.util.regex.Matcher.appendReplacement(Unknown Source)
>* error: at java.util.regex.Matcher.replaceAll(Unknown Source)
>* error: at java.lang.String.replaceAll(Unknown Source)
>* error: at syscommand.expandvars(syscommand.java:136)
>* error: at syscommand.cmd(syscommand.java:249)
>* error: at syscommand.access$000(syscommand.java:5)
>* error: at syscommand$1.run(syscommand.java:190)
>


Dan Nigrin
Defective Records
202 Hack / PC-1600 User / VSTi Host / OMS Convert / Jack OS X
http://www.defectiverecords.com

http://www.jackosx.com

#80995
Sep 7, 2006 at 2:37am

Hi Dan! – I want to do the same thing – cross platform folder creation. However I am a complete Java novice – I get compile errors when i try to compile the following:
======================================
import com.cycling74.max.*;
import java.io.File;

public class CreateFolder extends MaxObject
{

private static final String[] INLET_ASSIST = new String[]{
“inlet 1 help”
};
private static final String[] OUTLET_ASSIST = new String[]{
“outlet 1 help”
};

public CreateFolder(Atom[] args)
{
declareInlets(new int[]{DataTypes.ALL});
declareOutlets(new int[]{DataTypes.ALL});

setInletAssist(INLET_ASSIST);
setOutletAssist(OUTLET_ASSIST);

}

public void anything(String s, Atom[] args) {
f = new File(s);
f.mkdir();
}

}
=====================================

The errors Are:

/Applications/MaxMSP 4.6/Cycling ’74/java/classes/CreateFolder.java[ 26 ] cannot find symbol
symbol : variable f
location: class CreateFolder
f = new File(s);
^
/Applications/MaxMSP 4.6/Cycling ’74/java/classes/CreateFolder.java[ 27 ] cannot find symbol
symbol : variable f
location: class CreateFolder
f.mkdir();
^
2 errors
[ Sep 6, 2006 10:33:45 PM ]
compilation of /Applications/MaxMSP 4.6/Cycling ’74/java/classes/CreateFolder.java failed.

==============================================

What else do I need to do?

Thanks,
Arvid

#80996
Sep 7, 2006 at 7:52am

Sure. In Java, you have to delcare the type of your variable.

Here, you should write :

File f = new File(s);

because f wasn’t declared before.

cheers

f.e

f.e chanfrault | aka | personal computer music
> >>>>>> http://www.personal-computer-music.com
> >>>>>> |sublime music for a desperate people|

Arvid Tomayko-Peters wrote:
> Hi Dan! – I want to do the same thing – cross platform folder creation. However I am a complete Java novice – I get compile errors when i try to compile the following:
> ======================================
> import com.cycling74.max.*;
> import java.io.File;
>
> public class CreateFolder extends MaxObject
> {
>
> private static final String[] INLET_ASSIST = new String[]{
> “inlet 1 help”
> };
> private static final String[] OUTLET_ASSIST = new String[]{
> “outlet 1 help”
> };
>
> public CreateFolder(Atom[] args)
> {
> declareInlets(new int[]{DataTypes.ALL});
> declareOutlets(new int[]{DataTypes.ALL});
>
> setInletAssist(INLET_ASSIST);
> setOutletAssist(OUTLET_ASSIST);
>
> }
>
>
> public void anything(String s, Atom[] args) {
> f = new File(s);
> f.mkdir();
> }
>
> }
> =====================================
>
> The errors Are:
>
> /Applications/MaxMSP 4.6/Cycling ’74/java/classes/CreateFolder.java[ 26 ] cannot find symbol
> symbol : variable f
> location: class CreateFolder
> f = new File(s);
> ^
> /Applications/MaxMSP 4.6/Cycling ’74/java/classes/CreateFolder.java[ 27 ] cannot find symbol
> symbol : variable f
> location: class CreateFolder
> f.mkdir();
> ^
> 2 errors
> [ Sep 6, 2006 10:33:45 PM ]
> compilation of /Applications/MaxMSP 4.6/Cycling ’74/java/classes/CreateFolder.java failed.
>
> ==============================================
>
> What else do I need to do?
>
> Thanks,
> Arvid
>
>

#80997
Sep 7, 2006 at 11:39am

Hi Arvid, nice to see you here.

You need to tell Java what type of variable “f” is in the first place
- take a look back at my original code – you’ll see this line towards
the top, which is what you need to add:

private File f;

Alternatively, you can do what f.e. suggested, all in one line,
modifying your current f = new File(s) line:

File f = new File(s);

Hope that helps,
Dan

At 8:37 PM -0600 9/6/06, Arvid Tomayko-Peters wrote:
>Hi Dan! – I want to do the same thing – cross platform folder
>creation. However I am a complete Java novice – I get compile errors
>when i try to compile the following:
>======================================
>import com.cycling74.max.*;
>import java.io.File;
>
>public class CreateFolder extends MaxObject
>{
>
> private static final String[] INLET_ASSIST = new String[]{
> “inlet 1 help”
> };
> private static final String[] OUTLET_ASSIST = new String[]{
> “outlet 1 help”
> };
>
> public CreateFolder(Atom[] args)
> {
> declareInlets(new int[]{DataTypes.ALL});
> declareOutlets(new int[]{DataTypes.ALL});
>
> setInletAssist(INLET_ASSIST);
> setOutletAssist(OUTLET_ASSIST);
>
> }
>
>
>public void anything(String s, Atom[] args) {
>f = new File(s);
>f.mkdir();
>}
>
>}
>=====================================
>
>The errors Are:
>
>/Applications/MaxMSP 4.6/Cycling ’74/java/classes/CreateFolder.java[
>26 ] cannot find symbol
>symbol : variable f
>location: class CreateFolder
>f = new File(s);
>^
>/Applications/MaxMSP 4.6/Cycling ’74/java/classes/CreateFolder.java[
>27 ] cannot find symbol
>symbol : variable f
>location: class CreateFolder
>f.mkdir();
>^
>2 errors
>[ Sep 6, 2006 10:33:45 PM ]
> compilation of /Applications/MaxMSP 4.6/Cycling
>’74/java/classes/CreateFolder.java failed.
>
>==============================================
>
>What else do I need to do?
>
>Thanks,
>Arvid


Dan Nigrin
Defective Records
202 Hack / PC-1600 User / VSTi Host / OMS Convert / Jack OS X
http://www.defectiverecords.com

http://www.jackosx.com

#80998

You must be logged in to reply to this topic.