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 › Saving text for the next page
Page Index Toggle Pages: 1
Saving text for the next page (Read 259 times)
Saving text for the next page
Feb 2nd, 2009, 6:44am
 
Hi everybody,

I had a program in mind that would ask a series of questions such as:

What is your name?

What is your favorite food?

Etc.....

I would then like insert their responses into an existing story for Example,

Lets say the the person typed in John, then for favorite food they typed in Pizza.

After they press Enter, I would like to display.

"John went to the beach, and ate Pizza on the bench."


Which function will automatically insert the User's response into the underlined areas of the story?

"________went to the beach, and at __________ on the bench."

Appreciate every bit of advice, Thank you!

Re: Saving text for the next page
Reply #1 - Feb 2nd, 2009, 11:24am
 
You might be interested by the thread Creating a timer where I show two techniques to format such message.
The first one uses Java's MessageFormat, which is flexible, as you can change the order of parameters (useful for generic messages needing to be translated to a language using a different order) and indicate their formating.
The second one is the classical string concatenation, less suited to your need, I think.
There are alternatives, like Formatter.
Page Index Toggle Pages: 1