|
Author |
Topic: highscores and other string inputs (Read 300 times) |
|
danking Guest
|
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
|
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
|
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
|
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.
|
|
|
|
fjen
|
Re: highscores and other string inputs
« Reply #5 on: Jul 24th, 2004, 9:31am » |
|
uups. should have read the question thorougly. sorry.
|
|
|
|
|