Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Using waveformplot and waveformgraph with data in a .txt file

Hey,
 
I have a bunch of data arranged into columns (delimited by tabs) in a text file and am trying to use the data in each column as a seperate y-value plot (each row is an x-value). However, for future reference, I will have no idea how many columns (waveformplots) or rows (data points) I am going to have, and so I need to make it as general as possible... so far I can't get anything to show up except my legend (code as follows)
I am using VS .NET 2003, and Measurement Studio 7.1... can anyone help?
 
Thank you!
 
Dim legend as String
Dim nameArray() as String
Dim col as Integer
Dim SR as IO.StreamReader = IO.File.OpenText(filetextbox.Text)
 
legend = SR.ReadLine()
nameArray = legend.Split(vbTab)
 
Do
Legend1.Items(col).Text = nameArray(col)
Legend1.Items(col).Visible = True
col += 1
Loop Until nameArray(col) = "end"
0 Kudos
Message 1 of 10
(4,880 Views)

Hi Mrees515,

There are examples for plotting in Waveform graphs located on your hard drive at:  C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\UI\Graph.  In particular, the program "Plot Waveforms" should help. 

Cheers,

David Goldberg
National Instruments
Software R&D
0 Kudos
Message 2 of 10
(4,864 Views)
Yes, unfortunately those examples only provide instances of random data being plotted. I can plot random data just fine, I'm just not sure how to plot data from a text file - whenever I pull the data, it converts it to String, and I want it as plottable, numeric data. In VB.NET 2005, I could use the parse method to obtain numeric data, but there is no parse option with 2003... =(
0 Kudos
Message 3 of 10
(4,858 Views)
I am not sure which parse method you are referring but Double.Parse method exists in both VS2003 and VS2005 in VB.NET. This is what you could use to parse your strings to double values.
Abhishek Ghuwalewala | Measurement Studio | National Instruments
0 Kudos
Message 4 of 10
(4,844 Views)
There are several parsing methods available for vs2003. Double.Prase will convert a string to a double. Also take a look at the Measurement Studio Dataconvertor class to converting strings to numbers. The .NET string class also provides several parsing options as well for tokenizing strings based on a delimiter.

Bilal Durrani
NI
0 Kudos
Message 5 of 10
(4,841 Views)
Is your question really about how to read numerics from a text file?
Just read your text file, split each line, and convert strings to numerics:

    Dim col as Integer
    Dim SR as IO.StreamReader = IO.File.OpenText("...")
    Dim s As String
    Dim sa() As String
    Dim d As Double
    ' ...

    s = SR.ReadLine()
    sa = s.Split(vbTab)
    d = Convert.ToDouble(sa(col))
or
    d = CDbl(sa(col))

If your question is about something else, please clarify.
0 Kudos
Message 6 of 10
(4,843 Views)
Perfect! I got it to work, thank you! Smiley Happy
0 Kudos
Message 7 of 10
(4,820 Views)
Another solution which would elimate the need to put the code in a loop for different columns would be to use:

string

line = "1.0, 2.0, 3.5";

string[] s = line.Split(new char[]{' ', ','}, StringSplitOptions.RemoveEmptyEntries);

double[] test = NationalInstruments.DataConverter.Convert<double[]>(s);

This will convert the whole line into a double array of your values. I know this code is C# but I imagine in VB there is an equivalent.

Cheers

Adam

0 Kudos
Message 8 of 10
(4,779 Views)
Hi,
Haven gone through your post, i have the conviction that you can really help me in converting the 2-Dimensional array used as examples to a double value that i can read in a textbox or numberEdit control. I mean how do i convert the array in the sample supplied with measurement studio to display in a textbox or Numericedit control?
Thanks in anticipation of your favourable reply
 
Charlion 
0 Kudos
Message 9 of 10
(4,388 Views)
Hi Charlion,
 
Do you have MeasurementStudio 8.0.1 or later?  These versions have a NumericEditArrays, which would seem to be best suited for your application.  If so, there is an example for this at:
 
[Measurement Studio Installation Directory]\DotNET\Examples\UI\WindowsForms\ControlArray
Cheers,

David Goldberg
National Instruments
Software R&D
0 Kudos
Message 10 of 10
(4,365 Views)