Please find below one way to check via a script if the currently opened file is
dirty, written in JavaScript:


function CheckDirty() {

        // Get text for active editor
        var editor = newEditor(); // Create new editor object
        editor.assignActiveEditor(); // Get current editor
        var text1 = editor.Text();

        // Get text from disk
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        var ts = fso.OpenTextFile(editor.fileName(), 1);
        var text2 = ts.ReadAll();
        ts.close();

        // Compare
        if (text1 == text2)
                echo("File is clean.");
        else
                echo("File is dirty.");

}

function Init() {
    menuName = "&Sample";
    addMenuItem("Check if dirty"           , menuName, "CheckDirty");
}


Please advice if you have any questions.

-- 
<http://forum.pspad.com/read.php?2,38424,38452>
PSPad freeware editor http://www.pspad.com

Odpovedet emailem