I'm intrigued. Can you expand on how you implemented this please. In particular how you can modify variables and apparently (from the screenshot) evaluate code all (presumably) within the step event code.
Hi Andy,
The magic is all on your side. My solution is pretty simple.
The breakpoints are implemented as the Stepped event being called each time and there I evaluate whether the step is at one of the linenumbers a I put a breakpoint on.
If a break is needed:
- a new jBasicLib(debugging) instance is being generated and I create a default script to DIM all global and local variables (GetGlobalVars and GetLocalVars) of the code engine into the debugging instance (in the debugging instance they can all be declared as global as the names should be unique).
- Then I make sure the debugging script runs until the last DIM statement at which point I break and set all variables using SetArray and SetGlobalVar (obtaining the values from the code engine from the set of global and local variables).
- The Step then passes control to the debugging screen (websocket page) and waits until the user decides to proceed using you wonderful Lock (Lock.Waitfor).
- When the lock is being freed by the debugging screen the reverse operation is done: copying all variable values from the debugging engine back to the code engine (to Array, global and local variables). That's it basically ..
As said I did some minor modification to facilitate processing.
I initially modified the engine code to accept a debugging instance to be attached. When the debugging instance would run and obtain any of the internal variable values it would be directed to the internal structures of the code instance. This seem to work but seemed more of a hack and in this case I could not do any modification.
The way of work above seems a bit overhead in that I need to copy all variables back and forth, but your library is really fast so I do not notice it on my test applications.
Apart from this I have sys methods that mimic Maps and Matrixes (1 or 2- dimensional redimmable arrays that can be defined everywhere in the application). As these use internal maps I just share these internal maps between the code and debugging engine (so need to copy there).