Expression Evaluator window

BASin

Expression Evaluator window

The Expression Evaluator window is available from the View menu.

The Evaluate Expression window

This window, accessed from the View Menu, provides a simple calculator for Sinclair BASIC expressions. At the top of the window is an edit field where you can type in your expression, which also incorporates a drop-down list consisting of the "history" of all expressions you have typed. The expression can contain any keywords or functions accessible to Sinclair BASIC, including any variables you have declared either programmatically at runtime, or by Direct Command.

Upon pressing Return, or by clicking the "Evaluate" button, the expression will be parsed for errors and executed. This is performed by starting a new instance of Spectrum Emulation, and allowing the ROM to process the expression as though it had the keyword PRINT inserted before it. The resulting text which would be displayed on-screen is taken by BASin and sent to the larger "Result" field below the edit field.

Note: expressions by their nature can contain functions such as the USR function which can execute a section of memory as machine code. Although it's a valid function (and returns the value in BC as the code performs it's final RET) it can get stuck in infinite loops, or take an age to complete. This will mean that the Evaluate Expression Window will not respond to requests for more expressions, either at all or for a long time. To this end, you can press the "Evaluate" button again to halt the current expression. Any result returned will be displayed. Closing the Evaluate Expression Window will also have this effect.

Also, related to this, the Evaluation will use the same "engine" to produce the result as the Watches (and other evaluated expressions, such as Find Window parameters) and as such any expressions taking a long time to evaluate will "stall" other expressions waiting to execute. However, none of them will affect the progress of the main system emulation.

There is also the option, via the "Add as Watch" button, to add this expression as an Expression Watch to the Watches Window.