compare types
Blitz3D Forums/Blitz3D Programming/compare types
| ||
This doesn't seem to be working. So how do I check if test1 and test2 are the same or not the same without throwing in some "Field ID" in the definition of Type Test. I though this would work but it doesn't work in code I'm working on. for this1.Test Each Test for this2.Test = Each Test if (this1 = this2) then ; do something end if next next |
| ||
AFAIK, you can't nest type loops. |
| ||
And what would happen if you did? As far as I know you can nest them since I have done that before and it worked. But how do you compare them? Anyone knows`? |
| ||
In that code you're just comparing the type handles. To actually compare the contents (fields) of types, you have to do it manually i.e. compare each field. [edit] Also, using a nested loop like that will mean you will be comparing a type instance with itself at times, which will always match. :) |
| ||
Just an example of how I do it. This way cuts the comparisons down a fair bit.For b1.body = Each body b2.body = b1 While b2 <> Last body b2 = After b2 distance# = EntityDistance( b1\entity , b2\entity ) If Distance < ( b1\BT\Radius + b2\BT\Radius ) And ( b1\Collider And b2\Collider ) COLLISIONcheck( b1 , b2 ) COLLISIONcheck( b2 , b1 ) EndIf Wend Next |
| ||
nice, just what I looked for :) thanks for the example. >you have to do it manually i.e. compare each field. I did that and for some reason it didn't work, it match true even it if was not the case. |
| ||
You can nest type loops. Your code at the top of the page has a bug in the first line: missing "=" sign. I really don't know why people reply with wrong information when they obviously don't know the answer. Type myType Field name$ End Type a.myType = New myType a\name = "a" b.myType = New myType b\name = "b" For c.myType = Each myType For d.myType = Each myType If c = d Print "found type objects "+c\name+" and "+d\name EndIf Next Next WaitKey End |
| ||
I really don't know why people reply with wrong information when they obviously don't know the answer. Uh? Maximo did say "nice, just what I looked for". I know his first post looks like he wants to compare type handles but I deduced that's not what he wanted as it - and your example - are pointless because one type's handle will never match another type's. :) |
| ||
I didn't mean you. :) I actually only meant BlackD. Sorry if I offended anyone else. But it is still true that his code would not have worked either way cos of the missing =. |
| ||
Not offended, just a bit confused. :P But it is still true that his code would not have worked either way cos of the missing =. I can't argue with that. :) |