How do I use a variable in another tab?

edited October 2013 in Using Processing

Is there a way to use a variable from a tab in Java, into a tab in Processing Java? Thanks

Answers

  • edited October 2013 Answer ✓

    Even though code can be placed in diff. tabs, the effect is the same as if they were in the same tab! ~:>
    I believe you've meant how to access a variable everywhere? If so, just declare it outside any function/method! :ar!
    However, if we make a tab w/ .java suffix as its name, that works as a separate top-class! #-o

  • As said. Or, if I understand correctly after re-reading your question, you might want to allow code from a .java tab to communicate with the .pde tabs.

    Code in a .java is a standalone class. So it cannot access directly the global variables of the .pde sketch. You have to set fields in instances of this class, or pass an instance of the sketch (this in the .pde) to the class.

    You have to be more precise in your question, perhaps with a simplified code to illustrate your problem, if you want a less generic answer.

Sign In or Register to comment.