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.
Page Index Toggle Pages: 1
console input (Read 246 times)
console input
Mar 3rd, 2008, 6:46am
 
Sorry if this question has been answered somewhere. I cannot find anything that speaks to this.

I understand that Processing does not support console input using System.in. I am trying to work with a piece of code written for java, which contains a method (actually, a constructor) that takes one InputStream argument.

To call this constructor, one first has to create a variable like so:
       InputStream is = System.in;
And then this variable is passed to the constructor. But I guess this does not work in Processing.

Now, one thing I could do is to use keyPressed or keyTyped to grab every input character, put it into a String array, and pass the String array to the constructor when the user hits the enter key. I would have to rewrite the constructor to accept a String array rather than an input stream. This would involve some work, as the original constructor extends StreamTokenizer, and StringTokenizer does not quite provide the same functionality... Should I try this approach anyway? Is there a better way?

Thanks.






Page Index Toggle Pages: 1