J language's "load" command
Asked Answered
T

1

7

I'm working through the J primer, and getting stuck when it comes to the load command.

In particular, there are times when the next step in a tutorial is load 'foo' and I'll get an error like the following:

   load 'plot'
not found: /users/username/j64-801/addons/graphics/plot/plot.ijs
|file name error: script
|       0!:0 y[4!:55<'y'

When I do ls /users/username/j64/addons/ I only have config and ide in there, so it's sensible that graphics is not found.

My question: if given an example that says load 'foo', how do I go about finding and installing foo?

Thompson answered 19/5, 2014 at 20:12 Comment(0)
S
12

I'd recommend simply installing all the JAL packages ("Addons"). There aren't too many, so the download won't take long, and you'll have access to everything you need to run the Labs, Wiki examples, and any code posted by the community (e.g. on the J Forums).

To install all available Addons, type the following into Jconsole (you could theoretically type it into JHS or JQT instead, but since those are distributed as Addons, you might not be able to upgrade them while they're running):

   load'pacman'  NB. J PACkage MANager
   install'all'

The package manager will start running, and you'll see output like:

Updating server catalog...
Installing 52 packages
Downloading base library...
Installing base library...
Downloading api/gl3...
Installing api/gl3...
Downloading api/ncurses...
Installing api/ncurses...

Then stop and restart Jconsole, and run:

   load 'pacman'
   'update' jpkg 'all'

To make sure all recursive dependencies were satisfied and all packages are up to date (in particular, the base library). Ultimately, you want to see something like:

Updating server catalog...
Local JAL information was last updated: <datetime>
All available packages are installed and up to date.

Then stop & restart J one last time. When that's done, you should have everything you need to run the Labs.


To answer your final question, if you see a line like:

   load'foo'

The first thing you should do is run getscripts_j_ 'foo'. In your example:

   getscripts_j_ 'plot'
+--------------------------------------------------------------+
|c:/users/user/j64-801/addons/graphics/plot/plot.ijs|
+--------------------------------------------------------------+

Here, you can see the fully-qualified path of where J expects the package to live.

In particular, you can see it where it is relative to the addons directory, which will always be in the form addons/category/module/foo.ijs. The category and module name indicate which addon you need to install, so all you have to do pick the desired entry from the catalog visible in the package manager.

Scallion answered 19/5, 2014 at 20:48 Comment(1)
I see you've answered two of my J-related questions today, thanks @DanBron.Thompson

© 2022 - 2024 — McMap. All rights reserved.