Search code examples
labview

Is there a method for script file loading control in labview?


first, I cannot attach my vi files, sorry. I'm not allowed, but I can attach snippets.

I've got a vi that opens and executes functions from a script file, and I'd like to be able to continuously click a button to reload the script file without having to restart the program. Currently the script file commands sit outside my main while loop and and uses a case statement to put the system in idle mode (manual control) when the button is not depressed before launching the program, or if it is, it will instantly open a dialog box looking for a script file upon program launch. I'd like to be able to open a script file numerous times during the execution of my program, but don't fully understand how, and this may be my own misunderstanding of what's going on with the code if I move it inside the main while loop. how is this best accomplished? External Script Launch


Solution

  • If you put your code outside of the loop, it is only executed once (very important: "dataflow"). You need to put the code into a loop to execute it multiple times.

    You can insert the vi-snippet into your vi by drag&drop.
    My vi contains two different options. You can change the vi as you need it, my vi is incomplete. I inserted a simple 2D-Array because I'm not sure if the vi you use after building the path is selfmade or given by LabVIEW.

    For both options you should let the code run in some kind of state machine and use an Event Structure (I think you already implemented your program this way since you wrote about a main loop).


    Version 1:

    Everytime you click the button, the event is triggered and the code inside the event structure is executed.

    Version 2:

    Here you set a boolean if the button is pressed and handle the event with that value.

    Since you wrote that you already have a main while loop, this option might be better four you. The first loop would be your main-loop, second one would be the loop in Version 2. You just need to add another case for the script to be loaded in.


    VI:

    Two Options


    I hope this is helpful for your problem.
    Feel free to ask if you need more help or if you have any questions :)