FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   convert int to char
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: convert int to char  (Read 602 times)
st33d

WWW Email
convert int to char
« on: Mar 26th, 2005, 7:18pm »

How do I make this work?
Code:

String input = "";
void setup(){}
void loop(){
println(input);
}
void keyPressed(){
char keyInput = key;
input = input+keyInput;
}

I can't find any reference to derive a char or string from an int. The idea is to make a non standard textfield.
« Last Edit: Mar 26th, 2005, 7:19pm by st33d »  

I could murder a pint.
fry


WWW
Re: convert int to char
« Reply #1 on: Mar 27th, 2005, 12:20am »

char keyInput = (char) key;
will do the trick.
 
or even just:
input += (char) keyInput;
 
st33d

WWW Email
Re: convert int to char
« Reply #2 on: Mar 27th, 2005, 3:32am »

Code:

String input = "";
void setup(){}
void loop(){}
void keyPressed(){
  if (key == 10){
    println(input);
    input = "";
  }else{
    input += (char) key;
  }
}

Magic. Thanks.
« Last Edit: Mar 27th, 2005, 3:33am by st33d »  

I could murder a pint.
Pages: 1 

« Previous topic | Next topic »