tagnumber(
tagnumber(
TEXT
,
HEADER
,
TRAILER
,
POSITION
)

The tagnumber( function checks to see if a specified position is inside of a tag (usually an HTML tag).

Parameters

This function has four parameters:

text – is the item of text that contains the tag you want to locate.

header – is the text that you want to use as a tag header. For example, if you want to locate an HTML tag, use `"<"` as the header. If you wanted to locate a bold text item you would use `"<B>"` as the header. (Note: Upper or lower case is ignored, so `"<b>"` will also work.)

trailer – the text that you want to use as a tag trailer. For example, if you want to locate an HTML tag, use `">"` as the trailer. If you wanted to locate a bold text item you would use `"</B>"` as the trailer. (Note: Upper or lower case is ignored, so `"</b>"` will also work.)

position – is the position within the text parameter

Description

The tagnumber( function checks to see if a specified position is inside of a tag (usually an HTML tag). The function returns the tag number (1, 2, 3, etc.) or 0 if the position is not within any specified tag.

This example assumes you have a field or variable named myPage that contains an HTML page that is being edited with a Text Editor Object. The example will check the currently selected text to see if it is inside a tag. If it is, the body of that tag will be selected.

    local tStart,tEnd,clickStart,clickEnd,thetag
    activesuperobject "getselection",clickStart,clickEnd
    thetag=tagnumber(Page,"<",">",clickStart)
    if thetag>0
        tStart=tagstart(myPage,"<title>","</title>",1)
        if tStart=0
            rtn
        endif
        tEnd=tagend(myPage,"<title>","</title>",1)
        activesuperobject "setselection",tStart-1,tEnd-1
    endif

See Also

- gettaglocation -- locates the first matching tag within some text.
- gettaglocations -- locates all matching tags within some text.
- settagdata -- changes the contents of a tag.
- setxtagvalue -- changes the contents of a tag.
- tagarray( -- builds an array (see Text Arrays) containing the body of all the specified tags (usually HTML tags) in the text.
- tagcount( -- counts the number of times a specified tag (usually an HTML tag) appears in the text. See Tag Parsing for more information on HTML tags.
- tagdata( -- extracts the body of the specified tag (usually an HTML tag) in the text. See Tag Parsing for more information on HTML tags.
- tagend( -- returns the ending position of the specified tag (usually an HTML tag) in the text.
- tagparameter( -- extracts the value of a tag parameter embedded in some text, where the tag parameter takes the form *name=value*.
- tagstart( -- returns the starting position of the specified tag (usually an HTML tag) in the text.
- tagstrip( -- removes tags (usually HTML tags) from within a piece of text.
- xtag( -- generates an HTML/XML tag.
- xtagvalue( -- extracts the text from the first matching HTML or XML tag.

History

Version | Status | Notes
10.0 | No Change | Carried over from Panorama 6.0