Help Required for Possible Loss of Data due to Type Conversion

Haryani H
620

:) Hi

I'm having this MT4 indicator, which i didn't use for a long time, back then it was working perfectly well but now it's not loading and while compiling it's shows a warning "possible loss of data due to type conversion" for this code.

   // define count symbols

   if(Selected) { SymbolsNumber = (FileSize(hFile) - 4) / 128; Offset = 116;  }
   else         { SymbolsNumber = FileSize(hFile) / 1936;      Offset = 1924; }

   ArrayResize(Symbols, SymbolsNumber);

The developer who made this indicator for me has left providing services here in this site, can someone please help me to make this indicator usable

Above coding is part of this below section

int SymbolsList(string &Symbols[], bool Selected)
{
   string SymbolsFileName;
   int Offset, SymbolsNumber;
  
   if(Selected) SymbolsFileName = "symbols.sel";
   else         SymbolsFileName = "symbols.raw";
  
   // open file symbols

   int hFile = FileOpenHistory(SymbolsFileName, FILE_BIN|FILE_READ);
   if(hFile < 0) return(-1);

   // define count symbols

   if(Selected) { SymbolsNumber = (FileSize(hFile) - 4) / 128; Offset = 116;  }
   else         { SymbolsNumber = FileSize(hFile) / 1936;      Offset = 1924; }

   ArrayResize(Symbols, SymbolsNumber);

   // read symbols from file

   if(Selected) FileSeek(hFile, 4, SEEK_SET);
  
   for(int i = 0; i < SymbolsNumber; i++)
   {
      Symbols[i] = FileReadString(hFile, 12);
      FileSeek(hFile, Offset, SEEK_CUR);
   }
  
   FileClose(hFile);
  
   // return count of symbols

   return(SymbolsNumber);
}
//---
#define sectorSize  1936
#define HFILE_ERROR -1

Thanking you in advance for all your efforts to help me :)

Sardion Maranatha
757
Sardion Maranatha  
Haryani H:

:) Hi

I'm having this MT4 indicator, which i didn't use for a long time, back then it was working perfectly well but now it's not loading and while compiling it's shows a warning "possible loss of data due to type conversion" for this code.

The developer who made this indicator for me has left providing services here in this site, can someone please help me to make this indicator usable

Above coding is part of this below section

Thanking you in advance for all your efforts to help me :)

  if(Selected) { SymbolsNumber = (FileSize(hFile) - 4) / 128; Offset = 116;  }
   else         { SymbolsNumber = FileSize(hFile) / 1936;      Offset = 1924; }

try to change FilleSize(hfile) to any number, let's say 2000 and do the math..will it guarantee integer number return?


double tsymbolnumber = 0.0;
if(Selected) { tsymbolnumber = (FileSize(hFile) - 4) / 128; Offset = 116;  }
else         { tsymbolnumber = FileSize(hFile) / 1936;      Offset = 1924; }
SymbolsNumber = int(MathCeil(NormalizeDouble(tsymbolnumber,1)));

if (SymbolsNumber<1)
{
   FileClose(hFile);
   return(-1);
}
else
{
    ArrayResize(Symbols, SymbolsNumber);

   // read symbols from file

   if(Selected) FileSeek(hFile, 4, SEEK_SET);
  
   for(int i = 0; i < SymbolsNumber; i++)
   {
      Symbols[i] = FileReadString(hFile, 12);
      FileSeek(hFile, Offset, SEEK_CUR);
   }
  
   FileClose(hFile);
  
   // return count of symbols

   return(SymbolsNumber);
}

my best guess..i could be wrong

Haryani H
620
Haryani H  
Sardion Maranatha:
try to change FilleSize(hfile) to any number, let's say 2000 and do the math..will it guarantee integer number return?


my best guess..i could be wrong

I tried as suggested by you, but any of it didn't worked

Sardion Maranatha
757
Sardion Maranatha  
Haryani H:

I tried as suggested by you, but any of it didn't worked

freelance service could offer better help than me
Nagisa Unada
893
Nagisa Unada  
if(Selected) { SymbolsNumber = (int)(FileSize(hFile) - 4) / 128; Offset = 116;  }
else         { SymbolsNumber = (int)FileSize(hFile) / 1936;      Offset = 1924; }

Haryani H
620
Haryani H  
Nagisa Unada:

:D it worked, compilation successful. Thanks a lot

Now last thing that it's not attaching to a chart i.e. showing an error "Expert 'HSTconverter' is not custom indicator and will be removed"

Nagisa Unada
893
Nagisa Unada  

Haryani H:

Now last thing that it's not attaching to a chart i.e. showing an error "Expert 'HSTconverter' is not custom indicator and will be removed"

Nobody knows anything about that problem from the content of this thread.

Haryani H
620
Haryani H  
Nagisa Unada:

Nobody knows anything about that problem from the content of this thread.

can I dm you my indicator source file, so that you could have a look at it for the problem?

Nagisa Unada
893
Nagisa Unada  
Haryani H:

can I dm you my indicator source file, so that you could have a look at it for the problem?

No, I do not accept direct requests.

Haryani H
620
Haryani H  
Nagisa Unada:

No, I do not accept direct requests.

ok, thanks for all your help :)