Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
matta1989
matta1989's Profile
2
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
integers from array
[1 Reply]
30-Mar-2013 02:49 AM
Forum:
Programming Questions
hi,
i have a text file with a range of numbers in it.
i want to read the file and load the contents to an array. the display one random number on the screen from the array.
i wrote a piece of code, but every time im outputting the anwser im getting ' [L]Java.lang.String ..." instead of a number.
i know i can use the random keyword in processing to a get a random number. but i want it to read from a text file.
im doing something wrong - any help please?
below is my code ...
void setup() {
size (500, 500);
int[] data;
String[] numbers = loadStrings ("numbers.txt");
data = int(numbers);
int x = data[0];
text(""+numbers, 100,100,100,100);
}
void draw () {
text("Progress",20, 200, 150, 20);
for(int i =1; i < 2; i++) {
rect(100*i,200, 150, 20*i);
//rect(20*i,20,20,20*i);
}
}
wrinte to textfile ... new line problem
[3 Replies]
21-Mar-2013 12:56 PM
Forum:
Programming Questions
hi all,
im new to processing.
im writing a game, and im trying to store the scores in a text file.
first im loading the scores to text array of type int, the in the end write the score in a text file, however i would like to enter every score in a new line.
atm its writing always at the 1st line.
any help would be appreciated.
[code]
//array to store scores
int[] scrs = new int[2];
scorers[0] = currTime;
saveStrings("scrs.txt", str(scs));
[/code]
thanks
«Prev
Next »
Moderate user : matta1989
Forum