# Removing first entry when next enters

**URL:** <https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963>\
**Category:** Libraries\
**Created:** [January 8, 2020, 5:30pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963 "2020-01-08T17:30:38Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanoevelenstef](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@vanoevelenstef](https://discourse.processing.org/u/vanoevelenstef)\
**Post date:** [January 8, 2020, 5:30pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/1 "2020-01-08T17:30:38Z")

</div>

I’ve this code that lets you type words when keypressed but it only shows one word at the time. I want it to show multiply words (lets say 20) at the time and when word 21 is entered, the first word gets deleted and word 21 becomes 20, and so on and on.

Could somebody help me please? I don’t want to change the way I’ve coded the keys since I need it this way. Thanks in advance! Below is my code!

```auto
PFont font;

String myText = "Testing part"; // Starting Text, is only vissable once pressed

String aKPInput = "Medium"; // Input Key : A
String bKPInput = "Is"; // Input Key : B
String cKPInput = "The"; // Input Key : C
String dKPInput = "Message"; // Input Key : D
String eKPInput = "Conversation"; // Input Key : E
String fKPInput = "On"; // Input Key : F
String gKPInput = "We"; // Input Key : G
String hKPInput = "Contact"; // Input Key : H
String iKPInput = "Greenlight"; // Input Key : I
String jKPInput = "Processing"; // Input Key : J
String kKPInput = "Fake News"; // Input Key : K
String lKPInput = "Networking"; // Input Key : L
String mKPInput = "Enlightment"; // Input Key : M
String nKPInput = "Are"; // Input Key : N
String oKPInput = "Concept"; // Input Key : O
String pKPInput = "MAP"; // Input Key : P
String qKPInput = "Walking"; // Input Key : Q
String rKPInput = "Sunshine"; // Input Key : R
String sKPInput = "Greyscale"; // Input Key : S
String tKPInput = "Who"; // Input Key : T
String uKPInput = "Questionmark"; // Input Key : U
String vKPInput = "Probably"; // Input Key : V
String wKPInput = "And"; // Input Key : W
String xKPInput = "I"; // Input Key : X
String yKPInput = "Like"; // Input Key : Y
String zKPInput = "Big Butts"; // Input Key : Z

void setup() {
  size(1280, 720);
  font = createFont("Sans Serif", 80);
  textFont(font, 120);
  textAlign(CENTER, CENTER);
}

void draw() {
  background(0);
  // for (int i = 0; i < wordsDisplay; i++) {
  text(myText, 0, 0, width, height);
  // }
}

void keyPressed() {

  switch(key) {
  case 'a': // KEYBOARD A 
    myText = aKPInput;
    break;
  case 'b': // KEYBOARD B
    myText = bKPInput;
    break;
  case 'c': // KEYBOARD C 
    myText = cKPInput;
    break;
  case 'd': // KEYBOARD D 
    myText = dKPInput;
    break;
  case 'e': // KEYBOARD E 
    myText = eKPInput;
    break;
  case 'f': // KEYBOARD F
    myText = fKPInput;
    break;
  case 'g': // KEYBOARD G
    myText = gKPInput;
    break; 
  case 'h': // KEYBOARD H 
    myText = hKPInput;
    break;
  case 'i': // KEYBOARD I 
    myText = iKPInput;
    break; 
  case 'j': // KEYBOARD J 
    myText = jKPInput;
    break; 
  case 'k': // KEYBOARD K 
    myText = kKPInput;
    break;
  case 'l': // KEYBOARD L 
    myText = lKPInput;
    break;
  case 'm': // KEYBOARD M 
    myText = mKPInput;
    break;
  case 'n': // KEYBOARD N 
    myText = nKPInput;
    break;
  case 'o': // KEYBOARD O
    myText = oKPInput;
    break;
  case 'p': // KEYBOARD P
    myText = pKPInput;
    break;
  case 'q': // KEYBOARD Q 
    myText = qKPInput;
    break;
  case 'r': // KEYBOARD R 
    myText = rKPInput;
    break;
  case 's': // KEYBOARD S
    myText = sKPInput;
    break;
  case 't': // KEYBOARD T 
    myText = tKPInput;
    break;
  case 'u': // KEYBOARD U 
    myText = uKPInput;
    break;
  case 'v': // KEYBOARD V
    myText = vKPInput;
    break;
  case 'w': // KEYBOARD W 
    myText = wKPInput;
    break;
  case 'x': // KEYBOARD X 
    myText = xKPInput;
    break;
  case 'y': // KEYBOARD Y 
    myText = yKPInput;
    break;
  case 'z': // KEYBOARD Z 
    myText = zKPInput;
    break;
  }
}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 8, 2020, 6:58pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/2 "2020-01-08T18:58:13Z")

</div>

You can add myText to an arraylist.

When it reaches 20 (size()) for loop over it with i \< size()-2 (!!!)

a1.set(i) = a1.get(i+1);

---

<div class="post-metadata">

**Author:** ![vanoevelenstef](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@vanoevelenstef](https://discourse.processing.org/u/vanoevelenstef)\
**Post date:** [January 8, 2020, 7:43pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/3 "2020-01-08T19:43:27Z")

</div>

I never worked with an arraylist before. Could you suggest code please?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 8, 2020, 7:53pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/4 "2020-01-08T19:53:13Z")

</div>

See reference for Arraylist

You can also use array

---

<div class="post-metadata">

**Author:** ![vanoevelenstef](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@vanoevelenstef](https://discourse.processing.org/u/vanoevelenstef)\
**Post date:** [January 8, 2020, 8:17pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/5 "2020-01-08T20:17:07Z")

</div>

yeah sorry man. Realy sorry but I don’t understand anything of what you mean. I’m reading and watching videos about arraylists and how they work but can’t figure it out what you mean by (size)) and a1.set(i) …

It’s stupid to place my wrong codes that I’ve tried but honestly, I don’t understand it and I can’t figure it out.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 9, 2020, 12:28pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/6 "2020-01-09T12:28:23Z")

</div>

here it is (with array)

```auto

PFont font;

String[] wordsDisplay=new String[20];
int addIndex=0;
boolean firsttime=true; 

// -----------------------------------------------------------------------------

void setup() {
  size(1280, 720);
  font = createFont("Sans Serif", 17);
  textFont(font, 17);
  //textAlign(LEFT);
}

void draw() {
  background(0);
  for (int i = 0; i < wordsDisplay.length; i++) {
    if (wordsDisplay[i]!=null)
      text(wordsDisplay[i], 
        44, 44+i*19);
  }
}

//---------------------------------------------------------------------------

void keyPressed() {

  String myText = "Testing part"; // Starting Text, is only vissable once pressed

  String aKPInput = "Medium"; // Input Key : A
  String bKPInput = "Is"; // Input Key : B
  String cKPInput = "The"; // Input Key : C
  String dKPInput = "Message"; // Input Key : D
  String eKPInput = "Conversation"; // Input Key : E
  String fKPInput = "On"; // Input Key : F
  String gKPInput = "We"; // Input Key : G
  String hKPInput = "Contact"; // Input Key : H
  String iKPInput = "Greenlight"; // Input Key : I
  String jKPInput = "Processing"; // Input Key : J
  String kKPInput = "Fake News"; // Input Key : K
  String lKPInput = "Networking"; // Input Key : L
  String mKPInput = "Enlightment"; // Input Key : M
  String nKPInput = "Are"; // Input Key : N
  String oKPInput = "Concept"; // Input Key : O
  String pKPInput = "MAP"; // Input Key : P
  String qKPInput = "Walking"; // Input Key : Q
  String rKPInput = "Sunshine"; // Input Key : R
  String sKPInput = "Greyscale"; // Input Key : S
  String tKPInput = "Who"; // Input Key : T
  String uKPInput = "Questionmark"; // Input Key : U
  String vKPInput = "Probably"; // Input Key : V
  String wKPInput = "And"; // Input Key : W
  String xKPInput = "I"; // Input Key : X
  String yKPInput = "Like"; // Input Key : Y
  String zKPInput = "Big Butts"; // Input Key : Z

  switch(key) {
    //
  case 'a': // KEYBOARD A 
    myText = aKPInput;
    break;
  case 'b': // KEYBOARD B
    myText = bKPInput;
    break;
  case 'c': // KEYBOARD C 
    myText = cKPInput;
    break;
  case 'd': // KEYBOARD D 
    myText = dKPInput;
    break;
  case 'e': // KEYBOARD E 
    myText = eKPInput;
    break;
  case 'f': // KEYBOARD F
    myText = fKPInput;
    break;
  case 'g': // KEYBOARD G
    myText = gKPInput;
    break; 
  case 'h': // KEYBOARD H 
    myText = hKPInput;
    break;
  case 'i': // KEYBOARD I 
    myText = iKPInput;
    break; 
  case 'j': // KEYBOARD J 
    myText = jKPInput;
    break; 
  case 'k': // KEYBOARD K 
    myText = kKPInput;
    break;
  case 'l': // KEYBOARD L 
    myText = lKPInput;
    break;
  case 'm': // KEYBOARD M 
    myText = mKPInput;
    break;
  case 'n': // KEYBOARD N 
    myText = nKPInput;
    break;
  case 'o': // KEYBOARD O
    myText = oKPInput;
    break;
  case 'p': // KEYBOARD P
    myText = pKPInput;
    break;
  case 'q': // KEYBOARD Q 
    myText = qKPInput;
    break;
  case 'r': // KEYBOARD R 
    myText = rKPInput;
    break;
  case 's': // KEYBOARD S
    myText = sKPInput;
    break;
  case 't': // KEYBOARD T 
    myText = tKPInput;
    break;
  case 'u': // KEYBOARD U 
    myText = uKPInput;
    break;
  case 'v': // KEYBOARD V
    myText = vKPInput;
    break;
  case 'w': // KEYBOARD W 
    myText = wKPInput;
    break;
  case 'x': // KEYBOARD X 
    myText = xKPInput;
    break;
  case 'y': // KEYBOARD Y 
    myText = yKPInput;
    break;
  case 'z': // KEYBOARD Z 
    myText = zKPInput;
    break;
  }//switch 
  //

  if (addIndex > wordsDisplay.length-1) {
    // list is full - we move each element up before adding a new one at the end

    for (int i=0; i < wordsDisplay.length-1; i++) {  
      wordsDisplay[i] = wordsDisplay[i+1];
    }

    wordsDisplay[wordsDisplay.length-1] = myText;
    //
  } else {
    // list is not yet full
    wordsDisplay[addIndex] = myText; 
    addIndex++;
  }
  //
}//func 
//

```

---

<div class="post-metadata">

**Author:** ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)\
**Post date:** [January 9, 2020, 12:31pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/7 "2020-01-09T12:31:10Z")

</div>

If you feel like `Arraylist` is a bit overwhelming, it might be easier to start with [arrays](https://processing.org/reference/Array.html) instead. Once you get the hang of that you could take another look at `Arraylist`, because it might be better suited for your situation.

You could see an array as a variable that holds multiple variable values. If we look at the first example on the page I linked just now, it’s similar to:

```auto
int number1 = 90;
int number2 = 150;
int number3 = 30;
int a = number1 + number2;
int b = number2 + number3;

```

In your case you have value for each letter in the alphabet, meaning you need an array size of 26 slots. You could appoint the value of letter `a` to the first slot, the value of `b` to the second slot, etcetera, until all the slots in your array are filled.

Using arrays can be handy for many situations. Aside from keeping your data (in your case the words _Medium_, _Is_, _The_, etcetera) compact together, it simplifies certain activities for you. For instance, you can check the length of your array:

```auto
int[] numbers = new int[3];
numbers[0] = 90;
numbers[1] = 150;
numbers[2] = 30;
println(numbers.length);

```

If you would have three separate int variables instead of an array, this functionality wouldn’t be available to you.

Hope that helps you on your way!

**edit**  
Woops, studying @Chrisir his code and I made a mistake about the array size you need. Still hope this post is helpful in some way 🙂

---

<div class="post-metadata">

**Author:** ![vanoevelenstef](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@vanoevelenstef](https://discourse.processing.org/u/vanoevelenstef)\
**Post date:** [January 9, 2020, 12:54pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/8 "2020-01-09T12:54:03Z")

</div>

Thanks man. Wouldn’t have don’t it without you. Thanks man!

---

<div class="post-metadata">

**Author:** ![vanoevelenstef](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@vanoevelenstef](https://discourse.processing.org/u/vanoevelenstef)\
**Post date:** [January 9, 2020, 6:36pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/9 "2020-01-09T18:36:49Z")

</div>

I tried to implement the changes you send my in pm:  
Atm it only speaks one word at the time, but not the complete array. It also doesn’t have a delay yet.

This is the code so far:

```auto
PFont font;
import guru.ttslib.*;
TTS tts;

String[] wordsDisplay=new String[20];
int addIndex=0;
boolean firsttime=true; 

String myText = "Testing part"; // Starting Text, is only vissable once pressed

// -----------------------------------------------------------------------------

void setup() {
  size(1280, 720);
  font = createFont("Sans Serif", 17);
  textFont(font, 17);
  //textAlign(LEFT);
    tts = new TTS();
}

void draw() {
  background(0);
  for (int i = 0; i < wordsDisplay.length; i++) {
    if (wordsDisplay[i]!=null)
      text(wordsDisplay[i], 
        44, 44+i*19);
  }
  for (int i = 0; i < 2; i = i+1) {
 tts.speak(myText);
  println("Word " + myText + " is being spoken");}
}

//---------------------------------------------------------------------------

void keyPressed() {

  String aKPInput = "Medium"; // Input Key : A
  String bKPInput = "Is"; // Input Key : B
  String cKPInput = "The"; // Input Key : C
  String dKPInput = "Message"; // Input Key : D
  String eKPInput = "Conversation"; // Input Key : E
  String fKPInput = "On"; // Input Key : F
  String gKPInput = "We"; // Input Key : G
  String hKPInput = "Contact"; // Input Key : H
  String iKPInput = "Greenlight"; // Input Key : I
  String jKPInput = "Processing"; // Input Key : J
  String kKPInput = "Fake News"; // Input Key : K
  String lKPInput = "Networking"; // Input Key : L
  String mKPInput = "Enlightment"; // Input Key : M
  String nKPInput = "Are"; // Input Key : N
  String oKPInput = "Concept"; // Input Key : O
  String pKPInput = "MAP"; // Input Key : P
  String qKPInput = "Walking"; // Input Key : Q
  String rKPInput = "Sunshine"; // Input Key : R
  String sKPInput = "Greyscale"; // Input Key : S
  String tKPInput = "Who"; // Input Key : T
  String uKPInput = "Questionmark"; // Input Key : U
  String vKPInput = "Probably"; // Input Key : V
  String wKPInput = "And"; // Input Key : W
  String xKPInput = "I"; // Input Key : X
  String yKPInput = "Like"; // Input Key : Y
  String zKPInput = "Big Butts"; // Input Key : Z

  switch(key) {
    //
  case 'a': // KEYBOARD A 
    myText = aKPInput;
    break;
  case 'b': // KEYBOARD B
    myText = bKPInput;
    break;
  case 'c': // KEYBOARD C 
    myText = cKPInput;
    break;
  case 'd': // KEYBOARD D 
    myText = dKPInput;
    break;
  case 'e': // KEYBOARD E 
    myText = eKPInput;
    break;
  case 'f': // KEYBOARD F
    myText = fKPInput;
    break;
  case 'g': // KEYBOARD G
    myText = gKPInput;
    break; 
  case 'h': // KEYBOARD H 
    myText = hKPInput;
    break;
  case 'i': // KEYBOARD I 
    myText = iKPInput;
    break; 
  case 'j': // KEYBOARD J 
    myText = jKPInput;
    break; 
  case 'k': // KEYBOARD K 
    myText = kKPInput;
    break;
  case 'l': // KEYBOARD L 
    myText = lKPInput;
    break;
  case 'm': // KEYBOARD M 
    myText = mKPInput;
    break;
  case 'n': // KEYBOARD N 
    myText = nKPInput;
    break;
  case 'o': // KEYBOARD O
    myText = oKPInput;
    break;
  case 'p': // KEYBOARD P
    myText = pKPInput;
    break;
  case 'q': // KEYBOARD Q 
    myText = qKPInput;
    break;
  case 'r': // KEYBOARD R 
    myText = rKPInput;
    break;
  case 's': // KEYBOARD S
    myText = sKPInput;
    break;
  case 't': // KEYBOARD T 
    myText = tKPInput;
    break;
  case 'u': // KEYBOARD U 
    myText = uKPInput;
    break;
  case 'v': // KEYBOARD V
    myText = vKPInput;
    break;
  case 'w': // KEYBOARD W 
    myText = wKPInput;
    break;
  case 'x': // KEYBOARD X 
    myText = xKPInput;
    break;
  case 'y': // KEYBOARD Y 
    myText = yKPInput;
    break;
  case 'z': // KEYBOARD Z 
    myText = zKPInput;
    break;
  }//switch 
  //

  if (addIndex > wordsDisplay.length-1) {
    // list is full - we move each element up before adding a new one at the end

    for (int i=0; i < wordsDisplay.length-1; i++) {  
      wordsDisplay[i] = wordsDisplay[i+1];
    }

    wordsDisplay[wordsDisplay.length-1] = myText;
    //
  } else {
    // list is not yet full
    wordsDisplay[addIndex] = myText; 
    addIndex++;
  }
  //
}//func 
//

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 9, 2020, 6:59pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/10 "2020-01-09T18:59:46Z")

