# I am trying to input a couple of variables at the sketch startup

**URL:** https://discourse.processing.org/t/i-am-trying-to-input-a-couple-of-variables-at-the-sketch-startup/35558
**Category:** Coding Questions
**Created:** [March 4, 2022, 4:56pm UTC](https://discourse.processing.org/t/i-am-trying-to-input-a-couple-of-variables-at-the-sketch-startup/35558 "2022-03-04T16:56:17Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [March 4, 2022, 11:09pm UTC](https://discourse.processing.org/t/i-am-trying-to-input-a-couple-of-variables-at-the-sketch-startup/35558/2 "2022-03-04T23:09:27Z")

</div>

Hello @laptophead,

A simple example:

```auto
// Set Initial Value
// v1.0.0
// GLV 2022-03-04

int value;

boolean set; //default is false

void setup()
  {
  size(100, 100);
  textAlign(CENTER, CENTER);
  textSize(48);  
  }
  
void draw()
  {
  background(0);  
  
  // if set = false
  if (!set)
    {
    fill(0, 255, 0);  
    textSize(48);  
    text(value, width/2, height/2-10);
    return;
    }
    
  // while set = true  
  fill(255, 0, 0);
  text(value, width/2, height/2-10);  
  }    
  
void keyPressed()
  {
  if(!set)
    {
    if (key == '+')
      value++;
    if (key == '-')
      value--;
    value = constrain(value, -10, 10);  
    println(value); 
    if (key == 's') 
      set = true;
    }    
  }

```

This is useful for a small range of numbers…

There is also:

> [@Open console instead of window](https://discourse.processing.org/t/open-console-instead-of-window/31040/8):
>
> Hello, There is always javax.swing.JOptionPane for simple IO: import javax.swing.JOptionPane; int col; void setup() { } void draw() { background(col); } void keyPressed() { thread("MessageDialog\_thread"); } void MessageDialog\_thread() { String strInp = JOptionPane.showInputDialog(null,"Enter a color 0 to 255:"); col = int(strInp); JOptionPane.showMessageDialog(null, col, "Output", JOptionPane.PLAIN\_MESSAGE); }slight_smile

And lots of other options out there…

Have fun!

`:)`

---

_[View the full topic](https://discourse.processing.org/t/i-am-trying-to-input-a-couple-of-variables-at-the-sketch-startup/35558)._
