NoteWorthy Composer Forum

Forums => Tips & Tricks => User Tools => Topic started by: Robert Wilson on 2006-10-25 08:23 pm

Title: Clip to Text File
Post by: Robert Wilson on 2006-10-25 08:23 pm
Is there some simple way to convert the clip text to a normal text file which can be saved?
Title: Re: Clip to Text File
Post by: John Ford on 2006-10-25 08:27 pm
Grab your clip in NWC (using Ctrl-C); open Notepad (or any text editor) and press Ctrl-V.  Save the file as text.

- John
Title: Re: Clip to Text File
Post by: Robert Wilson on 2006-10-25 10:17 pm
Works slick!

Many thanks.
Robert
Title: Re: Clip to Text File
Post by: Rick G. on 2006-10-25 11:41 pm
Since you asked in the Tool Forum, here's a tool.
I named this: To NotePad.vbs
Use the command: wscript "Scripts\To NotePad.vbs"

Code: [Select · Download]
Option Explicit
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim f: f = fso.GetBaseName(fso.GetTempName) & ".txt"
f = fso.BuildPath(fso.GetSpecialFolder(2), f) ' 2 = %TEMP%
fso.CreateTextFile(f).Write(WScript.StdIn.Read(46080))
CreateObject("WScript.Shell").Run(f) ' leaves %TEMP%\nwt*.TMP
WScript.Sleep 500: fso.DeleteFile(f)
On Error Resume Next
For Each f In fso.GetSpecialFolder(2).Files
If Left(f.Name, 3) & Right(f.Name, 4) = "nwt.TMP" Then f.Delete
Next
If WScript.StdIn.AtEndOfStream Then WScript.Quit
MsgBox "Truncated to 45K bytes", vbExclamation, "Warning"
Title: Re: Clip to Text File
Post by: Lawrie Pardy on 2006-11-02 01:49 am
G'day Rick,
neat little tool - as usual for your contributions it works just nicely.
Title: Re: Clip to Text File
Post by: Rick G. on 2007-11-17 02:50 am
A slightly different take for those that want to use a specific editor:
Quote from: EditClip.vbs
Option Explicit
Dim fso, wso, e, f, s
Set wso = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

f = wso.ExpandEnvironmentStrings( _
   WScript.Arguments.Named("File"))
For Each e In WScript.Arguments.Unnamed
   s = s & Chr(34) & e & Chr(34) & " "
Next
If Not WScript.Arguments.Named.Exists("Pass2") Then
   fso.CreateTextFile(f).Write WScript.StdIn.ReadAll
   wso.Run Chr(34) & WScript.ScriptFullName & Chr(34) _
      & s & "/Pass2 /File:" & Chr(34) & f & Chr(34)
Else
   wso.Run s,, True
   fso.DeleteFile f
End If
The syntax for Command: is a bit complex. For WordPad using a file called 1.txt in the current directory, use:
Quote from:  WordPad example
WScript Scripts\Editclip.vbs write 1.txt /file:1.txt

For a different editor using the temporary directory:
Quote from:  Example 2
WScript Scripts\Editclip.vbs "C:\Program Files\SCiTE\SciTE.exe" %temp%\1.txt /file:%temp%\1.txt
Note that you must repeat the filename. Since the script knows nothing about the editor's commandline syntax, it can't know how and where to put the filename. Quotes are needed around the editor filename. Another set (of quotes) is needed around the temp filename if there are space(s) in it. Not every editor will expand environment settings so %temp% might not work for everyone.

This version also waits until you exit your editor to delete the temp file. In the earlier version, if the disk was hibernating, the script could delete the file before NotePad could load it.
Title: Re: Clip to Text File
Post by: Warren Porter on 2007-11-18 03:16 pm
Rick:
I installed your EditClip.vbs and for the Command part of the User Tool Description have the following:
Code: [Select · Download]
WScript Scripts\Editclip.vbs "C:\tse32\e32.exe"  %temp%\1.txt /file:%temp%\1.txt
It brings up the highlighted part of a staff in my editor, but changes I make are not reflected in the score after I save and exit from the editor.
Title: Re: Clip to Text File
Post by: Rick G. on 2007-11-18 04:33 pm
It brings up the highlighted part of a staff in my editor, but changes I make are not reflected in the score after I save and exit from the editor.
The program doesn't work that way. You have to Select All + Copy from your editor and then Paste into NWC2. Try it. If it is too cumbersome, I'll try to automate it some more. At this point I want to verify that my command line routines will let you automagically run a TSE macro on it.

To work the way you describe, the file would need to get loaded into the clipboard, then the keystrokes to paste it would need to be forced into NWC2. I can do that in about 80 lines of code, but it is dicey.
Title: Re: Clip to Text File
Post by: Rob den Heijer on 2007-11-18 09:09 pm
It might be time for me to do some experimenting now. Unfortunately, I am very busy for a few days, after which I will be out of the country. But "note to self" says that next week I must investigate - and report back. Kick me in the shins if I don't.
Title: Re: Clip to Text File
Post by: Rick G. on 2007-12-05 07:20 pm
... next week I must investigate - and report back. Kick me in the shins if I don't.
Consider yourself kicked  :)
Title: Re: Clip to Text File
Post by: Rob den Heijer on 2007-12-05 08:49 pm
yeah - and then I forgot it's time for Amnesty cards, for December performance rehearsals, for family visits and other unspecified but nice surprises. And the "Africa! Africa!" show. So it did not work - yet. Thanks anyway.