01-15-2016 04:22 AM
Is there any way to change Labview code while the code execution is paused and then again resume the new changed code execution?
01-15-2016 04:40 AM
Hi Jain,
no. And yes.
No: you cannot change code of a running executable (as you cannot change code in Word while you don't type any new text into it…)
Yes: you can change code in plugins while those plugins aren't used. After resuming your code you reload the plugin to execute your new code…
01-15-2016 06:04 AM
Hi GerdW,
Thanks for the reply.
Changing code into plugins will be a huge task and also not feasilible for my application scenerio as it will create many VIs and also the code changing event is not fixed.
What I think is to somehow instantiate a copy of executing code when we need to change it (i.e apply pause or any other button) which has the information like a) when pause event happened, b) values of all links and controls, c) till what point code has been executed. At this time, the previous code copy gets Aborted and allow user to change anything. While resuming, the control will goes back to previous copy with all the stored information so that it will start again from where it left.
Hope you understand the scenerio !!
Regards
Sambhav
01-15-2016 07:06 AM - edited 01-15-2016 07:07 AM
Hi Jain,
again: No! You CANNOT change code of a running executable! And "resuming" still means "running and waiting for user input"…
again: You might export code parts into plugins. When the plugin is unloaded you are able the change it, then load it again into your executable.
Changing code into plugins will be a huge task
Only when you don't plan for it when developing your executable!
not feasilible for my application scenerio as it will create many VIs
What? It's not feasable because you need to create some VIs?
Creating code in a manageable way means to create more VIs…
also the code changing event is not fixed
This doesn't matter for plugins…
01-15-2016 07:17 AM
If you think about the execution of a LabVIEW routine that embodies, say, a State Machine, where you have a button that says "Do This", and another that says "Do That", and you program your routine to handle both button pushes, you can certainly "change LabVIEW code" (in the sense of changing what the LabVIEW code does) during execution, even while not paused, just by pushing a button and executing the appropriate State.
If you mean "Pause LabVIEW, make some changes to the Block Diagram, and resume", that is much harder, and goes against LabVIEW's basic "compiled code" structure. What you seem to be wanting is a Matlab-like interpreter that executes "code fragments" as you develop them. I suppose, with LabVIEW scripting, you might be able to cobble together something, but it would be a ton of work, probably unstable, and almost certainly a Waste of Time and Exercise in Frustration/Futility.
Why do you want to do this, anyway? What do you need to do that you can't figure out how to do?
Bob Schor
01-15-2016 07:32 AM
Wanting to do this is almost certainly the wrong solution to a problem for which a better solution exists.
If you could explain what you are trying to do - why you want to do this - then perhaps a better solution can be suggested.
(I think) I understand your previous reply where you basically proposed saving the state information at a point where you want to make changes, stop execution, edit, and then re-load that state after changes have been made and the program re-started. But what kind of changes are you wanting to make to the code that couldn't be handled by a bit of clever programming so you don't have to stop and start it again?
01-15-2016 08:28 AM
It is possible to trick LabVIEW into allowing you to edit running code (paused code counts as running), but LabVIEW usually crashes when you do that. Even if it doesn't crash, you will have created an unstable situtaion, and possibly corrupted your VI.
If you really need* to edit some code while the main VI is running, put the modules that you will be editing in dynamically loaded VIs. Put provisions in your main VI that will allow you to control the loading/unloading of dynamic VIs.
*It's unlikely that you really need to do that.
01-15-2016 11:37 AM
@Stuart.Parkinson wrote:
Wanting to do this is almost certainly the wrong solution to a problem for which a better solution exists.
Totally agree. This is like asking, "After I compile C code into a executable can I change it while it is running?" Of course the answer is no, but there are ways to embed code to do what you want and be flexible at run time, but that logic must be built into the software. LabVIEW is not a scripting language, it is not interpreting what you tell it to do, it compiles it, into executable code and runs it.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
01-15-2016 11:46 AM
While I agree with the above posters that there is probably a better way to debug your code, I did see an interesting trick the other day. When using the JKI state machine you can save the Macros in a text file and load it any point in your program. So you could edit this text file while paused, and then reload it.