Professor Bernd: -------------------------------------------------------------------------------- pspad: -------------------------------------------------------------------------------- Ifvanything will modify your file from outside, stored undo is useless.--------------------------------------------------------------------------------
The user starts the above-mentioned VBScript by shortcut and thus knows that the file is modified externally. If the user does not like the result, he can use the Undo's to return to the previous state. Then he presses Ctrl+S and his file is back to the desired state. Ok, here is my workaround: When the user starts the external program, the current file is changed externally. Then I use VBScript to read the file as "*sNewText*" and replace the old text in the active editor/tab with "*obj.text(sNewText)*". This way all Undo's are preserved. _Problem_: The encoding (charset) of the file. In order to display all characters as they should be, the encoding from the read-in must match the encoding of the editor/tab. But this seems to be impossible in VBScript. So since it's not possible to reload the file without losing all Undo's, can you please add a function for VBScript for my workaround to get the encoding for the current editor/tab? For example: obj.encoding(): string [color=#009900]returns editor encoding (only for saved file)[/color] -------------------------------------------------------------------------------- Hi, I was just about to propose a workaround You found - i.e. replacing the text content via scripting instead of reloading the file. This way the undo history is preserved. However, I'm not quite sure about the encoding problem - I'd think, the external tool must somehow cope with the encoding correctly as well, otherwise it could corrupt the content.? Could it be, that it can handle the on-disk file (even without extra encoding information), however, it doesn't work if the text content is passed via scripting? Just a suggestion, I haven't actually tried it sofar - could a tempoorary copy of the current-tab's file be created as input for the external file? The result could (hopefully?) be read as a new content of the tab. In my experience, the encoding handling got much better with PSPad 5 (compared to previous versions), at least using Javascript (that I am more familiar with), the scripting can now pass general unicode characters from the tab (at least the "basic multilingual plane in unicode - BMP up to U+FFFF). I believe, the text is handled internally, mostly idependently of individual encodings, but one can assign some universal encoding, such as utf-8 to the above mentioned temporary file, and after external reformatting etc. the content would be used using the same encoding. However, it might well be I am not aware of some extra complications, since I guess, You likely already tried such an approach... regards, vbr -- <https://forum.pspad.com/read.php?2,74331,74334> PSPad freeware editor https://www.pspad.com