# Replace the current text with new text

**URL:** https://discourse.processing.org/t/replace-the-current-text-with-new-text/25565
**Category:** Processing.py
**Created:** [November 20, 2020, 3:01pm UTC](https://discourse.processing.org/t/replace-the-current-text-with-new-text/25565 "2020-11-20T15:01:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![cornedb2](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/cornedb2/32/11142_2.png) [@cornedb2](https://discourse.processing.org/u/cornedb2)
#### Post date: [November 20, 2020, 3:01pm UTC](https://discourse.processing.org/t/replace-the-current-text-with-new-text/25565/1 "2020-11-20T15:01:29Z")

</div>

Hello,

How can I update the current text in the `text()`, now every time it will make a new `text()` element.  
Code:

```auto
x = 0

def setup():
  size(500, 500)

def draw():
  global x
  text(str(x), 10, 10)
  x += 1

```

---

<div class="post-metadata">

### Author: ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)
#### Post date: [November 20, 2020, 3:10pm UTC](https://discourse.processing.org/t/replace-the-current-text-with-new-text/25565/2 "2020-11-20T15:10:24Z")

</div>

Hi @cornedb2!

I’m not sure I understad you correctly, but I think you might be missing the frame “clean up”, try using `background()` like this:

```auto
x = 0

def setup():
  size(500, 500)

def draw():
    global x
    background(200) # ops! GoToLoop saw I've misspelled it as blackground
    text(str(x), 10, 10)
    x += 1

```

Another idea is just to draw a small no-stroke rectangle, with the same color as the background, where the new text will be placed, so as to “clean” the pixels for it.

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [November 20, 2020, 7:47pm UTC](https://discourse.processing.org/t/replace-the-current-text-with-new-text/25565/3 "2020-11-20T19:47:50Z")

</div>

> [@cornedb2](#):
>
> `text(str(x), 10, 10)`

Function **text()** also accepts a number as its 1st parameter: 🤓

> **[text() / Reference](https://processing.org/reference/text_.html)**
>
> Draws text to the screen. Displays the information specified in the first parameter on the screen in the position specified by the additional parameters. A default font will be used unless a font is s…

So there’s no need to convert it to a string: `text(x, 10, 10)` 😉

> [@villares](#):
>
> `blackground(200)`

A small mistype there: `background(200)` 🤭
