Hi, I set int synthType to 2, print it (OK), call routine(), print it again (not OK, blank space in the below example, though I've seen 0 or long numbers instead depending on whether other code precedes it).
If I change things like replace numOfBanksPerSynth in routine() with 4 then it's OK again. If I increase the 3 in char dirName[3... then it's OK. If I paste the contents of routine() in setup, ie do the same code but without a call, then it's ok again! Please what am I doing wrong?
Thanks
If I change things like replace numOfBanksPerSynth in routine() with 4 then it's OK again. If I increase the 3 in char dirName[3... then it's OK. If I paste the contents of routine() in setup, ie do the same code but without a call, then it's ok again! Please what am I doing wrong?
Thanks
HTML:
const char *listOfSynthTypes[] = {"OB6", "Prophet6", "CCsynth", "Prologue", "Wave2"};
int synthType = 0;
int numOfBanksPerSynth = 4;
void setup() {
Serial.begin(9600);//diagnostic serial port
synthType = 2;
Serial.print("synthType is ");Serial.println(synthType);
routine();
Serial.print("synthType is now ");Serial.println(synthType);
} // end setup
void loop() {
}
void routine() {
for (int i = 0; i < 5; i++) {
for (int j = 1; j < numOfBanksPerSynth + 1; j++) {
char dirName[3 + strlen(listOfSynthTypes[i])];
sprintf(dirName, "%s/%.2d", listOfSynthTypes[i], j);
}
}
}