Errors, bugs, questions - page 921

 
sergeev:

- Does the broker support setting an order with time?

To do this, press F9 and check if the time can be set.


Everything works here, i.e. all pending orders are executed without errors.
 
Hello, I have this question - I bought an EA installed on my computer, then ordered a VPS server and installed the same EA. In the end I refused the rented server because the broker has a free service, but I cannot install the Expert Advisor for the third time (on three hardware). What can I do? Can I give up one server for another? Where to go? Thank you!
 

Two questions about working with files.

1. There is a text file containing strings in various languages (including Japanese, Arabic etc.). Accordingly the encoding of the file is UTF8. The data in the file is written as "Alias=Translation", where the alias is always in English and the translation is any other language. I was sure that FILE_UNICODE should be used while reading. But if you open the file like this:

int fileHandle = FileOpen(fileName, FILE_READ|FILE_TXT|FILE_UNICODE, 0, CP_UTF8);

we get a meaningless set of hieroglyphs when reading the lines. But if you open it like this:

int fileHandle = FileOpen(fileName, FILE_READ|FILE_TXT|FILE_ANSI, 0, CP_UTF8);

then it reads and subsequently outputs normally (I checked English, Russian, Ukrainian, Japanese, Arabic).

Question: why do we need to use flag FILE_ANSI? After all, ANSI is for single-byte characters and UTF8 unicode character encoding...


2. There is a class which has such a method:

string CTranslator::getTranslate(string str) {
//---
   int fileHandle = FileOpen(filename, FILE_READ|FILE_TXT|FILE_ANSI, 0, CP_UTF8);
   
   if ( fileHandle == INVALID_HANDLE ) {
      return(str);
   }
//---
   string temp, alias, traslation;
   int delimiterPos;
      
   for ( ; !FileIsEnding(fileHandle); ) {
      temp = FileReadString(fileHandle);
      delimiterPos = StringFind(temp, "=");
      alias = StringSubstr(temp, 0, delimiterPos);
      
      if ( StringCompare(str, alias, false) == 0 ) {
         traslation = StringSubstr(temp, delimiterPos+1);
          
         return(traslation);
      }   
   }
   FileClose(fileHandle);
//---
   return(str);
}

File name is a property and it's given a value when initializing an object. That is, when calling the method, we open the file, read line by line, and as soon as we find the matching string, we return its substring. If the file is not opened or there is no matching string, we return the string that was fed to the input.

If we call the method once, everything works. But if you call several times in a row - it works only the first time, while the second and subsequent attempts to open the file - INVALID_HANDLE (checked with print). What could be the problem?

Документация по MQL5: Стандартные константы, перечисления и структуры / Именованные константы / Прочие константы
Документация по MQL5: Стандартные константы, перечисления и структуры / Именованные константы / Прочие константы
  • www.mql5.com
Стандартные константы, перечисления и структуры / Именованные константы / Прочие константы - Документация по MQL5
 
Rone:

2. There is a class that has this method:

File name is a property and it is assigned a value during object initialization. That is, when the method is called, we open the file, read it line by line, and as soon as we find a suitable line, we return its substring. If the file is not opened or there is no matching string, we return the string that was fed to the input.

If we call the method once, everything works. But if you call several times in a row - it works only the first time, while the second and subsequent attempts to open the file - INVALID_HANDLE (checked with print). What could be the problem?

This might be the reason:

      if ( StringCompare(str, alias, false) == 0 ) {
         traslation = StringSubstr(temp, delimiterPos+1);
          
         return(traslation);
      }   
 
Rone:

...

2. There is a class that has a method like this:

The filename is a property and is assigned a value when the object is initialized. That is, when the method is called, we open the file, read it line by line, and as soon as we find a suitable line, we return its substring. If the file is not opened or there is no matching string, we return the string that was fed to the input.

If we call the method once, everything works. But if you call several times in a row - it works only the first time, while the second and subsequent attempts to open the file - INVALID_HANDLE (checked with print). What could be the problem?

Maybe because if "return the string that was fed to the input" the file is not closed?
 

maybe it works there

But does your brokerage company have a date option?

 
Contender:

Perhaps that's the reason:

...

tol64

...


Thanks for the prompt replies!

Sorry, I overlooked it, went out for a smoke and got it.

Here it is:

      if ( StringCompare(str, alias, false) == 0 ) {
         traslation = StringSubstr(temp, delimiterPos+1);
         FileClose(fileHandle);

         return(traslation);
      }

It's working now. But the first question still stands.

 
sergeev:

maybe that's where it works.

but does your brokerage company have a date option?

I have not heard anything clear from my broker for a week ... rrrrrrr....

 
Rone:


Thank you for your prompt replies!

Sorry, I overlooked it, went out for a smoke and got it.

Here it is:

It's working now. But the first question still stands.

On the first question.

If file is opened as unicode, no conversion is done (i.e. your CP_UTF8 is simply ignored), data is read "as is"

The code page works when converting to internal Unicode text ( string type data) when reading from a text file opened in ANSI mode.

 
Nikos52:

I haven't heard anything clear from my broker for a week now ... rrrrrr....


is the F9 on your brokerage terminal broken?