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.
IndexProgramming Questions & HelpProcessing Implementations › Newbie: Error using 'Print' in Ruby-Processing
Page Index Toggle Pages: 1
Newbie: Error using 'Print' in Ruby-Processing (Read 1808 times)
Newbie: Error using 'Print' in Ruby-Processing
Dec 18th, 2009, 3:07pm
 
Hi, I am using Ruby-Processing. I can use 'puts' in my code but when  I use 'print' I get the following error:

---------------------------------------------
Exception in thread "Animation Thread" exercise38.rb:36:in `draw': for method pr
int expected [#<Java::JavaClass:0x1248f2b>]; got: [java.lang.String]; error: arg
ument type mismatch (TypeError)
       from :1
       ...internal jruby stack elided...
       from Exercise38.draw(:1)
       from (unknown).(unknown)(:1)
---------------------------------------------

I am using Windows. Any ideas?

Izzy
Re: Newbie: Using Print in Processing
Reply #1 - Dec 18th, 2009, 3:53pm
 
could you show the part of the code where you use it
Re: Newbie: Using Print in Processing
Reply #2 - Dec 19th, 2009, 1:39am
 
Hi, Here is the section of code, simplified, which shows the problem.

---------------------------
def mousePressed
     #puts "hello"
     print "hello"
 end

--------------------------- gives me

C:\Documents and Settings\Imran>rp5 run exercise38.rb
Exception in thread "Animation Thread" exercise38.rb:44:in `mousePressed': for m
ethod print expected [#<Java::JavaClass:0x1455d1c>]; got: [java.lang.String]; er
ror: argument type mismatch (TypeError)
       from :1
       ...internal jruby stack elided...
       from Exercise38.mousePressed(:1)
       from (unknown).(unknown)(:1)

---------------------------

I should also say the Ruby & RP is installed on a partition, D:

ruby-processing (1.0.8)

ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]
-e:1: undefined local variable or method `rsion' for main:Object (NameError)


java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)


Thanks.

Izzy
Re: Newbie: Error using 'Print' in Ruby-Processing
Reply #3 - Dec 21st, 2009, 6:38pm
 
You're calling the wrong print method by accident, the java.awt.Container's print, which is an ancestor of the Processing sketch.

If you'd like to get at Ruby's print, you can use Kernel.print(), and if you'd like to use Java's print, you can call java.lang.System.out.print()

Hope that helps,
-- Jeremy
Page Index Toggle Pages: 1