Processing throw syntax error when I define a function

Hi all,
I can’t define any function because of syntax error.

void setup(){
  size(1000,1000);
}

line(100,100,200,300);

This code throws “Syntax Error - Missing operator, semicolon, or ‘}’ near ‘100’?” at line 5.
I try separating the function from main tab to another tab,but it doesn’t work.
I changed the name or type of return value,but I got same error.

version:4
platform:windows10

I appreciate any help.thanks.

You can’t have a line of code (your line() command, no pun intended) outside of any function (as soon as you have a function somewhere)

so surround your line () command with

void draw () {
   line….
}
1 Like

Chrisir

It works fine! Thank you so much!

1 Like

Of course you can have lines of code before setup() but no commands, just declarations like int i=0;

Also, this looks probably more sharp:

void draw () {
   background(0); 
   line….
}