LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

STRING SAVING IN TEXTFILE

Ihave used Arraytofile command to store data(float ) in text file.Now I want to store strings in a text file(I don't want to use VAL_CHAR as data type).What should I do?
0 Kudos
Message 1 of 3
(3,291 Views)

You can use standard ANSI C functions to open the file and write to it (fopen / fwrite / fclose). Similar functions can be found in the Formatting and I/O Library (OpenFile / WriteFile / WriteLine / CloseFile). An example of the second type of function can be found in atedemo.prj example (\examples\apps\atedemo folder), while in examples\apps\scopedemo folder you can find an example of standard ANSI C function usage.

I personally prefere to use Formatting and I/O Library functions since I find easier to design error checking routines for them. I know several CVI users tend to use standard file I/O function in seek of better portability and higher code standardization. I suggest you experience some of them and choose your personal solution.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 3
(3,288 Views)

Hi tupai,

Unfortunately if you look at the documentation for the ArrayToFile function, it does not allow you to use a string as the datatype of the array elements:
http://zone.ni.com/reference/en-XX/help/370051H-01/cvi/cviarraytofile/

So what you would have to do is write your own implementation of the ArrayToFile function that basically iterates through your string array and writes each string to the file using the ANSI C File I/O commands.
Searching google might be a good first step in implementing your own ArrayToFile function:
http://www.google.com/search?rls=en&q=ansi+c+file+functions

Jervin Justin
NI TestStand Product Manager
0 Kudos
Message 3 of 3
(3,259 Views)