heh sehr clever timm.
unfortunately i don't have a Windows machine here so i can't test it...
which leads to a very obvious problem with this idea:
different OSes use different shell commands, so i'd need to determine what the underlying OS is and then execute the right script? i'm a total noob regarding shell, terminal and these things...
however i've figured out the first step: how to (rudimentary) parse some code and write to disk.
indeed with increasing complexity, this could quickly become a large project.
to get the purely technical obstacles out of the way, i could use some help on how to write a script that
option [a], kinda easy:
take generatedCode.pde --> open with Processing IDE --> run
option [b], more elegant, would require to generate proper Java code though i suppose:
javac generatedCode.java, run.
Code:
ArrayList child;
String childName = "mickeyMouse";
String[] declareSetup =
{
"void setup()",
"{",
"}",
};
String[] declareDraw =
{
"void draw()",
"{",
"}",
};
String[] intoSetup =
{
// TODO: smart things
"\tsize(400, 300);",
"\tsmooth();",
};
String[] intoDraw =
{
// TODO: smart things
"\tbackground(0);",
"\tellipse(mouseX, mouseY, 30, 30);",
};
void setup()
{
buildChild();
writeChildToDisk(childName);
exit();
}
void buildChild()
{
child = new ArrayList();
child.add(declareSetup[0]);
child.add(declareSetup[1]);
for(int i = 0; i < intoSetup.length; i++)
{
child.add(intoSetup[i]);
}
child.add(declareSetup[2]);
child.add(" ");
child.add(declareDraw[0]);
child.add(declareDraw[1]);
for(int i = 0; i < intoDraw.length; i++)
{
child.add(intoDraw[i]);
}
child.add(declareDraw[2]);
child.add(0, "String myName = \""+childName+"\";");
child.add(1, " ");
}
void writeChildToDisk(String name)
{
String filePath = name+"/"+name+".pde";
PrintWriter output = createWriter(filePath);
for(int i = 0; i < child.size(); i++)
{
output.println((String)child.get(i));
}
output.flush();
output.close();
}