Data from serial cannot convert to int

Hello,

with this processing script below I get the right values into processing from Arduino, but

a. I can't convert the inByte to integer, when I do that I get 0.Why my variable numCol is 0?
b. How can I separate the incoming values for R G B every 3 incoming values?

Any help very appreciated.

import processing.serial.*;
Serial port;
 
void setup(){
     size(45,45);
     port = new Serial(this,Serial.list()[1], 9600);
            }


void draw() {
  
         while (port.available() > 0) {
         String inByte = port.readStringUntil(10);
         if (inByte != null) {
         int numCol = int(inByte);
         print("in Byte : ");
         print(inByte);
         println(numCol);
       }
     }
 port.clear();
}

OR why my initial script - reading directly with int variables - does not give me the right values from Serial?

please see the processing code below:

import processing.serial.*;
Serial port;
int x=0;
int y=0;
int i=0;   
 
void setup(){
     size(45,45);
     port = new Serial(this,Serial.list()[1], 9600);
            }

void draw() {
  
     delay(1000);
     while (port.available() > 0) {
      
       int inByteRED = port.read();
       println("inByteRED");
       println(inByteRED);
       delay(1000);
       int inByteGREEN = port.read();
       println("inByteGREEN");
       println(inByteGREEN);
       delay(1000);
       int inByteBLUE = port.read();
       println("inByteBLUE");
       println(inByteBLUE);
       delay(1000);
         
       color c = color(inByteRED, inByteGREEN, inByteBLUE);
       
       //Size of each rectangle with disctinct color
       int rectsize=3; 
       fill(c);
       noStroke();
       rect(x*rectsize , y*rectsize , rectsize , rectsize);

       x++;
       
       if (x > 14) {x = 0; y++;}
       if (y > 14) {noLoop();}      
           
    }
}

Because you have a string and you can't convert it to a number by type casting.
See:-
http://www.codeguru.com/forum/showthread.php?t=231054

hello mike,
thanks a lot for the answer but I still have difficulties to use the reference you sent to write a working code in processing.Can I use atoi in processing?any hints directly on the processing language?..thanks for any answer (btw processing site is down at the moment so can't look there much)

Try:-

Integer.parseInt(string);