New Tab Pages have an almost unique Element Type, Static Group.
Using that value, then this may do the trick for you:
var vElementName as string
var vElementList as string
var vListCount as Int
var vLoop as Int
var vThisElement as String
var vSortIndex as Int //Sorting Index = (800 * YPos) + XPos
var vIndexedElements as String //Unsorted Indexed elements
var vSortedPageElements as String //Sorted Indexed elements
// List all elements on the form
vElementList = @StringArrayElementList()
// Count elements in the list
vListCount = @CountStringArray(vElementList)
// Loop through all the elements
vLoop = 1
While(vLoop <= vListCount) {
// Extract each element in the list, Set the "ThisElement" pointer
vElementName = @AccessStringArray(vElementList, vLoop)
SetThisElement(vElementName)
// Make Sort Index for elements using Y/Z positions
vSortIndex = (800 * @YPos(ThisElement) ) + @XPos(ThisElement)
vIndexedElements += vSortIndex + vElementName + "/Y:" + @YPos(ThisElement) + "/X:" + @XPos(ThisElement) + ";"
// Sort elements by Y/Z positions on each Tab Page / FieldType = "1016/Static Group"
If @ElementType(ThisELement) = "1016" Then {
vIndexedElements = @SortStringArray(vIndexedElements,1) //Sort current element list by numbers
vSortedPageElements += vIndexedElements //Append to Sorted list
vIndexedElements = "" //Clear for next page of elements
WriteLn(vSortedPageElements) //Review list of Sorted elements
} //Can Copy/Paste to review
vLoop += 1
} //End of While Loop
Logic of the programming:
1. The TabPage has an Element Type = Static Group, or code 1016.
2. Go thru the list of elements and make a sorting Index and append each element to a string array (vIndexedElements).
3. When you get to an element type = 1016, then this is the begining of a new tab.
4. So take the existing list, sort it, and append the results to the Sorted elements (vSortedPageElements).
5. Now clear out the current list (vIndexedElements) so that you can start again on the next Tab Page.
6. Repeat through all elements (vListCount)
Is this a Sensible Solution?