# Strings! Hi Guys i can't understand why my code doesn't work!

**URL:** <https://discourse.processing.org/t/strings-hi-guys-i-cant-understand-why-my-code-doesnt-work/9961>\
**Category:** Coding Questions\
**Created:** [April 4, 2019, 12:33pm UTC](https://discourse.processing.org/t/strings-hi-guys-i-cant-understand-why-my-code-doesnt-work/9961 "2019-04-04T12:33:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 4, 2019, 12:33pm UTC](https://discourse.processing.org/t/strings-hi-guys-i-cant-understand-why-my-code-doesnt-work/9961/1 "2019-04-04T12:33:09Z")

</div>

Hi guys can you explain me the strings? Why my code doesn’t work?

```auto
PFont myFont;
int x;
int y;
String s="AVFTA";

void setup(){
  size(500,500);
  background(255);
myFont=createFont("SansSerif-48.tff",24);
text(s,50,50);}

void draw(){
  
  textFont(myFont);
  //fill(0);
  
  
 for(x=0; x< 250; x=x+1)
// for(y=0;y<250;y=y+1)
{ // color a=color(150,30,60,5);
//color b= color(150,30,60,1);
    fill(0);
//fill(b);
//alpha(b);
//translate(50,50);
   //rotate(PI/3);
   
   textFont(myFont,random(130));
   text(s.charAt(x),x*15,x*15);
  }
}

```

---

<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:** [April 4, 2019, 12:40pm UTC](https://discourse.processing.org/t/strings-hi-guys-i-cant-understand-why-my-code-doesnt-work/9961/2 "2019-04-04T12:40:18Z")

</div>

pls edit your topic and repair your code posting,  
paste your formatted code into the

```auto
</> code tag

```

---

<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:** [April 4, 2019, 3:52pm UTC](https://discourse.processing.org/t/strings-hi-guys-i-cant-understand-why-my-code-doesnt-work/9961/3 "2019-04-04T15:52:50Z")

</div>

What happens, what do you want to happen instead?

The for loop is too long: 250 !!!

---

<div class="post-metadata">

**Author:** ![Stanlepunk](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stanlepunk/32/11509_2.png) [@Stanlepunk](https://discourse.processing.org/u/Stanlepunk)\
**Post date:** [April 4, 2019, 5:42pm UTC](https://discourse.processing.org/t/strings-hi-guys-i-cant-understand-why-my-code-doesnt-work/9961/4 "2019-04-04T17:42:38Z")

</div>

Before posting is better to clean your code to identify the problem… there was a lot when I copy and paste this one. After cleaning your code work :

problem part  
syntax poblem

> [@fwtini](#):
>
> text(s.charAt(x),x _15,x_ 15);

quote problem

> [@fwtini](#):
>
> myFont=createFont(“SansSerif-48.tff”,24);

> [@fwtini](#):
>
> String s=“AVFTA”;

```auto
int y;
String s ="AVFTA";

void setup(){
  size(500,500);
  background(255);
  String [] list = PFont.list();
  myFont=createFont(list[0],24);
  text(s,50,50);
}

void draw(){
  textFont(myFont);
  //fill(0);

  for(x=0; x< 250; x=x+1) { 
    fill(0);
    textFont(myFont,random(130));
    text("TRUC",15,15);
  }
}

```

---

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 5, 2019, 8:05am UTC](https://discourse.processing.org/t/strings-hi-guys-i-cant-understand-why-my-code-doesnt-work/9961/5 "2019-04-05T08:05:51Z")

</div>

Thank you but I don’t understand what the _ **s.charAt** _ is helping me on?

---

<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:** [April 5, 2019, 8:28am UTC](https://discourse.processing.org/t/strings-hi-guys-i-cant-understand-why-my-code-doesnt-work/9961/6 "2019-04-05T08:28:38Z")

</div>

A String is made from chars

with s.charAt(3) you get the 4th letter in the word s

So you can use text() to write the word letter by letter

Look at String in the reference; there is also a tutorial about text I think

---

<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:** [April 5, 2019, 9:00am UTC](https://discourse.processing.org/t/strings-hi-guys-i-cant-understand-why-my-code-doesnt-work/9961/7 "2019-04-05T09:00:53Z")

</div>

> [@fwtini](#):
>
> helping me on?

i still wait that you repair your code in the topic.

---

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 5, 2019, 2:35pm UTC](https://discourse.processing.org/t/strings-hi-guys-i-cant-understand-why-my-code-doesnt-work/9961/8 "2019-04-05T14:35:04Z")

</div>

So sorry I found the wrong thank you!
