Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving and reading from saved file

I'm saving my data points according to the format shown in the attached file.
The number of data points acquired is random. How do I retrieve my saved data and plot it out for analysis later?
U got one similar answer in your website but it is in Visual Basic. PLEASE give me some example instructions in VISUAL C++! I'd know nothong about Visual Basic!
0 Kudos
Message 1 of 5
(3,458 Views)
Well, there are two ways. I'm not sure how familiar you are with MFC, but the usual way to save off data objects in MFC in through persistence (serialization). Our Vector data object have Serialize methods that are setup to output/input to a CArchive object in MFC. That is the easiest way. Our application note in the help on the document/view architecture discusses serialization.

If you are unfamiliar with serialization and don't want to learn it, then you could just make the first 4 bytes of the file, the size in bytes of the data array and read it off first so you know how much data is in the file.

Best Regards,

Chris Matthews
National Instruments
Message 2 of 5
(3,458 Views)
Well, Chris, the main problem I have is not saving or retrieving the data. But I just can't convert my double array in a format that can be plotted by CNiGrapgh::PlotY! Is there any way I can convert the double array into CNiReal64Vector?
Please Help!
0 Kudos
Message 3 of 5
(3,458 Views)
Sure. There is a constructor specifically for this. If your buffer is a double* or double[], then you can put it in a CNiReal64Vector like this:

CNiReal64Vector vData(numElements, data);

where numElements is an integer specifying the number of double values and data is the double pointer.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 4 of 5
(3,458 Views)
Also, another note, there are cast operators from a double array to a CNiReal64Vector. That means that in functions where you see it ask for a CNiReal64Vector, you can just put in a double array and it will accept it. For example, something like

double data[100];
...
m_graph.PlotY(data);

should work fine.

Chris
0 Kudos
Message 5 of 5
(3,459 Views)