# TROComplexType Boolean Property - not evaluation fail

**URL:** https://talk.remobjects.com/t/trocomplextype-boolean-property-not-evaluation-fail/4647
**Category:** Remoting SDK
**Created:** [July 24, 2014, 3:17pm UTC](https://talk.remobjects.com/t/trocomplextype-boolean-property-not-evaluation-fail/4647 "2014-07-24T15:17:32Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dennisew](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/d/3ab097/32.png) [@dennisew](https://talk.remobjects.com/u/dennisew)
#### Post date: [July 24, 2014, 3:17pm UTC](https://talk.remobjects.com/t/trocomplextype-boolean-property-not-evaluation-fail/4647/1 "2014-07-24T15:17:33Z")

</div>

Just seen a post on StackOverflow that is poorly described but got me thinking (the poster refers to RO SDK)

> <https://stackoverflow.com/questions/24930228/delphi-not-operator-returns-incorrect>

  
so assume:

```
TFoo = class (TROComplexType)
...
published    
  property CanEdit: Boolean read fCanEdit write fCanEdit;
end;

```

TROStreamSerializer treats boolean true as a value of 255

and looking into TROStreamSerializer.ReadEnumerated I see that the value of fCanEdit would be set to 255 if fCanEdit should be true.

Good so far, except:

```
var
 temp : Boolean;
begin
  // De-serialize Foo from a stream and CanEdit is set to True
 Assert (Foo.CanEdit); 
 temp := not Foo.CanEdit;
  // temp is true

```

Inspect the memory and you will see:  
Byte (Foo.CanEdit) = 255  
Byte (Temp) = 254

Ouch, boolean evaluation on boolean property of TROComplexType does not work as one would expect.

The poster appears to have solved his/her problem, but thought it would be prudent to show what I found contemplating said posters problem.

As a side note I have a fairly oldish version of RO SDK, so maybe it’s already fixed, don’t know.

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [July 29, 2014, 8:45am UTC](https://talk.remobjects.com/t/trocomplextype-boolean-property-not-evaluation-fail/4647/2 "2014-07-29T08:45:24Z")

</div>

I can’t reproduce this case with XE5 and BinMessage.  
Server-side:

```auto
function TNewService.NewMethod: NewStruct;
begin
  Result := NewStruct.Create;
  Result.NewField := true;
end;

```

client-side:

```auto
procedure TClientForm.Button1Click(Sender: TObject);
var
  a: Newstruct;
  b:boolean;
begin
  a := (RORemoteService as INewService).NewMethod;
  b:= not a.NewField ;
  if a.NewField = b then
    raise Exception.Create('a.NewField is equal b')
  else
    ShowMessage('a = '+BoolToStr(a.NewField,True) +', b = '+BoolToStr(b,True));
end;

```
