0

variable.txt file :

10;20;30;40;50

how to import the variable.txt into mql4 variable

a=10

b=20

c=30

d=40

e=50

thank you

luator
  • 4,769
  • 3
  • 30
  • 51
  • Have you seen this https://stackoverflow.com/questions/51061059/integrating-the-ohlc-value-from-python-api-to-mt5-using-mql5/51199962#51199962 ? Skip python and use only MQL4/5 part of the answer, if you need to parse some message manually -`getSymbolFromFileName()` function shows what to do – Daniel Kniaz Oct 05 '19 at 09:59
  • can you help me, with the basic simple code? thank you – Seteven Wei Oct 05 '19 at 11:50
  • all the code is there. copy and paste, add debug when you received a message and tell us what is the problem – Daniel Kniaz Oct 05 '19 at 14:41

1 Answers1

0

This does not reproduce the lettering indicated in your suggested output, but is perhaps a more useful example in general:

  ResetLastError();
  int next_int = 0;
  int filehandle = FileOpen("variable.txt",FILE_READ|FILE_CSV|FILE_ANSI);
  if( filehandle != INVALID_HANDLE ) {
    while(!FileIsLineEnding(file_handle) && !FileIsEnding(file_handle)) {
      next_int = StringToInteger(FileReadString(filehandle));
      Print("the next int is ",next_int);
    } // while
    FileClose(filehandle);
  } // if
  else {
    Print("FileOpen('variable.txt') failed, error= ",GetLastError());
  } // else

Review the MQL4 documentation for FileOpen(), FileIsLineEnding() and FileReadString() for more clarity. Note the opened file path is relative to the MetaTrader4 Terminal path, as described in doc for FileOpen().

B Custer
  • 241
  • 2
  • 7