JavaScript to MEL Conversion?

I'm new to MEL, and I've done some digging, but all I can come up with is a list of MEL Commands. Does anyone here know of a good tutorial that lays out the rules of MEL syntax?

I'm familiar enough with JavaScript, and I've noticed some similarities, so I've written out what I need to do in JS and am hoping to find a way to convert it to MEL.

 
var x = 3;
var rem = 0;
var convert1 = 0;
var fincalc = 0;
 
 
if (x >= -360 && x < -270)
    {
    convert1 = (x+360);
    }
else if (x >= -270 && x <= -90)
    {
    rem = x+90;
    convert1 = (90+rem)*-1;
    }
 
else if (x > -90 && x < 90)
    {
    rem = (x-90)*-1;
    convert1 = 90-rem;
    }
else if(x >= 90 && x <= 270)
    {
    rem = (x-90);
    convert1 = (90-rem);
    }
else if(x > 270 && x <= 360)
    {
    rem = (x-270);
    convert1 = (90-rem)*-1;
    }
 
fincalc = (convert1)/900;
 
document.write(x + "<br>");
document.write(rem + "<br>");
document.write(convert1 + "<br>");
document.write(fincalc);

 
float $x = 3.0;
float $rem = 0.0;
float $convert1 = 0.0;
float $fincalc = 0.0;
 
 
if ($x >= -360.0 && $x < -270.0)
    {
    $convert1 = ($x+360.0);
    }
else if ($x >= -270.0 && $x <= -90.0)
    {
    $rem = $x+90.0;
    $convert1 = (90.0+$rem)*-1.0;
    }
else if ($x > -90.0 && $x < 90.0)
    {
    $rem = ($x-90.0)*-1.0;
    $convert1 = 90.0-$rem;
    }
else if($x >= 90.0 && $x <= 270.0)
    {
    $rem = ($x-90.0);
    $convert1 = (90.0-$rem);
    }
else if($x > 270.0 && $x <= 360.0)
    {
    $rem = ($x-270.0);
    $convert1 = (90.0-$rem)*-1;
    }
 
 
$fincalc = ($convert1)/900.0;
 
print ($x + "\n");
print ($rem + "\n");
print ($convert1 + "\n");
print ($fincalc);

NOTE: fixed formatting for easier reading

good tutorial that lays out the rules of MEL syntax?

pretty much looks like shell scripting, its defined in the manual, but the short path since you already know programming concepts can be found here:

MEL for programmers
(excerpt form maya manual, hit f1 to access it)

Im not sure you need all that code tough It looks awfully a lot like a job for not using the nestled ifs but the code is so confusingly written that its hard to see. Some pointers about style tough for example why on earth would anybody write:

rem = x+90;
convert1 = (90+rem)*-1;

Its easier to read if you write:

rem = x+90;
convert1 = -1*(x+180);

So that  is what you should write

PS: plot rem and convert1 and youll see how it all has a much easier interpretation except for the -360 - -270 which is just weird for the remainder resuilt... possible bug?