LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

create a small data base stored in a file

I want to create a small data base of about 10 to 20 items. Each item will have an item number, serial number, time stamp and description. I want to store these 10 items in a file and be able to retrieve them by item number. How can I do this with LabView?
0 Kudos
Message 1 of 8
(2,667 Views)
For something this small, use a single VI to manage it in memory:

It has a FUNCTION input, an enum with values of (INIT, READ FILE, WRITE FILE, ADD ITEM, FIND ITEM).

It has a CLUSTER input, which is your record type {Item number, serial number, time stamp, description}

It has a CLUSTER output, of the same type.

It has an ITEM NUMBER input, which is an integer (assuming your item number is truly a number).

The code is a WHILE loop with the CONTINUE input wired to FALSE (it never loops).

Inside the WHILE LOOP is a CASE statement, with the selector wired to the FUNCTION control.

For case INIT, make an empty array of records (your cluster type) and feed it to a shift register on the WHILE loop.

For case WRITE FILE, take the shift regis
ter input and CREATE, WRITE, and CLOSE a file. (pass it thru to the output as well). Wire the cluster to the DATALOG TYPE of the CREATE FILE function to create a datalog file.

For case READ FILE, use OPEN FILE, READ FILE, and CLOSE FILE functions, with DATALOG TYPE wired to the cluster type.

For case ADD ITEM, just append the new item (input cluster control) to the array from the shift reg and put the array back in the shift reg.


For case FIND ITEM, just search thru the array (from the shift reg) until you find the matching item number, then return the whole record in the output.


You'll have to pass the left shift reg thru the case to the right shift reg in all cases except INIT, READ FILE, and ADD ITEM.

This means the actual storage is in the shift reg, for max efficiency.

If you get beyound a hundred items, I would suggest a different FIND ITEM technique (keep a separate list for ITEM NUMBERS and search that, rather than the whole thing).

This assumes you ha
ve control of shutdown - any changes you make are lost unless you call WRITE FILE afterwards.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 8
(2,667 Views)
Here is a VI that is similar to one I made for a project. It looks in a file of csv data, and will find that line that matches the item#, assuming that the item# is the first variable in the line. If nothing is found, then the result is empty. If a match is found, then the whole line is output as the result.

If you want assistance on creating the data file, let me know.
Message 3 of 8
(2,667 Views)
Do you have a sample program in LabView 6 or earlier version?
0 Kudos
Message 4 of 8
(2,667 Views)
Yes how do you create the data file?
0 Kudos
Message 5 of 8
(2,667 Views)
No, I program for a living.
Everything you need is in my previous answer.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 6 of 8
(2,667 Views)
Here is an example. It is not in the exact format that you need, but it can easily be modified.
0 Kudos
Message 7 of 8
(2,667 Views)
RayPh;

If you are using Windows, you may want to consider this XML-toolkit for Labview. It includes a database sample.

Regards;
Enrique
www.visecurity.com
www.vartortech.com
0 Kudos
Message 8 of 8
(2,667 Views)