Create Object so it is at the End of the Module

How do I create an Object so that it is at the END of the module and not the beginning.

Module m1 = current Module
Object o1 = create m1

the above puts it at the beginning of the module

Is there a simple way to put it at the end of the module, or do I have to search the module for the last object, store that object, then place the new object after

Object o1 = create o2 //whatever is the last object is stored as o2
phan423 - Mon Feb 27 21:09:18 EST 2012

Re: Create Object so it is at the End of the Module
SystemAdmin - Mon Feb 27 22:14:21 EST 2012

Module m1 = current Module
Object o1 = create last m1

this creates an object as a sibling of the last object of the module

to create a top level heading you need to cycle through the top level objects and then create after:-

Module m1 = current Module
Object o1
for o1 in top m1 do;
create after o1

Re: Create Object so it is at the End of the Module
SystemAdmin - Mon Feb 27 22:19:07 EST 2012

The following will navigate to the object at the very end of the module object tree - as per the "Objects > Navigation from an Object" section of the DXL Reference Manual - I would recommend you add some tests in the code to determine if this absolutely last object is deleted (for when soft deleted objects are configured to be visible), or if it's a table cell, or any other cases where the last object might not be a suitable candidate for creating a new object after it.
 

Module m = current;
Object oFirst = first m;
Object oNew = (null oFirst)?(Object create m):(create last sibling oFirst);

 


Remember that if the last object is at level 3 then an object inserted after it will also be at level 3, maybe you wanted it to be at level 1, that requires identifying the last level 1 object and not the absolute last object at the very end of the module.

 

 

 


Paul Miller
Melbourne, Australia

 

 

Re: Create Object so it is at the End of the Module
llandale - Tue Feb 28 15:19:23 EST 2012

Both Sean and Paul are correct, but I think Sean's solution should be the default one.

Here is the real issue: if the module has 3 objects with these paragraph numbers:

1.
1.1
1.1.1


The the new "last" object could have any of these paragraph numbers, and you must decide which you want:

 

2.    level 1, "after" the 1st, which is the lowest top-level object as per Sean
1.2     level 2, "after" the 2nd object, or "last below" the 1st.
1.1.2   level 3, "after" the 3rd object, or "last below" the 2nd
1.1.1.1 level 4, "below" the 3rd object


Yes this is confusing even for a 3-object module.

-Louie

Always display "Object Number" (paragraph) and "Object Level" columns when even remotely thinking about the module hierarchy; especially when moving or placing objects.

 

Re: Create Object so it is at the End of the Module
SystemAdmin - Tue Feb 28 17:52:36 EST 2012

llandale - Tue Feb 28 15:19:23 EST 2012

Both Sean and Paul are correct, but I think Sean's solution should be the default one.

Here is the real issue: if the module has 3 objects with these paragraph numbers:

1.
1.1
1.1.1


The the new "last" object could have any of these paragraph numbers, and you must decide which you want:

 

2.    level 1, "after" the 1st, which is the lowest top-level object as per Sean
1.2     level 2, "after" the 2nd object, or "last below" the 1st.
1.1.2   level 3, "after" the 3rd object, or "last below" the 2nd
1.1.1.1 level 4, "below" the 3rd object


Yes this is confusing even for a 3-object module.

-Louie

Always display "Object Number" (paragraph) and "Object Level" columns when even remotely thinking about the module hierarchy; especially when moving or placing objects.

 

"...The the new "last" object could have any of these paragraph numbers, and you must decide which you want:..."

I thought that that was the point of my last sentence - you need to know what level you want that last object to be at, as well as whether the last object is a suitable base for inserting a new object e.g. if it's a deleted object or a table cell object.


Paul Miller
Melbourne, Australia

Re: Create Object so it is at the End of the Module
Reik_Schroeder - Wed Feb 29 01:15:27 EST 2012

SystemAdmin - Mon Feb 27 22:14:21 EST 2012
Module m1 = current Module
Object o1 = create last m1

this creates an object as a sibling of the last object of the module

to create a top level heading you need to cycle through the top level objects and then create after:-

Module m1 = current Module
Object o1
for o1 in top m1 do;
create after o1

Hi Sean,

an faster idea to solve this problem is:
 

Object o1 = first current Module 
Object o2 = last current Module 
 
current = o2

 


This will create an object on top level at end of module, even if the module is empty.

Best regards
Reik
_______________________Evosoft GmbH / Siemens AG

 

Re: Create Object so it is at the End of the Module
SystemAdmin - Thu Mar 01 08:18:00 EST 2012

Reik_Schroeder - Wed Feb 29 01:15:27 EST 2012

Hi Sean,

an faster idea to solve this problem is:
 

Object o1 = first current Module 
Object o2 = last current Module 
 
current = o2

 


This will create an object on top level at end of module, even if the module is empty.

Best regards
Reik
_______________________Evosoft GmbH / Siemens AG

 

yes 'last sibling' is better than the loop

I knew it worked for navigation but seems it also works for creation

Re: Create Object so it is at the End of the Module
phan423 - Thu Mar 01 14:57:50 EST 2012

SystemAdmin - Thu Mar 01 08:18:00 EST 2012
yes 'last sibling' is better than the loop

I knew it worked for navigation but seems it also works for creation

This was my work around. I kept getting errors using the other methods above, I think because I have more than one Module involved in my code, so I used this method below instead:

Object obj = last mainMod
Object newObj = create mainMod

move(newObj, obj)