!     filename  FOOTCHK         11/07/93
VAR oops
VAR startFrameName
VAR startMarker
VAR holdFrameName
VAR framePageNumber
VAR oopsMessage
VAR currentFrameName
VAR placeMarker
VAR tagPageNumber
VAR message
VAR charAtCursor
VAR previousFootnoteCount
VAR currentFootnoteCount
VAR addedFootnotes

MACRO  CheckIfOnSamePageInitial   
        GoToLinkTag "startpoint"
        SET startFrameName TO FrameName
        SET startMarker TO CursorPosition
        SET placeMarker TO CursorPosition 
        SET currentFrameName TO FrameName
        SET SelectedFrame TO "footnote data"
        CursorHome
        SET x TO 0
        REPEAT
                TableCellTab
                TableCellTab
                SET charAtCursor TO CursorCharacter
                TableCellTab
                TableCellTab
                TableCellTab
                EXIT WHEN charAtCursor = "0"
                SET x TO x + 1
        END REPEAT
        SET previousFootnoteCount TO x
        SET SelectedFrame TO currentFrameName
        SET x TO 1
        REPEAT
                ParagraphDown
                SET x TO x + 1
                EXIT WHEN EndOfFrame
                SET currentFootnoteCount TO x
        END REPEAT
        SET CursorPosition TO placeMarker
        SET addedFootnotes TO currentFootnoteCount - previousFootnoteCount
        IF addedFootnotes = 0 THEN
        ELSE    
                IF addedFootnotes =1 THEN
                        MSG "You have added one footnote. You should skip the Initial Check Phase when you 'Create Footnotes'"
                ELSE
                        END IF
                IF addedFootnotes =2 THEN
                        MSG "You have added two footnotes. You should skip the Initial Check Phase when you 'Create Footnotes'"
                ELSE
                        END IF
                  IF addedFootnotes =3 THEN
                        MSG "You have added three footnotes. You should skip the Initial Check Phase when you 'Create Footnotes'"
                ELSE
                        END IF
                IF addedFootnotes =4 THEN
                        MSG "You have added four footnotes You should skip the Initial Check Phase when you 'Create Footnotes'"
                ELSE
                        END IF
                IF addedFootnotes =5 THEN
                        MSG "You have added five footnotes. You should skip the Initial Check Phase when you 'Create Footnotes'"
                ELSE
                        END IF
                IF addedFootnotes >5 THEN
                MSG "You have added more than five footnotes. You should skip the Initial Check Phase when you 'Create Footnotes'"
                ELSE
                        END IF
        END IF
        IF addedFootnotes = 0 THEN
        ELSE
                IF addedFootnotes < 0 THEN
                        SET addedFootnotes TO 0 - addedFootnotes        
                        IF addedFootnotes = 1 THEN
                                MSG "You have deleted one footnote. You should skip the Initial Check Phase when you 'Create Footnotes'"
                        ELSE
                                END IF
                        IF addedFootnotes = 2 THEN
                                MSG "You have deleted two footnotes. You should skip the Initial Check Phase when you 'Create Footnotes'"
                        ELSE
                                END IF
                        IF addedFootnotes = 3 THEN
                                MSG "You have deleted three footnotes. You should skip the Initial Check Phase when you 'Create Footnotes'"
                        ELSE
                                END IF
                        IF addedFootnotes = 4 THEN
                                MSG "You have deleted four footnotes You should skip the Initial Check Phase when you 'Create Footnotes'"
                        ELSE
                                END IF
                        IF addedFootnotes = 5 THEN
                                MSG "You have deleted five footnotes. You should skip the Initial Check Phase when you 'Create Footnotes'"
                        ELSE
                                END IF
                        IF addedFootnotes > 5 THEN
                                MSG "You have deleted more than five footnotes. You should skip the Initial Check Phase when you 'Create Footnotes'"
                        ELSE
                                END IF
                ELSE
                END IF
        END IF
        SET oops TO "off"       
        SET x TO 1
        SET holdFrameName TO FrameName
        SET currentFrameName TO FrameName
        SET SelectedFrame TO "footnote data"
        SET placeMarker TO CursorPosition
        CursorHome
        SET SelectedFrame TO holdFrameName
        REPEAT
                SET StatusMessage TO "Checking if footnotes are on the correct page........"
                SET holdFrameName TO FrameName
                SET SelectedFrame TO "footnote data"
                DefineToWordEnd
                CopyToClipboard
                CancelDefinedBlock
                SET m TO PastedClipboard        
                TableCellTab
                TableCellTab
                DefineToWordEnd
                CopyToClipboard
                CancelDefinedBlock
                TableCellTab
                TableCellTab
                TableCellTab
                SET x TO PastedClipboard
                EXIT WHEN x = "0"
                CONVERT x TOSTRING x
                SET LinkTagName TO x
                SET SelectedFrame TO holdFrameName
                IF LinkTagExists THEN
                        GoToLinkTag x
                        SET tagPageNumber TO CursorPageNumber
                        SET SelectedFrame TO x
                        SET framePageNumber TO CursorPageNumber
                        CONVERT x TOVALUE x
                        IF framePageNumber < tagPageNumber THEN
                                SET m TO "Footnote " + m
                                SET m TO m + " on Page "
                                CONVERT framePageNumber TOSTRING framePageNumber
                                SET m TO m + framePageNumber
                                SET m TO m + " is before its reference number on Page "
                                CONVERT tagPageNumber TOSTRING tagPageNumber
                                SET m TO m + tagPageNumber
                                SET m TO m + ".        Run FOOTSTRT to correct this."
                                SET oops TO "on"
                                SET StatusMessage TO "This footnote is on the page before its reference. This can be corrected."
                                MSG m
                        ELSE
                                IF framePageNumber > tagPageNumber THEN
                                        SET m TO "Footnote " + m
                                        SET m TO m + " on Page "
                                        CONVERT framePageNumber TOSTRING framePageNumber
                                        SET m TO m + framePageNumber
                                        SET m TO m + " is after its reference number on Page "
                                        CONVERT tagPageNumber TOSTRING tagPageNumber
                                        SET m TO m + tagPageNumber
                                        SET m TO m + ".        Run FOOTSTRT to correct this."
                                        SET oops TO "on"
                                        SET StatusMessage TO "This footnote is on the page after its reference. This can be corrected."
                                        MSG m
                                ELSE                    
                                END IF
                        END IF
                ELSE
                        EXIT
                END IF
                CONVERT x TOVALUE x
                EXIT WHEN x = 2100
                EXIT WHEN x = 0
                SET x TO x + 1
        END REPEAT
        SET SelectedFrame TO holdFrameName
        IF oops = "on" THEN
        ELSE
                MSG "All previous footnotes are correctly placed. Use The 'Create 'Footnotes' option if you've added or deleted any. "
                SET SelectedFrame TO holdFrameName
                SET CursorPosition TO placeMarker
         END IF
SET SelectedFrame To startFrameName
SET CursorPosition TO startMarker 

END MACRO
