Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Processing 'It looks like you're mixing "active" and "static" modes.'

Processing keeps giving me this error when I run it even though it is just a print command. When I delete the comment block it works fine. Here's the code:

/*
    float[] cortToPolar(int xcorr, int ycorr) {
    float returns[] = new float[2];
    returns[0]= degrees(tan(ycorr/xcorr));
    returns[1]= sqrt(pow(xcorr,2)+pow(ycorr,2));
    return returns;
}

float lawCos(int a, int b, int c) {
  return degrees(
     acos(
     (pow(a,2)+pow(b,2)-pow(c,2))/
       (2*a*b)
     )
  );
}
*/
print(0); 

Why doesn't it like my comment?

like image 479
Nate711 Avatar asked Jul 12 '11 02:07

Nate711


2 Answers

Processing runs in two separate modes: static or active

Static mode simply means it's a list of instructions/calls to existing functions (e.g. draw a bunch of lines then exit)

Active mode uses the setup() and draw() calls and runs continuously (gets updated every 'frame').

Only in active mode you are allowed to define own functions like cortToPolar and lawCos (regardless of the fact they are commented - this could be a Processing editor bug).

Use the setup() call to print because using setup will bring Processing into active mode.

/*
float[] cortToPolar(int xcorr, int ycorr) {
    float returns[] = new float[2];
    returns[0]= degrees(tan(ycorr/xcorr));
    returns[1]= sqrt(pow(xcorr,2)+pow(ycorr,2));
    return returns;
}

float lawCos(int a, int b, int c) {
  return degrees(
     acos(
     (pow(a,2)+pow(b,2)-pow(c,2))/
       (2*a*b)
     )
  );
}
*/
void setup(){
  print(0);
}

(Should you need to use active mode and control how draw() is called you can use noLoop() and loop().)

like image 132
George Profenza Avatar answered Oct 02 '22 12:10

George Profenza


The message could be shown when the actual problem is a syntax error. I encountered this error with the following (silly) code:

boolean state = false;

setup() {
  size(200, 800);
}

void draw() {
}

It is missing the 'void' modifier for the setup function. This is a syntax error (at least, it should be). But the Processing IDE gives you this "active vs. static" message instead.

So in this case, it should be void setup() { } rather than just setup() { }.

like image 40
Gabe Johnson Avatar answered Oct 02 '22 12:10

Gabe Johnson