;InstallGraceNoteHint
(let ()
 (define (get-grace)
    (define str "(d-InsertBlankWholeNote)(d-MoveCursorLeft)(d-ToggleGrace)")
    (d-PushPosition)
    (let ((duration (d-GetNoteBaseDuration)) )
     (set! str (string-append str "(d-Change" (number->string duration) ")(d-MoveCursorRight)")))
    (let loop ()
        (if (d-NextChordInMeasure)
          (if (d-IsGrace)
            (begin
              (set! str (string-append str "(d-InsertBlankWholeNote)(d-MoveCursorLeft)(d-ToggleGrace)" "(d-Change" (number->string (d-GetNoteBaseDuration)) ")(d-MoveCursorRight)"))
              (loop)))))
      (d-PopPosition)
      str)
  (define (move-to-next start)
		(define this (d-GetStartTick))
		(if (and (or (not (Music?)) (> start this)) (d-NextObjectInMeasure))
			(move-to-next start)))
      ;;;;;;;;; procedure starts here
      (while (and (d-IsGrace) (d-PrevObjectInMeasure)))
      (if (not (d-IsGrace))
		(d-NextObjectInMeasure))
	  (if (d-IsGrace)
		(let ((hint (get-grace)) (start (d-GetStartTick)))
			(while (d-MoveToStaffUp))
			(let loop ()
				(define this (d-GetStartTick))
				(if this
					(begin
						(move-to-next start)
						(if (and (= start (d-GetStartTick))(not (d-IsGrace)) (not (d-Directive-standalone? "MultiMeasureRests")))
							  (eval-string hint))
						(if (d-MoveToStaffDown)
							(loop)))
					(d-WarningDialog (_ "Cannot have empty measures")))))
		(d-WarningDialog (_ "Not on a grace note"))))