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 › Call variables from other methods
Page Index Toggle Pages: 1
Call variables from other methods (Read 401 times)
Call variables from other methods
Nov 28th, 2007, 8:36pm
 
Hello everybody!

I'm just learning the basics of programming and i'm really lucky to see what is possible with processing.
While i'm waiting for my handbook get's shipped from the US, i have to ask a very basic question here:

I try to access a variable which is defined in a other method and Processing still gets me error messages like: "No field named "test" was found...)

Basically i try to check my Mail account with the Java mail library and call the method "checkMail()" from the "draw()" method. So far, so good. But i want to access all the variables inside of checkMail() - how is this possible?


Thanks in advance
Re: Call variables from other methods
Reply #1 - Nov 28th, 2007, 8:55pm
 
If you're asking what I think you are, you can't.

You can only access things which the object makes available in some way.

For example:

Code:

int funcA()
{
int wibble=3;
// do stuff;
return 0;
}

int funcB()
{
return wibble; // this will not work, since wibble is:
// a: resricted to the funcA function only
// b: temporary. It only exists whilst funcA is running
}
Re: Call variables from other methods
Reply #2 - Nov 28th, 2007, 9:14pm
 
Thanks for your fast reply. I defined the variables to fill in the main program now and filled them in the function. Nice!
Page Index Toggle Pages: 1