access positition in array of arrays to typecast
in
Programming Questions
•
2 years ago
Hi,
i want to access the stimulusParameter[2] wich is located in the stimuli array to change it from string to color.
"stimuli[j] stimulusParameter[2] = unhex("FF" + stimuli[j] stimulusParameter[2]); "- gives me an error.
How can I do it?
if anybody has an idea i would be very thankful!
stimulus[] stimuli;
void setup() {
size (1024,768);
smooth();
String[] data = loadStrings("data.txt");
stimuli = new stimulus[data.length];
for (int i = 0; i < stimuli.length; i++){
// Each line from the data-Array is split into an array of Strings
String[] stimulusParameter = split(data[i],",");
for(int j = 0; j < stimuli.length; j++){
stimuli[j] stimulusParameter[2] = unhex("FF" + stimuli[j] stimulusParameter[2]);
}
// The stimulusParameters in the Array are passed into the stimulus class constructor.
stimuli[i] = new stimulus(stimulusParameter[0],stimulusParameter[1],stimulusParameter[2]);
}
}
}
void draw(){
background(0);
// stimulus Car = new stimulus ("Car" ,Blue );
// Car.display();
}
// Define Class Stimulus
class stimulus {
char condition;
String word;
color kleur;
// Construct Stimulus
stimulus(String C, String W, color K) {
this.condition = n;
this.word = mouse;
this.kleur = #FF0000;
}
// Method to display Stimulus
void display() {
textAlign(CENTER, CENTER);
textSize(45);
fill(kleur);
text(word, horizPos, vertiPos);
}
}
void setup() {
size (1024,768);
smooth();
String[] data = loadStrings("data.txt");
stimuli = new stimulus[data.length];
for (int i = 0; i < stimuli.length; i++){
// Each line from the data-Array is split into an array of Strings
String[] stimulusParameter = split(data[i],",");
for(int j = 0; j < stimuli.length; j++){
stimuli[j] stimulusParameter[2] = unhex("FF" + stimuli[j] stimulusParameter[2]);
}
// The stimulusParameters in the Array are passed into the stimulus class constructor.
stimuli[i] = new stimulus(stimulusParameter[0],stimulusParameter[1],stimulusParameter[2]);
}
}
}
void draw(){
background(0);
// stimulus Car = new stimulus ("Car" ,Blue );
// Car.display();
}
// Define Class Stimulus
class stimulus {
char condition;
String word;
color kleur;
// Construct Stimulus
stimulus(String C, String W, color K) {
this.condition = n;
this.word = mouse;
this.kleur = #FF0000;
}
// Method to display Stimulus
void display() {
textAlign(CENTER, CENTER);
textSize(45);
fill(kleur);
text(word, horizPos, vertiPos);
}
}
1
