Scripts/CallJ

From J Wiki
Jump to navigation Jump to search

This script gives examples of calling J from J. Similar routines may be written in other languages that can call DLLs or shared objects.

Download the script File:Callj.ijs

Download (and update as needed) this script to call J701 from J602 File:Calljdm.ijs

Main definitions:

 jcmd     send sentence, return result
 jdo      send sentence to be executed
 jget     retrieve value of J noun
 jset     assign value to J noun

Utilities:

 jinit    initialize J instance, sets global pJ
 jfree    free J instance

For example:

  jinit''
158471920
   jdo 'a=: i.3'
0
   jget 'a'
0 1 2
   'a' jset 'hello'
   jget 'a'
hello
   jcmd '2 * 1 2j3'
2 4j6
   jfree''
0