# Get functions / variables / classes from Processing and user

**URL:** <https://discourse.processing.org/t/get-functions-variables-classes-from-processing-and-user/30100>\
**Category:** Development\
**Created:** [May 14, 2021, 3:25pm UTC](https://discourse.processing.org/t/get-functions-variables-classes-from-processing-and-user/30100 "2021-05-14T15:25:15Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Ov3rM1nD](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ov3rm1nd/32/1756_2.png) [@Ov3rM1nD](https://discourse.processing.org/u/Ov3rM1nD)\
**Post date:** [May 14, 2021, 7:29pm UTC](https://discourse.processing.org/t/get-functions-variables-classes-from-processing-and-user/30100/10 "2021-05-14T19:29:18Z")

</div>

The resolution is analogous to the used for methods

```auto
import java.lang.reflect.Field;
import java.util.Collections;

Foo foo;
String something;
int somthingElse;

void setup() {
  println("\n *****PAPPLET FIELDS:*****");
  printFields(getClass().getFields());

  println("\n *****USER FIELDS:*****");
  printFields(getClass().getDeclaredFields());

  println("\n *****USER CLASS FIELDS:*****");
  for (Class c : getClass().getDeclaredClasses()) printFields(c.getDeclaredFields());

  exit();
}

String clean(String str) {
  str = str.substring(str.lastIndexOf('.') + 1);
  if (str.contains("$")) str = str.substring(str.indexOf('$') + 1); // get rid of the sketch class name and keep only the child class name
  return str.replaceAll("[^\\w]", "");
}

void printFields(Field[] list) {
  ArrayList<String> result = new ArrayList();

  for (Field f : list) {
    String name = clean(f.getName());
    String type = clean(f.getType().toString());

    result.add(name + " : " + type);
  }
  Collections.sort(result);
  for (String s : result) println(s);
}

class Foo {
  int fooInt;
  boolean fooState;
  Foo fooInstance;
}

```

---

_[View the full topic](https://discourse.processing.org/t/get-functions-variables-classes-from-processing-and-user/30100)._
