I have not been able to find a full statement of the syntax for if-else
. My observation is that only certain kinds of statements are allowed after if
, but what are they?
If I write this user-defined function
functions{
real mre(real x) {
real y;
if(x < 0)
y = -1;
else
y = 1;
return(y);
}
}
then it parses.
But if I write this:
functions{
real mre(real x) {
real y;
if(x < 0)
print(y);
else
y = 1;
return(y);
}
}
I get:
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
Variable "else" does not exist.
error in 'modelaef6c7c5a76_mre' at line 6, column 8
-------------------------------------------------
4: if(x < 0)
5: print(y);
6: else
^
7: y = 1;
-------------------------------------------------
In my real life function I want to reject()
if a certain variable is negative, but return
it if it is positive. it appears that reject
is not allowed after if
.
Where is this syntax defined, please?