Download MetaTrader 5
To add comments, please log in or register
Why to sell products in MetaTrader AppStore? Find that out from the article!
kenykau
45
kenykau 2016.07.20 07:57 

Hi all,

I have encountered an unexpected bug or error while using the ObjectSetDouble function, following is the program segment.

#define error Print("Error: ", GetLastError());
void Deserializer::Create(long id){
   int len = ArraySize(this.obj);
   for(int i=0; i<len; i++){
      if(!ObjectCreate(id, this.obj[i].name, (ENUM_OBJECT)this.obj[i].type, this.obj[i].subwin, 0, 0)){
         error;
         return;
      }
      int count = ArrayRange(this.obj[i].prop, 0);
      for(int j=0; j<count; j++){
         int p=(int)StringToInteger(this.obj[i].prop[j][_prop]);
         int m = (int)StringToInteger(this.obj[i].prop[j][_mod]);
         
         //double typed property never updated!
         if(this.obj[i].prop[j][_type] == "ENUM_OBJECT_PROPERTY_DOUBLE")
            if(!ObjectSetDouble(id, this.obj[i].name, p, m, StringToDouble(this.obj[i].prop[j][_val]))) error;  /*not updated and no error message*/

         //successfully updated
         if(this.obj[i].prop[j][_type] == "ENUM_OBJECT_PROPERTY_INTEGER")
            if(!ObjectSetInteger(id, this.obj[i].name, p, m, StringToInteger(this.obj[i].prop[j][_val]))) error;
         
         //successfully updated
         if(this.obj[i].prop[j][_type] == "ENUM_OBJECT_PROPERTY_DOUBLE")
            if(!ObjectSetString(id, this.obj[i].name, p, m, this.obj[i].prop[j][_val])) error;

      }
   }
}

Does anyone has an idea?

Thanks in advance.

Ken

Ovo Cz
2963
Ovo Cz 2016.07.20 13:06  
My idea would be printing out the obj[i].prop[j][_val]
kenykau
45
kenykau 2016.07.21 03:48  

Ovo,

My idea would be printing out the obj[i].prop[j][_val]

Thanks for your reply.

I have already tried. It seems no problem for the value, as the _val had been Serialized previously.

I also tried to hard code the _val in a test script, which performed correctly.

Later on, I felt I found the problem as the modifier variable may affect the correctness, but finally turned out it is not the cause.

This drives me crazy.

Ovo Cz
2963
Ovo Cz 2016.07.21 05:29  

Weird, i would bet the problem was with parsing the StringToDouble parameter. Does it really contain only digits (no whitespace)?

/
To add comments, please log in or register