# Array input field

**URL:** https://discourse.processing.org/t/array-input-field/12266
**Category:** Libraries
**Created:** [June 24, 2019, 2:28pm UTC](https://discourse.processing.org/t/array-input-field/12266 "2019-06-24T14:28:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![FlameOfPhoenix](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@FlameOfPhoenix](https://discourse.processing.org/u/FlameOfPhoenix)
#### Post date: [June 24, 2019, 2:28pm UTC](https://discourse.processing.org/t/array-input-field/12266/1 "2019-06-24T14:28:10Z")

</div>

I have a question about input fields(I’m using the ones from controlp5) and was asking myself if you can have it so, that every entry in that field are integers and also added to an array. Thank you for your help

Edit: As my project is a decoder, it would have to be editable with a keyboard.

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [June 24, 2019, 11:01pm UTC](https://discourse.processing.org/t/array-input-field/12266/2 "2019-06-24T23:01:16Z")

</div>

Hello,

You can use the function `yourString.split("")` to parse the input string of your text field and then convert each string number into integers with `Integer.parseInt(yourString)`.

Here is the complete example (adapted from the `ControlP5 Textfield example`:

```auto
import controlP5.*;
import java.util.Arrays;

ControlP5 cp5;
int[] arrayTextField;

void setup() {
  size(700,400);
  
  PFont font = createFont("arial",30);
  
  cp5 = new ControlP5(this);
  
  cp5.addTextfield("input")
     .setPosition(20,100)
     .setSize(200,40)
     .setFont(font)
     .setFocus(true)
     .setColor(color(255,0,0))
     ;
}

void draw() {
  background(0);
}

public void input(String theText) {
  //Splitting the numbers
  String[] splittedText = theText.split("");
  arrayTextField = new int[splittedText.length];
  
  //Inserting them into the array
  for(int i=0;i<splittedText.length;i++){
    arrayTextField[i] = Integer.parseInt(splittedText[i]);
  }
  
  //Printing the array
  println(Arrays.toString(arrayTextField));
}

```

---

<div class="post-metadata">

### Author: ![InferNova](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/infernova/32/6009_2.png) [@InferNova](https://discourse.processing.org/u/InferNova)
#### Post date: [June 24, 2019, 11:10pm UTC](https://discourse.processing.org/t/array-input-field/12266/3 "2019-06-24T23:10:24Z")

</div>

Hey There!

There are different types that the things can be in the field :  
[http://www.sojamo.com/libraries/controlP5/reference/](http://www.sojamo.com/libraries/controlP5/reference/)

In textfieldInput
