Rejoignez notre page de fans
- Vues:
- 4205
- Note:
- Publié:
- 2013.03.29 11:55
- Mise à jour:
- 2016.11.22 07:32
-
Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance
The script reads and prints data from a file which is located in the terminal local folder. Reading performs in the loop by the FileReadString() function until the end of the file. The FileIsEnding() function is used to check, if the end of the file is reached.
It should be noted that to define the end of the file, the function tries to read the next string from the file. If it doesn't exist, the function will return true, otherwise it will return false.
Code:
//--- show the window of input parameters when launching the script #property script_show_inputs //--- input parameters input string InpFileName="file.txt"; // file name input string InpDirectoryName="Data"; // directory name input int InpEncodingType=FILE_ANSI; // ANSI=32 or UNICODE=64 //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- print the path to the file we are going to use PrintFormat("Working %s\\Files\\ folder",TerminalInfoString(TERMINAL_DATA_PATH)); //--- reset the error value ResetLastError(); //--- open the file for reading (if the file does not exist, the error will occur) int file_handle=FileOpen(InpDirectoryName+"//"+InpFileName,FILE_READ|FILE_TXT|InpEncodingType); if(file_handle!=INVALID_HANDLE) { //--- print the file contents while(!FileIsEnding(file_handle)) Print(FileReadString(file_handle)); //--- close the file FileClose(file_handle); } else PrintFormat("Error, code = %d",GetLastError()); }
Traduit du russe par MetaQuotes Ltd.
Code original : https://www.mql5.com/ru/code/1617
![i-IntradayFibonacci](https://c.mql5.com/i/code/indicator.png)
Intraday Fibonacci levels
![Demo_FileFlush](https://c.mql5.com/i/code/script.png)
The script demonstrates the example of using the FileFlush() function
![Demo_FileGetInteger](https://c.mql5.com/i/code/script.png)
The script demonstrates the example of using the FileGetInteger() function
![Demo_FileWriteArray](https://c.mql5.com/i/code/expert.png)
The script demonstrates the example of using the FileWriteArray() function