Size only accepts literals not expressions 4 beta

float[] data=new float[50000];
void setup(){
  size(300*3,300);
  background(0);
  for(int i=0;i<50000;i++){
    data[i]=randomGaussian();
  }
  for(int i=0;i<50000;i+=2){
    int x=150+int(50f*data[i]);
    int y=150+int(50f*data[i+1]);
    set(x,y,color(255,230,0));
  }
}  
  

Gives:size() cannot be used here, see Reference / Processing.org
However this is okay:

float[] data=new float[50000];
void setup(){
  size(900,300);
  background(0);
  for(int i=0;i<50000;i++){
    data[i]=randomGaussian();
  }
  for(int i=0;i<50000;i+=2){
    int x=150+int(50f*data[i]);
    int y=150+int(50f*data[i+1]);
    set(x,y,color(255,230,0));
  }

Lol.
Also you might want to check save and save as…
If you accidentally click save as when you should have clicked save, … well I lost some code.

If you want to use expressions use settings. The processing pre-processor hides the fact that processing uses settings under the hood before the java code gets compiled.

That’s kinda unfortunate, kinda non-standard behavior, that sometimes we must just accept in life. Lol. :smiley_cat:

If you read the documentation of the size() function, it says:

As of Processing 3.0, to use variables as the parameters to size() function, place the size() function within the settings() function (instead of setup() ). There is more information about this on the settings() reference page.

And in the settings() reference page:

The settings() function is new with Processing 3.0. It’s not needed in most sketches. It’s only useful when it’s absolutely necessary to define the parameters to size() with a variable.

Everything is explained here and it’s not specific to Processing 4 beta :wink:

Also save as works without trouble on Processing 4.0b2. If you have any reproducible bugs, please report them on the GitHub issue page: Issues · benfry/processing4 · GitHub

I tried (for fun) setting size in a object initializer section which is to help setup inner classes, it didn’t work, but the error report was better. Lol.
Eg.

{ 
  size(2*100,200);
}

void setup(){}