Oct SALT in Dyalog V1.17
Oct Introduction SALT is a Simple APL Library Toolkit It is a source code management system for Classes and script-based Namespaces in Dyalog APL.
Oct Basics -SALT consists in a series of functions stored in []SE to manipulate the source ([]SRC) of objects. -The source code for each object (function or namespace) is stored in a single Unicode text file with a file extension of “.dyalog”. -All functions take a string to do their work. -This string describes the arguments and possibly some -modifiers for the function
Oct Commands All SALT functions are monadic. They -Save objects in files -List files -Explore them -Load them -and more…
Oct SALT stores source in Unicode (UTF-8) files whose extension is.Dyalog.Dyalog files are configured to be opened automatically with Notepad under Windows upon installation Under Unix, the naming of the files is case sensitive. Storage
Oct Requirements There are NO special requirements (not even.Net) V11 is the minimum version SALT will run under SALT is packaged and comes in already available with V11.
Oct Enabling SALT in V12 By default SALT is enabled when V12 is installed. To disable SALT you can use the configuration menu.
Oct Enabling SALT in V12 The configuration menu:
Oct Some SALT registry keys The registry key HKEY_CURRENT_USER\Software\Dyalog\Dyalog APL/W 12.0\SALT contains some keys which must be specified a value: ValueDefault SettingWhat is it? AddSALT0Controls whether SALT is initialized when the session file is loaded. CompareCmdAPLSpecifies how to call a file comparison utility. SourceFolder[Dyalog]\SALTSpecifies folders for source files separated by ";". Default folder is located below the main Dyalog folder. EditorCMDnotepad.exeSpecifies which program to run to edit script files outside APL
Oct Enabling SALT The registry key HKEY_CURRENT_USER\Software\Dyalog\Dyalog APL/W 12.0\SALT\AddSALT MUST have the value ‘1’ for SALT to be enabled. Once this key is set all subsequent sessions will have SALT enabled until this key is changed back to ‘0’ (not ‘1’)
Oct Enabling SALT You can also use the included SALT workspace to enable or disable SALT: )load SALT enableSALT disableSALT
Oct Starting SALT Upon starting Dyalog SALT will identify itself:
Oct Storing using SALT We can now store any sourced object:
Oct The Save function Save takes a string as argument. To find its syntax give it a single ‘?’:
Oct The Save function Ask SALT to store it in a specific path:
Oct The Save function Ask SALT to store it in a relative path: mine\test’ C:\Program Files\Dyalog\V12\SALT\mine\test.Dyalog
Oct Storing using SALT By default SALT will store the source under [Dyalog]\SALT where [Dyalog] is the installation location. SALT will replace [Dyalog] by whatever location Dyalog is installed.
Oct Storing using SALT Here Dyalog was installed under C:\Program Files\Dyalog\V12 and the installation location was [Dyalog]\SALT so the sources will all be stored under C:\Program Files\Dyalog\V12\SALT Since we asked to store test under mine\test the final path, after adding the extension, is C:\Program Files\Dyalog\V12\SALT\mine\test.Dyalog
Oct Storing using SALT If a different location is desired the workdir setting must be modified to specify the location. For example you could decide that all scripts go under \CMS\DYW instead of the default
Oct Viewing the file in Notepad Double click the file opens with Notepad
Oct Listing folder contents List takes a pathname as argument and displays its contents:
Oct Listing folder contents Example, list the contents of study\GUI:
Oct Listing folder contents Example, list Samples recursively:
Oct Explore Explore allows to look at a script with an external editor or to browse using the OS’ explorer:
Oct Exploring folders Exploring a folder merely opens up the disk Explorer. Example, exploring folder Samples:
Oct Exploring folders Example, exploring folder Samples\GUI:
Oct Exploring files Exploring a file opens up the file with Notepad. Example, exploring file Samples\GUI\Othello:
Oct Exploring files Notepad is the program used by default. To change this use the SALT setting editor, e.g. []SE.SALT.Setting ’editor...\WordPad’ To use another program for just this time use the modifier –use with the name of the program to use e.g. []SE.SALT.Explore’Othello –use=...\WordPad’
Oct Loading from file Objects can be brought back from file through the use of Load:
Oct Loading from file By default objects are brought in the current namespace. To select a different namespace use the –target modifier:
Oct Loading from file By default all the functions and variables in a namespace are kept in their namespace: WS fn1fn2 Target=# fn1fn2
Oct Loading from file To bring them separately you can use the –disperse modifier: WS fn1fn2 Target=# fn1fn2 Specific elements can be selected
Oct Loading from file You can bring several files at once using a pattern: WS Fn1 Fn2 Target=# fn1fn2 []SE.SALT.Load ‘Fn*’
Oct Settings Some functions assume global settings, e.g. Explore assumes Notepad to view files. Settings come from the registry and are brought into the session at start-up. They can be modified for the session or even for the time a function is used. Modifications can be saved back for the next APL session.
Oct Settings A particular setting has a name and a value, just like in the registry. The value can only be a string. It may be empty.
Oct Settings This function takes ‘’ or ‘a_name’ or ‘a_name followed by a value’. With ‘’ it returns all the settings and their values:
Oct Settings With a_name it returns the value associated with that particular setting name. Here the path to the editor to use:
Oct Settings With a name & value it associates the value with the name. Here we change the editor setting to use for the session to “WordPad”:
Oct Settings RegistryWs The settings can be permanently stored in the registry using the –permanent modifier:
Oct Settings The settings can be restored from the registry using the –reset modifier: RegistryWs
Oct Settings Settings can also be overridden temporarily for the duration of a statement, for example to use temporarily another editor while exploring:
Oct Features SALT has a number of features that make it more interesting than a simple store and retrieve utility. It can -save entire workspaces at once -store several versions of a script -compare them -remove versions -run scripts without fixing them in the ws -start automatically
Snapping workspaces Instead of using Save to store each function/namespace in the workspace you can use to do the work: []SE.SALT.Snap ‘\my\location’ Will store everything to \my\location, one script per function/namespace. Oct
Snapping workspaces can be used on a subset: All namespaces: []SE.SALT.Snap ‘\my\scripts –class=9’ All objects starting with the letter ‘U’: []SE.SALT.Snap ‘\my\utils –pattern=U’ All (remaining) functions: []SE.SALT.Snap ‘\my\fns –class=3 ’ Oct
Snapping workspaces Oct remembers what has been saved and won’t save again what hasn’t been modified. It also remembers where objects have been saved so “Snapping” again will put changed objects where they belong.
Oct Storing several versions of a script SALT can save back a script on file right after it has been modified. After modification you are prompted to confirm saving over the present script file: Modify
Oct Storing several versions of a script This also happens if you modify a fn of a class on the stack. After modification you are prompted to confirm saving over the present script file. Once saved both the script and the class are modified and you can resume execution. Error happens Stack shows up Edit the function
Oct Keeping several versions of a script You can store and KEEP several versions of a script. By using the –version modifier you tell SALT to start using version numbering:
Oct Keeping several versions of a script Every time you modify a script SALT stores the definition in a new file: V0V1
Oct Keeping several versions of a script List can show the various versions: But you need to supply the –version modifier: If started without version numbering, the original has no version number The latest (using date) version is always visible and on top
Oct Comparing versions Compare is used for that. You must give it the name of the script(s) and the versions to compare. If no version is specified the 2 highest versions are used. If a single number is specified it is compared with the highest version. Ex: []SE.SALT.Compare ‘fileA –version=5’ will compare version 5 of with its highest version (probably also most recent) =?
Oct Comparing versions Normally, Compare will use its own comparing code to perform the comparison. If a different program is wanted it should either be specified on the statement line with the –use modifier or in the settings. The Setting to use then is compare It should specify the path of the program to use or ‘APL’ if SALT is to do it itself. =?
Oct Comparing versions externally For example, to use Compare It!, a third party program available from the net, you can use the SALT command Settings to set it to [ProgramFiles]\Compare It! or the full pathname to its location =?
Oct Comparing versions externally You can also insert -use=pathnameToProgram to call said program in the statement, e.g: =?
Oct Comparing versions externally =? External program pops up automatically
Oct =? Showing differences between versions If ‘APL’ is the method chosen to compare, the output will appear in the session like this: lines inserted lines modified → is used to denote inserted lines ← is used to denote deleted lines
Oct =? Showing differences between versions If the class to be compared is already in the workspace you can use ws as value to the –version switch: []SE.SALT.Compare 'script\file –version=ws'
Oct Cleaning up (removing versions) After a while many versions may clutter a folder and some versions may get ridden of. SALT allows to selectively erase files. RemoveVersion is the function to use, like this:
Oct Cleaning up (removing versions) To remove less than a version (e.g.7) you can use -version=, etc) To remove them all instead use -all Note that -all leaves 1 version (the highest version) around which it renames to remove the version number. If 4 is the highest mine\test.4.dyalog becomes mine\test.dyalog
Oct Cleaning up (removing versions) The collapsing effect of -all can be achieved with higher versions by using -collapse: The last file of the group deleted has been given the next version number and renamed accordingly.
Oct Running scripts When scripts are Loaded into the ws they become objects ready to be used. For example, if script mine\testB contains class TB then this class can be used immediately as in
Oct Running scripts Sometimes a different name is needed. Load can be instructed to return a class instead of fixing it in the ws by using the -noname modifier:
Oct Running scripts Sometimes it is unnecessary to bring in the class and only an instance is needed. New uses internally Load’s -noname modifier to achieve that:
Oct Automatic start SALT also supports the loading and starting of applications from an “application file” with an extension of “.dyapp”.
Oct Automatic start You put in the dyapp file the instructions to perform the task: all the loads and 1 run statement. e.g.:
Oct Other goodies -SALT allows to have multiple working directories -can perform the required loads automatically -has external utilities -works with Spice
Oct Multiple workdirs You can have several working directories to split work into logical areas. For ex: you could put all utilities in a separate tree. To tell SALT to use different directories you list them in the SALT registry key SourceFolder separated by ;, e.g. [Dyalog]\Classes;\CMS\Dyw
Oct Multiple workdirs When using Load, SALT searches directories in the order specified until it finds the file You can also specify the directories via Settings (and make it permanent):
Oct Required Loads SALT allows required loads to be done automatically. For example, if script A needs script B to be present, A can specify in the code that B be Loaded before A is loaded
Oct Required Loads Example:
Oct Utilities These are not part of SALT but were created with SALT. They are located under Tools:
Oct Utilities: CallingTree This utility allows to view the calling tree of a fn in a namespace or to cross-reference all the functions and their references. To use do z← ⎕ new CallingTree ‘file\class -options’ z.Calls ‘ctor -view’ ⍝ show calls from or z.View ⍝ to view → z.Xref ⍝ produce a cross-reference
Oct Utilities: fileUtils This file contains a namespace with fns to e.g. traverse a directory tree using.Net Fn allows to show regular expressions in text (& Unicode) files, e.g. ‘\temp -type=php -rec’ showExpr ‘\bA.*= *123\b’ will show names starting with ‘A’ being assigned the number 123 in PHP files under \temp, recursively.
Oct Utilities: Regex This regexMatch class allows to create a Regex.Net instance given a pattern and possibly options. The options are m=multiline (default), s=singleline, i=case insensitive The pattern accepts ⍺ as APL name and ⍵ as a number, e.g. ⍺ ⍺ ← ⍵ ⍵ means 2 names assigned 2 numbers
Oct Utilities: compare This namespace contains functions to perform comparison. Function produces a report of the differences between 2 lists of strings, e.g. ([]NR ‘Fa’) compecv ([]NR ‘Fb’) will compare 2 functions and show where lines have been deleted, inserted and changed
Oct Utilities: NStoScript This namespace found in Lib contains functions to perform conversion of namespaces to []SRC format. Function takes the name of a namespace and changes it into sourced mode, e.g. NStoScript.Convert mynamespace will convert it. You can then edit it and store it using SALT
Oct
Oct
Oct Spice Utilities Spice is a utility working with SALT. It creates an input area at the bottom of the screen to issue commands using SALT. Spice can be initialized directly from SALT:
Oct Spice Utilities Spice can also be started automatically by setting SALT registry key AddSPICE to ‘1’
Oct Enabling SPICE in V12 The configuration menu:
Oct Enabling SALT You can also use the included SALT workspace to enable or disable SALT: )load SALT enableSPICE disableSPICE
Oct Spice Utilities To get a list of all available commands you enter ]? or ‘?’ in the input area:
Oct Spice Utilities: locate locate regex to locate strings in SALT, e.g.: ]locate abc>0 ]loc ‘\[‘, to find where the character ‘[‘ is catenated to the left (we must add ‘\’ to prevent ‘[‘ from being interpreted as a regex symbol)
Oct Spice Utilities: props ]props f returns the properties of object f and their values It also shows its ChildList and its EventList
Oct Spice Utilities: SALT commands All the SALT commands but New can be issued here, e.g.: ]save name file ]compare file1 -ver=4 ]list mine ]settings ]load myfile ]removeversions filex -v=<9
Oct Spice Utilities: fndiff This command compare 2 functions in the workspace. This is the Dfn implemented as a SPICE command: ]fndiff fnA fnB
Oct Spice Utilities: calls This command shows the calls made by a fn in a script, e.g.: ]calls file fn The output can be simple (fns only) or detailed showing if elements are local, global, glocal, labels, used, etc. It takes into account ⍎, []TRAP strings. The output can be viewed in a tree object.
Oct Spice Utilities: calls example Show the details of calls made by fn Run in file spice\Props. o is local ! is unused local G is global F is function
Oct Spice Utilities: calls example Same example viewed in a tree objects by adding -tree to the command
Oct Spice Utilities: summary This command allows to see the scope (Public, Shared, Ctor, Dtor), size and syntax of functions is a file.
Oct Spice Utilities: xref This command shows a cross-reference of all the objects made by all the fns in a script, e.g.: ]xref file The symbols are the same as in calls
Oct Final SALT & SPICE are tools. They can be used as a start point to maintain code and small applications. Classes provide new ways to make code sharing easier. SALT provides a way to do this.
Oct Short Final More information can be found in the SALT document. Dyalog 2009