For a Text object named Text 1, use the following syntax:
var numLinks = Text_1.GetNumberHypertext()
To display the text for all hyperlinks in a Text object named Text 1, use the following syntax:
var numLinks = Text_1.GetNumberHypertext()
if (numLinks !=0)
{
link = Text_1.GetFirstHypertext()
Debug.trace(link.GetText() + "\n")
nextLink = link
for (loop=1;loop<=numLinks-1;loop++)
{
newLink = Text_1.GetNextHypertext(nextLink)
Debug.trace(newLink.GetText() + "\n")
nextLink = newLink
}
}
In Example 2 above, the variable numLinks contains the number of hyperlinks in the Text object named Text_1. The lines of code in the If statement are run when numLinks is not zero (i.e. it contains at least one hyperlink). The variable link will contain the first hyperlink, which is then displayed in a Debug window using the Debug.trace function. The variable nextLink is used as the parameter for the GetNextHypertext function. The first time it is used, nextLink is set to the first hyperlink (i.e. nextLink = link) and then it is set in the for loop to the next hyperlink (i.e. nextLink = newLink).
The for loop starts at a count of 1 because the first hypertext has already been displayed. The loop will continue for the total number of hyperlinks minus 1 (because we have already displayed the first hypertext), so we need to make sure we loop 1 less than the total number of hyperlinks in the Text object.