Page 1 of 1

Simple script - works slightly differently with RJTE upgrade

Posted: 25 Sep 2014 18:18
by jgodfrey

I wrote the below simple script several years ago to remove Visual Studio style info from clipboard text. Basically, it simply pastes the clipboard text to a new temporary document, copies the document text back to the clipboard, and close the temporary document.

I've wired the script to a RJTE toolbar command, so a simple press of my toolbar button cleans up the text currently in the clipboard. However, at some point in RJTE upgrades, the script began opening a "The current file has changed. Save changes?" dialog upon the call to "Document.Close()". According to my comments (again, from several years ago), that's the reason I called Document.Undo() just prior to Document.Close() - which apparently used to bypass the "Save?" dialog.

Interestingly, if I comment out the "Document.Close()" call, I can interactively close the temp document *without* seeing the "Save?" dialog.

I really just want to close the temp file without being asked to save it. What's the best way to do that using a current version (9.20) of RJTE?



Code: Select all

#language C++Script

// Remove the VSS theme colorization from clipboard data and put the cleaned code
// back into the clipboard.  This makes it possible to email code snippets without
// them containing the VSS theme colors.
   // Create a new TXT document

   // Paste the clipboard contents into the new doc

   // Select the entire document

   // Copy the selection to the clipboard

   // Undo the paste to prevent a "Save?" question on doc close

   // Close the document (cleaned code is in the clipboard)

   // Add message to the status area.
   MainApp.SetStatusText("Cleaned text is in the clipboard.");

Re: Simple script - works slightly differently with RJTE upg

Posted: 27 Oct 2014 17:19
by jgodfrey
Friendly bump...

Re: Simple script - works slightly differently with RJTE upg

Posted: 01 Nov 2014 11:46
by Rickard Johansson
I've made a couple of changes in v10 (beta 1) that may help.

The "Clipboard" object enables access to the Windows clipboard.

Code: Select all

String s = Clipboard.AsText;
Clipboard.AsText = s;
I also added an argument to the close function.

Code: Select all

bool Document.Close(bool bDiscardChanges = false);
If you set bDiscardChanges to true the document will close and all changes are discarded (lost).

Re: Simple script - works slightly differently with RJTE upg

Posted: 01 Nov 2014 20:02
by jgodfrey
Thanks for the input and the enhancements. As soon as I get a v10 beta installation going, I'll update my script.