NoteWorthy Software, Inc.
2014-04-19 11:20 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Licensed NWC2 users can upgrade their community membership [more]
 
   Home   Help Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Inline editing of user tools  (Read 23588 times)
Lawrie Pardy
Virtuoso


« on: 2007-09-02 09:04 AM »

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?
Logged

I plays 'Bones, crumpets, coronets, floosgals 'n youfonymums
NoteWorthy Online
Admin


« Reply #1 on: 2007-09-02 12:45 PM »

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.
Logged
Rick G.
Virtuoso
« Reply #2 on: 2007-09-02 12:57 PM »

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.
Logged

Registered user since 1996
Lawrie Pardy
Virtuoso


« Reply #3 on: 2007-09-02 06:26 PM »

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.
Logged

I plays 'Bones, crumpets, coronets, floosgals 'n youfonymums
Rick G.
Virtuoso
« Reply #4 on: 2007-09-06 11:11 AM »

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.  :(
« Last Edit: 2007-09-06 08:47 PM by Rick G. » Logged

Registered user since 1996
Lawrie Pardy
Virtuoso


« Reply #5 on: 2007-09-06 06:16 PM »

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.
Logged

I plays 'Bones, crumpets, coronets, floosgals 'n youfonymums
Rick G.
Virtuoso
« Reply #6 on: 2007-09-06 06:49 PM »

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.
« Last Edit: 2011-11-20 02:57 PM by Rick G. » Logged

Registered user since 1996
Andrew Purdam
Dormant Virtuoso
« Reply #7 on: 2007-09-06 07:32 PM »

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.
Logged
Rick G.
Virtuoso
« Reply #8 on: 2007-09-06 07:59 PM »

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 :)
« Last Edit: 2011-11-20 03:01 PM by Rick G. » Logged

Registered user since 1996
Lawrie Pardy
Virtuoso


« Reply #9 on: 2007-09-06 08:09 PM »

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...
Logged

I plays 'Bones, crumpets, coronets, floosgals 'n youfonymums
Keith Mckenna
Dormant NWC2 User


« Reply #10 on: 2007-09-07 03:59 PM »

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
Logged

Illigitimi Non Carborundum
Rob den Heijer
NWC2 User


« Reply #11 on: 2007-09-07 06:31 PM »

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.
Logged
John Ford
Dormant Virtuoso
« Reply #12 on: 2007-09-08 09:19 PM »

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.
Logged

Warren Porter
Virtuoso


« Reply #13 on: 2007-09-10 07:57 AM »

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. http://bellsouthpwp.net/w/b/wbport/nwc2/
Logged

Since 1998
Rob den Heijer
NWC2 User


« Reply #14 on: 2007-09-14 01:51 AM »

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.
Logged
Rob den Heijer
NWC2 User


« Reply #15 on: 2007-09-14 04:10 AM »

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?
« Last Edit: 2007-09-14 04:30 AM by Rob den Heijer » Logged
NoteWorthy Online
Admin


« Reply #16 on: 2007-09-14 05:01 AM »

In regard to Warren's site: It seems to need IE. I get the 404 error in Forefox, but not IE.
Logged
Rob den Heijer
NWC2 User


« Reply #17 on: 2007-09-14 05:41 AM »

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.
Logged
NoteWorthy Online
Admin


« Reply #18 on: 2007-09-14 06:02 AM »

Now I get the 404 error on both IE and FF, so perhaps the server is flaky.
Logged
Warren Porter
Virtuoso


« Reply #19 on: 2007-09-14 08:44 AM »

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.
« Last Edit: 2007-09-15 08:56 AM by Warren Porter » Logged

Since 1998
Warren Porter
Virtuoso


« Reply #20 on: 2007-09-15 09:02 AM »

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.

http://bellsouthpwp.net/w/b/wbport/nwc2/.
Logged

Since 1998
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by SMF 1.1.19 | SMF © 2013, Simple Machines
Page created in 0.644 seconds with 19 queries.

Copyright © 2014 Noteworthy Software, Inc.