FileReadString reading gibrish

 

Hi

This code is expected to read the content of C:\Users\myName\AppData\Roaming\MetaQuotes\Terminal\Common\Files\spread\EURGBP.txt which is "0 10" with out the quotes. But I am getting "No value in file".

Any idea why and how to fix it so that it reads the content of "0 10"? Thanks

    int fH = FileOpen(fileName, FILE_READ | FILE_COMMON, 0);
    if(fH == INVALID_HANDLE){
      Print("File does not exist: ", mSymbol);
    } else {
      string value = FileReadString(fH);
      string result[];
      uint k = StringSplit(value, StringGetCharacter(" ", 0), result); // k is 1 but I expected it to be 2, why? and how to fix?
      if(k == 2){
        // do stuff...
      } else {
        Print("No values in file: ", mSymbol); // <<<<<<<<<<<<<<< this is printing 
      }
    }
 
samjesse:

Hi

This code is expected to read the content of C:\Users\myName\AppData\Roaming\MetaQuotes\Terminal\Common\Files\spread\EURGBP.txt which is "0 10" with out the quotes. But I am getting "No value in file".

Any idea why and how to fix it so that it reads the content of "0 10"? Thanks

Are you sure the separator is a space and not a tab ?

You could also have to use FILE_ANSI or FILE_UNICODE.

Reason: