HasTagInString Script

Build 1501 on 14/Nov/2017  This topic last edited on: 9/May/2012, at 13:03

Description

Returns true if the GNML tag strTag exists in strParaCmdString.

Usage:   bResult = HasTagInString(">hld")

Syntax

bResult = HasTagInString(strParaCmdsString, strTagName)

strParaCmdsString

string that contains GNML tags, usually provided by Text.GetTxt after all paragraph and tags were selected, or by

strTagName

tag name with or without tag brackets. Add brackets for an exact match.

Code

Function HasTagInString(ByVal strString, ByVal strTag)

  ' Purpose:   Returns true if the GNML tag strTag exists in strParaCmdString

  ' Usage:   bResult = HasTagInString(">hld")

  ' strTag may end with a space or with < or with any other char

   HasTagInString = False

  If InStr(strString, strTag) > 0 Then

    If Right(strTag, 1) = " " Then   ' parameter was ">co "

       HasTagInString = True

      Exit Function

    End If

    If Right(strTag, 1) = "<" Then   ' parameter was ">co<"

       HasTagInString = True

      Exit Function

    End If

    If InStr(strString, strTag + "<") > 0 Then   ' parameter was ">co" and command is >co<

       HasTagInString = True

      Exit Function

    End If

    If InStr(strString, strTag + " ") > 0 Then   ' parameter was ">co" and command is >co value<

       HasTagInString = True

      Exit Function

    End If

  End If

End Function

See also

HasTagInPara, HasTag, sysHasParaTags