DeleteNotes script

Build 1501 on 14/Nov/2017  This topic last edited on: 1/Mar/2013, at 15:50

DeleteNotes: deletes all the text in notes mode. Note: this function require specific constants. See Constants for TxtPosDesc functions.

Sub DeleteNotes

  ' Create a cursor at the beginning of the text

  ' The cursor is always in 'source mode with markup' mode

  ' so that the function will work in the same way

  ' regardless of the current editing mode

 

  dim objCur = Text.GetCursor(modeSrcOn,cposBegin,False)

 

  ' Main loop through all the notes mode text fragments

 

  Do

 

    ' First inner loop: move the cursor to the first 

    ' character in notes mode

 

    Do

 

      ' Get the description of the current position, if it is

      ' text in notes mode exit from the loop

 

      dim objDesc = objCur.Desc

      If objDesc.GetType = tptText And objDesc.GetRemCode <> 0 Then

        Exit Do

      End If

 

      ' Move to the next position - if the move fail we are at 

      ' the end of the text and we can exit from the function

 

      If objCur.Move(1) > 0 Then

        Exit Sub

      End If

 

    Loop

 

    ' Save the current positoon in objFrom

 

    dim objFrom = objCur.Duplicate

 

    ' Second inner loop: move the cursor to the first position

    ' that is no longer text in notes mode - or to the end

    ' of the text

 

    Do While objCur.Move(1) = 0

 

      ' Get the description of the current position, if it is

      ' not text or not in notes mode exit from the loop

 

      dim objDesc = objCur.Desc

      If objDesc.GetType <> tptText Or objDesc.GetRemCode = 0 Then

        Exit Do

      End If

 

    Loop

 

    ' Delete the text in notes mode, and loop to the next

 

    Ted.DelRange objFrom,objCur

  Loop

End Sub

 

See also DeleteCommands procedure.