We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexSuggestions & BugsWebsite,  Documentation,  Book Bugs › serialEvent() - The 'which' parameter
Page Index Toggle Pages: 1
serialEvent() - The 'which' parameter (Read 1697 times)
serialEvent() - The 'which' parameter
Apr 4th, 2009, 9:21am
 
For serialEvent() - The 'which' parameter is not adequately explained, nor does its explanation make sense in context with the sample code. I have yet to understand it.

I think I see it now. I think it would be clearer if the sample code was:
Code:

void serialEvent(Serial myPort) {
inString = (myPort.readString());
}


And the 'which' parameter described as:
"The port name defined in a new Serial() statement."

Re: serialEvent() - The 'which' parameter
Reply #1 - May 6th, 2009, 11:38pm
 
I agree! As someone who just learned that function yesterday, I was a little thrown by the sample code. But then I realized the author may have been trying to emphasize that 'which' is not looked at if only 1 serial port is used.

I'd rather have overridden the method call to support both serialEvent() /* no param */ and serialEvent( Serial which).

But Processing is a cool language for beginners, and if the authors like it this way, I'm not going to complain (just comment a little).

Mike
Re: serialEvent() - The 'which' parameter
Reply #2 - Oct 18th, 2009, 10:20am
 
I hear you. This will be updated with the next release and will hopefully be more clear.
Page Index Toggle Pages: 1