Book a Demo

Author Topic: JScript reference  (Read 5945 times)

Dominik

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
JScript reference
« on: April 25, 2016, 07:44:01 pm »
We are running EA 12.1.1225 Corporate Edition. Where can I find the language reference for the JScript engine used? According to the EA support I shall have a look at the MS website, but I'm not even shure what version of JScript is used in EA. Or does that depend on the Windows version we run on?

For example, I have trouble to find documentation on:

  • the "as" keyword, as used in "var theElement as EA.Element;" - hard to google, by the way  ;)
  • how to open a file dialog to make the user choose a file name (to be used for documentation generation output)
  • what is the difference between JScript and javascript (I suspect javascript will not run on the MS but on some Mozilla engine, but again: which one?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: JScript reference
« Reply #1 on: April 25, 2016, 09:32:13 pm »
The "as" keyword is something EA invented and will only work in EA.
It allows the editor to know which type of object you are defining you it can show the "intellisense" dropdown with feature of that element.

In the script JScript-Dialog from the Script library MDG there's an example on how to invoke the file selection dialog
There are few differences between JScript and JavaScript. One of them is the way to instantiate objects from other libraries (new ActiveXObject())

In all fairness, I think you would be much better off with VBScript as it pretty good documented, and there are a lot more examples to draw from. (one of them being my EA VBScritp Library on Github)

Code: [Select]
/**
 * Displays an Open File dialog and returns the file name that the user selected.
 *
 * @param[in] filterString (String) A filter string that lists the sets of filename filters that
 * can be applied in the dialog. Each filter is a string pair delimited by the pipe symbol (|),
 * with the first string containing a description of the filter (eg "Documents") and the second
 * string containing a semicolon delimited list of file patterns to filter on (eg
 * "*.doc;*.xml;*.odt"). Multiple filters can be provided in filterString, delimited also by the
 * pipe symbol (eg "All Files |*.*|Documents|*.doc;*.xml;*.odt")
 * @param[in] defaultFilterIndex (Number) The filter index that will be selected by default (starts
 * at 1)
 *
 * @return A String value representing the file name that the user selected
 */
function DLGOpenFile( filterString /* : String */, defaultFilterIndex /* : Number */ ) /* : String */
{
if ( filterString == null || filterString == "" )
{
filterString = "All Files (*.*)|*.*";
defaultFilterIndex = 1;
}

// Create new CommonDialog object
var openFileDialog = new ActiveXObject("MSComDlg.CommonDialog");

// Set appropriate flags
openFileDialog.MaxFileSize = DLG_MAXFILESIZE;
openFileDialog.Filter = filterString;
openFileDialog.FilterIndex = defaultFilterIndex;
openFileDialog.Flags = OF_FILEMUSTEXIST;

// Show the dialog and return the selected file name
openFileDialog.ShowOpen();
return openFileDialog.FileName;
}

Geert