Sim 'Current variable name' idea ...

Jeremy Leach

Senior Member
This is just an idea about the Simulator and how it displays the variables ...

As the code is stepped through, could the simulator keep track of the current name that's assigned to the variable?

For instance, sometimes - because there aren't enough underlying variables - a variable such as b0 is used for different reasons, with multiple symbols pointing to it. Say we had symbols 'Brightness' and 'Speed' both assigned to b0. When the code gets to something like 'Brightness = 6' or 'Peek address, Brightness', it knows that the current meaning of b0 is 'Brightness' - so the Sim could display 'Brightness (b0)' in the variable dialog.

In theory the Sim could also be a bit clever here - if for instance the current meaning of b0 was 'Brightness' and then the code said 'Let X = 5 * Speed' the Sim could flag an error (warning) saying that 'Speed' isn't one of the currently used symbol names.

In the Sim it would just be a case of holding a running table of currently used symbol names. A current 'context' is perhaps the way to describe it.

One issue is that this 'context' would only work sequentially - and so if you start the Sim at a random point in the code then it would have to start from not knowing the context - but as long as that's made clear then I don't see it would be a problem.

It might not be too hard to implement and I think it might help a lot when using overlapping symbol definitions.
 

hippy

Ex-Staff (retired)
I've logged the idea and it could be useful.

It may not be quite so easy to implement though. It's easy enough to note from Symbol definitions which variables have what names but it would need noting for simulation, for each command, which variables have which name at that time. It would depend on how easy it is to add something which can do that within the simulation process which can relate names to actual variable used. Simulation takes 'Let x=y', converts both 'x' and 'y' and produces something like 'Let b0=b1' which is ultimately then simulated and it would need a mechanism to tie what's generated to what was used to generate it. It's probably not impossible but may be much more difficult than it first appears.
 

Jeremy Leach

Senior Member
Ah yes, see what you mean - I expect the Sim doesn't use symbol names at all while it's running. Well it's a possibility and thought I'd mention it :)
 
Top