Skip to main content

How to compare to structs

  • May 28, 2019
  • 3 replies
  • 1 view

Ingo Stiller
Forum|alt.badge.img+3

If I do have a complex struct and do have two extra struct variables "pointing" into this struct.
My intention is to do some synchronisation on the two structs and for the sake of performance I like to skip this.

So, how to check, if this two variables are pointing to the same branch in the global struct?

IF( v_STRUCT_A==v_STRUCT_B) does not work, as UnifAce first converts the two structs to a scalar string.
Okay  v_STRUCT_A->$dbgstring==v_STRUCT_B->$dbgstring would be a (not perfect) workaround.
But this I want to avoid, as

*  convert to DBG_STRING tooks time
*  compare of long strings tooks time
*  the sync is is not such long

Is there any way to compare two pointers/things for identity as in other program languages?

Ingo

3 replies

Jonke Korzelius

If I do have a complex struct and do have two extra struct variables "pointing" into this struct.
My intention is to do some synchronisation on the two structs and for the sake of performance I like to skip this.

So, how to check, if this two variables are pointing to the same branch in the global struct?

IF( v_STRUCT_A==v_STRUCT_B) does not work, as UnifAce first converts the two structs to a scalar string.
Okay  v_STRUCT_A->$dbgstring==v_STRUCT_B->$dbgstring would be a (not perfect) workaround.
But this I want to avoid, as

*  convert to DBG_STRING tooks time
*  compare of long strings tooks time
*  the sync is is not such long

Is there any way to compare two pointers/things for identity as in other program languages?

Ingo

Hi Ingo,

We have a Proc function that can help you with this:

if ($equalStructRefs(vStructA, vStructB) != 1)
  <do something> 
endif



Ingo Stiller
Forum|alt.badge.img+3
  • Author
  • Participating Frequently
  • May 28, 2019

If I do have a complex struct and do have two extra struct variables "pointing" into this struct.
My intention is to do some synchronisation on the two structs and for the sake of performance I like to skip this.

So, how to check, if this two variables are pointing to the same branch in the global struct?

IF( v_STRUCT_A==v_STRUCT_B) does not work, as UnifAce first converts the two structs to a scalar string.
Okay  v_STRUCT_A->$dbgstring==v_STRUCT_B->$dbgstring would be a (not perfect) workaround.
But this I want to avoid, as

*  convert to DBG_STRING tooks time
*  compare of long strings tooks time
*  the sync is is not such long

Is there any way to compare two pointers/things for identity as in other program languages?

Ingo

Super, thanks


Michael Taylor

If I do have a complex struct and do have two extra struct variables "pointing" into this struct.
My intention is to do some synchronisation on the two structs and for the sake of performance I like to skip this.

So, how to check, if this two variables are pointing to the same branch in the global struct?

IF( v_STRUCT_A==v_STRUCT_B) does not work, as UnifAce first converts the two structs to a scalar string.
Okay  v_STRUCT_A->$dbgstring==v_STRUCT_B->$dbgstring would be a (not perfect) workaround.
But this I want to avoid, as

*  convert to DBG_STRING tooks time
*  compare of long strings tooks time
*  the sync is is not such long

Is there any way to compare two pointers/things for identity as in other program languages?

Ingo

Hi Ingo,

There is quite a bit of information in the ulibrary about comparing structs

Regards,

Mike