Migrating scripts to Javascript

Just for reference, here is the Javascript page.

I would happily migrate all my scripts to Js, if it was not for the time it’s going to take. :face_without_mouth:

I’ll also probably have a bunch of questions, among which :

  • How to share global variables across Js and legacy scripts ?
    (I read it’s possible in the old forum)

  • Also regarding this code (to be placed in a “jsconfig.json” file, which version (target) can we use ? :

{
  "compilerOptions": {
    "target": "ES2016",
    "module": "commonjs"
  },
  "exclude": ["node_modules"]
}
  • can we have common modules like “mySharedFunctions.js” with module.exports = {f1, f2};
    and then const{f1, f2} = require(“./mySharedFunctions.js”); referenced in other modules.

… and also,

  • can I put js files in a different directory than legacy scripts?
  • do we have some logging capabilty, like with post() ?

Those are good questions.

  • The idea of creating a migration tool for scripts has crossed my mind, but without thinking it through, I deemed it too complex, and I have way too many other things to do that I find more important.

  • It’s the same variable controller for global variables in both the old and new script engines, so as long as the variables are named the same (without the @ prefix), they will work across all scripts.

  • The GitHub page for the JavaScript engine has a long list of what it supports.

    GitHub - sebastienros/jint: Javascript Interpreter for .NET · GitHub

  • Exports and references to shared resources are currently not supported. These features are incompatible with how the JavaScript engine is integrated with the plugin. I recognize the potential benefits of having these features, but I haven’t had time to explore possible solutions.

  • Each script reference is independent, so you can place scripts anywhere you like.

  • I have considered logging, but unfortunately, it is not available yet. Where do you want log entries to be written: in the plugin log file or elsewhere?

Hello,
In response to your answers …

  • migration tool for scripts. Maybe an IA fed with the scripting language documentation would help, don’t you think ?
  • global variables. The point is getting notified in js when they change, as in the old scripts. any idea ?
  • Exports and references to shared resources. I understand it is now available. Correct ?

And to be a bit provocative :melting_face:
why not getting rid of c# ?

migration tool for scripts. Maybe an IA fed with the scripting language documentation would help would help, don’t you think ?

Cool suggestion, I didn’t think of that. :slightly_smiling_face:

global variables. The point is getting notified in js when they change, as in the old scripts. any idea ?

That’s what the OnGlobalVariableChanged(name, value) event is used for.

Exports and references to shared resources. I understand it is now available. Correct ?

Correct.

And to be a bit provocative :melting_face:
why not getting rid of c# ?

I didn’t understand that. Where would I be getting rid of C#? If you’re suggesting that I should spend time converting 6 years of C# development to JavaScript, I think I’ll pass. :wink: