How to start learning JScript?

I'd like to learn the basics of JScript in order to be able to create some buttons on my own.
I understand that JScript is related to JavaScript, but not the same. Does it make sense to do some JavaScript tutorials or online courses? Or should I check for tutorials that are specifically for JScript?
Anything that you would recommend?

The only thing I'd use it for (right now) would be Opus and I don't have any real knowledge of any programming language so far.
I guess learning JScript makes more sense than learning VBScript, right?
Even though both are apparently considered to be outdated, JScript is supposed to be similar to JavaScript which is widely used.

You are right, JScript used by Opus scripting is outdated version of JavaScript, but it is better to learn JScript than the VBScript since its structure is more modern so getting used to it is more broadly useful.

For more information about the Microsoft's JScript version used in Opus see this awesome post: Here are the Windows Script Host / ActiveScript Reference Manuals

Quick tip: since the Opus is using the Microsoft's WSH (Windows Script Host) for scripting support, you can search JScript WSH to find other interesting/advanced examples on the web that work in Opus too.

Hello !
I am also attempting to learn Javascript.
I am well into this online javascript tutorial

I have an advantage of some time ago knowing a fair amount of PHP.
Many of the ideas are similar, but expressed differently with javascript being far more object oriented.
I'm beiginning to understand scripts a bit more now and the default button Jscript template seems within my reach.


Speaking of web JavaScript (since we're in the Off-Topic category), here's something fun to try right now in the browser: press F12 and click the Console tab. Now you can enter and execute JavaScript code in the context of this web page.

  • To change the upper-left Opus logo of this forum to Leo's avatar enter this code (press enter): document.getElementById("site-logo").src = ""
  • To flip it upside down enter this code: document.getElementById("site-logo").style.transform = "rotate(180deg)"
  • You can also flip the entire webpage upside-down: = "rotate(180deg)" (reset it back either by refreshing the page or setting the rotation value to 0deg or clearing the entire parameter: = undefined

Cool !

JScript is ECMAScript 5 (ES5) compliant as far as I know, modern Javascript is ES6+ It makes sense to specifically look into ES5 vs ES6+ differences to better understand why specific things don't work in JScript and at the same time, what would still work.

JScript on Windows throws in some additional objects and methods to get access to OS, filesystem, WMI etc (like WSH.Echo() method). It's the same for JScript/Javascript in a browser, the browser will also add additional functionality to the language to gain access to the actual website, requests, cookies etc. (like console.warn() method). Another example: DOpus adds DOpus.Output() method to the script context to make console output available within the application.

Javascript itself cannot interact with anything (OS, browser, etc.), so it's important to understand what is core Javascript (native objects and methods), what are the differences between Javascript iterations (ES5, ES6) etc. and what objects and methods are added to the Javascript context by the surrounding environment to allow interaction with it.

If you know you are running a ES5 interpreter (like JScript) and know it's syntax restrictions and you know you are not running in a browser, not running via Window's cscript.exe, but you know you are within DOs script context, it is quite clear what functionality is available, what syntax works and which things will never work.

Using "let myVar = console.warn('hello')" will never work in a DO-JScript script, since "let" is a ES6 keyword and "console" object is not present in DOs context.

Simple JScript things are easy to be tried out with "cscript.exe MYFILE.js". This works on every windows since Windows2000, I use it a lot to tinker with snippets and quickly trying scripting foo, which is to be used in DO or other JScript based environments.

When using internet search, it is a wise idea to exclude "javascript" hits from your search for JScript related things (by adding a minus to one or more search terms).
"JScript find index of character in string -javascript" is what your search with Google should look lie, to not end up in trillions of NodeJS and current browser related ES6 scripting examples, which still might work, but often are not compatbile with ES5/JScript.

If there is a method on a native Javascript ES6 object which does not exist in ES5-JScript (like, which is ES6+ only), you can search for a "array map polyfill". Polyfills are pieces of Javascript, which can add functionality (methods, objects etc.) to your context, even though it is not available by default. You can run many ES6 based code on a ES5 engine, if you have added the polyfills to your code. This works for objects and methods only, it does not work if you try to "back-port" native language syntax or keywords like "let". It will always be "var"-only in ES5/JScript, since there is no polyfill-magic to extend the language itself, you can only extend objects with polyfills (add missing methods e.g.).

That said, editing ES6 "let" statements into JScript/ES5 "var" statements is quite easy, it will do in most cases, but there is code which requires "let" to be used, because it works differently than "var". Both statements declare variables, but when used in conjunction with "Closures" (look that up) it can make a huge difference to how your code works. If you know you need "let" in an ES5 engine, there is a solution, but this is advanced stuff for later. o)

That's all, I hope this helps to cut through the mist! o)


To summarize some of the tbone's points, when using the WSH scripting (JScript or VBScript) in Opus, broadly speaking the following categories of functionality become available to you:

  1. JScript (or VBScript) core language functionality such as variables, loops etc. (see the tbone's explainer mentioning ES5) which enable more complex scripting than using just the standard internal Opus commands.
  2. Opus-specific functionality (via Opus-provided scripting API), such as DOpus.Output("Hello!")
  3. Windows system-wide functionality (via ActiveScripting), such as ability to mute/unmute audio, eject the CD drive tray etc. -- nicely integrated in Opus (e.g., trigger on button click).
1 Like

Thanks, that makes the differences between JScript and JavaScript as well as the general concept a lot clearer!

I would say that's a weird choice for an example image... but Leo's avatar was also the first image my "Download file from clipboard URL to folder path" button downloaded when it finally worked. :laughing:

Post deleted by author.
It was stupid.

Look what ChatGPT just told me about VBasic, JScript and Dopus:

Please note that JScript is no longer supported in recent versions of Directory Opus. If you're using an older version that still supports JScript, you can use this code. However, it's recommended to migrate to VBScript or other supported scripting languages if you're using a newer version of Directory Opus.

I told her that doesn't sound correct, I hope she'll remember. :sweat_smile:

ChatGPT isn't worth asking about anything. :slight_smile:

1 Like

Yes, especially her knowledge of Dopus is an interesting combination of self-confidence and wackiness!

However, she explains code really well, it helped me understanding and combining the code snippets I've found. And her regex skills aren't bad either. It's always difficult getting into regex again after not using it at all for months.

Asked ChatGPT several times about Regex - not once did I get a working one. But transferred batch-files, to Powershell scripts to JScript. You need to be patient and figure out an optimal "syntax" aswell as checking the results, alas. But it most certainly is fun :smiley: