I am stuck trying to figure out how to capture a variable the equals the sum or total amount of times a repeat statement is run? It should be simple but it is not for me.
For instance, in my script below you will see the part of my code that is repeating dialog boxes with a value of one.
Rather than having a dialog box pop up, i.e. six times, I would like to attach a number variable that knows how many times this had to happen. For instance “6”.
Then later in my script I could compare this hypothetical number “6” to another number.
I realize I have asked a lot. But I appreciate all of your help.
Many thanks,
Jeff
tell application "Adobe InDesign CS2"
tell active document
--try
set theRoot to (item 1 of XML elements) -- the root element
set theElements to every XML element of theRoot
set theElementsCount to count of theElements
display dialog theElementsCount
set numberAPNBox to count of (every XML element of theRoot whose name of markup tag is equal to "aPNBox")
set theAPNBoxes to every XML element of theRoot whose name of markup tag is equal to "aPNBox"
display dialog numberAPNBox
repeat with x in theElements
try
set y to every XML element of x
if (name of markup tag of x is equal to "aPNBox") then set theSubElements to every XML element of x
-------------- This repeat statement below is what I want to capture as a number variable equal to how many times it runs ----------
repeat with y in theSubElements
if (name of markup tag of y is equal to "expirationdate") then set expCount to (count of y)
display dialog "Eventually I want to figure out how to add up all of these 1's being returned. So if this dialog had to pop up 6 separate times, I would somehow have a variable that equals six." & expCount
end repeat
end try
end repeat
--end try
end tell
end tell