User created function not found

edited December 2014 in Developing Processing

If i am creating a function(say void myFunc() ) in PApplet class and calling in the code written in PDE its giving function not found. Can someone help please.

Answers

  • Make it public?

  • ".java" tabs aren't touched by Processing's pre-compiler. So it must adhere to strict Java syntax!
    For example, fields & methods in ".pde" tabs get public prefixed to them if no access keyword is used!

  • GoToLoop, we are in Developing Processing category, and I think it is the right one if Akarshit really puts the functions in a custom version of PApplet. So there is no .java tabs here, as he probably code in Eclipse or similar.

  • Oops, never pay attention to category! Anyways, I guess any Java dev knows that public is needed in a member supposed to be accessed outside! :-?

  • edited December 2014

    @PhiLho , @GoToLoop - Actually the function is public ( but it shouldn't matter as the code from the setup() function is overridden over the default setup() in PApplet ) . And i am using eclipse , the actual problem is that i was looking into issue #548 but the changes i was making in the rect() function were not reflecting in the output . So i decided to make a function of my own and try to access it using code in PDE but for some reason the function isn't visible to the code.

  • PApplet's rect() is just a wrapper for canvas' PGraphics's rect().
    Since canvas is already instantiate and held in field g, I'm afraid there's nothing we can do about it! :-SS

  • but the parameter to g.rect() are passed in the PApplet's rect() , even if i am passing g.rect(0,0,0,0) the rectangle is been drawn at the position i specified in the code in PDE , Shouldn't it be drawn at 0, 0.

  • I don't get what you mean by "Shouldn't it be drawn at 0, 0.". :-??
    I'm just saying that we can't change the rect()'s internal behaviors but those 4 parameters! ~:>

  • edited December 2014

    this is my rect() function as in PApplet

    public void rect(float a, float b, float c, float d) {
    if (recorder != null) recorder.rect(a, b, c, d);
    g.rect(0, 0, c, d); // passing 0 , 0 as the (x,y) co-ordinates
    }

    this is the code in the .pde which i am running

    void draw(){
    rect(width / 2 , height / 2 , 10 , 10 );
    }

    so shouldn't the rectangle be drawn at 0, 0.

  • ... as in PApplet.

    Sketches from ".pde" files extend the original PApplet class.
    Question is, where your rect() method is defined? :-?

  • edited December 2014

    as in PApplet means in processing.core.PApplet .
    I have changed the rect() in processing.core.PApplet class .

  • GoToLoop, again, I think Akarshit compiles his own version of PApplet, and perhaps other classes, so "we can't change the rect()'s internal behaviors" shouldn't apply here. Idem for "original PApplet class" which isn't relevant here.

    Akarshit, do you have a complete custom version of the PDE, independent of the official one? Perhaps there is a classpath mix up?

  • Screenshot from 2014-12-03 06:16:15 Screenshot from 2014-12-03 06:16:51

    @PhiLho Yes you are right there is something wrong in the build path because when i add processing/core classes as libraries it the custom rect() is working but when i add processing-core as an project required on build path the custom version no longer works. Can you please guide me through steps to set up the build path. I have provided the current setting of build path in the screenshots above.

  • Sorry @Akarshit. But I've got no experience w/ other IDEs!

  • If you are a contributor to Processing then in which IDE do you work ?

  • Just a forum helper! And still w/ lotsa learn yet! :-&

  • ok , thanks for the time @GoToLoop

Sign In or Register to comment.