This code is getting me crazy!

 
Why would this code:

//+------------------------------------ ------------------------------+
//| Crear_subdirectorio.mq4 |
//| Copyright 2014, MetaQuotes Software Corp. |
//| / |
//+------------------------------------ ------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict

#property script_show_inputs
input string nombre="PRUEBA.txt";
//+------------------------------------ ------------------------------+
//| Script program start function |
//+------------------------------------ ------------------------------+
void OnStart()
{
int handle;
//---
ResetLastError();
if(handle=FileOpen(nombre,FILE_READ )!=INVALID_HANDLE)
//Se ha abierto correctament
{
Alert("Open Succesfully");
Alert("Pointer is: ", FileTell(handle));

while(!FileIsLineEnding(handle))
{
FileReadString(handle);
}

FileClose(handle);
Alert("Last Error= ", GetLastError());
}
else
Alert("File not open and last error was= ", GetLastError());


}
//+------------------------------------ ------------------------------+


Work sometimes, sometimes work one time and the time I try it doesnt work....

Now is not reading anything and give no errors...

The file is ok and in the right place...

help!
 
Try FileIsEnding() instead of FileIsLineEnding() and at least print the result of FileReadString(). Here is an example: https://docs.mql4.com/files/fileisending
 

Not working is very strange it started working... at the beggining.

 

JDell Sorry!


Yeah I forgot the print -_-   and I changed it to FileisEnding() and now it reads it! But I cant still make it work with FileisLineEnding dont know why. Do you have an idea?



//+------------------------------------ ------------------------------+
//| Crear_subdirectorio.mq4 |
//| Copyright 2014, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------ ------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property script_show_inputs
input string nombre="datos.txt";
//+------------------------------------ ------------------------------+
//| Script program start function |
//+------------------------------------ ------------------------------+
void OnStart()
{
int handle;

//---
Alert("---------------------------");
ResetLastError();

if(handle=FileOpen(nombre,FILE_READ)!=INVALID_HANDLE)
//Se ha abierto correctament
{
   Alert("Open Succesfully");
   Alert("Pointer is: ", FileTell(handle));
 
   while(!FileIsEnding(handle))
      {
         Alert(FileReadString(handle));
      }
 

   Alert("Pointer is  2: ", FileTell(handle));
   FileClose(handle);
   Alert("Last Error= ", GetLastError());
}

else

Alert("File not open and last error was= ", GetLastError());
}
//+------------------------------------ ------------------------------+

 
Please edit and use SRC when posting codes. Much better that way.
Reason: