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

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

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);
  }
}

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

</> code tag

What happens, what do you want to happen instead?

The for loop is too long: 250 !!!

1 Like

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

quote problem

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);
  }
}

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

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

1 Like

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

So sorry I found the wrong thank you!