i originaly wanted to use an array, but i didnt know how to change the values of the array as they were read from serial... wow im stupid, heh i see how i could do it now.
i now have "int[] JoyData = new int[7];" at the beginning of the code where "ArrayList JoyData = new ArrayList();" was
//Handle data recieved; something like: 1023,1023,1023,1,1,0,1,
string[] split = RxString.Split(new Char[] { ',' });
int cntwrite=0;
foreach (string s in split)
{
if (s.Trim() != "")
{
int c = Int32.Parse(s);
JoyData[cntwrite]=c; //adds each new value split(s) from SerRead string to JoyData array
Console.WriteLine("split #s:");
Console.WriteLine(c);
++cntwrite;
if(cntwrite >7) //reset cntwrite for next time serial data is recieved
{
cntwrite=0;
}
}
}
but now when i try to use
int y=JoyData[2] * 512 / 1023 + 0;
int x=Joydata[1] * 512 / 1023 + 0;
for the graph in "public Form1()" i get "JoyData doesnt exsist in this context". i thought declaring the JoyData array in the class would fix it, but the error only happens when i use "int y=JoyData[0]"(trying to access first number stored in array), but if i use "int y=JoyData[3]" it doesn't give me an error. arrays start at 0 so why does this happen?
ok thats really weird, now it works....