Hi all
I'm just beginning writing some scritpt reports and I have a couple of questions.
First, how do you version script sources? I did not see any built-in versioning capabilities for scripts. I was thinking of using github for versioning the scripts and copy/paste between github and aris script editor. The downside is script tables (which contains text constants definitions) : is it possible to export/import the content of the script tables to version them with git ?
My second question is about testing object occurrence equality. For example, given the object occurrences of a model, I get the relationships of the object and I want to test if a given object occurrence is the target or source of the relationship.
So far I'm using this test :
if (relations_list[i].TargetObjOcc().ObjDef().ObjectID()== anObjOcc.ObjDef().ObjectID())
which seems pretty complicated (but it does the trick)
because the test (relations_list[i].TargetObjOcc() == anObjOcc ) does not seem to work (I'm learning javascript at the same time)
But is there a more simple test ?
Thanks for your answsers,
Michel
I don't have any experience with versioning reports, can't help you there.
Regarding your second question:
Your approach doesn't work in 100 % of all imaginable test cases.
Plug two occurrences with the same object definition into the same model, and let a report check whether or not they are the same occurrence with your approach. Your report would tell you they are the same, even though they are not the same (they only share the same object definition, but can be placed in different parts of your model graph).
You can either scratch the .ObjDef() from your way of doing it (occurrences have an ObjectID() method too), or use the more convenient wrapper method .IsEqual(...) which you can find for many object types (occurrences, object definitions, databases,...). .IsEqual(...) compares objects using their ObjectIDs too, but it's easier to use.
if (relations_list[i].TargetObjOcc().IsEqual(anObjOcc))
.IsEqual(...) simply returns the boolean true if the ObjectIDs match, or false if they don't match.
Thanks Key
If I understand well :
relations_list[i].TargetObjOcc().IsEqual(anObjOcc) is True when TargetObjOcc and anObjOcc are the same occurrences
while
relations_list[i].TargetObjOcc().ObjDef().IsEqual(anObjOcc.Def()) is True when TargetObjOcc and anObjOcc relate to the same Object definition (but are possibly different occurrences , maybe in the same model)