MQL4 ObjectSetDouble Bug!

Back to topics list To post a new topic, please log in or register
avatar
7
kenykau 2016.07.20 09: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

avatar
1109
Ovo 2016.07.20 15:06 #
 
My idea would be printing out the obj[i].prop[j][_val]
avatar
7
kenykau 2016.07.21 05: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.

avatar
1109
Ovo 2016.07.21 07:29 #
 

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

Back to topics list  

To add comments, please log in or register