# Problem with Library Methods

**URL:** <https://discourse.processing.org/t/problem-with-library-methods/15455>\
**Category:** Development\
**Created:** [November 13, 2019, 10:52am UTC](https://discourse.processing.org/t/problem-with-library-methods/15455 "2019-11-13T10:52:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![NumericPrime](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/numericprime/32/16318_2.png) [@NumericPrime](https://discourse.processing.org/u/NumericPrime)\
**Post date:** [November 13, 2019, 10:52am UTC](https://discourse.processing.org/t/problem-with-library-methods/15455/1 "2019-11-13T10:52:49Z")

</div>

Hi I’m trying to create a processing library using eclipse, everything Looks fine so far but if I use following Code for a class  
package test;  
import processing.core.\*;  
public class Testclass{  
PAppplet parent;  
Testclass(PApplet parent){  
this.parent=parent;  
parent.registerMethod(“method1”,this);  
}  
public float method1(float x){  
return …;  
}  
public float method2(){  
return …;  
}  
}

As I used the processing Code:

Import test.\*;  
Testclass x=new Testclass(this);  
println(x.method1(5));

I got the Error  
There is no Public method1 method in test.Testclass

If I registered method2 instead it works perfectly fine!

How do I fix this?

PS: I’m new to this forum, so I don’t know the Question Layout.

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [November 13, 2019, 11:11am UTC](https://discourse.processing.org/t/problem-with-library-methods/15455/2 "2019-11-13T11:11:25Z")

</div>

The registered method cannot have parameters i.e. no `float x`.

---

<div class="post-metadata">

**Author:** ![NumericPrime](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/numericprime/32/16318_2.png) [@NumericPrime](https://discourse.processing.org/u/NumericPrime)\
**Post date:** [November 13, 2019, 11:23am UTC](https://discourse.processing.org/t/problem-with-library-methods/15455/3 "2019-11-13T11:23:27Z")

</div>

Is there a method wich makes it possible to do Register Methods with parameters?

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [November 13, 2019, 12:38pm UTC](https://discourse.processing.org/t/problem-with-library-methods/15455/4 "2019-11-13T12:38:13Z")

</div>

Well, you could do this :

```auto
myFloatVar1 = 17;
public float myFloat() {
return myFloatVar1;
}

```

And in Processing :

```auto
println(x.myFloat()); //17

```

Basically using a global variable to cheat your access/use to/of the variable for the function.

---

<div class="post-metadata">

**Author:** ![NumericPrime](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/numericprime/32/16318_2.png) [@NumericPrime](https://discourse.processing.org/u/NumericPrime)\
**Post date:** [November 13, 2019, 1:19pm UTC](https://discourse.processing.org/t/problem-with-library-methods/15455/5 "2019-11-13T13:19:30Z")

</div>

> [@Lexyth](#):
>
> global

Could you please ahow a example of how you can use this to make method with parameters?

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [November 13, 2019, 2:56pm UTC](https://discourse.processing.org/t/problem-with-library-methods/15455/6 "2019-11-13T14:56:08Z")

</div>

I am not sure why you are trying to register a method called `method1`. Can you explain because AFAIK registering a method with an arbitrary name is meaningless.

The `registerMethod` is used for two reasons

1. provide user defined processing of mouse, key and touch events
2. to provide methods to be called during Processing’s main execution thread e.g. pre, draw, post, dispose etc.

You can read about this [here](https://github.com/processing/processing/wiki/Library-Basics).

---

<div class="post-metadata">

**Author:** ![NumericPrime](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/numericprime/32/16318_2.png) [@NumericPrime](https://discourse.processing.org/u/NumericPrime)\
**Post date:** [November 13, 2019, 4:07pm UTC](https://discourse.processing.org/t/problem-with-library-methods/15455/7 "2019-11-13T16:07:36Z")

</div>

Thanks for this information I tried to make new commands using this method.  
Do you know how you do this?

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [November 13, 2019, 4:19pm UTC](https://discourse.processing.org/t/problem-with-library-methods/15455/8 "2019-11-13T16:19:20Z")

</div>

> [@NumericPrime](#):
>
> I tried to make new commands

I assume by this you are trying to make “Processing commands” like `fill(...)`, `stroke(...)` etc. again I would ask why you would want to do this.

Although in theory you could extend the PApplet class to provide additional methods but I would strongly recommend that you don’t even attempt it. The problems associated with doing this would make an angel cry 😭

---

<div class="post-metadata">

**Author:** ![NumericPrime](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/numericprime/32/16318_2.png) [@NumericPrime](https://discourse.processing.org/u/NumericPrime)\
**Post date:** [November 13, 2019, 5:10pm UTC](https://discourse.processing.org/t/problem-with-library-methods/15455/9 "2019-11-13T17:10:14Z")

</div>

> [@quark](#):
>
> associated

Ok I’ll try to avoiid that!
