> Well this whole thing to me looks like a halfhouse between an IF - END IF > clause (more readable at that) and a SELect ON - END SELect clause. From > what I have read, WHEN allows for any kind of data type. Seems to allow many of the tests you can put into an IF statement.
If I've understood it properly, it's not an inline program structure - it seems, like WHEN ERROR, to be something activated when a given condition occurss irrespective of where the program is at the time. I'm not sure how the interpreter handles this, it's almost as thought it starts a job to monitor variables which sends a signal to suspend what's happening and jump to the relevant WHEN variable or WHEN condition statement, unless perhaps between statements there is a call to check for any WHEN clauses and divert the program between statements accordingly. Just noticed the QLiberator manual and readme files provide a bit of insight into this as well: "Under the interpreter, a watched variable cannot trigger a WHEN clause as the result of an assignment through a READ or INPUT operation." Behaviour is replicated in QLiberator for the sake of compatibility. To work around this, use a LET statement to assign a variable to itself! SO while my example of INPUT a would not trigger the WHEN clause example I gave, INPUT a:LET a=a should do so. WHEN a<0 PRINT"Don't enter negative numbers!" END WHEN INPUT"Enter a number";a LET a = a : REMark force WHEN to take note! REMark resumes here after END WHEN QLiberator seems to handle WHEN variable, but I don't know if Turbo does: perhaps George Gwilt will let us know about this. I haven't looked yet, but I suspect the Rich Mellor SuperBASIC Reference Guide might have insights on this. I can't find any reference to it in Jan Jnoes's book, though. Might be worth writing this up for QL Toady and my QL Documentation CD if I can get some definitive documentation. -- Dilwyn Jones