T
Tony Strazzeri
My mind is not working well at the moment and I need some help to
create an algorithm to do as follows. I have jurie-rigged some
working code but frankly I am embarassed to make it public.
Any help with an elegant approach will be much appreciated.
Cheers
TonyS.
I need to be able to generate a list of number pairs representing a
range of values that fall in-between the specified value pairs.
To be more precise, this is a list or Microsoft Word document ranges.
The labels "Choice" and "Nested_Itm" represent bookmark ranges.
When option "Ch_B3" is selected I iterate through all bookmarks that
fall within the range of the specified bookmark. The following is the
list of values that are returned.
Choice | Nested_Itm | Start | End |
--------------------------------------------------------------------------
Ch_B3 | | 1003 | 1768 |
| Ch_A2 | 911 | 3148 |
| Ch_B3 | 1003 | 1768 |
| Ch_C1 | 1234 | 1521 |
| Ch_D1 | 1376 | 1412 |
| Ch_E1 | 1378 | 1400 |
| Ch_F1 | 1390 | 1495 |
| Ch_D2 | 1525 | 1528 |
| Ch_D3 | 1540 | 1550 |
| Ch_C2 | 1568 | 1761 |
--------------------------------------------------------------------------
This table represents the Start and End position of every bookmark
within the Chosen bookmark. Word considers any bookmark whose range
starts, ends or traverses the specified bookmark to be within the
selected bookmark.
The list is sorted from lowest to highest start point.
The following may not be readily apparent but is true about the list.
1. Selected bookmark is Ch_B3 which starts at 1003 and ends at 1768.
2. Ch_A2 starts before and ends after the selected bookmark.
3. Ch_B3 is shown again (at line 2 of the list) because it is the next
bookmark with a start point greater than Ch_A2.
4. Ch_C1 is nested (one level) inside Ch_B3 (because it starts and
ends within B3's range)
5. Ch_D1 is fully nested inside Ch_C1 as are D1, D2, D3, E1 and F1
(because they all start and end within C1's range).
6. Ch_C2 is nested (one level) inside Ch_B3 (like C1)
Any items nested more than one level deep (eg items in point 5) can be
ignored as they are encompassed by their parent nested item.
The result I need is an algorithm that processes the above list and
returns a set of ranges (start/end locations) representing the space
between the start and end of the selected item's range but excluding
the ranges represented by the nested ranges.
The above example should therefore return a list as follows;
Start End
1003 1234
1521 1525
1528 1540
1550 1568
1761 1768
Thanks!
P.S. Apologies if this appears twice. I reposted several hours later
when I thought it had not gone through.
create an algorithm to do as follows. I have jurie-rigged some
working code but frankly I am embarassed to make it public.
Any help with an elegant approach will be much appreciated.
Cheers
TonyS.
I need to be able to generate a list of number pairs representing a
range of values that fall in-between the specified value pairs.
To be more precise, this is a list or Microsoft Word document ranges.
The labels "Choice" and "Nested_Itm" represent bookmark ranges.
When option "Ch_B3" is selected I iterate through all bookmarks that
fall within the range of the specified bookmark. The following is the
list of values that are returned.
Choice | Nested_Itm | Start | End |
--------------------------------------------------------------------------
Ch_B3 | | 1003 | 1768 |
| Ch_A2 | 911 | 3148 |
| Ch_B3 | 1003 | 1768 |
| Ch_C1 | 1234 | 1521 |
| Ch_D1 | 1376 | 1412 |
| Ch_E1 | 1378 | 1400 |
| Ch_F1 | 1390 | 1495 |
| Ch_D2 | 1525 | 1528 |
| Ch_D3 | 1540 | 1550 |
| Ch_C2 | 1568 | 1761 |
--------------------------------------------------------------------------
This table represents the Start and End position of every bookmark
within the Chosen bookmark. Word considers any bookmark whose range
starts, ends or traverses the specified bookmark to be within the
selected bookmark.
The list is sorted from lowest to highest start point.
The following may not be readily apparent but is true about the list.
1. Selected bookmark is Ch_B3 which starts at 1003 and ends at 1768.
2. Ch_A2 starts before and ends after the selected bookmark.
3. Ch_B3 is shown again (at line 2 of the list) because it is the next
bookmark with a start point greater than Ch_A2.
4. Ch_C1 is nested (one level) inside Ch_B3 (because it starts and
ends within B3's range)
5. Ch_D1 is fully nested inside Ch_C1 as are D1, D2, D3, E1 and F1
(because they all start and end within C1's range).
6. Ch_C2 is nested (one level) inside Ch_B3 (like C1)
Any items nested more than one level deep (eg items in point 5) can be
ignored as they are encompassed by their parent nested item.
The result I need is an algorithm that processes the above list and
returns a set of ranges (start/end locations) representing the space
between the start and end of the selected item's range but excluding
the ranges represented by the nested ranges.
The above example should therefore return a list as follows;
Start End
1003 1234
1521 1525
1528 1540
1550 1568
1761 1768
Thanks!
P.S. Apologies if this appears twice. I reposted several hours later
when I thought it had not gone through.