Loop through Tag Annotations

How do you create a loop that will change the text box name with every iteration?

For example, I have a graph with 80 tags annotated on it. Each tag has a text name, namely text0 through text79. How do I increment from text0 to text79 in steps of 1 ?

Here is an example:


Function Demo(graphOrLayoutName, showTag)
	String graphOrLayoutName		// "" for top graph or layout
	Variable showTag				// 1 to show tags, 0 to hide tags
	
	String list = AnnotationList(graphOrLayoutName)
	Variable numItems = ItemsInList(list)
	Variable i
	for(i=0; i<numItems; i+=1)
		String name = StringFromList(i, list)
		String info = AnnotationInfo(graphOrLayoutName, name)
		String typeStr = StringByKey("TYPE", info, ":")
		Variable isTag = CmpStr(typeStr,"tag") == 0
		if (isTag)
			Tag /C/N=$name/W=$graphOrLayoutName /V=(showTag)
		endif
	endfor
End


You can demo it like this:

Make jack=sin(x/8)
Display jack
Tag/C/N=text0/L=2 jack, 20,"text0"
Tag/C/N=text1/L=2 jack, 40,"text1"
Tag/C/N=text2/L=2 jack, 60,"text2"
Demo("", 0)
Demo("", 1)