Contents
J has two related concepts, folder and project, that help you work with source files. Both are simply references to directories.
Folder
A folder is a name given to a directory. Using folder names instead of full pathnames means that names are typically much shorter, and that it is easy to share code between users with very different directory structures.
The nouns SystemFolders_j_ and UserFolders_j_ have tables of such names, for example:
SystemFolders_j_ +-------+---------------------------------+ |addons |/home/chris/j7/addons | +-------+---------------------------------+ |bin |/home/chris/j7/bin | +-------+---------------------------------+ |break |/home/chris/j7/user/break | +-------+---------------------------------+ |config |/home/chris/dev/user/config/linux| ...
UserFolders_j_ +----+----------------------------------------+ |Grid|/home/chris/deb/base/grid | +----+----------------------------------------+ |R |/home/chris/deb/addons/stats/r | +----+----------------------------------------+ |Ide |/home/chris/deb/addons/gui/gtkide/source| +----+----------------------------------------+ |Main|/home/chris/deb/base7/main | ...
SystemFolders is initialized in the boot up process. UserFolders and additional entries for SystemFolders are given in the configuration file folders.cfg (open with menu Edit|Configure|Folders).
Most of the time, system folders and user folders are used together. The main difference is that the IDE expects J source to be stored under user folders, not under system folders. By convention, system folders have names beginning with lowercase, and user folders have names beginning with upper case.
Verb jpath references the folder tables. It converts strings with folder names preceded with ~ into their full pathname:
jpath &> '~bin/profile.ijs';'~config/folders.cfg';'~R' /home/chris/j7/bin/profile.ijs /home/chris/dev/user/config/linux/folders.cfg /home/chris/deb/addons/stats/r
Dots can be used to reference parent folders:
jpath '~.R/base/random.ijs' /home/chris/deb/addons/stats/base/random.ijs
Project
A project is a subdirectory that contains a file with extension .jproj with the same name as the directory. For example, if file c:/dev/mywork/grid/grid.jproj exists, then the directory c:/dev/mywork/grid is recognized as a project directory.
Typically, project directories are subdirectories of folders. For example, if folder name Mywork points to c:/dev/mywork, then this grid project can be referred to as ~Mywork/grid. In the IDE, the ~ prefix is usually omitted.
A *.jproj file has two possible formats, and defines up to three nouns:
Build - the script that is loaded when Build is invoked in the IDE.
Run - the script that is loaded when Run is invoked in the IDE. A build is automatically done first.
Source - a list of files that would typically be the source files used to build a target script.
By default, a project file contains a simple list of files that define Source. In this case, Build and Run are build.ijs and run.ijs. To allow for different Build/Run scripts, the three nouns can be defined explicitly.
Project Verbs
Verbs to work with projects are in locale jp. These include:
readsource_jp_ - this reads all files in a project's Source and returns a character string
- writesource_jp_ - this reads the source, and writes to file
Corresponding verbs ending in x delete all comments.
For example, the following reads all source in the project ~Main/project, decomments it, and writes to ~system7/util/project.ijs. Typically, this command would be given in the project's build script:
writesourcex_jp_ '~Main/project';'~system7/util/project.ijs'
Example
An example of using folders and projects is the base and addons source. To install this:
1. checkout or export the addons, base7 and public repositories from Subversion. These can go anywhere on your machine. The following examples assume they are written to ~home/svn.
2. load the J Gtk IDE, then select menu Edit|Configure|Folders. In the config file, add entries for:
Main ~home/svn/base7/main Ide ~home/svn/public/ide/gtk/source Gtk ~home/svn/public/gui/gtk/source Addons ~home/svn/addons
Note that the paths can be jpaths as above, or full pathnames, as in:
Main /home/elmo/svn/base7/main
3. Close and reload J Gtk IDE. Ctrl-M to open the editor, and select menu Project|Open (or click the corresponding toolbar button). You should see the new folders listed in the first panel, and their projects in the second. Select a project to open it in the editor.
