LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Logging in and switching to another VI

Solved!
Go to solution

You're saying "switch to another VI" but that's not how LabVIEW works.  If you're coming from another language I can kind of understand the confusion, where you might tell the program to close one form and open another, but that's not what you do in LabVIEW.

 

In LabVIEW, a VI is both the interface (front panel) and the code (block diagram).  The block diagram cannot contain an instruction that means "switch to another VI".

 

To do what you want, you need to set up your code in one of three ways.

 

Way #1: Main VI, with subVIs as popups

Run one main VI.  Have a subVI in it that shows your login window.  When the login window is done, it outputs its results, and the main VI then either displays the next subVI as a popup, or whatever else should happen if it fails.

 

Way #2: Hide login panel, open subVI popup

When the login is done, tell your VI to hide itself and then run another subVI to launch itself as a popup.

 

Way #3: Change your front panel, no popups

Set up your front panel in such a way that you see the login portion of it at the start, and when that succeeds it changes its appearance to do the next things it needs to do.

For example, you could set up a tab control, hide the tabs from the user so they can't change them, and have one tab be the login tab and the other be the main program.  If the user logs in right, you programmatically change the tab.

Or you could just use a bunch of controls stacked on top of each other, and use the "Visible" properties of each to show or hide them.

Or you could turn off scroll bars and resizing while running, and change the front panel's "origin" property to move around to different sections of the panel to make it look like the VI changes but it's actually the same VI.

 

 

Message 11 of 19
(200 Views)
Solution
Accepted by topic author shreyaskarnad

Hi shreyaskarnad,

 


@shreyaskarnad wrote:

how to switch to another VI if the login details are correct


I repeat: use a case structure with your "another VI" as subVI in one of the cases!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 12 of 19
(197 Views)

I love you man! IT WORKS! Thank you so much!!!

0 Kudos
Message 13 of 19
(171 Views)

Ok so I was able to get the subvi to open but now the problem is it is opening the subvi even if I enter wrong credentials. I am attaching the VI in the details. Can you please help?

Download All
0 Kudos
Message 14 of 19
(164 Views)

Hi shreyaskandar,

 


@shreyaskarnad wrote:

Ok so I was able to get the subvi to open but now the problem is it is opening the subvi even if I enter wrong credentials.


Right now your "Login" VI is not executable because of a missing wire!

You need to wire a condition to the case structure…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 15 of 19
(149 Views)

Yes I got that thing working. But what the next hurdle is I am not able to switch to the 3rd subVI. That subVI contains a MATLAB node for executing a MATLAB code. Both the methods - SubVI and Tab switch are not working. When I click the switch button on second tab and second SubVI to switch to 3rd page or 3rd SubVI, it just hangs and doesn't go anywhere. Attaching the file for your reference

0 Kudos
Message 16 of 19
(152 Views)

Hi shreyaskandar,

 


@shreyaskarnad wrote:

Attaching the file for your reference


Why don't you cleanup that code! It's really horrible!

(And way too large…)

 


@shreyaskarnad wrote:

When I click the switch button on second tab and second SubVI to switch to 3rd page or 3rd SubVI, it just hangs and doesn't go anywhere.


You can resolve any DATAFLOW problem by using debugging tools like highlight execution!

(Cleaning up the code really helps to follow DATAFLOW while debugging…)

 

Hint: When does a loop iterate? Answer: Accordin to DATAFLOW as soon as the code inside the loop is executed!

Question: when is the code inside your outer while loop is finished?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 17 of 19
(143 Views)

I had kept the outer loop only to keep the program running until I click close button which was supposed to be on page 3. But the thing is the moment I remove MATLAB node the program works like charm. But when I add it back it hangs. Why is this happening? It's really frustrating that LabVIEW doesn't have any function to switch to other VI without this tabs and subvi stuff! Anyway, I'll figure out something thanks.

0 Kudos
Message 18 of 19
(132 Views)

Hi shreyaskandar,

 


@shreyaskarnad wrote:

I had kept the outer loop only to keep the program running until I click close button which was supposed to be on page 3.


When you don't understand the term "Think DATAFLOW!" then you should take the training resources offered at the top of the LabVIEW board to learn LabVIEW basics.

Putting loops inside loops (like you did) shows missing basics knowledge…

 

Spoiler
I told you to watch the DATAFLOW using highlight execution debugging. Apparently you did not follow my recommendation.

@shreyaskarnad wrote:

But the thing is the moment I remove MATLAB node the program works like charm. But when I add it back it hangs. Why is this happening?


When I "remove the MATLAB node" then the VI is shown "broken" and so not able to execute. I don't know how you "remove the MATLAB node" and still keep your VI running…

 

Spoiler
I guess you delete the whole loop including the MATLAB node: this way you fix the DATAFLOW problem as mentioned before…

@shreyaskarnad wrote:

It's really frustrating that LabVIEW doesn't have any function to switch to other VI without this tabs and subvi stuff!


Right now you have only ONE VI, there is nothing to "switch to other VI". All you can do (and this would be very easy) is to switch tabs of a tab container.

 

Recommendation: to solve programming problems it really helps to ask the right questions, using the correct wording. As you can see from my comments your wording is very unclear/misleading…

 

Edit:

I attached a simple (very, very simple) VI to show how to switch tabs programmatically…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 19 of 19
(127 Views)