Guides/Startup

From J Wiki
Jump to: navigation, 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

The noun Public_j_ defines short names and the corresponding full form. The short names may be used in open or load verbs. Items of Public_j_ are lines of a table:

   2 {. Public_j_
+--------+-----------------------------------+
|afm     |~system\classes\plot\afm.ijs       |
+--------+-----------------------------------+
|bigfiles|~system\packages\files\bigfiles.ijs|
+--------+-----------------------------------+

If you want to define your own names, you may add them to Public_j_ in your startup file. The easiest way to do this is to use the buildpublic_j_ verb:

   buildpublic_j_ 0 : 0
langexten    C:\myfiles\langexten
utils        C:\myfiles\utils
)

After executing the lines above, I can open one of my files simply by typing

   open 'langexten'

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