LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert VB2005 read file routine to Labview

Solved!
Go to solution

Greetings Everyone,

 

     I am very NEW to Labview (using Labview 2010) and I'm in the process of trying to convert a Visual Basic 2005 dot Net program to Labview format.

 

     My question for the group is, I would like to convert the VB code below in to Labview.  This is one of many text file reads that my VB program does.

 

'*****Read Frequency Data file and Convert to Double*****
        List = 0
        oRead = IO.File.OpenText("C:\TPS_Data\PA_Freq_List.txt")
        While oRead.Peek <> -1
            LineIn = oRead.ReadLine()
            TFL(List) = LineIn
            TestFreq(List) = Convert.ToDouble(TFL(List))
            List =  + 1
        End While
        oRead.Close()

 

     These files are calibration/offset and frequency data for my RF ATE test equipment.  Once the operator selects an amplifier to test, the program loads into memory these amplifier specific files.  These variables whether they are integer, double or whatever are store in a sub array (ex: TestFreq(0), TestFreq(1), etc.).  Each frequency has its own offset and calibration data that is sent to the respective test equipement per each frequency being tested.  Is this line of code possible or do I have to come up with another way of doing this?  If so, how do I store and retrieve this data at any given time during the test.

 

     I appreciate all the information that this group provides.  Thank you in advance.

 

Regards,

 

Scott

0 Kudos
Message 1 of 5
(2,870 Views)

Here's what you need: http://zone.ni.com/reference/en-XX/help/371361G-01/glang/read_from_spreadsheet_file/

 

That VI will return to you a 2D array, but you can use Index Array to peel off the first column, if all you have is a single column of data.

 

Aside: NEVER hard-code paths in your code.

 

Also: To learn more about LabVIEW it is recommended that you go through the introduction material, tutorial(s), and other material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

0 Kudos
Message 2 of 5
(2,865 Views)

Greetings Smercurio_fc,

 

     Thanks for your reply.

 

     I understand the rules of not hard coding file paths, as taught by Core1 instructor, but these locations NEVER change.  It's part of the installation process for my Vb code.

 

     Yes, you are correct that the file contains a single column of data.

 

     Ok, the suggestion you made with regards to using the Index Array function seems to be working, it took a little time to figure it out.

 

     Now how do I extract each variable from the array separately to be used during the test process.  Example row:0 = 200, I want to store this as TestFreq(0) to be used at any given time during the test process.  Is this possible or am I asking too much?

 

Regards,

 

Scott

0 Kudos
Message 3 of 5
(2,849 Views)

 


@Scott754 wrote:

Greetings Smercurio_fc,

 

     I understand the rules of not hard coding file paths, as taught by Core1 instructor, but these locations NEVER change.  It's part of the installation process for my Vb code.


Yeah, that's what they all say. EVERY time I've heard that it's NEVER turned out to be true. I'm going to bet people a dollar from now on. I'll be able to retire within a year.

 

 

 


     Now how do I extract each variable from the array separately to be used during the test process.  Example row:0 = 200, I want to store this as TestFreq(0) to be used at any given time during the test process.  Is this possible or am I asking too much?


 

You use the same function: Index Array. Or, you auto-index a for-loop. It depends on what the numbers mean and what you're trying to do. Your question is a bit vague, so I can't really give you a more specific answer.

 

To learn more about LabVIEW it is recommended that you go through the introduction material, tutorial(s), and other material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

0 Kudos
Message 4 of 5
(2,847 Views)
Solution
Accepted by topic author Scott754

Greetings smercurio_fc,

 

     Thanks for your recent reply.

 

     Between your most recent reply and another post that I came across today by searching on google, I was able to accomplish what I wanted to do.  The basic function was to read the text file, which is a list of test frequencies and move a RF signal generator to each frequency in the list.

 

     Thanks again for your time.

 

Regards,

 

Scott 

0 Kudos
Message 5 of 5
(2,831 Views)