op.countSubs

Syntax op.countSubs (levels)

Params levels is a number which defines the relative level of the outline to which you wish to count the number of subheads.

Action Counts the number of subheads under the current heading which are at, or above, the level defined in levels.

Returns The number of subheads under the current heading which are at, or above, the level defined in levels. Returns 0 if no subheads are found.

Examples In examples.Sample Outline 2, position the cursor on the first summit and then execute:
op.countSubs (1)


   » 2

There are two level-1 subheads under the first summit, one labeled "Subhead 1, Summit," and one labeled "Subhead 2, Summit."

Remaining at the same point in examples.Sample Outline 2 as in Example 1, execute:
op.countSubs (3)


   » 6

The subheads have been counted to the level of "Subhead 1.1.1," a third-level subhead.

Position the cursor on the heading labeled "Subhead 1.1" in Sample Outline 2. Now type and execute:
op.countSubs (2)


   » 2

Notice that even though Subhead 1.1. is a Level 3 heading, it counts its subheads that are two levels lower than it in the outline. This illustrates that level is relative to the position of the cursor bar.

Notes If levels exceeds the maximum nesting level of the subheads under the current heading, op.countSubs returns the number of all subheads.

If you don't know how many levels of indentation may be present beneath a heading, you can use "infinity" as the value of levels to count all subheads.

All subheads are counted, whether they are collapsed or expanded.

See Also op.countSummits

Discuss