Simple script - works slightly differently with RJTE upgrade

Ask questions about how to create a script or swap scripts with other users.
Post Reply
jgodfrey
Posts: 471
Joined: 19 Aug 2011 23:02
Location: Missouri, USA

Simple script - works slightly differently with RJTE upgrade

Post by jgodfrey »

Hello,

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?

Thanks,

Jeff

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
   MainApp.NewDocument(".txt");

   // Paste the clipboard contents into the new doc
   Document.PasteFromClipboard;

   // Select the entire document
   Document.SelectAll();

   // Copy the selection to the clipboard
   Document.CopyToClipboard();

   // Undo the paste to prevent a "Save?" question on doc close
   Document.Undo();

   // Close the document (cleaned code is in the clipboard)
   Document.Close();

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

jgodfrey
Posts: 471
Joined: 19 Aug 2011 23:02
Location: Missouri, USA

Re: Simple script - works slightly differently with RJTE upg

Post by jgodfrey »

Friendly bump...

User avatar
Rickard Johansson
Site Admin
Posts: 6001
Joined: 19 Jul 2006 14:29

Re: Simple script - works slightly differently with RJTE upg

Post 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

Ex.
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).

jgodfrey
Posts: 471
Joined: 19 Aug 2011 23:02
Location: Missouri, USA

Re: Simple script - works slightly differently with RJTE upg

Post by jgodfrey »

Thanks for the input and the enhancements. As soon as I get a v10 beta installation going, I'll update my script.

Jeff

Post Reply