# I need Help with save a int

**URL:** <https://discourse.processing.org/t/i-need-help-with-save-a-int/20934>\
**Category:** Processing for Android\
**Created:** [May 16, 2020, 9:25am UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934 "2020-05-16T09:25:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rogo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rogo/32/12349_2.png) [@Rogo](https://discourse.processing.org/u/Rogo)\
**Post date:** [May 16, 2020, 9:25am UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/1 "2020-05-16T09:25:34Z")

</div>

Hello I wanted to ask how I can Save the int below in the Text because someone has an idea?

```auto
int score = 0;

void setup(){
  orientation(PORTRAIT);
}

void draw(){
  background(0);
  fill(#FFFFFF);
  textSize(75);
  text(score, displayWidth/2, displayHeight/12);
}

void mousePressed(){
  ++score;
  fill(0);
  rect(0, 0, displayWidth, displayHeight);
}

```

---

<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:** [May 16, 2020, 10:03am UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/2 "2020-05-16T10:03:59Z")

</div>

Hello

Do you want to save the score on hard drive and load it next time?

---

<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:** [May 16, 2020, 10:08am UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/3 "2020-05-16T10:08:42Z")

</div>

Hello,

I was not seeing the text in your example until I used:  
fullScreen();

`:)`

---

<div class="post-metadata">

**Author:** ![Rogo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rogo/32/12349_2.png) [@Rogo](https://discourse.processing.org/u/Rogo)\
**Post date:** [May 16, 2020, 10:08am UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/4 "2020-05-16T10:08:43Z")

</div>

Yes! 🙂 …

---

<div class="post-metadata">

**Author:** ![Rogo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rogo/32/12349_2.png) [@Rogo](https://discourse.processing.org/u/Rogo)\
**Post date:** [May 16, 2020, 10:09am UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/5 "2020-05-16T10:09:27Z")

</div>

I added thank you xD\*

---

<div class="post-metadata">

**Author:** ![Rogo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rogo/32/12349_2.png) [@Rogo](https://discourse.processing.org/u/Rogo)\
**Post date:** [May 16, 2020, 10:10am UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/6 "2020-05-16T10:10:08Z")

</div>

and how can I if. the number from 99 to 100 which automatically pushes to the left?

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [May 16, 2020, 10:10am UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/7 "2020-05-16T10:10:10Z")

</div>

@Rogo === supposing that you want to save the last score:

- you create a .text file that you put in your data folder; at this point you write in your text file 0 as the first score;
- when launching the app you get this file and read it with loadStrings();
- when exiting the app you save the new score to the same file (replacing the first one only if the last is \> than the first. This can be done using the onPause();

---

<div class="post-metadata">

**Author:** ![Rogo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rogo/32/12349_2.png) [@Rogo](https://discourse.processing.org/u/Rogo)\
**Post date:** [May 16, 2020, 10:14am UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/8 "2020-05-16T10:14:09Z")

</div>

@akenaton that’s just too much for me i haven’t been programming with processing for long

---

<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:** [May 16, 2020, 10:15am UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/9 "2020-05-16T10:15:52Z")

</div>

> [@Rogo](#):
>
> i haven’t been programming with processing for long

> **Resources \< Click here to expand !**
>
> I encourage you to review the resources available here:
> 
> - The Processing website has references, examples, tutorials, etc.  
> [https://processing.org/](https://processing.org/)
> - Those available with the Processing PDE (IDE).  
> An exploration of the tabs will reveal what is available; there are libraries and examples there.
> - The Coding Train  
> [https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1\_aw](https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1_aw)  
> [https://thecodingtrain.com/](https://thecodingtrain.com/)
> - Happy Coding  
> [Processing Tutorials - Happy Coding](https://happycoding.io/tutorials/processing/)
> - The Processing Foundation  
> [https://processingfoundation.org/](https://processingfoundation.org/)  
> Check out the tabs.  
> In the education tab, there is a reference to the Coding Train.

`:)`

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [May 16, 2020, 10:15am UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/10 "2020-05-16T10:15:57Z")

</div>

@Rogo === that is easy to do; try by yourself, put your code and i can help if needed

---

<div class="post-metadata">

**Author:** ![Rogo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rogo/32/12349_2.png) [@Rogo](https://discourse.processing.org/u/Rogo)\
**Post date:** [May 16, 2020, 10:17am UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/11 "2020-05-16T10:17:24Z")

</div>

Okay thank you 🙂

---

<div class="post-metadata">

**Author:** ![Rogo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rogo/32/12349_2.png) [@Rogo](https://discourse.processing.org/u/Rogo)\
**Post date:** [May 16, 2020, 10:38am UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/12 "2020-05-16T10:38:16Z")

</div>

how can I make the int a string?

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [May 16, 2020, 11:55am UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/13 "2020-05-16T11:55:35Z")

</div>

Type str() in reference.

---

<div class="post-metadata">

**Author:** ![Rogo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rogo/32/12349_2.png) [@Rogo](https://discourse.processing.org/u/Rogo)\
**Post date:** [May 16, 2020, 12:45pm UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/14 "2020-05-16T12:45:45Z")

</div>

My code dont working why?

```auto
int score = 0;

void setup(){
  orientation(PORTRAIT);
  fullScreen();
  score = str(score);
}

void draw(){
  background(0);
  fill(#FFFFFF);
  textSize(75);
  text(score, displayWidth/2.4, displayHeight/12);
}

void mousePressed(){
  ++score;
  redraw();
}

```

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [May 16, 2020, 12:55pm UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/15 "2020-05-16T12:55:33Z")

</div>

You can’t use same name for int AND string.  
Use for instance :  
String score\_str;  
int score\_int;

---

<div class="post-metadata">

**Author:** ![Rogo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rogo/32/12349_2.png) [@Rogo](https://discourse.processing.org/u/Rogo)\
**Post date:** [May 16, 2020, 1:26pm UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/16 "2020-05-16T13:26:41Z")

</div>

Error: 1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/spiel/spiel.java (at line 25)  
score\_int = str(score\_str);

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [May 16, 2020, 1:29pm UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/17 "2020-05-16T13:29:37Z")

</div>

Did you declare the variable “int score\_int;” as global on the top of your sketch?

---

<div class="post-metadata">

**Author:** ![Rogo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rogo/32/12349_2.png) [@Rogo](https://discourse.processing.org/u/Rogo)\
**Post date:** [May 16, 2020, 1:29pm UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/18 "2020-05-16T13:29:55Z")

</div>

🙂 🙂

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [May 16, 2020, 1:41pm UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/19 "2020-05-16T13:41:20Z")

</div>

@Rogo ===

```auto
String score_str;
int score_int;

void setup(){
  orientation(PORTRAIT);
  fullScreen();
  //size(800,1000);
  
}

void draw(){
  background(0);
  fill(#FFFFFF);
  textSize(75);
  score_str = str(score_int);
  text(score_str, displayWidth/2.4, displayHeight/12);
}

void mousePressed(){
  ++score_int;
  redraw();
}

```

---

<div class="post-metadata">

**Author:** ![Rogo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rogo/32/12349_2.png) [@Rogo](https://discourse.processing.org/u/Rogo)\
**Post date:** [May 16, 2020, 1:42pm UTC](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934/20 "2020-05-16T13:42:47Z")

</div>

```auto
String score_str;
int score_int;

void setup(){
  orientation(PORTRAIT);
  fullScreen();
  score_str = str(score_int);
}

void draw(){
  loadStrings("score.txt");
  background(0);
  fill(#FFFFFF);
  textSize(75);
  text(score_int, displayWidth/2.4, displayHeight/12);
}

void mousePressed(){
  ++score_int;
  saveStrings("score.txt", score_str);
  redraw();
}

```

Error: 1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/spiel/spiel.java (at line 38)  
saveStrings(“score.txt”, score\_str);

[Next page](https://discourse.processing.org/t/i-need-help-with-save-a-int/20934.md?page=2)
