I forgot to add- I'm working with Indesign Cs3 and Applescript
Don't know AppleScript, but here's the basic.
You could start out by searching for all numbers in selected item (or document) - longest match (Any Digit in Indd find menu)
Loop on the resulting array, for each found value + 1.
Have a look at the Text -> Search script examples.