Skip to content

Session Startup

Paul Mansour edited this page Aug 10, 2019 · 4 revisions

AcreTools provides a mechanism for executing code at the beginning of an APL session. This code can do anything, but typically it is used to set up your session by specifying system variables, loading developer tool code into ⎕SE, setting function key actions, loading projects and workspaces, etc. In addition this mechanism installs user commands.

Session Startup Files

AcreTools will process zero or more session startup files when APL is started. A session startup file is simply a scripted namespace in a .dyalog text file. On startup, each namespace is fixed anonymously, and then if the namespace contains a function named OnSessionStart, this function is executed. Note that this function does not have to exist for the startup file to have an effect. The simple fixing of a scripted namespace may have serious intended (or otherwise) side effects (for example: #.⎕IO←1).

In addition, if the startup file contains a functions named List, then the startup file is considered to be a user command file as well and this function is executed to install a set of user commands. List is executed after OnSessionStart.

AcreTools enhances each startup namespace with two items at fix-time. Both of these should be considered reserved names. SourceFile is a variable containing the name of the source file. This is useful for finding resources related to the startup file. Include is a function that takes another session startup file name as an argument and returns a reference to the namespace. This means that any session startup file can take advantage of any code in any other session startup file. The session startup file System.dyalog contains common startup utilities and thus often the first line For example, the OnSessionStart function for AcreTools itself is:

      OnSessionStart←{
         s←Include 'System'
         s.LoadAcreToolsApplication SourceFile
       }

The order in which session startup files are processed within a given folder may be assumed to be the order in which ⎕NINFO returns results. However, the Include function can be used to guarantee that the OnSessionStartup function of one startup file runs before another.

AcreTools searches for startup session files in the session startup folder. Any .dyalog file found in this folder is considered to be a startup file. Unlike the Dyalog User Command framework, however, subfolders are not searched.

A file can be both a user command file and a startup session file. For user commands that require some type of initialization, it is convenient to enhance a user command file by adding an OnSessionStart function.