Count how many lines on a text file...

 

Good Day...

Is there a way on how to count how many lines are there in a text file?

for example the text file contains...

EURUSD

GBPUSD

EURJPY

USDCHF

after reading the text file using FileOpen it should return 4 as it contains only 4 symbols or 4 lines...

Thank you very much...

 
int nLines = 0,
    handle = FileOpen(nameOPT, FILE_CSV|FILE_READ, '~');
if(handle < 1) ...
while(true){
   string   line = FileReadString(handle);
   if(      line == "") break; // EOF
   nLines++;
}
FileClose(handle);
Print("File contains "+nLines+" lines");
See also get list of all symbols running in mt4 programatically - MQL4 forum
Reason: