Confirmed User Question - reaffect variable (ID,etc...) in 3 types when edit/remove
Hi,
It's been almost ten days that I spent my time on this – and I decided tonight to ask for help.
I'm working on a big application project but can't talk further about this.
I'm SORRY FOR THE LONG EXPLANATION, but it's a precise method that I need.
I will try to be the clearest I can (english is not my native so...)
I have objects which are dynamically created by the user. Each objects has a unique ID, and a type which can be 0,1 or 2.
Each objects has a child object which has a unique ID, a parent ID (which is the unique ID of the parent object), a parent type (which is the Type of the parent object)
I'm trying to create a function (by a deactivate group) which'll let me reaffect unique ID to objects when they are modified (user can change the Type of each object) or delete, and finally, change Parent ID and Parent Type of its child(s).
Hopefully I'm clear.
The fact is, each type of object has to have its ID started by 1 – I mean we can't have*:
Object Type 0 – ID 1
Object Type 0 – ID 2
Object Type 2 – ID 2
It has to be like this*;
Object Type 0 – ID 1
Object Type 0 – ID 2
Object Type 2 – ID 1
(for example, if you add an Object Type 0 in this configuration, its ID will be 3, if you delete Object Type 0 – ID1, the Type 0 – ID2 will become ID1, and ID3, will become ID2).
And here is my problem – I tried hundred of different solutions, some of them was really close that I expect, but it's not exactly what I need.
So for now, here is what I have (Just remember, object and child are correctly created, ID, type, and parent ID/Type are correctly affected when created. This is just my reaffection ID function which's not working):
At creation, Object are added to a foreach group called ''update_uid_group''
In this function, I use three counter, one by type, to count how many object exists in each type.
Code:
On ForEach loop ''update_uid''
+ Fixed Value of Object = LoopFixedValue(''update_uid'')
+ Object Type value = 0
- Add 1 to Type0_counter
On ForEach loop ''update_uid''
+ Fixed Value of Object = LoopFixedValue(''update_uid'')
+ Object Type value = 0
+ Child Parent_ID value = Object Unique ID value
+ Child Parent_Type vlaue = Object Type value
- Set Object Unique ID value to Type0_counter value
- Set Child Parent ID value to Type0_counter value
- Set Child Type value to 0
The same thing for type = 1 and type = 2,
Then I deactivate the group with
Code:
LoopIteration(''update_uid'') = GroupSize(''ForEach'', ''update_uid_group'')
The fact is, it doesn't work at all – My question, and I'm sorry for this long explication, is how reaffect ID by type to each objects after delete one, or modify the type of one object, and in the same time, change the each child information (parent ID and parent type)
If a confirmed coder of MMF2 could help me, I will be really grateful for this*!!
Thanks again.