GotoTxtEx Method (Article)

Build 1501 on 14/Nov/2017  This topic last edited on: 22/Mar/2016, at 17:07

Description

Edits the specified text in the specified mode.

Syntax

object.GotoTxt (nIdx, bSrc, bOnly, bOpenMode)

object

Required. Object name. Returned by Ted.GetActiveArticle.

nIdx

Index of the text to edit, ranging from 0 = first text in the article to NTxts-1 = last text in the article. If nIdx is outside this range a run-time error is raised. To get the idx of the current element, use GetCurTxtIdx.

bSrc

If true the text is edited in a source window, if false in the WYSIWYG window

bOnly

If true the command fails if the window required by the bSrc parameters is not available

if false and the required window type is not availabe the other type is used - e.g. if bSrc=false (i.e. request WYSIWYG editing) and bOnly=false there is no WYSIWYG window the specified text is edited in a source window.

bOpenMode

0: use the same R/W access as article

1: R/O open

2: R/W open (if permitted).

Remarks

If the text is already being edited GotoTxtEx just sets the focus to its editing window, otherwise it opens an editing window for the text and then sets the focus. See also GotoNodeEx.

Example

This script edit the current text element.

If Ted.HasActiveArticle Then

  dim objArticle = Ted.GetActiveArticle

  objArticle.GotoTxtEx (objArticle.GetCurTxtIdx,True,False, 0)

End If

This script opens in the source panel all text elements, and puts the cursor in the first element. It won't work in Fred, as there it's impossible to open more element than one in the source panel.

If Ted.HasActiveArticle And Not Ted.isFred Then  

  dim objArt = Ted.GetActiveArticle  

  dim nIdx as Integer = objArt.GetCurTxtIdx  

  For i=0 To objArt.NTxts-1  

    objArt.GotoTxtEx (i,True,False,0)

  Next  

  If nIdx >= 0 Then   

    objArt.GotoTxtEx (nIdx,True,False,0)  

  Else  

    If objArt.NTxts > 0 Then  

      objArt.GotoTxtEx (0,True,False, 0)

    End If  

  End If  

  objArt.GotoTxtEx (0,True,False, 0)

End If  

This script edits the head element.

 

If Ted.HasActiveArticle Then

  dim objArt = Ted.GetActiveArticle

  dim strTypeName as String = "head"

  dim nIdx as Integer = -1

  dim i as Integer = 0

  While i < objArt.NTxts And nIdx < 0

    dim objNode = objArt.GetTxtNode(i)

    If objNode.TypeName = strTypeName Then

      nIdx = i

    End If

    i = i+1

  End While

  If nIdx >= 0 Then 

    objArt.GototxtEx (nIdx,True,False,0)

  Else 

    MsgBox ("The article does not contain a " & strTypeName & " element")

  End If

End If

This script edits the next element.

 

If Ted.HasActiveArticle Then

  dim objArt = Ted.GetActiveArticle

  dim nIdx as Integer = objArt.GetCurTxtIdx

  If nIdx < 0 Then

    If objArt.NTxts > 0 Then

      nIdx = 0

    End If

  Else

    If objArt.CloseTxt(nIdx,False) <> 0 Then

      nIdx = -1

    Else 

      nIdx = nIdx + 1

      If nIdx >= objArt.NTxts Then

        nIdx = 0

      End If 

    End If

  End If

 

  If nIdx >= 0 Then

    objArt.GotoTxt (nIdx,True,False,0)

  End If  

End If

Context

Article object