Download MetaTrader 5

This code is getting me crazy!

To add comments, please log in or register
Luis
226
Luis  
Why would this code:

//+------------------------------------ ------------------------------+
//| 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="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!
JDeel
238
JDeel  
Try FileIsEnding() instead of FileIsLineEnding() and at least print the result of FileReadString(). Here is an example: https://docs.mql4.com/files/fileisending
Luis
226
Luis  

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

Luis
226
Luis  

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());
}
//+------------------------------------ ------------------------------+

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI  
Please edit and use SRC when posting codes. Much better that way.
To add comments, please log in or register