Level Collection Methods
In this section, we discuss the Level Collection methods. The methods are discussed in alphabetical order.
The Add method adds a new level called LevelName to the database. The specified level must be a new level, that is, it cannot exist in the database. LevelName takes a string value.
Note: LevelName must be 8 characters or less.
If no levels currently exist in the tree, the level is added at the top level. If levels already exist in the tree, the new level is added as the last level. You can change the level number of a level using the Number property.
If the new level is the first level, the AllValuesAudit property is automatically set to True.
The new level is notadded to the database until the tree is explicitly saved.
This method returns a reference to the new level object.
The Item method returns a reference to the specified level in the level collection executing the method as an object. The LevelName parameter specifies the name of the level to access. This parameter takes a string value. The LevelNumber parameter specifies the number at which the level exists. This parameter takes a number value. For example, suppose your level collection contains the following levels, in this order:
You want to access the fourth level, DEPARTMENT. You would use the following code:
&MYLEVEL = &LVLCOLLECTION.Item("DEPARTMENT", 4);
The Remove method deletes the current level from the database. You can use this method only after you have used the First, Next, or Item properties: otherwise the system doesn’t know which level to delete from the tree. If no level has been indicated yet system tries to remove the last level. If the level to remove has nodes associated with it, the system doesn't remove the level. The rest of the levels in the collection after the deleted level are moved up in the list and renumbered so that the levels remain consecutively numbered.
A number; 0 if the level is successfully removed.