</div>

Question:

- Did you do a research whether we can ask tts if it’s still speaking?

my version:

speaks when a new word is added (see `keyPressed()`)

Chrisir

```auto

PFont font;
import guru.ttslib.*;
TTS tts;

String[] wordsDisplay=new String[20];
int addIndex=0;
boolean firsttime=true; 

String myText = "Testing part"; // Starting Text, is only vissable once pressed

// -----------------------------------------------------------------------------

void setup() {
  size(1280, 720);
  font = createFont("Sans Serif", 17);
  textFont(font, 17);
  //textAlign(LEFT);
  tts = new TTS();
}

void draw() {
  background(0);
  for (int i = 0; i < wordsDisplay.length; i++) {
    if (wordsDisplay[i]!=null)
      text(wordsDisplay[i], 
        44, 44+i*19);
  }//for
}

//---------------------------------------------------------------------------

void keyPressed() {

  String aKPInput = "Medium"; // Input Key : A
  String bKPInput = "Is"; // Input Key : B
  String cKPInput = "The"; // Input Key : C
  String dKPInput = "Message"; // Input Key : D
  String eKPInput = "Conversation"; // Input Key : E
  String fKPInput = "On"; // Input Key : F
  String gKPInput = "We"; // Input Key : G
  String hKPInput = "Contact"; // Input Key : H
  String iKPInput = "Greenlight"; // Input Key : I
  String jKPInput = "Processing"; // Input Key : J
  String kKPInput = "Fake News"; // Input Key : K
  String lKPInput = "Networking"; // Input Key : L
  String mKPInput = "Enlightment"; // Input Key : M
  String nKPInput = "Are"; // Input Key : N
  String oKPInput = "Concept"; // Input Key : O
  String pKPInput = "MAP"; // Input Key : P
  String qKPInput = "Walking"; // Input Key : Q
  String rKPInput = "Sunshine"; // Input Key : R
  String sKPInput = "Greyscale"; // Input Key : S
  String tKPInput = "Who"; // Input Key : T
  String uKPInput = "Questionmark"; // Input Key : U
  String vKPInput = "Probably"; // Input Key : V
  String wKPInput = "And"; // Input Key : W
  String xKPInput = "I"; // Input Key : X
  String yKPInput = "Like"; // Input Key : Y
  String zKPInput = "Big Butts"; // Input Key : Z

  switch(key) {
    //
  case 'a': // KEYBOARD A 
    myText = aKPInput;
    break;
  case 'b': // KEYBOARD B
    myText = bKPInput;
    break;
  case 'c': // KEYBOARD C 
    myText = cKPInput;
    break;
  case 'd': // KEYBOARD D 
    myText = dKPInput;
    break;
  case 'e': // KEYBOARD E 
    myText = eKPInput;
    break;
  case 'f': // KEYBOARD F
    myText = fKPInput;
    break;
  case 'g': // KEYBOARD G
    myText = gKPInput;
    break; 
  case 'h': // KEYBOARD H 
    myText = hKPInput;
    break;
  case 'i': // KEYBOARD I 
    myText = iKPInput;
    break; 
  case 'j': // KEYBOARD J 
    myText = jKPInput;
    break; 
  case 'k': // KEYBOARD K 
    myText = kKPInput;
    break;
  case 'l': // KEYBOARD L 
    myText = lKPInput;
    break;
  case 'm': // KEYBOARD M 
    myText = mKPInput;
    break;
  case 'n': // KEYBOARD N 
    myText = nKPInput;
    break;
  case 'o': // KEYBOARD O
    myText = oKPInput;
    break;
  case 'p': // KEYBOARD P
    myText = pKPInput;
    break;
  case 'q': // KEYBOARD Q 
    myText = qKPInput;
    break;
  case 'r': // KEYBOARD R 
    myText = rKPInput;
    break;
  case 's': // KEYBOARD S
    myText = sKPInput;
    break;
  case 't': // KEYBOARD T 
    myText = tKPInput;
    break;
  case 'u': // KEYBOARD U 
    myText = uKPInput;
    break;
  case 'v': // KEYBOARD V
    myText = vKPInput;
    break;
  case 'w': // KEYBOARD W 
    myText = wKPInput;
    break;
  case 'x': // KEYBOARD X 
    myText = xKPInput;
    break;
  case 'y': // KEYBOARD Y 
    myText = yKPInput;
    break;
  case 'z': // KEYBOARD Z 
    myText = zKPInput;
    break;
  }//switch 
  //

  // speak new word 
  tts.speak(myText);
  println("Word " + myText + " is being spoken");

  // add word to list 
  if (addIndex > wordsDisplay.length-1) {
    // list is full - we move each element up before adding a new one at the end

    for (int i=0; i < wordsDisplay.length-1; i++) {  
      wordsDisplay[i] = wordsDisplay[i+1];
    }

    wordsDisplay[wordsDisplay.length-1] = myText;
    //
  } else {
    // list is not yet full
    wordsDisplay[addIndex] = myText; 
    addIndex++;
  }
  //
}//func 
//

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 9, 2020, 7:02pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/11 "2020-01-09T19:02:37Z")

</div>

this above version speaks the word as soon as it is entered

do you want this?

Or do you want the entire list to be spoken on and on?

---

<div class="post-metadata">

**Author:** ![vanoevelenstef](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@vanoevelenstef](https://discourse.processing.org/u/vanoevelenstef)\
**Post date:** [January 9, 2020, 7:16pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/12 "2020-01-09T19:16:22Z")

</div>

The entire list to be spoken on and on. And when entering a new word, pause for a second to start looping again so this way the system couldn’t be overrun.

So when no key has been pressed for 3 seconds, then start entire list to be spoken on and on again. Is that possible?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 9, 2020, 7:37pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/13 "2020-01-09T19:37:58Z")

</div>

Possible

I don’t have time

but for speaking the list try

in draw

```auto
 // speak new word 
  tts.speak( wordsDisplay[i_speak] );
  println("Word " 
  + wordsDisplay[i_speak]
  + " is being spoken");

