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)
   highscores and other string inputs
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: highscores and other string inputs  (Read 300 times)
danking
Guest
Email
highscores and other string inputs
« on: Jul 20th, 2004, 8:21pm »

Is it possible for the user to insert a name? For example in C++ u would do cin >> name (im not sure if the > is in the correct direction, Sorry!).  Where 'name' is the varible where the string is stored.
 
Does anyone know?
 
fjen

WWW
Re: highscores and other string inputs
« Reply #1 on: Jul 23rd, 2004, 8:00am »

yes you can. in the reference there is the following example:
 
http://processing.org/reference/loadStrings_.html
 
Code:

// textfile get's loaded into array "lines". //
String lines[] = loadStrings("list.txt");
 
// output length of the array //
println("there are " + lines.length + " lines");
 
// output every entry in array lines //
for (int i=0; i < lines.length; i++) {
  println(lines[i]);  
}
« Last Edit: Jul 23rd, 2004, 8:03am by fjen »  
Bijeoma

myloveiloved
Re: highscores and other string inputs
« Reply #2 on: Jul 23rd, 2004, 7:54pm »

cin in c++ if i remember correctly read input from the command line and as far as i know, you cannot read direct command line input in the processing environment.  
 
as an alternative a simple textfield which reads characters direct from key press should work.  
 
-bryan
« Last Edit: Jul 23rd, 2004, 7:57pm by Bijeoma »  
fry


WWW
Re: highscores and other string inputs
« Reply #3 on: Jul 24th, 2004, 1:36am »

the equivalent of using 'cin' is to read from System.in (same as System.out is same as 'cout'). but it's very very rare in a java (or p5) program that you'd want to use this type of input. as the previous poster suggested, you prolly want to track key events and make yourself a text field of some sort.
 
narain


Re: highscores and other string inputs
« Reply #4 on: Jul 24th, 2004, 7:37am »

A basic textfield has been implemented in p5:
http://processing.org/discourse/yabb/board_Programs_action_disp_lay_num_1089966915.html
 
fjen

WWW
Re: highscores and other string inputs
« Reply #5 on: Jul 24th, 2004, 9:31am »

uups. should have read the question thorougly. sorry.
 
Pages: 1 

« Previous topic | Next topic »