Guides/Startup

From J Wiki
Jump to navigation Jump to search

Configuration

The Edit|Configure menu allows you to change the interpreter's settings. Look through the tabs to see what is available. Note especially the Folders tab, which lets you specify the folders Project Manager and Find In Files will use to organize your work.

In addition to the configuration variables, you can have startup commands executed whenever J starts, or you can specify a script in the command line that will run after J has been initialized. The startup sequence is described in detail here. If you just want to run some startup commands, jump to the section describing the user startup file.

Startup Sequence

  1. The command line is parsed into words. The words are assigned to the variable ARGV_z_. The first word is the name of the J executable. The subsequent words, the parameters, tell J what to do. The first parameter that is not a switch is the name of the command script which is the J script you want to execute.
  2. If the first parameter is the -jijx switch, the normal J IDE window, where you type commands and see them executed, will not be created. You must have a fully standalone application. Except for creating the IDE window, the J startup sequence will be followed as described below, and the -jprofile switch will be honored.
  3. If the command line contains the -jprofile switch, you are taking full control of J's startup. Your command script will be executed instead of J's normal start sequence. Make sure you get it right! If the command script is omitted, J will skip the startup sequence entirely.
  4. If you don't specify the -jprofile switch, you get J's normal startup sequence which winds up by executing the command script. The normal startup sequence is contained in the script ~bin\profile.ijs, which goes through the following steps:
    1. The variable SystemFolders_j_ is created, containing the paths J uses to get to your home directory, the system, etc. You can look at this variable after J has started to see what folders are defined. If you want to change these directories, you do so by creating the script ~bin\profilex.ijs. Use ~bin\profilex_template.ijs as the template for creating your custom script.
    2. Any missing directories referred to in SystemFolders_j_ are created.
    3. Normal startup continues by running ~system\util\boot.ijs. This file loads the J system files stdlib.ijs, scripts.ijs, regex.ijs, task.ijs, configure.ijs, ctag.ijs, jadetag.ijs, and (if appropriate), 'qt.ijs'. Use 4!:3 to see all the scripts that are loaded at startup.
    4. Next, if the J executable was Jconsole, the console window is created and the console startup file ~config/startup_console.ijs is executed. User customization is not performed.
    5. If the J executable was not Jconsole, the user customization steps are performed:
      1. The J IDE is loaded and the configuration files are executed:
        1. the user configuration from the Edit|Configure menu
        2. the addons configuration file ~addons\config\config.ijs.
      2. After configuration, the user startup script is executed. This script is contained in the Edit|Configure|Startup Script menu. This script is where you put the definitions that you want executed every time J starts. It is executed in the base locale.
    6. Finally, the command script is loaded if there is one. Normally this is a file, but if the inline script indicator -js is given in place of the name of the command script, the words of ARGV_z_ following the -js are taken to be lines of J code, and they are put into the verb ARGVVERB which is used as the command script. The command script is executed in the base locale. If the command script is omitted, nothing is run.
  5. When the startup sequence finishes, J may wait for user input. This input may come from a form, or, if -jijx was not specified, from the IDE window; but if neither of these sources of input exists, the interpreter will exit with no prompt. If your program expects input from another source, such as a timer or socket interrupt, you need to display a dummy form to keep J from terminating.

Public Names

For frequently used scripts, the utility verbs: load and open accept short names, e.g.

load 'plot'
open 'primitives'

The collection of short names is defined by the system table: Public_j_

  • The first column consists of all the recognized short names (boxed)
  • The second column consists of the corresponding paths (boxed).

Successful changes made to Public_j_ take effect immediately.

Suppose you find out that

open 'stdlib'

doesn't work because J looks for it in the wrong folder. Indeed, you discover that there is no mention of stdlib in Public_j_

   1 e. 'stdlib' E. ;Public_j_
0

Thus you must add a row to Public_j_ with the short name stdlib and the correct path ~system/main/stdlib.ijs.
(The actual path may change in future versions of J.)

The most convenient way to do this is with the utility verb buildpublic_j_

   buildpublic_j_ 'stdlib ~system/main/stdlib.ijs'

   1 e. 'stdlib' E. ;Public_j_     NB. now it works!
1
   Public_j_
+----------+-----------------------------------------+
|afm       |~addons/graphics/afm/afm.ijs             |
+----------+-----------------------------------------+
|bmp       |~addons/graphics/bmp/bmp.ijs             |
+----------+-----------------------------------------+
…
+----------+-----------------------------------------+
|stdlib    |~system/main/stdlib.ijs                  |
+----------+-----------------------------------------+
…
+----------+-----------------------------------------+
|viewmat   |~addons/graphics/viewmat/viewmat.ijs     |
+----------+-----------------------------------------+
|wdooo     |~addons/tables/wdooo/wdooo.ijs           |
+----------+-----------------------------------------+

To make this alteration persist across J sessions, you must add the line:

buildpublic_j_ 'stdlib ~system/main/stdlib.ijs'

to your startup script, viz. ~config/startup.ijs

In jqt: Edit > Configure > Startup Script

To add more than one short name with a single call of buildpublic_j_

   buildpublic_j_ 0 : 0
stdlib ~system/main/stdlib.ijs
tte ~addons/debug/tte/tte.ijs
)

Seeing What Scripts Have Run

The foreign 4!:3 tells what scripts have been loaded. You can execute this just after startup to see the sequence of startup scripts.

See Also