# Length won't work in a function

**URL:** <https://discourse.processing.org/t/length-wont-work-in-a-function/19780>\
**Category:** Beginners\
**Created:** [April 14, 2020, 6:14pm UTC](https://discourse.processing.org/t/length-wont-work-in-a-function/19780 "2020-04-14T18:14:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![codebodger](https://avatars.discourse-cdn.com/v4/letter/c/a9adbd/32.png) [@codebodger](https://discourse.processing.org/u/codebodger)\
**Post date:** [April 14, 2020, 6:14pm UTC](https://discourse.processing.org/t/length-wont-work-in-a-function/19780/1 "2020-04-14T18:14:21Z")

</div>

I have a fairly simple custom function. It takes two inputs (an `int[]` and an `int`) and returns an `int[]`. It takes the length of the `int[]` input, however it gives the error `The variable "length" does not exist`

Here is all of the code:

```auto

  int[] Chromatic(int[] converter,int range) {
    for(int i = 0; i < length.converter; i++) {
      converter[i] = converter[i] % range;
    }
    return converter;

```

What is the issue?

Thanks in advance for any and all responces.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [April 14, 2020, 6:19pm UTC](https://discourse.processing.org/t/length-wont-work-in-a-function/19780/2 "2020-04-14T18:19:32Z")

</div>

_length_ is an array field, not a variable: [Processing.org/reference/Array.html](http://Processing.org/reference/Array.html)

Use the accessor operator dot `.` in order to access field _length_ over an array’s reference:  
[Processing.org/reference/dot.html](http://Processing.org/reference/dot.html)

`length.converter` -\> `converter.length`

---

<div class="post-metadata">

**Author:** ![codebodger](https://avatars.discourse-cdn.com/v4/letter/c/a9adbd/32.png) [@codebodger](https://discourse.processing.org/u/codebodger)\
**Post date:** [April 14, 2020, 6:21pm UTC](https://discourse.processing.org/t/length-wont-work-in-a-function/19780/3 "2020-04-14T18:21:48Z")

</div>

Thank you, now that you point that out it seems really obvious!
