# Why can't I use the back button in state 2?

**URL:** https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360
**Category:** Coding Questions
**Created:** [March 3, 2020, 7:00pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360 "2020-03-03T19:00:49Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)
#### Post date: [March 3, 2020, 7:00pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/1 "2020-03-03T19:00:49Z")

</div>

I want to go back to start 0 when I’m in start 2, why is that not possible?

Code:👇

```auto
float mainx1 = 300;
float mainy1 = 400;
float mainw1 = 500;
float mainh1 = 250;
float mainx2 = 900;
float mainy2 = 400;
float mainw2 = 500;
float mainh2 = 250;
float bx = 100;
float by = 100;
float bw = 50;
float bh = 50;
int start = 0;
int sekunde;
int minute;
int stunde;
int tag;
int monat;
int yahr;

void update(){
  sekunde = second();
  minute = minute();
  stunde = hour();
  tag = day();
  monat = month();
  yahr = year();
}

void setup(){
  orientation(LANDSCAPE);
  fullScreen();
  frameRate(90);
}
  
void draw(){
  if(start==0){
    background(0);
    fill(255);
    rect(mainx1,mainy1,mainw1,mainh1);
    rect(mainx2,mainy2,mainw2,mainh2);
    if(mousePressed){
      if(mouseX>mainx1 && mouseX <mainx1+mainw1 && mouseY>mainy1 && mouseY <mainy1+mainh1){
        delay(1000);
        start = 2;
      }
    }
    if(mousePressed){
      if(mouseX>mainx2 && mouseX <mainx2+mainw2 && mouseY>mainy2 && mouseY <mainy2+mainh2){
        delay(1000);
        start = 1;
      }
    }
  if(start == 2){
    background(0);
    rect(bx, by, bw, bh);
    textSize(50);
    text("Fenster2", 500, 500);
    if(mousePressed){
      if(mouseX>bx && mouseX <bx+bw && mouseY>by && mouseY <by+bh){
        print("lol");
      }
    }
  }
  if(start == 1){
    background(0);
    update();
    textSize(200);
    String s = String.valueOf(tag);
    fill(#FFFFFF);
    update();
    text(s, 750, 450);
    text(".", 850, 450);
    s = String.valueOf(monat);
    update();
    text(s, 900, 450);
    text(".", 1000, 450);
    s = String.valueOf(yahr);
    update();
    text(s, 1050, 450);
    textSize(75);
    s = String.valueOf(sekunde);
    update();
    text(":", 1157, 595);
    text(s, 1175, 600);
      if(sekunde<10){
        fill(0);
        rect(1175, 540, 90, 70);
        fill(#FFFFFF);
        text("0", 1175, 600);
        text(s, 1220, 600); 
    }
    s = String.valueOf(minute);
    update();
    text(s, 1075, 600);
    text(":", 1055, 595);
    s = String.valueOf(stunde);
    update();
    text(s, 975, 600);
    update();
    orientation(LANDSCAPE);
    }
  }
}

```

---

<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: [March 3, 2020, 7:07pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/2 "2020-03-03T19:07:30Z")

</div>

first don’t use mousePressed as a variable, use it as a function mousePressed(); the difference is in the brackets() - see reference

second:

```auto
if(start==0){
........
if(start == 2){
...........

```

better make if…else if…else if… for the entire things

```auto
if(start==0){
........
}else if(start == 2){
...........
}

```

---

<div class="post-metadata">

### Author: ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)
#### Post date: [March 3, 2020, 7:31pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/3 "2020-03-03T19:31:26Z")

</div>

I dont understand this i started processing a week ago can you send me this code?😅❤

Pls

---

<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: [March 3, 2020, 7:32pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/4 "2020-03-03T19:32:54Z")

</div>

Welcome to processing!

Please show your attempt as code

---

<div class="post-metadata">

### Author: ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)
#### Post date: [March 3, 2020, 7:33pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/5 "2020-03-03T19:33:59Z")

</div>

I come in the 2 but I can not click on the back bottun😅

---

<div class="post-metadata">

### Author: ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)
#### Post date: [March 3, 2020, 7:34pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/6 "2020-03-03T19:34:44Z")

</div>

Okey wait 2 Minute​:joy:😂😂

---

<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: [March 3, 2020, 7:34pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/7 "2020-03-03T19:34:56Z")

</div>

Überprüfe bitte, wo diese Klammern { wieder geschlossen werden:

Ist das richtig so?

```auto
void draw() {
  
  if (start==0) {

```

---

<div class="post-metadata">

### Author: ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)
#### Post date: [March 3, 2020, 7:37pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/8 "2020-03-03T19:37:41Z")

</div>

Can you speak german?

---

<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: [March 3, 2020, 7:37pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/9 "2020-03-03T19:37:52Z")

</div>

> [@MonteliaRO](#):
>
> I want to go back to start 0 when I’m in start 2

where do you think do you say start=0; ?

Ich spreche auch Deutsch

---

<div class="post-metadata">

### Author: ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)
#### Post date: [March 3, 2020, 7:39pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/10 "2020-03-03T19:39:34Z")

</div>

Okey gut also ich will das so machen ich öffne das Programm bin in dem Fenster “start 0” dann klicke ich auf das rechte fenster womit ich “start 2” öffne und wenn ich in start 2 bin will ich ein bottun machen womit ich wieder in das Auswahl fenster komme aber wenn ich das mache und da drauf drücke dann passiert nix

Edit: es ist schwer zu erklären

---

<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: [March 3, 2020, 7:42pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/11 "2020-03-03T19:42:40Z")

</div>

I see that you give the seconds a leading zero  
(like 03 instead of 3)

you can just say String sa = nf(seconds(), 2);

---

<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: [March 3, 2020, 7:43pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/12 "2020-03-03T19:43:17Z")

</div>

where do you think do you say `start=0;` ? Because that’s “go back to start 0”.

you just print lol !!!

---

<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: [March 3, 2020, 7:45pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/13 "2020-03-03T19:45:13Z")

</div>

statt einzelne text()

```auto
    text(s, 750, 450);
    text(".", 850, 450);

```

kannst du sagen

`text(s + ".", 750, 450);`

---

<div class="post-metadata">

### Author: ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)
#### Post date: [March 3, 2020, 7:46pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/14 "2020-03-03T19:46:12Z")

</div>

Ich schreib das wie ich es meine

---

<div class="post-metadata">

### Author: ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)
#### Post date: [March 3, 2020, 7:48pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/15 "2020-03-03T19:48:24Z")

</div>

So meine ich das😂

```auto
float mainx1 = 300;
float mainy1 = 400;
float mainw1 = 500;
float mainh1 = 250;
float mainx2 = 900;
float mainy2 = 400;
float mainw2 = 500;
float mainh2 = 250;
float bx = 100;
float by = 100;
float bw = 50;
float bh = 50;
int start = 0;
int sekunde;
int minute;
int stunde;
int tag;
int monat;
int yahr;

void update(){
  sekunde = second();
  minute = minute();
  stunde = hour();
  tag = day();
  monat = month();
  yahr = year();
}

void setup(){
  orientation(LANDSCAPE);
  fullScreen();
  frameRate(90);
}
  
void draw(){
  if(start==0){
    background(0);
    fill(255);
    rect(mainx1,mainy1,mainw1,mainh1);
    rect(mainx2,mainy2,mainw2,mainh2);
    if(mousePressed){
      if(mouseX>mainx1 && mouseX <mainx1+mainw1 && mouseY>mainy1 && mouseY <mainy1+mainh1){
        delay(1000);
        start = 2;
      }
    }
    if(mousePressed){
      if(mouseX>mainx2 && mouseX <mainx2+mainw2 && mouseY>mainy2 && mouseY <mainy2+mainh2){
        delay(1000);
        start = 1;
      }
    }

  if(start == 2){
    background(0);
    rect(bx, by, bw, bh);
    textSize(50);
    text("Fenster2", 500, 500);
    if(mousePressed){
      if(mouseX>bx && mouseX <bx+bw && mouseY>by && mouseY <by+bh){
        delay(500);
        start = 0;
        background(0);
      }
    }

  }
  if(start == 1){
    background(0);
    update();
    textSize(200);
    String s = String.valueOf(tag);
    fill(#FFFFFF);
    update();
    text(s, 750, 450);
    text(".", 850, 450);
    s = String.valueOf(monat);
    update();
    text(s, 900, 450);
    text(".", 1000, 450);
    s = String.valueOf(yahr);
    update();
    text(s, 1050, 450);
    textSize(75);
    s = String.valueOf(sekunde);
    update();
    text(":", 1157, 595);
    text(s, 1175, 600);
      if(sekunde<10){
        fill(0);
        rect(1175, 540, 90, 70);
        fill(#FFFFFF);
        text("0", 1175, 600);
        text(s, 1220, 600); 
    }
    s = String.valueOf(minute);
    update();
    text(s, 1075, 600);
    text(":", 1055, 595);
    s = String.valueOf(stunde);
    update();
    text(s, 975, 600);
    update();
    orientation(LANDSCAPE);
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)
#### Post date: [March 3, 2020, 7:49pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/16 "2020-03-03T19:49:35Z")

</div>

Echt danke das du mir hilfst☺

---

<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: [March 3, 2020, 7:53pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/17 "2020-03-03T19:53:26Z")

</div>

nochmal:

wo schließt diese geschweifte Klammer { von ` if (start==0) {` ?

Du kannst es sehen, wenn du den cursor direkt neben die Klammer platzierst,  
dann leuchtet die dazugehörige schließende Klammer } auf!!!

Ist es die richtige Klammer???

Oder hast du die Klamer } falsch gesetzt???

---

<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: [March 3, 2020, 7:56pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/18 "2020-03-03T19:56:43Z")

</div>

yahr schreibt man Jahr

delay(1000); würde ich löschen

---

<div class="post-metadata">

### Author: ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)
#### Post date: [March 3, 2020, 7:58pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/19 "2020-03-03T19:58:10Z")

</div>

Die Klammer ist die ganze vorletzte im code

---

<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: [March 3, 2020, 7:58pm UTC](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360/20 "2020-03-03T19:58:49Z")

</div>

Aha!

Ist das falsch oder richtig??

Wenn falsch: löschen und statt dessen eine neue } an der richtigen Stelle setzen.

[Next page](https://discourse.processing.org/t/why-cant-i-use-the-back-button-in-state-2/18360.md?page=2)
