This is a way to split chunk of data based on the comma (,) as separator. You can revamp the code above by using the split()
function as documented in the reference.
If you still have issues, make sure you print and you inspect the content of val
and used debugging tools available with processing to understand what is going on. If the issue persists, provide a snippet on the arduino code as well as your updated Processing code.
Kf