Help with simple text String Array
in
Programming Questions
•
2 years ago
Hey I'm a noob with Processing and programming in gen., I have done some OK stuff but I need some help please! What I'm trying to do is to get the letters from this string array converted in numbers so I can turn them into MIDI notes. As is all I can get is the length of the array (6), but I am wanting the numbers representing the individual character in each array entry. I was able to do this using the tweetstream library and the length() function in a different sketch but i get the error that:
cannot convert string type [] to string when using "length" without the parenthesis works. Please help me out here is the code:
String[] headlines = {
"Jesse (1:25 AM): Made it home fine. Still pissed at the douche tho. Hope when your the bartender you don’t get butt hurt when I flip you off." ,
"Tierna (9:05 AM): Can you meet @ 330?" ,
"Jason (9:37 AM): Don’t live like it’s your last day. That’s dumb. You’d be like, crying. Make today awesome and live like it’s today." ,
"@Jesse (10:00 AM): Hey just got yr text glad you made it safe and don’t worry about my coworker he’s sensitive" ,
"@Tierna (10:01 AM): Yeah that should be fine I just have to be at work by five in rio rancho." ,
"@Jason (10:03 AM): Sage words" ,
};
PFont f; // Global font variable
float x; // Horizontal location
float t;
int index = 0;
void setup() {
size(screen.width,screen.height);
rectMode(CENTER);
f = createFont( "Arial" ,20,true);
// Initialize headline midscreen
x = width/2;
}
void draw() {
background(0);
fill(255);
// Display headline at x location
textFont(f,20);
textAlign (CENTER);
// A specific String from the array is displayed according to the value of the "index" variable.
text(headlines[index],x,height-200,width/2,100);
t=t+1;
if(t>=100){
index = (index + 1) % headlines.length;
t=0;
}
convert();
}
void convert(){
int i;
int iAscii;
for ( i = 0; i < headlines.length; i++ ) {
println(headlines.length);
}
}
cannot convert string type [] to string when using "length" without the parenthesis works. Please help me out here is the code:
String[] headlines = {
"Jesse (1:25 AM): Made it home fine. Still pissed at the douche tho. Hope when your the bartender you don’t get butt hurt when I flip you off." ,
"Tierna (9:05 AM): Can you meet @ 330?" ,
"Jason (9:37 AM): Don’t live like it’s your last day. That’s dumb. You’d be like, crying. Make today awesome and live like it’s today." ,
"@Jesse (10:00 AM): Hey just got yr text glad you made it safe and don’t worry about my coworker he’s sensitive" ,
"@Tierna (10:01 AM): Yeah that should be fine I just have to be at work by five in rio rancho." ,
"@Jason (10:03 AM): Sage words" ,
};
PFont f; // Global font variable
float x; // Horizontal location
float t;
int index = 0;
void setup() {
size(screen.width,screen.height);
rectMode(CENTER);
f = createFont( "Arial" ,20,true);
// Initialize headline midscreen
x = width/2;
}
void draw() {
background(0);
fill(255);
// Display headline at x location
textFont(f,20);
textAlign (CENTER);
// A specific String from the array is displayed according to the value of the "index" variable.
text(headlines[index],x,height-200,width/2,100);
t=t+1;
if(t>=100){
index = (index + 1) % headlines.length;
t=0;
}
convert();
}
void convert(){
int i;
int iAscii;
for ( i = 0; i < headlines.length; i++ ) {
println(headlines.length);
}
}
1