Author Topic: MSScript for EA 16 64 Bit  (Read 3154 times)

Helmut Ortmann

  • EA User
  • **
  • Posts: 967
  • Karma: +42/-1
    • View Profile
MSScript for EA 16 64 Bit
« on: September 22, 2023, 06:14:59 pm »
Hello,

I want to use MSScript for EA 16 64 Bit to start a JScript. The existing MSScript seems not to run in the EA 64 Bit environment.

Is there a way to start a JScript via MSScript or a workaround?

Thanks for your help.

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Helmut Ortmann

  • EA User
  • **
  • Posts: 967
  • Karma: +42/-1
    • View Profile
Re: MSScript for EA 16 64 Bit
« Reply #1 on: September 25, 2023, 07:50:41 pm »
Hello,

The error seems to be known and confirmed by SPARX:
- https://sparxsystems.com/forums/smf/index.php?topic=46571.0
    Best regards,

    Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Helmut Ortmann

  • EA User
  • **
  • Posts: 967
  • Karma: +42/-1
    • View Profile
Re: MSScript for EA 16 64 Bit
« Reply #2 on: September 28, 2023, 07:50:18 pm »
Hello,

OpenSource tsc64.dll (64 bit Tablacus Scripting Control) solves the issue. It's a 64-bit replacement of Microsoft ScriptControl ActiveX.

See:
https://tablacus.github.io/scriptcontrol_en.html

Good luck,

Helmut

Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Jan van Duuren

  • EA Novice
  • *
  • Posts: 12
  • Karma: +1/-0
    • View Profile
Re: MSScript for EA 16 64 Bit
« Reply #3 on: December 21, 2023, 07:12:09 pm »
I found a solution, which works, whithout using ScriptControl or Tablacus solution.

you find my solution here:
https://sparxsystems.com/forums/smf/index.php/topic,46571.msg279900.html#msg279900
EA scripting since 2013 (JScript and Javascript)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1317
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: MSScript for EA 16 64 Bit
« Reply #4 on: April 16, 2024, 06:01:54 pm »
Whilst a solution has been found for Javascript, there isn't any for JScript  + EA 16 64 bits. Is it unlilkely there will be any solution in the future (feasbility issue) ?

Options are:
- Use EA 16.1 32 bits: whilst using 64 bits is a default recommendation, I'm not convinced yet there will be any major impact for users in installing the 32 bits version
- Migrate the code to Javascript and use the custom solution: this can be time consuming if there is quite a lot of code to make compatible with Javascript

Notes:
- there doesn't seem to be any impact for VBScript projects with EA 16 64 bits
- Session.input is unfortunately limited as it doesn't support a custom text to be displayed e.g. provide the name of the diagram to process: A, B, C...
« Last Edit: April 16, 2024, 06:23:22 pm by Guillaume »
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Jan van Duuren

  • EA Novice
  • *
  • Posts: 12
  • Karma: +1/-0
    • View Profile
Re: MSScript for EA 16 64 Bit
« Reply #5 on: May 02, 2024, 11:39:31 pm »
Herewith the JScript MsgBox and InputBox example for EA 16 64bit


!INC Local Scripts.EAConstants-JScript

/*
 * Script Name: JScript MsgBox (EA 16 x64)
 * Author     : Jan van Duuren
 * Purpose    : Test MsgBox and InputBox with JScript in EA 16 64bit
 * Date       : 02.05.204
 */
 
// global vars
var fso = new ActiveXObject("Scripting.FileSystemObject");
var WSH = new ActiveXObject("WScript.Shell");

function main()
{
   var result = InputBox("Please enter here", "MyInput", "default_text");
   MsgBox(result, "MyTitle", 64);
   
}

main();

function MsgBox(prompt, title, style) {
   if (prompt == null) prompt = "";
   if (title == null) title = "MsgBox";
   if (style == null) style = 0;
      
   style += 4096; // to make the popup active (foreground)
   return WSH.Popup(prompt, 0, title, style);
}

function InputBox(prompt, title, defaultText) {
   if (prompt == null) prompt = "Input";
   if (title == null) title = "InputBox";
   if (defaultText == null) defaultText = "";
   
   var vbsScriptFile = WSH.ExpandEnvironmentStrings("%TEMP%\\ea_inputbox.vbs");
   var tmpInputFile  = WSH.ExpandEnvironmentStrings("%TEMP%\\ea_input.tmp");

   if (!fso.FileExists(vbsScriptFile)) {
      CreateInputboxVBS(vbsScriptFile);
   }

   var cmd = 'WScript "' + vbsScriptFile + '" "' + tmpInputFile + '" "' + prompt + '" "' + title + '" "' + defaultText + '"';
   Session.Output(cmd);
   WSH.Run(cmd, 1, true);
   var ForReading = 1;
   var file = fso.OpenTextFile(tmpInputFile, ForReading);
   if (!file.AtEndOfStream) {
      return file.ReadAll();
   }
}

function CreateInputboxVBS(vbsScriptFile) {
   // function to create the inputbox VBS sripts in folder
   var vbsScriptContent = "dim tmpInputFile, prompt, title, defaultText, input\r\n\
      Set objArgs = WScript.Arguments\r\n\
      If objArgs.Count = 4 Then\r\n\
         tmpInputFile = objArgs(0)\r\n\
         prompt       = objArgs(1)\r\n\
         title        = objArgs(2)\r\n\
         defaultText  = objArgs(3)\r\n\
         input        = InputBox(prompt, title, defaultText)\r\n\
      End if\r\n\
      \r\n\
      Const ForWriting = 2, CreateIfNeeded = true\r\n\
      set fso = CreateObject(\"Scripting.FileSystemObject\")\r\n\
      set file = fso.OpenTextFile(tmpInputFile, ForWriting, CreateIfNeeded)\r\n\
      file.write input\r\n\
      file.close".replace(/\t\t/g, '');
   
   var overwrite=true, unicode=true;
   var file = fso.CreateTextFile(vbsScriptFile, overwrite, unicode);
   file.Write(vbsScriptContent);
   file.Close();
}
EA scripting since 2013 (JScript and Javascript)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1317
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: MSScript for EA 16 64 Bit
« Reply #6 on: May 03, 2024, 10:33:00 pm »
Hi Jan,

Thank you for sending the new script which works in EA16 64 bits  :D

Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


philchudley

  • EA User
  • **
  • Posts: 727
  • Karma: +19/-0
  • UML/EA Principal Consultant / Trainer
    • View Profile
Re: MSScript for EA 16 64 Bit
« Reply #7 on: May 05, 2024, 10:50:45 pm »
Hi Jan

Fantastic! Thanks a lot.

Does anyone out there have a JavaScript version of this?

Phil
follow me on Twitter

@SparxEAGuru

philchudley

  • EA User
  • **
  • Posts: 727
  • Karma: +19/-0
  • UML/EA Principal Consultant / Trainer
    • View Profile
Re: MSScript for EA 16 64 Bit
« Reply #8 on: May 05, 2024, 10:58:24 pm »
Hi Jan

Apologies I found your JavaScript version just after posting my previous message :)

Thanks again for both versions of this script

Phil
follow me on Twitter

@SparxEAGuru