The 'specification' didn't go into that much detail, but it did imply the behaviour by calling for a good degree of compatibility with the Microsoft BASICs of the day. In those BASICs it was legitimate to write:Rich Talbot-Watkins wrote: ↑Wed Feb 12, 2020 12:57 pmDo you remember if the BBC BASIC specification required this to work, or whether it's just an undefined consequence of how BBC BASIC implements variable assignment (allocating a new variable and defaulting it to zero prior to evaluating the RHS)?
Code: Select all
A = A + 1
Code: Select all
PRINT A
In practice it's extremely useful to have a way of forcing a variable to exist if it doesn't, but not changing its value if it does (for example when releasing resources in a 'cleanup' routine). I tend to use the compound += operator, introduced in BBC BASIC V, for this:
Code: Select all
var% += 0
IF var% THEN PROCrelease(var%)