DO11: Adding jscripts to Toolbars->Scripts doesnt work?

I've written a few scripts in Jscript that I'd sure love to test :slight_smile:... but when I copy them into the Script AddIns folder manually, nothing happened when I executed the actions intended to trigger the scripts. After thinking my scripts were just bonkers, I then noticed they didn't appear in the list of Scripts under Prefs -> Toolbars -> Scripts.

I then tried dragging them from Opus into that page in Prefs but Opus doesn't accept the drop action. Same is true for the 'Select Newest Files' example script you provided... Opus rejects the drop.

Dragging and dropping any of the VBscripts into Prefs works fine though...

Jscripts == .js
VBscripts == .vbs

Hmmm, so I converted one of my test jscripts to vbscript and it worked and tested fine. As I began making edits to the script, Opus was initially auto-detecting the updated version of the vbs file I was then manually copying into the Script AddIns folder, and retesting it made it obvious the changes were being actioned.

But then, after some sloppy code changes where things stopped working, I reverted back to an older copy that had DEFINITELY worked and it's still not working. I'm now unable to get Prefs to recognize the drop of a previously working VBscript (even the sample Events script included in your examples - which had previously dropped fine into Prefs).

I don't know what's going on here... I happen to be doing a large copy of files (200+ GB) to a USB drive during all of this, but I dn't see why that would have any bearing. If we write horribly bad code - is it possible to ~crash the script hosting interface or something? After this big file copy finishes, I'll try exiting and restarting Opus to see if things return to working.

Restarting Opus might bring things back to life. (DO11: Behaviour With Script Errors suggests it may be possible for a script error to break the scripting interface until Opus is restarted, in the current betas.)

Ah - sorry, should have seen that thread... ok, will hold tight until file copy finishes. Thanks.

FWIW: something still isn't right... (I'm running Beta 4 at the moment).

After clearing out all files from the Script AddIns folder and fully exiting and restarting Opus, after dragging and dropping EITHER the "Select Newest Files" jscript you guys provided... or the very basic test script below... Opus doesn't seem to 'accept' either script. There's neither a visual indication in the Prefs UI, nor any copy of the file getting dropped into the Script AddIns folder in the background.

What's more, after manually copying the following test script to the Script AddIns folder and fully exiting and restarting Opus again just to be sure, I'm not getting any of the expected output messages on folder change.

My sample OnAfterFolderChange_test script... am I doing something wrong in this extremely minimal code somewhere that's causing Opus to fail to parse and initialize it?

[code]// OnAfterFolderChange_test:
// (c) 2014 steje
//
// This is a script for Directory Opus.
// See http://www.gpsoft.com.au/redirect.asp?page=scripts for development information.

// Called by Directory Opus to initialize the script
function OnInit(initData)
{
// Provide basic information about the Script
initData.name = "OnAfterFolderChange_test";
initData.desc = "Check for successful folder change";
initData.copyright = "(c) 2014 steje";
initData.default_enable = true;
}

// Called whenever the folder is changed
function OnAfterFolderChange(afterFolderChangeData)
{
DOpus.OutputString("Folder change detected...");
}[/code]

...whereas a VBscript variant of this works as I'd expect.

Your script is working fine for me.

I reported a problem whereby after a Script error and fully exiting Opus, DOpus.exe was still present and had to be killed. After killing dopus.exe and fixing or removing the broken script then restarting Opus, all was well again. Maybe this is your problem too?

Regards, AB

Your sample works for me when I try it.

Wow, really? Ok, I'll make sure that dopus.exe is definitely gone - but I'm fairly sure it was. I'll reboot just in case...

Thanks AB, yeah that was the post Leo pointed me to earlier when I filed this report before seeing yours.

Even after cleaning out the AddIns folder and rebooting I still can't get the Prefs UI to accept the sample script OR get it to work after copying it manually into the AddIns folder (i.e. there are no messages logged after folder changes).

I'm going to roll back to my most recent backup image and see if there's any change on a clean system and fresh install of Beta 4.

This is a major bummer - I was hoping to do most of my script work in Jscript.

Opus uses the file extension to work out which script language is in use, so make sure it has a .js suffix. And if it does then maybe something's happened to that file extension on your system? On my machine, HKEY_CLASSES_ROOT.js points to JSFile, which has a ScriptEngine sub-key, the value of which is JScript.

Thanks for that Jon... that helped again. Don't know when this changed, but my .js definition pointed to UltraEdit.js. After setting it back to JSFile manually and restarting Opus I'm now getting expected behavior for both the drag and drop and and actual event handling.

Might be worth including a note in the Scripting Reference docs that Opus will need JSFile and VBSFile to be properly defined for the scripting interface to work.

We might look at hard-coding those extensions since it seems like the registry might be unreliable.

Yeah, and IDMComp is a legit developer in my experience, so anything to prevent WTF's coming your way from ppl with who-knows-what happening with their system filetype associations is probably a good idea :slight_smile:.