08-13-2015 03:53 AM
mr wolfgang..
as per now arraytofile code is working...array values which im entering is storing into a text file in a way as shown below.
1 2 3 4 5 6 7
but it stores in a first line of the text file..i need it to be stored from the 2nd line...becouse i need to print a characters above each values as shown below..
first line:- a b c d e f g
second line:- 1 2 3 4 5 6 7
plz help me out
08-13-2015 04:41 AM
I see - ArrayToFile cannot write a header line, so you will need to first open a file, write your header line (including a line feed), and then append the contents of the array using ArrayToFile; this requires that you change the last parameter of ArrayToFile to VAL_APPEND.
For writing your header line you can either use the functions from the Formattting and IO library (e.g., OpenFile, WriteFile) or the ANSI C library
08-13-2015 07:52 AM
so an example for a possible solution is:
int fileHandle = 0;
int my_array [ 10 ] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
fileHandle = OpenFile ( "C:\\users\\Wolfgang\\myfile.txt", VAL_WRITE_ONLY, VAL_TRUNCATE, VAL_ASCII );
WriteFile ( fileHandle, " a b c d e f g h i j\n", 41 );
ArrayToFile ( "C:\\users\\Wolfgang\\myfile.txt", my_array, VAL_INTEGER, 10, 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_ROWS, VAL_CONST_WIDTH, 4, VAL_ASCII, VAL_APPEND);
08-17-2015 01:26 AM
almost Done and working as expected...thank you
How to clear the text file before writing the new data into it ? and how to read the file and display its contents?
08-17-2015 01:51 AM
If you don't want to append text to your file but instead want to write from the beginning, you can change the parameter VAL_APPEND to VAL_TRUNCATE, see here.
Let me suggest that you try coding the file read operation yourself, you already know about the Help and Example Finder, and of course if you're stuck me and others will be willing to assist more