Q:

Processing boolean logic, no error noticed, but won't run

//I will make a program that generates a square in the center of
//the screen if my mouse is located on the top half of the display
//and an ellipse if my mouse is located on the bottom half of the
//screen

//Global variables

int mouseposy;
float rect;
float ellipse;

//Setup

void setup() {
    size(600,600);
    mouseposy = mouseY;
}

//Draw

void draw() {
    background(0);
}

if {

    (mouseposy > 300);
    fill(mouseX,0,mouseY);
    rect(300,300,50,50);

} else {

    (mouseposy < 300);
    fill(mouseX,0,mouseY);
    ellipse(300,300,50,50);

}

By all means this should work, correct? This should give me a rectangle in the center of the display when I'm above 300px in the display coordinates, and an ellipse when I'm below 300px. Am I writing the if statement in the wrong section or something? When I press the run button, it just highlights the if statement and nothing else. I get no error message, just the highlight. Does anyone know what I'm doing wrong here?
///EDITED CODE///
//Global variables

int mouseposy;
float rect;
float ellipse;

//Setup

void setup() {
    size(600,600);
    mouseposy = mouseY;
}

//Draw

void draw() {
    mouseposy = mouseY;
    background(0);

if (mouseposy >= 300){

    fill(mouseX,0,mouseY);
    rect(300,300,50,50);

} else if(mouseposy =< 300) {

    fill(mouseX,0,mouseY);
    ellipse(300,300,50,50);

    }
}

I'm guessing I still have butchered one or another element of the code, but if anyone can see what's still wrong with this code I would appreciate the help. Now it is giving me the 'unexpected token: 300' error message.

A:

I see three problems, first of all the syntax of an if statement is
if (condition) statement

In you example you don't have any condition at all, you have mouseposy > 300 which you probably intended as a condition but used as a statement, which is an expression which discards its own result. Probably you meant something like
if (mouseposy > 300) {
  fill(...);
}

The second issue is the fact that you are using the variable mouseposy but it is set just in the setup() method, which is invoked once when the sketch starts and it is never updated, you should directly use mouseY variable or update it in your draw method.
The third issue is that the if/else statement doesn't cover all the cases, since you have
if (foo < 300) { .. }
else if (foo > 300) { ..}

What happens when foo == 300? You should use an >= operator or turn the second else if into an else.

