Errors, bugs, questions - page 1970

 
pavlick_:

Got an error in my script, trying to localise it, so it's bypassed for now.

I think I found it:

if(sizeof(color) <= sizeof(ulong))
   {
      
      if( ObjectCreate(0, "any_object", OBJ_TREND, 0, 0, 0)  &&
          ObjectSetInteger(0, "any_object", OBJPROP_COLOR, clrNONE) )
      {
         ulong clr;
         if( ObjectGetInteger(0, "any_object", OBJPROP_COLOR, 0, clr) )
         {
            Alert("clr == clrNONE ?  ", clr == (ulong)clrNONE);
            Alert("clrNONE value = ", (ulong)clrNONE);
            Alert("value that was returned = ", clr);
         }
         
      }
   }

Alert:

clr == clrNONE ? false

clrNONE value = 4294967295

value that was returned = 18446744073709551615

I.e., we set colour clrNONE for the object, then we read colour of the object and compare it with clrNONE - they do not converge.
 
pavlick_:

I.e. set the object's colour to clrNONE, then read the object's colour

read colour of another object
 

Yes, thank you. I fixed the names there, but the error is still there.

 
pavlick_:

set the object to colour clrNONE, then read the colour of the object, compare it with clrNONE - they do not match.

Alert("clr == clrNONE ?  ", (color)clr == clrNONE); // true

clrNONE - all bits of 4 bytes are filled with ones.

ulong clr - all bits of 8 bytes are filled with ones.

 
pavlick_:

Yes, thank you. I fixed the names there, but the error is still there.

In fact, in ObjectGetInteger, instead of

void ObjectGetInteger( long& x ) { x = clrNONE; }

.

void ObjectGetInteger( long& x ) { x = -1; }

solution: then write x instead of x everywhere.

(color)x
 
fxsaber:

clrNONE - all bits of the 4 bytes are filled with ones.

ulong clr - all bits of 8 bytes are filled with ones.

There is some kind of error here, I think.

1. clrNONE is a positive 4-byte number since Alert( long(clrNONE) ) == 4294967295 (if it were negative (color sign), it would go into minus)

2. We converted it to long in SetInteger, the value could not change

3. Why do I get a non-primary number in SetInteger?

Either the color inside the terminal is converted to a signed type, int for example, and then grows when converted to along, or something else.

 
Once again, thank you all very much. I'm almost sure that inside colour is casted to signed, with reverse casting and error. Well, it's up to developers to write a valid ObjectGetInteger(), it only takes a few characters: ObjectGetInteger() { return long((uint)internal_clr); }
 
Is this an error (different arrays) or not?
void OnStart()
{
  short Data[] = {1};
  short Data2[];
  
  StringToShortArray(ShortArrayToString(Data), Data2);
//  StringToShortArray(ShortArrayToString(Data), Data2, 0, ArraySize(Data)); // так массивы совпадут
  
  ArrayPrint(Data);  // 1
  ArrayPrint(Data2); // 1 0
}
 
fxsaber:
Is this an error (different arrays) or not?
no, just a final 0 added.
 
Комбинатор:
No, it just adds a terminating 0.

Added a line above - specified to copy the length of the line. It started to match. I.e. it turns out that input parameter count = -1 adds zero to the end, while count = StringLen adds nothing. Nyuansyk!