;;;ConvertIncorrectSlursToTies
(d-PushPosition)
(let ((note #f))
  (define (do-staff)
      (d-MoveToBeginning)
      (let loop ()
        (set! note (d-GetNoteName))
        (if (and note (d-IsSlurStart))
            (let ((nextnote #f))
                (d-NextChord)
                (set! nextnote (d-GetNoteName))
                (if (and (d-IsSlurEnd) nextnote (equal? note nextnote))
                    (begin
                        (d-ToggleEndSlur)
                        (d-PrevChord)
                        (d-ToggleBeginSlur)
                        (d-ToggleTie)))))
        (if (d-NextChord)
            (loop))))
            
  (define (do-movement)
    (while (d-StaffUp))
    (do-staff)
    (while (d-StaffDown)
        (do-staff)))
        
  (while (d-PreviousMovement))
  (do-movement)
  (while (d-NextMovement)
        (do-movement)))
(d-PopPosition)