Buzby
Senior Member
Hi,
I can 'sort of' see why "IF 125 < 126 THEN" is flagged as a syntax error, even though it it is a perfectly logical, but useless, construction.
The syntax error is generated by the 125, which is a constant, but the compiler is expecting a variable.
This can be proved by trying "IF 125 < b0 THEN" which gives the same error, but swapping the terms to put the variable on the left is OK.
It means you can test for 'is MyHeight less than 6ft', but not 'is 6ft greater than MyHeight'.
This is not usually a problem, as it's easy to swap the terms and change the comparison.
The problem comes when you pass a constant as a parameter to a #macro, and that constant ends up in a comparison with another constant.
I cannot see a way around this, other than copying the parameter to a variable within the #macro itself, then doing the comparison, which seems to rather defeat the object of passing a parameter in the first place.
Is there a specific reason why the compiler can't have a constant after the IF ?.
Could it be fixed in a compiler revision, or is it built into the firmware ?.
Cheers,
Buzby
I can 'sort of' see why "IF 125 < 126 THEN" is flagged as a syntax error, even though it it is a perfectly logical, but useless, construction.
The syntax error is generated by the 125, which is a constant, but the compiler is expecting a variable.
This can be proved by trying "IF 125 < b0 THEN" which gives the same error, but swapping the terms to put the variable on the left is OK.
It means you can test for 'is MyHeight less than 6ft', but not 'is 6ft greater than MyHeight'.
This is not usually a problem, as it's easy to swap the terms and change the comparison.
The problem comes when you pass a constant as a parameter to a #macro, and that constant ends up in a comparison with another constant.
I cannot see a way around this, other than copying the parameter to a variable within the #macro itself, then doing the comparison, which seems to rather defeat the object of passing a parameter in the first place.
Is there a specific reason why the compiler can't have a constant after the IF ?.
Could it be fixed in a compiler revision, or is it built into the firmware ?.
Cheers,
Buzby