Thanks a lot, that was clever, making a bool and conditioning everything on that.
I wrote something like,
if (Serial.list().length > 0)
{
serialConnect =true;
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil(lf);
//myPort = new Serial (this, "/dev/tty.wchusbserial5d10", 115200);
myPort.clear();
} else
{
serialConnect =false;
}
And then only listen to the serial port if the Serialconnect boolean is true.
Thanks a lot, Learned something new.