Arduino/Genuino 101 CurieIMU Orientation Visualiser

I cannot get this to run. I changed the port in the Processing code to the port the 101 is using with no success. The preocessing sketch is unsuccessful.

Help

I read the Genuino post which did not help me (unfortunaty). My Arduino is on COM3 so I inserted a 3 in the "myPort = new Serial(this, Serial.list()[2], 9600);" where the 2 is. When I run the Processing sketch that line is highlighted and I get the message "ArrayIndexOutOfBoundsException:3". hat am I missing?

mine genuino101 is connected to the port com4 and after a few test runs with this setting:

myPort = new Serial(this, Serial.list()[1], 9600);

I did not understand why it works

The Arduino finally worked using 0 (zero) for the port number. Maybe that makes sense to someone, but not me.

I am really new to Processing. After reading about Serial I think I finally figured out what is going on (sort of). If you know the port that the Arduino (Genuino) is using put that port in parens in place of ""Serial.list()[3]". In my case the port is COM3 so substitute "COM3". I'm sure everyone else had figured this out, but not me the newbie.

After further investigation I found that if you run

import processing.serial.*;

// The serial port
Serial myPort;

// List all the available serial ports
printArray(Serial.list());

it wil l return a number followed by a COM port
ie. 1 COM6

The number is what you enter between the square brackets in "myPort = new Serial(this, Serial.list()[2]," in this case instead of the 2. This works or the method from my previous post.