Hi again all, i'm looking to change the index of my array with a for loop, but for some reason i'm getting these build errors:
error C2143: syntax error : missing ',' before '<='
error C2086: 'int i' : redefinition
see declaration of 'i'
syntax error : missing ';' before '{'
Here is the loop:
for(int i = MajorIntervalAscend[i], i<= 7, i++)
{
sendMidiMessage(0x90, MajorIntervalAscend[0], 0x7f);
delay(userDelay);
sendMidiMessage(0x80, MajorIntervalAscend[0], 0x7f);
}
i'm an absolute beginner so its probably some glaring error that i cant see =[
#include <iostream>
usingnamespace std;
int main ()
{
int test[10];
int i = 0;
//initializing array test[], otherwise it won't work the way your for loop is written
for (i=0; i<=9; i++){ test[i] = i; cout << test[i];}
cout << "\n";
i = 0; // this initialization will reset test[i] to '0' instead of '9' from previous array initialization
// without this initialization the loop won't run
//next is the format your loop is written('i' takes on the value of test[i])
for(i = test[i]; test[i]<=7; i++) cout << test[i];
cout << "\n";
i = 0;// reinitializing to '0' so next loop will run
//if you want test[i] to take on the value of 'i', the loop should be written as below
//and the array initialization loop (1st loop) above is unnecessary
for(test[i] = i ; test[i]<=7; i++) cout << test[i];
return 0;
}
EDIT: sorry, I forgot you were using the array in the upper boundary part of the loop, I changed the examples to reflect that
Double EDIT: I also posted this mistakenly to your other thread,,, jeez louise! :)
the MajDirection variable is of type char
If you press 1 on the keyboard you will get the ascii code for 1 which is 49 - not decimal 1 as you are expecting. That is why the switch doesn't work
I'm not sure if this will solve the problem, but it did get the for loop going for me. I initialized 'i' before the for loop then replaced the : for(int i = MajorIntervalAscend[0]; i<= 7; i++)
with the loop as you originally intended to display: for(int i = MajorIntervalAscend[i]; i<= 7; i++)]
thankyou all =] i get where the problem is now, but i still cant get it to work. the major scale has set intervals defined by the array, but then i need the loop to index each stage of the array to play the relevant midi note.
i'm really sorry to keep arsing around and probably wasting your time but i've really hit a wall here.
the for loop DOES work as I layed out above. I don't have audio.h in my library so I had to modify the program to display to the console the values as shown here, with the output I get(input '60' as MajStartingNote) .
looking at the rest of your arguements in your for loop(I am completely unfamiliar with audio applications) I am wondering if your arguements for MajorIntervalAscend should be changed to: