Skip to main content
Topic: Inline editing of user tools (Read 34201 times) previous topic - next topic

Inline editing of user tools

G'day all,
it occurs to me that it might be helpful if there was a mechanism that allowed you to spawn an instance of, say, notepad - or even your editor of choice - from the edit usertools dialogue.

I'm not sure exactly how this would work but currently if you go to edit a tool invocation you get a dialogue that allows you to edit the Name and the Command.

Perhaps if the Command field were to be split into Program (E.G. php or wscript to name 2 common ones), Command (actual script file) and Parameters (passed to the command) fields then the command field might be passed to the editor to enable you to edit the actual script from within NWC2.

Would this be truly useful or is it more likely to be unnecessary "bells and whistles"?

Thoughts anyone?
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: Inline editing of user tools

Reply #1
We will think about this.

For now, if you setup a text editor file associate with your scripts, you can easily engage it. Simply click Browse in the edit box, and then right click on any of the scripts.

Re: Inline editing of user tools

Reply #2
To expand on this, use: Tools->User Tools...->Edit...->Browse... to get an Open Dialog of all you scripts. Right Click on the one you want to edit and select: Edit

Or just create a ShortCut to you scripts folder.
Registered user since 1996

Re: Inline editing of user tools

Reply #3
G'day Noteworthyonline,
true, I forgot about going into the browse box and invoking an editor from there.  That's probably easy enough for the needs of those with the skills to develop scripts anyway...

G'day Rick,
to add to what you suggested (Right click|Edit) I usually add a shortcut to Notepad in my "Send To" folder (C:\Documents and Settings\user name\SendTo) - this is a hidden folder so in Windows Explorer you need to go to |Tools|Folder Options|View (tab)|"Show hidden files and folders" radio button and OK

Once in the "Send To" folder, right click anywhere, "New" from the context menu, "Shortcut" from the submenu and follow the prompts.

Useful for lots of stuff.
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: Inline editing of user tools

Reply #4
Here's a VBScript to do something close. It finds the script/batch file from the last User Tool run and launches whatever Edit action associated with that file. Copy the code to NotePad and save it as EditLUT.vbs
Code: [Select · Download]
Option Explicit ' Edit Last NWC2 User Tool Run
' Standalone script, not a User Tool
' by Rick G. tested on Win98, NWC2 Beta 2.19
Const exts = ".php|.vbs|.js|.py|.cmd|.bat"
Const NWC2RK = "HKCU\Software\NoteWorthy Software\NoteWorthy Composer 2\"
Dim wso: Set wso = CreateObject("WScript.Shell")
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim sho: Set sho = CreateObject("Shell.Application")
Dim ext, delimiter, lut, s

lut = wso.RegRead(NWC2RK & "Options\LastToolRun")
s = fso.BuildPath(NWC2Folder("Config"), "nwc2UserTools.ini") ' filename
s = fso.OpenTextFile(s).ReadAll ' file contents
s = Filter(Split(s, vbCr), vbLf & lut & "=")(0) ' pertinent line from file
s = Split(s, "=")(1) ' &Command:
For Each ext In Split(exts & "|", "|")
  If InStr(1, s, ext, 1) Then Exit For
Next
If ext = "" Then WScript.Quit ' no match

If Asc(s) = 39 Then s = Mid(s, 2, Len(s) - 2) ' strip single quotes
delimiter = Mid(s & " ", InStr(1, s, ext, 1) + Len(ext), 1) ' space|quote
s = Filter(Split(s, delimiter), ext, vbTrue, 1)(0) ' relative path

wso.CurrentDirectory = NWC2Folder("root")
s = fso.GetAbsolutePathName(s)
sho.Namespace(Left(s, 3)).ParseName(Mid(s, 4)).InvokeVerb("&Edit")

