Description
Returns the GNML tags present on the beginning of the current paragraph.
The difference with GetAllTags is that GetParaCmds uses SelectPara, and it's not table-sensitive.
Syntax
sTags = GetParaCmds(ByVal iBuff, ByVal bMode) |
iBuff
number of buffer: 0 to 5
bMode
False: return tags but do not delete them; True: return tags and remove them
Function GetParaCmds(ByVal iBuff, ByVal bMode) ' Purpose: Returns the GNML tags present on the beg. of current para ' select and get paragraph styles ' reselect if only reading Dim bRestoreSelection As Boolean = False Dim oBegSel As Cursor = Nothing Dim oEndSel As Cursor = Nothing If Text.TestTextSelection Then bRestoreSelection = True oBegSel = Text.GetCursor(1, 3, True) oEndSel = Text.GetCursor(1, 4, True) End If Text.CursorSave(iBuff) SelectPara() Dim strselblock As String = Text.GetTxt Dim lg As Integer = 0 Dim tPos As Integer = 0 Dim inTag As Boolean = False Dim bFound As Boolean = False Dim curChar As String = "" Dim strRight As String = ""
' Ted.find first text character If Left(strselblock, 1) <> ">" Then GetParaCmds = "" Else lg = Len(strselblock) inTag = True For t = 2 To lg curChar = Mid(strselblock, t, 1) If curChar = "<" Then inTag = False Else If Not inTag And curChar <> ">" Then tPos = t bFound = True Exit For End If End If If curChar = ">" Then inTag = True Next If bFound = True Then GetParaCmds = Left(strselblock, tPos - 1) If bMode = True Then strRight = Mid(strselblock, tPos) Text.DelChar() Text.InsTedText(strRight) End If Else GetParaCmds = "" End If End If If bMode = False Then ' cursorrestore functions only if no deleting happens Text.CursorRestore(iBuff) If bRestoreSelection Then ' restore the selection as it was If Not oBegSel Is Nothing AndAlso Not oEndSel Is Nothing Then Text.CursorTo(oBegSel) Text.EditBlockStart() Text.CursorTo(oEndSel) Text.EditBlockEnd() End If End If Else ' when we delete, the position is on the beg of the next paragraph or text end Text.CursorLeft() Text.CursorStartPara() End If End Function |
See also