Processing not recognizing enum

I am trying to program an interpreter in Processing, and I’m trying to use enums. However, when I try to reference one of the values from the enum, Processing tells me that the value cannot be resolved into a variable.

1 Like

?? this might be still valid:
https://stackoverflow.com/questions/13370090/enums-in-processing-2-0 ?
enum_test.pde

Status status;

enum_code.java


enum Status { STOPPED,MOVING };

but i have no idea what i am talking about, just good in google search

1 Like

I have the enum code in a java file with that general syntax, and it does seem to recognize the enum typing; however, the problem seems to lie in me trying to define a variable of that enum typing with a value from the enum.

I don’t know much about this.

processing seems to have advanced in terms of using enum

here is an example where we don’t have a java tab

Chrisir

// https://forum.processing.org/two/discussion/7048/easiest-way-to-make-a-finite-state-machine


public enum State {
  SETUP, RADAR, POINTER, HISTOGRAM;
}

private State _state = State.SETUP;

// ------------------------------------------------


void setup() {
  size(1220, 950);
}

void draw() {

  background(111); 

  switch(_state) {
  case SETUP:
    setup_2();
    break;

  case RADAR:
    radar();
    break;

  case POINTER:
    pointer();
    break;

  case HISTOGRAM:
    histogram();    
    break;

  default:
    //error 
    break;
  }
}

// -----------------------------------------------------------------------

private void setup_2() {
  // some code here 
  _state = State.RADAR;
  println("setup_2");
}

private void radar() {
  //some code here
  print("radar");
  stroke(0); 
  rect(681, 734, 
    90, 100); 
  if (mouseX>681 && 
    mouseX<781 && 
    mouseY>734 && 
    mouseY<856 && 
    mousePressed) {
    _state = State.POINTER;
  }
}

private void pointer() {
  //some code here
  println("pointer");
  if (mouseX>681 && mouseX<771 && mouseY>734 && mouseY<756 && mousePressed) {
    _state = State.HISTOGRAM;
  }
}

private void histogram() {
  //some code here
  if (mouseX>681 && mouseX<771 && mouseY>734 && mouseY<756 && mousePressed) {
    // _state = State.RADAR;
  }
}
3 Likes

Woah wild! This is actually great news. Love enums :wink:

1 Like