# Size only accepts literals not expressions 4 beta

**URL:** https://discourse.processing.org/t/size-only-accepts-literals-not-expressions-4-beta/33372
**Category:** Beginners
**Created:** [November 7, 2021, 12:46pm UTC](https://discourse.processing.org/t/size-only-accepts-literals-not-expressions-4-beta/33372 "2021-11-07T12:46:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![seanc4s](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@seanc4s](https://discourse.processing.org/u/seanc4s)
#### Post date: [November 7, 2021, 12:46pm UTC](https://discourse.processing.org/t/size-only-accepts-literals-not-expressions-4-beta/33372/1 "2021-11-07T12:46:22Z")

</div>

```auto
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](https://processing.org/reference/size_.html)  
However this is okay:

```auto
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.

---

<div class="post-metadata">

### Author: ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)
#### Post date: [November 7, 2021, 1:29pm UTC](https://discourse.processing.org/t/size-only-accepts-literals-not-expressions-4-beta/33372/2 "2021-11-07T13:29:11Z")

</div>

If you want to use [expressions use settings](https://processing.org/reference/settings_.html). The processing pre-processor hides the fact that processing uses settings under the hood before the java code gets compiled.

---

<div class="post-metadata">

### Author: ![seanc4s](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@seanc4s](https://discourse.processing.org/u/seanc4s)
#### Post date: [November 8, 2021, 12:41am UTC](https://discourse.processing.org/t/size-only-accepts-literals-not-expressions-4-beta/33372/3 "2021-11-08T00:41:56Z")

</div>

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

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [November 8, 2021, 7:44pm UTC](https://discourse.processing.org/t/size-only-accepts-literals-not-expressions-4-beta/33372/4 "2021-11-08T19:44:32Z")

</div>

If you read the documentation of the [size()](https://processing.org/reference/size_.html) 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()`](https://processing.org/reference/settings_.html) 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 😉

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](https://github.com/processing/processing4/issues/)

---

<div class="post-metadata">

### Author: ![seanc4s](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@seanc4s](https://discourse.processing.org/u/seanc4s)
#### Post date: [November 9, 2021, 12:12am UTC](https://discourse.processing.org/t/size-only-accepts-literals-not-expressions-4-beta/33372/5 "2021-11-09T00:12:15Z")

</div>

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.

```auto
{ 
  size(2*100,200);
}

void setup(){}

```