Function NWC2Folder(sKey)
  Select Case sKey
    Case "Songs": NWC2Folder = wso.SpecialFolders("MyDocuments")
    Case "InstrumentTrees": NWC2Folder = "itrees"
    Case "AutoSave", "Config", "Templates": NWC2Folder = sKey
    Case "PageCopy", "root"
    Case Else: Err.Raise 17, "NWC2Folder", sKey ' bad sKey
  End Select
  On Error Resume Next
  NWC2Folder = wso.RegRead(NWC2RK & sKey)
  If Err = 0 Or sKey = "Songs" Then Exit Function
  NWC2Folder = fso.BuildPath(fso.GetFile( _
    wso.RegRead("HKCR\nwcomposer\shell\nwc2\command\") _
    ).ParentFolder, NWC2Folder)
End Function

The program gets the last User Tool from the registry and scans nwc2UserTools.ini to find the corresponding line. The line is parsed to find the script filename's path which is usually relative to where nwc2.exe is. This name is fully qualified and passed to Windows' ActiveX "Shell.Application" object with instructions to invoke the "&Edit" verb on it.

A function: NWC2Folder is provided which will return the many folders used by NWC2, whether set by the user or left at their default.

This script cannot be set up as a User Tool. If it is, it will just invoke the editor on itself.  :(
Registered user since 1996

Re: Inline editing of user tools

Reply #5
G'day Rick,
darn, couldn't get it to work :(  Then I realised I didn't have an edit verb for php extensions - added one and all is well :)

The fact that this opens the last tool used is a useful thing I reckon - that's the one most likely to need editing if one is working on developing a user tool.

Still, it would be nice to be able to execute it from within NWC2 itself...  Perhaps this is an appropriate time to request some user definable buttons in the toolbars - ones that can invoke external proggy's like this one as well as user tools.  You know, have "Global_Mod" etc. - whatever we each use most commonly - just click the button!

Hmm, on second thought, in the interest of keeping the code for NWC small and efficient, this button idea should only be considered if it would have a minimal impact - there is already toolbar code in NWC so if the ability to set customisable buttons can be a very small amount of code then fine, otherwise I'm happy to use the <Alt-F8> dialogue.
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: Inline editing of user tools

Reply #6
The fact that this opens the last tool used is a useful thing I reckon - that's the one most likely to need editing if one is working on developing a user tool.
That was my thought. I also have some tools that are easier to configure by editing the source than by changing Command:
Still, it would be nice to be able to execute it from within NWC2 itself...  
It could be a user tool if NWC2 would wait until the Tool ran before updating the registry.

Some irony here. A registry key called "LastToolRun" updates before the current tool can read it, but "FileHistory" doesn't update until NWC2 is closed. Ideally, "FileHistory\Title1" would be the Active Window.

I use a Recorder macro when I need to run the same Tool on many different sections. An integral HotKey (like F11) would be much better.
Registered user since 1996

Re: Inline editing of user tools

Reply #7
When I was working on scripts a lot, I'd just have the scripts folder open.
Often I'd have the script loaded in notepad or whatever, and just keep saving it and rerunning.
(It's nice that Windows lets us run more than one program at a time...)
Not too onerous for someone who's been programming for 25 years (I started off on TI58 programmable calculators).
That's the sort of nerd I am.

Re: Inline editing of user tools

Reply #8
I started off on TI58 programmable calculators.
I started in 1970 with a dedicated lea$e line connecting a mainframe to one of <these>. Better than punch cards :)
Registered user since 1996

Re: Inline editing of user tools

Reply #9
G'day Andrew,

When I was working on scripts a lot, I'd just have the scripts folder open.
Often I'd have the script loaded in notepad or whatever, and just keep saving it and rerunning.
<snip>

I used to do something similar donkey's years ago when I was developing in DataFlex, under DOS.  Used to run "Sidekick" and use its' editor in TSR mode.  Hotkey in and out of Sidekick and run the updated code...
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

 

Re: Inline editing of user tools

Reply #10
Rick;
I haven't seen one of those beasts for 30 years. Was all we had connected to pdp 8's when I started at digital equipment corporation in the mid 70's. For our connections to the time sharing pdp10 we had it's big brother, the ASR35.

Keith
Illigitimi Non Carborundum

Re: Inline editing of user tools

Reply #11
I started out on Data General Nova-3. Never touched a pdp-11 in my life, even though DG and Digital were very close relatives.
Later, all this MS-Dos stuff (I tried the Commodore 128, but used it for games only...) came along, and still, whenever I work on an XP machine, I have at least one cmd-window open! Can't do without it! I use TSE as my favourite editor.
The way I work is very much like the description Andrew gave.

Re: Inline editing of user tools

Reply #12
Hey, Rob -

I presume by TSE, you mean "The Semware Editor".  I've used it since it was QEdit (TSR under MS-DOS) and have upgraded ever since.  Best text editor I ever used and it's macro and repeat ability makes it a breeze to edit anything that has some sort of pattern to it.
John

Re: Inline editing of user tools

Reply #13
I presume by TSE, you mean "The Semware Editor".  I've used it since it was QEdit (TSR under MS-DOS) and have upgraded ever since.  Best text editor I ever used and it's macro and repeat ability makes it a breeze to edit anything that has some sort of pattern to it.
I've also used it since my 1st computer in 1991 and have macros to convert midi triplets to real ones, change the duration of a piece, and remove digits from text on the system clipboard.  The last one was useful in removing measure numbers from sung text but with the addition of insertion points in the text coinsiding with where it is in the score, the last one may not be needed anymore. www.wjporter.com/nwc
Since 1998

Re: Inline editing of user tools

Reply #14
That is absolutely cool!
I'll find some time to compare your triplet.s to mine - and I can have a look at the other macros, too.
cheers,
Rob.

Re: Inline editing of user tools

Reply #15
A pity. Visiting the page gives me a directory, but I cannot access the files.
"HTTP Error 404 - File or directory not found." is the only reaction.

Could you post the files elsewhere please?
Or (if you can do that) change the attributes of the files. I think they now have "700" ; they need "744" at least.
Am I making sense?

Re: Inline editing of user tools

Reply #16
In regard to Warren's site: It seems to need IE. I get the 404 error in Forefox, but not IE.

Re: Inline editing of user tools

Reply #17
Ah. It could have to do with restrictions, here at work.
Will try at home; there I have FF and IE. Thanks for the tip.

Re: Inline editing of user tools

Reply #18
Now I get the 404 error on both IE and FF, so perhaps the server is flaky.

Re: Inline editing of user tools

Reply #19
I had the same problem, I could see the files in IE but couldn't look at or save them unless I was in my FTP program.  Until I can look into it, here is the triplet.s code:

Removed by author.
Since 1998

Re: Inline editing of user tools

Reply #20
I renamed my scripts to end in ".txt" and are visible now.  Still need to check with Ma Bell about what the problem is with nwc files. These were written to work with material from the clipboard so they might need to be modified to process a nwctxt file.

www.wjporter.com/nwc.
Since 1998