We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Using typed text by user in multiple pages.
Page Index Toggle Pages: 1
Using typed text by user in multiple pages. (Read 190 times)
Using typed text by user in multiple pages.
Feb 3rd, 2009, 6:10am
 
Hi, I am trying to have the typed name show up in the next page but it is not working, I don't know what else to do. I want the name typed to show up in the next page where there is supposed to be a name, right now it is typing then after I press enter the space where there is supposed to be a name is blank, please help resolve, will appreciate greatly.

current code:

int page = 1;
PFont font;
String letters = "";
String answer = "";
String Hi = "Hi";
void setup()
{
 size(400,400);
 font= loadFont("Hel.vlw");
 textFont(font);
 textAlign(CENTER);
 background(0);


}

void draw(){
  //black background
background(0);
 if (page==1){
   text("What is your name?", 200,100);//question one
   text(letters,200,150);  
}else if(page == 2){
   background(0);
   stroke(255);
   if(letters.equals(letters))//if answer is yes, then the
   {
     stroke(255);
     text("Hi",150,200);
     text(letters, 200,200);//question is
     text("you look very pretty today.", 200,225);
   }
   letters="";
 }

}

void keyPressed(){
 if((key == ENTER)|| (key == RETURN))
 {
   page = 2;

}
if((key > 31) && (key !=CODED))
{
letters =letters +  key;
}}
Re: Using typed text by user in multiple pages.
Reply #1 - Feb 3rd, 2009, 2:31pm
 
Haven't run your sketch, but I see two issues:
if(letters.equals(letters))
is always true. That's OK, but it might not be what you want.

And letters=""; in page 2.
That means that the text will be displayed on the first frame after Enter have been detected, then it will be erased on the next frame by the (double) background call.
Hard for the eye to see the subliminal message! :-P
Page Index Toggle Pages: 1