Description
Inserts a newly created text at the specified position in the article - i.e. a new first level element in the article tree.
Available in Ted and Fred.
Syntax
object.InsNewTxt (nIdx,strType, nReferenceBasketId) |
object
Required. Object name. Returned by Ted.GetActiveArticle.
nIdx
Insert position of the new text, ranging from 0 = before the first element in the article to NTxts = after the last element in the article. If this parameter is negative the user is prompted to select the insertion position and type for the new text. To get the idx of the current element, use GetCurTxtIdx.
strType
Name of the type of the new text. It must be one of the valid types for the insert position as specified in the schema. If this parameter is an empty string the user is prompted to choose the type among all the valid ones for the insert position.
nReferenceBasketId
Id of the initial basket for the referenced object selection dialog - if it is 0 the dialog starts in the same basket of the last selected object of the same kind (picture or multi-media or URL).
Remarks
The type of the new text is decided based on the current schema depending on the insert position; if more than one types are compatible with the insert position the user is prompted to choose one.
If the type of the newly created text requires a referenced object (i.e. a picture, multi-media or URL element) the user is prompted to choose it using a standard object selection dialog. Note that in such a case when selecting a picture it is also possible to create a new dummy one.
The Fred version does not prompt the user to chose a referenced picture (it behaves like Ted for multi-media and URL).
The nReferenceBasketId can be also negative, thus not prompting to select the referenced picture or multi-media object when inserting article elements that reference pictures or multi-media (see the example #5).
Examples
1. This example creates a new text element in the current article:
'ArticleInsNewTxt
If Ted.HasActiveArticle Then
Dim objArticle = Ted.GetActiveArticle
objArticle.InsNewTxt(objArticle.GetCurTxtIdx, "", 0)
End If
2. This example creates a two text elements in the current article: head and body, leaving the cursor in the body element, for editing.
If Ted.HasActiveArticle Then
Dim objArticle = Ted.GetActiveArticle
objArticle.InsNewTxt(objArticle.GetCurTxtIdx, "head", 0)
objArticle.SelNode(objArticle.GetRootNode)
objArticle.InsNewTxt(objArticle.GetCurTxtIdx, "body", 0)
End If
3. This example does the same as above, but it does not initiate text editing.
If Ted.HasActiveArticle Then
Dim objArticle = Ted.GetActiveArticle
objArticle.InsNewTxt(objArticle.GetCurTxtIdx, "head", 0)
objArticle.CloseTxt(objArticle.GetCurTxtIdx, False)
objArticle.SelNode(objArticle.GetRootNode)
objArticle.InsNewTxt(objArticle.GetCurTxtIdx, "body", 0)
objArticle.CloseTxt(objArticle.GetCurTxtIdx, False)
objArticle.SelNode(objArticle.GetRootNode)
End If
4. This example adds the photo caption prompting for the picture.
If Ted.HasActiveArticle Then
Ted.GetActiveArticle.InsNewTxt(-1, "", 0)
End If
5. This example adds the photo caption without prompting to select a picture, thus insert not referencing a picture.
If Ted.HasActiveArticle Then
Ted.GetActiveArticle.InsNewTxt (-1,"",-1)
End If
Context
Article object
See also
InsChildNode, InsNodeAtCur, InsObj, InsObjDlg, InsTxt, InsTxtDlg.