if(!tts.isSpeaking())
    i_speak++; 

```

and before setup()

` int i_speak=0;`

---

<div class="post-metadata">

**Author:** ![vanoevelenstef](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@vanoevelenstef](https://discourse.processing.org/u/vanoevelenstef)\
**Post date:** [January 9, 2020, 7:46pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/14 "2020-01-09T19:46:10Z")

</div>

isSpeaking doesn’t exist so this don’t work :s

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 9, 2020, 8:03pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/15 "2020-01-09T20:03:37Z")

</div>

do research please, if there is another possibility

otherwise, just do a timer and if it’s applies:

```auto
    i_speak++; 

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 10, 2020, 8:56pm UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/16 "2020-01-10T20:56:19Z")

</div>

see here

[https://www.local-guru.net/blog/pages/ttslib](https://www.local-guru.net/blog/pages/ttslib)

I haven’t found something like isStillSpeaking()

I think though, it’s queuing the text automatically internally.

So texts spoken won’t overlap

---

<div class="post-metadata">

**Author:** ![vanoevelenstef](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@vanoevelenstef](https://discourse.processing.org/u/vanoevelenstef)\
**Post date:** [January 13, 2020, 8:11am UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/17 "2020-01-13T08:11:37Z")

</div>

I haven’t figured it out how to speak the how list at once over and over again. I don’t get the I\_speak++; like you suggested implemented in the code :s Any suggestions still left?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 13, 2020, 9:16am UTC](https://discourse.processing.org/t/removing-first-entry-when-next-enters/16963/18 "2020-01-13T09:16:16Z")

</div>

how about a restart timer with some estimated settings

```auto
import guru.ttslib.*;
StereoAudioPlayer sound; // unused interface

String[] words = {"Hi!","I","am","a","speaking","Processing","sketch"};
TTS tts = new TTS();

long ts,tm; // ______________________ repeat timer

void setup() {
  tts.setPitch( 350 );
  tts.setPitchRange( 50 );
  tts.setPitchShift( 0.5 );
  tm = words.length * 500+2000; //__ 2 words per sec + delay ??
  ts = millis(); // _________________ timer init
}

void draw() {
  timer(); // _______________________ timer check / call
}

void speak() { // ___________________ make text to speak and talk
  String tspeak = "";
  for (int i = 0; i< words.length; i++) tspeak += " "+words[i];
  println(tspeak);
  tts.speak(tspeak);  
}

void timer() { // ___________________ timer function
  if ( millis() > ts + tm ) {
    ts += tm; // restart
    println("_tevent");
    speak(); 
  }
}

```
