I'm not saying that. The statement in question is an assignment, in the form [LET] variable = expression, so the only expression here is the call to the function 'two' which returns 200 but also increments array index x as a side effect. Then, the array element a(x) gets assigned but QDOS takes the value of x as array index before it evaluates the expression, and SMSQ/E does this afterwards. I've taken a look at Jan Jones's 'SuperBASIC Definitive Handbook' but coudn't find anything that defines the order of evaluation when the variable to be assigned to is dependent on the result of the expression...stevepoole wrote:Hi,
If I remember correctly, the QDOS 'expression evaluator' evaluates a statement from left to right, (except where parentheseses override priority).
So the QDOS evaluation is correct ?
As for SMSQ/E, I cannot remember reading about expression evaluation priorities at all... or any changes to them.
So it looks like SMSQ/E got it wrong...
That said, I believe it would be a good idea if SMSQ/E would change this behaviour to match that of QDOS, just for compatibility reasons...
That would also make it impossible for a function to assign a value to a global variable... If your intention is to use a variable only locally, you should declare it in a LOCal statement. I must admit I have sinned here too in the past, as pre-Minerva versions of S*BASIC couldn't handle more than 10 LOCals or else would crash...To make matters more compatible, x as a parameter to 'two' would be automatically local, and help get rid of the bug !
regards, Jan.