LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Global Variable

Hello. I am very new to labview and am working on a project that involves tracking data. I have a login screen that, when the correct password is entered, opens a new VI. I have a global variable that records information about the user login and is placed in a table. It works fine transferring from one VI to the next, but the problem is that when the program is closed and reopened, the table resets itself to have nothing in it. I was wondering if there was a way to keep the global variable data so that each time I open the program I am still able to view the data. I will post the two VI's below for reference. Password for Connor = 111, each name after that is 222, 333, 444, 555, and 666. (Open the username and password VI first)

Download All
0 Kudos
Message 1 of 6
(2,794 Views)

What you need is an "external" Variable in which to save your data.  There is such a variable that is present in almost all Programming Languages, and has the magical property that the data remains when the program is stopped, and even will persist if the PC is turned off.  It has the curious name of a "file", not the tool you use to shape metal, but an ordered set of data you would save in some type of storage, like a printout, a disk, "the cloud".

 

Incidentally, you didn't have to tell us you were "very new to LabVIEW" -- the title of your Post tells us you don't yet understand LabVIEW.  Please don't use Global Variables, but learn to use the LabVIEW "variable", the "wire", as your primary way of moving Data around.

 

To get the most helpful comment from this Forum (particularly if you don't mind helpful criticism that (ideally) will correct "newbie" mistakes and mis-comprehensions, always attach your VI (please, no pictures, as they are hard for us to "look behind" or edit) when you make a Post.  You obviously already have a VI, and I already know I won't like it (it uses Global Variables -- I'd love to show you "another way", but my Crystal Ball is cloudy and I can't even tell whether your VI is within 100 miles or across an ocean).

 

Bob Schor 

0 Kudos
Message 2 of 6
(2,770 Views)

Thank you for you help Bob it was very insightful and clear. Now that I know what a file is I may just be able to complete my program. Clearly you are an expert in Labview so I would love for any other advice you may have for me - perhaps on the topic of opening an old file. I bet they call you Mr. Labview down at work Bob!

 

PS - I included my VI's in the original post, not sure why you implied I didn't, so it would be helpful if you could at least try and look at them before giving advice.

 

Thanks 🙂

0 Kudos
Message 3 of 6
(2,757 Views)

I don't know what is going on, but there were no attachments visible when I read and responded to your post.  I do see them now, and will have a look ...

 

BS

0 Kudos
Message 4 of 6
(2,740 Views)

@ND: event structure is recommended, furthermore, can lose the transpose, conditional for can be replaced with search 1D array on column-indexed (0) 2D array, and case logic based on >=0 comparison on the index returned

 

*just recommendation for improvements

CY (expired CLAD)
0 Kudos
Message 5 of 6
(2,734 Views)

Looked at "Next Person".  Tried to figure out what it was doing.  There are three Boolean controls (one unlabelled, with an "X" on it, acting like a "Stop" for the While loop).  They were in a While Loop, so until "X" was pushed, the loop will "spin" at top speed, using as much CPU power as available.  Because of the Latching action of the buttons, any push (actually, any release) will trigger one action.  "Extract Data" opens Excel, writes a String as a Title into Row 0, Column 0 (with fancy formatting), writes Global "Login History" as a 2D array with Column Headers, then there's a Save Report to File. 

 

Some problems.  First, a deprecated function, "New Report" (with a big red X on it when opened with LabVIEW 2018, the same version the Poster was using) was used (although the Help for this function suggests using the currennt "Create Report" function), a Save Report is specified, but no Path is specified to write the File (so the function will simply return an error), and Excel is never closed.  A second push of "Extract Data" will try to open Excel again and repeat the same peculiar code.

 

None of this makes sense.  If you want to save tabular data in an Excel file, there are examples that ship with LabVIEW that show how to do this.  I suggest doing some simple examples before worrying about titles, headers, formats, etc.  I also suggest learning about Event loops -- with an Event loop, if no button is pressed, no CPU time is used, while in your case, if not button is pressed, all the CPU time is used (asking "Is any button pressed?").

 

Bob Schor

0 Kudos
Message 6 of 6
(2,718 Views)