Reading a Text File - Can't Read the Entire Record

 


Hi All

I have a text file the has one record in it with two pieces of information:

5W;100

My read function is only returning "5W"  and I want if to return(read)

5W;100 so that I can parse the information from the whole string.


 

My Question is:

How can I read the whole text file record and not just to the first semi-colon?

Many Thanks


 

Kody_Devl


 


 


 


 

 
  • read the whole file:
int readCsvFile( const string fName, string &lines[] ) { // alternative to FileOpen 
  uchar Bytes[];
  return( FileLoad(fName, Bytes) ? StringSplit(CharArrayToString(Bytes), '\n', lines) : 0);
}
  • Now you can split each line[i] into cells:
int getAllCells(const string line, string &cells[], ushort sepItm=';'){
   return( StringSplit(line, sepItm, cells) );
}

=>

   string lines[], cells[], fName = "myFile.csv";
   int l = readCsvFile( fName, lines );
   while(l-->0) {
      int c = getAllCells(lines[i], cells);
      while(c-->0) { ...
      }
   } 
That simple ;)



Reason: