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 & HelpSyntax Questions › "Cannot find a class or type named" …
Page Index Toggle Pages: 1
"Cannot find a class or type named" … (Read 2804 times)
"Cannot find a class or type named" …
Aug 20th, 2009, 2:16pm
 
I've just downloaded Processing on my Mac, have looked through a lot of the examples, and started writing something of my own. Right away, I created some classes, but then I decided to follow some of the examples' suit and separate them into individual files for each class.

But when I do that and try to run my program, I get a red bar with the text in the subject: "Cannot find a class or type named [ClassName]".

Below an example that makes Processing deliver this error.

Test.pde:

Code:
class Test {
 int n;
 Test(int num) {
   n = num;
 }
 int value() {
   return n;  
 }
}


ClassTest.pde:

Code:
Test a; 


Re: "Cannot find a class or type named" …
Reply #1 - Aug 20th, 2009, 2:33pm
 
It works,

either if you embed the class code before you instantiate a new object, all in the same tab:
Code:
class Test {
 int n;
 Test(int num) {
   n = num;
 }
 int value() {
   return n;  
 }
}

Test a;


or if you have at least a call to setup() or draw() in your main tab:

Code:
Test a;

void setup() {}
Re: "Cannot find a class or type named" …
Reply #2 - Aug 21st, 2009, 12:29pm
 
Yay, that worked! Thanks so much.
Page Index Toggle Pages: 1