LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Read file from different locations in cvi (Urgent) ?

Hi All

I want to read a 10Mb file in CVI, but 10 words in one attempt. How it will posible to set file pointer in next location ? I also used

 

SetFilePtr (FileHandler1, 11, 1); but there is no effect on the output...

 

FileHandler1 = OpenFile ("TestFile.txt", VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII);

 

FileToArray ("Bc2Rt.txt", ReadData1, VAL_UNSIGNED_SHORT_INTEGER, 10, 1, VAL_DATA_MULTIPLEXED, VAL_GROUPS_AS_COLUMNS, VAL_ASCII);
FileToArray ("Bc2Rt.txt", ReadData2, VAL_UNSIGNED_SHORT_INTEGER, 10, 1, VAL_DATA_MULTIPLEXED, VAL_GROUPS_AS_COLUMNS, VAL_ASCII);

 

for(count=1;count<=10;count++)
{
     SetTableCellVal (panelHandle, PANEL_TABLE1,MakePoint(1, count), ReadData1[count-1]); 
     SetTableCellVal (panelHandle, PANEL_TABLE2,MakePoint(1, count), ReadData2[count-1]); 
}

 

 

There is any example code or anyone help me

 

Regards

Umer

0 Kudos
Message 1 of 3
(3,260 Views)

Yes, there is an example on the function FileToArray in fileio\arrayfile.cws

Message 2 of 3
(3,257 Views)

Unfortunately FileToArray does not permit you to skip some values before reading: it reads a specified number of samples but always starting at the beginning of file.

Using SetFilePtr is of no help, since FileToArray opens, reads and closes the file by itself as specifiend in the online help.

 

To obtain the behaviour you want you must use the file I/O functions OpenFile, SetFilePtr, ReadFile/ReadLine, CloseFile (or fopen, fseek, fread, fclose if you prefere to use native ANSI C functions)



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?
Message 3 of 3
(3,252 Views)