J Language Active Script Connector. Implements Windows script interfaces. Allows J to be used as script for various scripting hosts: cscript/wscript shell with .ijss extension or a Windows Script File job, ASP, Internet Explorer; as well as custom applications that support scripting extensions. See more at http://olegykj.sourceforge.net/.
The following steps will allow you to download the archive, install the script component and run examples.
JayScript requires general/pcall addon from properly installed JAL/Package Manager.
Use JAL/Package Manager to download the general/jayscript addon
Register bin\jayscript_reg.bat and J DLL j\bin\jreg.bat
Download the archive JayScript_test-x.x.x.zip at http://olegykj.sourceforge.net/ under JayScript
- Extract to any folder to see the following under
Registration and DLL are located in JayScript/test for j601 and bin folder for j602.
jayscript.dll Script component jayscript_reg.bat Registration
Browse the test folder and run examples:
test01.wsf WSF example test02.ijss WSH example, Hello World test03.ijss WSH example, more comples test04.html Internet Explorer example test05.asp ASP example
After registration the .ijss files will have a yellow J icon. (May need to re-open Windows Explorer.)
On Vista: user 32-bit installation of J (even for 64-bit OS). After install register J as Admin (browsing to the bin folder, right-click the jreg.bat, select "as Admin"), register JayScript as Admin (in addons/general/jayscript/bin folder, use jayscript_reg.bat).
The following examples show how to use JayScript in different hosting applications.
Common to all examples, is that when JayScript is loaded by the host application, it loads the default J profile and the general/pcall addon.
There is currently only limited error handling: Issuing a common exception without description.
Windows Script Host
WSH is Windows shell for scripting languages, typically VBScript or JScript. Plain text scripts have language extensions: .vbs, .js or .ijss for JayScript.
See MSDN for more help about Windows Script Host in particular reference of available WSH objects.
Scripts are run either from the command prompt (MS-DOS window) or by double-clicking or selecting Open from Right-click menu.
We will start with a simple Hello World script.
'Echo' do__WScript 'Hello, World!'
Open command prompt, cd to the test folder and run it:
d:\>cd JayScript\test d:\JayScript\test>test02.ijss Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. Hello, World!
WScript is a "root" object, which was provided by the host application, so that script could interact with it. Echo is its method and 'Hello, World!' is argument(s).
It is equivalent to VBScript statement WScript.Echo("Hello, World!"). The invokation is done using general/pcall/disp interface that provide OLE Automation functionality.
Besides "root" objects, it is possible to access their member objects; as well as list all exposed functions and properties.
'Echo' do__WScript 'This is J version',LF,' ',9!:14'' 'Echo' do__WScript 'Time now is ', ":6!:0'' 'Echo' do__WScript 'First ten integers: ', ": 1+i.10 'Echo' do__WScript 'Their sum (+/ 1+i.10): ', ": +/ 1+i.10 'Echo' do__WScript info__WScript '' StdIn=: disp 'StdIn' get__WScript '' 'Echo' do__WScript 'Enter your name:' line=. 'ReadLine' do__StdIn '' 'Echo' do__WScript 'Hello, ',line,'!'
Member-object StdIn is obtained and interned with disp, whence it is accessible the same way as a root. info applied to any object shows available operations.
d:\JayScript\test>test03.ijss This is J version j601/2006-11-17/17:05 Time now is 2007 7 29 21 11 39.687 First ten integers: 1 2 3 4 5 6 7 8 9 10 Their sum (+/ 1+i.10): 55 IHost NB. Windows Script Host Application Interface HRESULT ScriptName BSTR* out_ScriptName HRESULT ScriptFullName BSTR* out_ScriptFullName HRESULT Arguments IArguments2** out_Arguments HRESULT Version BSTR* out_Version HRESULT BuildVersion int* out_Build HRESULT Timeout long* out_Timeout HRESULT Timeout long out_Timeout HRESULT CreateObject BSTR ProgID BSTR Prefix IDispatch** out_Dispatch HRESULT Echo SAFEARRAY pArgs HRESULT GetObject BSTR Pathname BSTR ProgID BSTR Prefix IDispatch** out_Dispatch HRESULT DisconnectObject IDispatch* Object HRESULT Sleep long Time HRESULT ConnectObject IDispatch* Object BSTR Prefix HRESULT StdIn ITextStream** out_ppts HRESULT StdOut ITextStream** ppts HRESULT StdErr ITextStream** ppts Enter your name: test Hello, test!
There is also a special file format WSF (Windows Scirpt File) that allows you to combine scripts in different languages, include files, process input arguments, etc.
<job> <script language="JScript"> WScript.Echo("JScript: ", 1,2,3,4) </script> <script language="VBScript"> WScript.Echo "VBScript",1,2,3,4 </script> <script language="JayScript"> 'Echo' do__WScript 'JayScript:';": +/i.3 4 </script> <script language="VBScript"> WScript.Echo "VBScript again",1,2,3,4 </script> <script language="JayScript"> 'Echo' do__WScript 'JayScript again:';": +/i.3 4 </script> </job>
d:\JayScript\test>test01.wsf JScript: 1 2 3 4 VBScript 1 2 3 4 JayScript: 12 15 18 21 VBScript again 1 2 3 4 JayScript again: 12 15 18 21
The only root object exposed is window, which has method alert, but document can be obtained to use the write method.
See HTML Reference at MSDN, in particular the window object.
Events are not implemented yet.
Run .html with Internet Explorer 32-bit, allow Blocked Content in upper bar, allow ActiveX in security prompt. If it shows nothing against JayScript, try the following security setting: menu Tools, (Internet) Options, Security tab, select Local Intranet, Custom level. In ActiveX Controls and Scripting sections, those items that are marked disabled change to Prompt, especially "Run ActiveX not marked as safe for scripting". After experimenting reset to previous levels, or apply a default appropriate level: Medium or High.
<html><body> ... <hr>JayScript<br> <script language="JayScript"> document=: disp 'document' get__window '' 'write' do__document ": +/i.3 4 </script> <hr>JayScript Event (not working yet)<br> <input type=button id=bntTest value="Call J"> <script for=bntTest event="onclick()" language="JayScript"> 'alert' do__window 'Hello from J' </script> </body></html>
ASP exposes as roots its standard objects Request, Response, etc. The regular <% %> notation applies and JayScript can be combined with other scripting languages on one page.
See Active Server Pages at MSDN.
To run this example, make the test folder available from IIS as JayScript root.
On Vista: the JayScript application must be in Classic 32-bit pool.
<%@ Language="JayScript" %> <html> <% timeNow=: 3 : 0 ": 6!:0'' ) %> <body> <hr>JayScript Script<br> <script language="JayScript" runat=server> 'Write' do__Response 'executed at end' </script> <hr>JayScript Immediate<br> <% 'Write' do__Response timeNow'' %> <hr>JayScript Value<br> <%= ": +/3 4 ?@$ 100 %> <hr> </body></html>
Windows Script Host at Wikipedia
Active Server Pages (ASP) at MSDN.
Contributed by OlegKobchenko