LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop and passing a string to a SubVI problem

Solved!
Go to solution

Hi everyone,

 

My problem is the following: I have a MainVI and a SubVI, the MainVI is running a while loop in which the SubVI is called and is handed over 2 parameters, 1 bool and 1 string. the problem is, inside the SubVI the string should be put in a text box so the user can see it before pressing ok.

 

Background of this: normally the "Get_DMC.vi" opens up with just the text box and a cancel button, meant for scanner input 10 chars big. this always works fine. If the user selects Dummy DMC in the MainVI, it should only copy the Dummy DMC from the MainVI (the string mentioned earlier) to the SubVI and show it in the text box as well as enabling another button "OK" to give the (advanced) users a chance of controlling this themselves.

 

The SubVI is reloaded with every call because it would be stuck in the while loop, had I not done that. Not quite sure why though, if anyone has an answer to that aswell please tell me.

 

Many Thanks in advance,

 

Regards,

 

Pedro

0 Kudos
Message 1 of 6
(3,124 Views)
Solution
Accepted by Pedro89

It could be that the writing of the Dummy DMC  to 'DMC value' is happening before the 'DMC Reinit to Default'.  Try wiring the error out of DMC Reint to Default to the error in of DMC Value to force the order of execution

 

Ken

Message 2 of 6
(3,121 Views)

And how right you are. Just found out before reading your post 😄

 

Kudos to you my good sir, anyway and yours is the solution!

0 Kudos
Message 3 of 6
(3,117 Views)

Pedro89 wrote:

The SubVI is reloaded with every call because it would be stuck in the while loop, had I not done that. Not quite sure why though, if anyone has an answer to that aswell please tell me.


You have several big no-no's in your code. You should never have two event structures in two different cases of the same case structure. Even the other event structure will accumulate items in the event queue, which can never be serviced if the code is in the other case. None of your "reninit to defaults" are needed. For the string you just write an empty string to a local or value property and for the buttons you need to make sure that the terminal is inside their event case. latch action boolean reset once the new value is read by the code, and placing the terminal inside the event ensure that they reset when the event has been handled.

 

Here's  very quick attempt at a rewrite using a single event structure. It might need some tweaks but I think it works as it should. You should also assign the [cancel] key to the abbrechen control. Notice how much simpler things are now?

Message 4 of 6
(3,107 Views)

O wow, I knew my LabView skills are at total beginner level, but I'm just baffled by how sweet this looks just now. Thanks very much for the modification 🙂

One thing though, after 10 chars are read, it's supposed to terminate by itself, for the purpose of efficiency. Already changed that right now, just had to switch the "AND" to and "OR" and rewire a little.

 

Anyway, are there any good tutorials for wiring well that you know of?

 

Regards,

 

Pedro

0 Kudos
Message 5 of 6
(3,082 Views)

Was going to attempt somthing similar to altenbach but unfortunately ran out of time. Kudos anyway

 

Ken

0 Kudos
Message 6 of 6
(3,079 Views)