Download MetaTrader 5
To add comments, please log in or register
Interested in MetaTrader 5 features? Learn more about them!
rogivilela
25
rogivilela 2016.09.30 01:32 

Ola pessoal estou tendo dificuldades com a leitura de um arquivo TXT, peguei um programa q ja faz isso porem por algum motivo na hora da leitura dos dados a funcao entra em loop infinito. Poderiam me ajudar com o problema ou postar algum codigo exemplo.
segue a baixo o ponto q entra em loop infinito e o arquivo do codigo completo em ZIP


bool GetValuesParamsFromFile(int hdl,double &array[])
{
int
sgn=0, // Sign number "="
cnts=0; // String counter
string str=""; // String that is read
ulong tell_seek=0,tseek=0; // Position of the pointer
string delUser="------\nThe user has deleted the program from the chart!";
//---
FileSeek(hdl,0,SEEK_SET); // Move the pointer to the beginning
//---
// Read until the file pointer reached the end of the file
while(!FileIsEnding(hdl))
{
if(IsStopped()) // If the user has deleted the program
{
// Delete all objects created by the Expert Advisor
DeleteAllExpertObjects();
Print(delUser); return(false);
}
//---
while(!FileIsLineEnding(hdl)) // Read until the end of the file
{
if(IsStopped()) // If the user has deleted the program
{
// Delete all objects created by the Expert Advisor
DeleteAllExpertObjects();
Print(delUser); return(false);
}
//---
str=FileReadString(hdl); // Read the string
//---
sgn=StringFind(str,"=",0); // Get the separator number
str=StringSubstr(str,sgn+1); // Get everything that is after the separator
array[cnts]=SD(str); // Place the value in the array having converted it to the double type
//---
tell_seek=FileTell(hdl); // Get the position of the pointer
//---
if(FileIsLineEnding(hdl)) // If it is the end of the string
{
// Go to the next string if it is not the end of the file
if(!FileIsEnding(hdl))
{ tseek=tell_seek+1; } // Increment the counter for the pointer
//---
// Move the pointer
FileSeek(hdl,tseek,SEEK_SET); cnts++; break;
}
}
//---
// If it is the end of the file, exit the loop
if(FileIsEnding(hdl)) { break; }
}
//---
// Return that reading has been completed successfully
return(true);
}
Files:
/
To add comments, please log in or register