# \[SOLVED\] Command Line Arguments Width and Height

**URL:** https://discourse.processing.org/t/solved-command-line-arguments-width-and-height/12985
**Category:** Gallery
**Created:** [July 25, 2019, 10:59pm UTC](https://discourse.processing.org/t/solved-command-line-arguments-width-and-height/12985 "2019-07-25T22:59:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![figraham](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/figraham/32/4161_2.png) [@figraham](https://discourse.processing.org/u/figraham)
#### Post date: [July 25, 2019, 10:59pm UTC](https://discourse.processing.org/t/solved-command-line-arguments-width-and-height/12985/1 "2019-07-25T22:59:07Z")

</div>

It took me a while to figure out how to run a processing sketch with a size defined by the command line arguments so I thought I’d share the solution I came up with. If someone has suggestions to make this more streamlined I’d love to hear them.

**sketch.pde**

```auto
void settings() {
  int argWidth = 0;
  int argHeight = 0;
  String usage = "Usage width(int) height(int)";
  if (args == null || args.length != 2) {
    println(usage);
    exit();
  }
  try {
    argWidth = Integer.parseInt(args[0]);
    argHeight = Integer.parseInt(args[1]);
  } catch (NumberFormatException e) {
    println(usage);
    exit();
  }
  size(argWidth, argHeight);
}

void setup() {
  
}

void draw() {
  
}

```

**tasks.json for use with VS Code, not necessary but makes it easier to run the sketch**

```auto
// Visual Studio Code tasks.json for the sketch
// Uses Processing VS code extension (https://github.com/TobiahZ/processing-vscode)
// Width and Height are hard coded in this file for rapid testing.
// Ctrl + Shift + B to Run
// Only tested on Linux

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "All",
      "type": "shell",
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "command": "echo",
      "presentation": {
        "reveal": "always",
        "focus": false,
        "panel": "shared",
      },
      "args": [
        "Running Clean, Build, and Run Tasks",
      ],
      "dependsOrder": "sequence",
      "dependsOn": [
        "Clean",
        "Build",
        "Run"
      ]
    },{
      "label": "Clean",
      "type": "shell",
      "group": "build",
      "command": "rm",
      "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "shared",
      },
      "args": [
        "-rf",
        "${workspaceRoot}/out",
      ],
    },{
      "label": "Build",
      "type": "shell",
      "group": "build",
      "command": "${config:processing.path}",
      "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "shared",
      },
      "args": [
	    	"--force",
	    	"--sketch=${workspaceRoot}",
	    	"--output=${workspaceRoot}/out",
        "--export"
	    ],
    },{
      "label": "Run",
      "type": "shell",
      "group": "build",
      "command": "${workspaceRoot}/out/${workspaceFolderBasename}",
      "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "shared",
      },
      "args": [
        "512",
        "512",
      ]
    }
  ]
}

```

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [July 28, 2019, 6:53pm UTC](https://discourse.processing.org/t/solved-command-line-arguments-width-and-height/12985/2 "2019-07-28T18:53:02Z")

</div>

Thanks for sharing this!

Some previous related discussions for earlier versions from 2017 and 2016:

- [https://forum.processing.org/two/discussion/6457/how-to-use-arguments-with-an-application-built-with-processing](https://forum.processing.org/two/discussion/6457/how-to-use-arguments-with-an-application-built-with-processing)
- [https://forum.processing.org/two/discussion/16463/command-line-arguments-in-3-0-2](https://forum.processing.org/two/discussion/16463/command-line-arguments-in-3-0-2)
