Question

I have created a processing application and then exported it using file->export application. Initially some of the parameters were hard coded to simply make it run. Now I want to supply these (string) parameters using command line while executing the exported application.

I have been trying to look for something similar to C language or Java but it seem that won't work.

I export my application in Win32 and it creates a folder named "application.windows32". Inside the folder there is "myapp.exe" a "source" folder and a "lib" folder. "lib" folder contains "args.txt" and other ".jar files". To run this applet I double click "myapp.exe" and it runs. Could you please tell me what commands will be used inside the processing source-code to achieve:

myapp.exe arg1 arg2?

Any example or suggestions?

Was it helpful?

Solution

Every Processing sketch is a subclass of the PApplet class which has an args property

Here's a very basic example:

void setup(){
  if(args != null){
     for(int i = 0; i < args.length; i++) 
        text(args[i],0,10+i*10);
  }
}

Save this code as a sketch, export it, than run the executable from the command line and pass arguments to see what I mean.

OTHER TIPS

Look for the main method... it has a signature like this

public static void main(String[] args) {
  for (String s : args) {
    System.out.println(s);
  }
}

Which (when run with your supplied arguments) would output

arg1
arg2?

If you're looking to use command line arguments in a significant way, you may want to look at Commons CLI.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top