JuraScript Documentation

Last Updated 07/01/2013

1. Introduction
2. Installation
3. Using ActiveXObject
4. Legacy WSH Support
5. 'require' and 'exports' support

1. Introduction

 JuraScript's goal is to bring the flexibility of the JavaScript language, the power of the .NET framework and backwards compatibility with Active Scripting together in an easily deployable package. JuraScript targets system administrators, web developers and end-users through compatibility with the Windows Script Host, Classic ASP, a powerful JavaScript console and scripting runtime and possibly in the future ASP.net Web Forms and ASP.net MVC.

JuraScript accomplishes this by harnessing the Jurassic JavaScript project which is a correct, complete, performant, well-tested implementation of ECMAScript.

Eventually, WSH JScript scripts should be able to take advantage of JuraScript by simply renaming the file extension to .JUR. Classic ASP pages should be able to do the same by simply changing their language declaration. 

2. Installation

There are two ways to install JuraScript. You can use nuget to add JuraScript to an existing project, or you can use the MSI to install JuraScript on your system.

Installing the MSI ...
- Associates the .JUR extension with JuraScript. You can double-click .JUR files to execute them.
- Adds a JuraScript program folder with a "JuraScript Console" shortcut for an interactive mode.
- Adds .JUR to PATHEXT for command-line execution of .JUR files (run them like you would .BAT or .JS)
 

3. Using ActiveXObject

JuraScript scripts can use the ActiveXObject constructor with the same syntax and objects used in WSH or JScript scripts. This can be used to access or automate Microsoft Office products like Excel and Outlook, Internet Explorer, Windows Management Instrumentation (WMI), the FileSystemObject and RegExp  objects and many more through COM. JuraScript adds support for Enumerators such as in the case of accessing the FileSystemObject.Drives property.

4. Legacy WSH support

JuraScript provides a WScript object for legacy script support and compatibility.
The WScript object that JuraScript provides currently supports the following:

WScript.Quit();
WScript.Quit(int errCode);
WScript.Echo(object txt);
WScript.Version; // Returns "0"
WScript.BuildVersion; //Returns ""
WScript.FullName; //Returns Assembly.GetEntryAssembly().FullName;
WScript.Interactive; //Returns true
WScript.Name; //Returns "Jurassic Script Host"
WScript.Path; //Returns Assembly.GetExecutingAssembly().Location;
WScript.ScriptFullName;
WScript.ScriptName;
WScript.Sleep(int time); //Sleep in milliseconds
WScript.CreateObject(string progId); //Other overloads are not supported.
WScript.StdError; //Property exists, but has no functionality
WScript.StdOut; //Property exists, but has no functionality
WScript.StdIn.Read();
WScript.StdIn.Read(int characters);
WScript.StdIn.ReadLine();
WScript.StdIn.Skip(int characters);
WScript.StdIn.SkipLine();

4. 'require' and 'exports' support

JuraScript offers simple support for the require() function and the exports object.
To offer functionality to other scripts, assign properties and functions to the global exports object.

exports.sayHello = function() { return "Hello from my module."; };


To consume the functionality offered from another script, use the global "require()" function:

var myModule = require("myModule.jur"); //Load a script file
var assertModule = require("assert"); //Load built-in module 'assert' - which is a Work-In-Progress
 


When calling require, the following behavior occurs:
JuraScript tests if any built-in module matches the string passed to 'require()'.  These are presently stored as resources within the JuraScriptObject.dll library. If none match, JuraScript tests for the existence of a file matching the string passed to require() that ends with ".jur". In other words, passing "mymodule.jur" and "mymodule" are equivalent as JuraScript will search for "mymodule.jur" in both cases. 


Last edited Jul 1, 2013 at 6:06 PM by aikeru, version 6

Comments

No comments yet.