Errors, bugs, questions - page 2132

 
fxsaber:

When the author is a part-time moderator.

Rather, a moderator and part-time coder.

 
fxsaber:
Is it right for the author of EAs at KB to remove third-party comments in the relevant discussion that point out errors in his code?

no of course.

 
fxsaber:
Is it right for the author of EAs at KB to delete third-party comments in the relevant discussion that point out errors in his code?
No, of course not. Such comments contribute to correcting those errors. Silencing or mashing them up makes the KB a bad manual.
 

I don't get it, what was the point of doing it the other way around in MQL?

C++ VS2017
MQL
printf( "%s", ... )
printf( "%S", ... )
printf( "%S", ... )
printf( "%s", ... )
printf( "%c", ... )
printf( "%C", ... )
printf( "%C", ... )
printf( "%c", ... )
in fact MQL::printf corresponds to CPP::wprintf, though there is no analog of CPP::printf in MQL
 
A100:

I don't get it, what was the point of doing it the other way around in MQL?

C++ VS2017
MQL
printf( "%s", ... )
printf( "%S", ... )
printf( "%S", ... )
printf( "%s", ... )
printf( "%c", ... )
printf( "%C", ... )
printf( "%C", ... )
printf( "%c", ... )
actually MQL::printf corresponds to CPP::wprintf, though there is no analog of CPP::printf in MQL
MQL5 is all unicode, so we have completely abandoned single-byte strings.
 
Renat Fatkhullin:
MQL5 is all unicode, so we have completely abandoned single-byte strings.

I don't believe that completely! Everything works.

void OnStart()
{
        uchar ch[] = { 0x41,0x6E,0x73,0x69,0x20,0x69,0x73,0x20,0x61,0x6C,0x69,0x76,0x65,0x21 };
        string ansi;
        for ( int i = 0, j = 0; i < ArraySize( ch ); i+=2, j++ )
                StringSetCharacter( ansi, j, ch[ i ] | ch[ i + 1 ] << 8 );
        printf( "%S", ansi );
}

Result: Ansi is alive!

 
A100:

I don't believe that completely! Everything works.

Result: Ansi is alive!

Packing binary to unicode and then getting the risk of exploding on a call via a system function is unwise.

Will probably filter out such attempts later.

 
Renat Fatkhullin:

It's unreasonable to get the risk of exploding on a system function call.

Do not exaggerate because string is guaranteed to end with zero. And besides, single-byte characters along with multibyte ones are actually part of Unicode and in MQL it all works fine, which makes it possible to output in Experts tab with normal (and not that awful monospaced) font, for example.

This is like to prohibit call from dll function with argument uchar[], fearing that the user will fill it incorrectly (for example, will not end with zero), while many system functions require exactly uchar[] and not ushort[] (which incidentally can also be filled incorrectly)

 

The 2nd line is the output in human (not monospace) font. As you can see, it is technically easy to leave the monospace font only for ::ArrayPrint()

 

Hello. Please help me find the cause of this error. I'm transferring an indicator from mql4 to mql5. I am using the following "shell" for iHigh functions:

double iHigh(string symbol,ENUM_TIMEFRAMES tf,int index)
  {
   if(index < 0) return(-1);
   double Arr[1];
   if(CopyHigh(symbol,tf,index,1,Arr)>0)
      return(Arr[0]);
   else
     {
      Print(__FUNCTION__,GetLastError());
      return(-1);
     }
  }

As a result, I get the error 4301: "Unknown symbol", even though a string returned by the Symbol() function is passed as the symbol parameter. Here is a piece of code of the function that calls iHigh

ENUM_TIMEFRAMES tf=Period();
   string symbol = Symbol();
   if(filtr1==false) 
      return(true);  
   int i1,i2=0; 
   for(i1=i+1; i2<6; i1++)
     {
      
      if(iLow(symbol,tf,i1)<=iLow(symbol,tf,i1+1) && 
         iHigh(symbol,tf,i1)>=iHigh(symbol,tf,i1+1)) 
        {
         break; //выход из цикла
        }
      else
        {
         i2++;
        }
     }
Reason: