Apply the same format on all article elements

Build 1501 on 14/Nov/2017  This topic last edited on: 1/Sep/2016, at 14:22

It is not common to apply the same format to all article elements in Fred4, as usually head has different format than body, and so on.

If under certain circumstances you want that to happen, use the following script:

Sub applyformatonall()

    If Page.TxtFormat = EOK Then

      Dim strname = ""

      Dim objid = Page.GetSelectedId

      If Ted4.HasActiveTxt Then strname = Ted4.GetActiveTxt.FormatName

      If Ted4.HasActiveArticle And strname <> "" Then

        Dim objArt = Ted.GetActiveArticle

        Dim nIdx = objArt.GetCurTxtIdx

        For i = 0 To objArt.NTxts - 1

          objArt.GotoTxt(i, False)

          Page.TxtFormatName(strname)

          objArt.CloseTxt(i, False)

        Next

        If nIdx >= 0 Then

          objArt.Gototxt(nIdx, False)

          Page.TxtFormatName(strname)

          objArt.CloseTxt(nIdx, False)

        Else

          If objArt.NTxts > 0 Then

            objArt.GotoTxt(0, False)

            Page.TxtFormatName(strname)

            objArt.CloseTxt(0, False)

          End If

        End If

      End If

      Page.ObjSelectId(objid, False)

    End If

  End Sub