Differences between revisions 11 and 31 (spanning 20 versions)
Revision 11 as of 2010-12-26 19:31:29
Size: 2726
Editor: KaiJaeger
Comment: Minor update
Revision 31 as of 2019-05-30 09:04:34
Size: 3598
Editor: KaiJaeger
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## page was renamed from UserCommand_Adoc
## page was renamed from UserCommandAdoc
= User Command ADOC (Dyalog) =
<<TableOfContents>>

= User Commands - where should they go? =
Line 5: Line 6:
[[ADOC]] is a utility useful to generate documentation (semi-) automatically from class scripts as well as namespace scripts.
Line 7: Line 7:
Obviously it makes sense to make ADOC's services available as a User Command. By default Dyalog is looking for User Commands in a sub folder `Salt\Spice` within the Dyalog installation folder. Therefore the easiest way to get your own User Commands recognized by Dyalog is to put put them into that directory.
Line 9: Line 9:
This page offers a small class script `ADOC` which is designed to do exactly that. Easy may it be but it also has a couple of serious disadvantages: messing up Dyalog user commands with your own user commands is not a good idea because ...
Line 11: Line 11:
== Assumptions ==
When User Commands got introduced in Dyalog with version 12.1, the User Commands where expected to reside in a sub folder `Salt\Spice` inside the Dyalog installation folder. This means that the script `ADOC.dyalog` attached to this page must go into this directory. Only then the User Commd "ADOC" is recognized.
 * Dyalog might introduce a new user command with a name already used by you.
 * When a new version of Dyalog arrives you are in trouble
 * You need admin rights to add, change or delete files in `Salt/Spice`
 
It's certainly a much better idea to keep Dyalog's user commands separate from your own ones.
Line 14: Line 17:
That script, which represents the ADOC User Command, assumes that there is a sibling folder of your APL installation folder available named `UserCommands`. Please make sure that the [[ADOC]] script is copied into this folder `UserCommands`. This enables the User Command script to address the '''real''' ADOC script `{MyDyalogInstallationFolder}..\UserCommands\ADOC`. == Solution ==
Line 16: Line 19:
For example, in case your version of APL is installed in `C:\Program Files (x86)\Dyalog\Dyalog APL 12.1 Unicode` which is the default on Windows 7 64 bit, then the folder `UserCommands` is supposed to be located at `C:\Program Files (x86)\Dyalog\UserCommands`. === For all versions of Dyalog and all user accounts ===
Line 18: Line 21:
== Samples ==
Given that the two different ADOC scripts went into the right folders, this would be a sample session:
To separate your own user commands from the Dyalog user commands is not too difficult.
Line 21: Line 23:
For this you need a folder that hosts all your user commands. Of course that folder can have any name you like but in this document we refer to this folder as `C:\MyUserCommands`.

 1. Create the folder `C:\MyUserCommands`.
 1. Add that folder to the SALT search path:
    1. Call "Configuration" from the "Options" menu.
    2. Activate the "User Commands" tab.
    3. Press the "Browse" button and browse to `C:\MyUserCommands`.
    4. Press the "Add" button.
    5. Press "OK"

Note that the forth step can be easily forgotten.

Now either restart Dyalog or execute the user command `]ureset`.

=== For all versions of Dyalog but a specific user account (Windows) ===

Since this page was created Dyalog has invented a general mechanism that allows you to save any user command in a certain place because all versions of Dyalog supported at the time of writing (May 2019: 15.0 and better) scan a folder `MyUCMDs` which is located under `%USERPROFILE%\Documents\MyUCMDs` in Windows and `~` (home directory) in Linux and Mac OS.

A script file with the name `setup.dyalog` in this folder will be executed as part of the start-up procedure of any version of Dyalog, but any other script will be considered a user command script.

== Complex User Commands ==

If the code which is the "real thing" is small it can and probably will go into the script which is defining the User Command as such. If it is a big thing (like ADOC) or a complete application (like [[Fire]]) than it will reside in a workspace.

That workspace can be saved along with the user command itself. Within your user command you should not use a real path to copy what it needed from that workspace. Instead you can find out what the path is by checking `##.SourceFile`: that gives you the fully qualified name of the user command.

This will give you the folder name that hosts the current user command:
Line 22: Line 51:
      ]?ADOC
"??" for general help, "?CMD" for more specific info on command CMD

 Group Name Description
 ===== ==== ===========
 ADOC ADOC.Browse Creates full documentation and displayes it in the default browser
        ADOC.List Prints syntax of all public stuff to the session

      ]?ADOC.Browse
Command "ADOC.Browse". Syntax: 1 arguments; accepts switches -b=
Script location: ........\SALT\Spice\ADOC

Gathers all sort of information from a class script,
compiles an HTML page with these pieces of information
and displays it in a browser. Use the -b flag to specify
a browser different from your default browser.

      ]?ADOC.List
Command "ADOC.List".
Script location: ........\SALT\Spice\ADOC

Prints a list with all sorts of information to the session
about all public stuff given in the script specified in the right argument

]ADOC.Help
Watch your browser

Shows extensive information about ADOC. It's basically doing `ADOC.Browse ADOC`.
{⎕IO←1 ⋄ ⍵↓⍨-⌊/'\/'⍳⍨⌽⍵} ##.SourceFile
Line 52: Line 54:
== Download == == Scripts ==
Line 54: Line 56:
[[attachment:ADOC.dyalog | Download]] the script. Sometimes a user command will not contain all the code itself but use one or more scripts to perform a certain task.
Line 56: Line 58:
== Version ==
The script is version 1.0.2 from 2010-12-26
Note that you cannot save such files with the extension `dyalog` within the folder that hosts user commands because Dyalog assumes that everything that is saved in such a file is a user command.
Line 59: Line 60:
Author: KaiJaeger The solution to the problem is to give the script(s) a different extension. For example `code` would be just fine. You can still load such a script with the SALT commands; you just have to specify the extension explicitly.


Author: -- KaiJaeger <<DateTime(2015-04-04T08:50:51Z)>>

Last update: 2019-05-30.
Line 62: Line 68:
CategoryDyalogUserCommands

User Commands - where should they go?

Overview

By default Dyalog is looking for User Commands in a sub folder Salt\Spice within the Dyalog installation folder. Therefore the easiest way to get your own User Commands recognized by Dyalog is to put put them into that directory.

Easy may it be but it also has a couple of serious disadvantages: messing up Dyalog user commands with your own user commands is not a good idea because ...

  • Dyalog might introduce a new user command with a name already used by you.
  • When a new version of Dyalog arrives you are in trouble
  • You need admin rights to add, change or delete files in Salt/Spice

It's certainly a much better idea to keep Dyalog's user commands separate from your own ones.

Solution

For all versions of Dyalog and all user accounts

To separate your own user commands from the Dyalog user commands is not too difficult.

For this you need a folder that hosts all your user commands. Of course that folder can have any name you like but in this document we refer to this folder as C:\MyUserCommands.

  1. Create the folder C:\MyUserCommands.

  2. Add that folder to the SALT search path:
    1. Call "Configuration" from the "Options" menu.
    2. Activate the "User Commands" tab.
    3. Press the "Browse" button and browse to C:\MyUserCommands.

    4. Press the "Add" button.
    5. Press "OK"

Note that the forth step can be easily forgotten.

Now either restart Dyalog or execute the user command ]ureset.

For all versions of Dyalog but a specific user account (Windows)

Since this page was created Dyalog has invented a general mechanism that allows you to save any user command in a certain place because all versions of Dyalog supported at the time of writing (May 2019: 15.0 and better) scan a folder MyUCMDs which is located under %USERPROFILE%\Documents\MyUCMDs in Windows and ~ (home directory) in Linux and Mac OS.

A script file with the name setup.dyalog in this folder will be executed as part of the start-up procedure of any version of Dyalog, but any other script will be considered a user command script.

Complex User Commands

If the code which is the "real thing" is small it can and probably will go into the script which is defining the User Command as such. If it is a big thing (like ADOC) or a complete application (like Fire) than it will reside in a workspace.

That workspace can be saved along with the user command itself. Within your user command you should not use a real path to copy what it needed from that workspace. Instead you can find out what the path is by checking ##.SourceFile: that gives you the fully qualified name of the user command.

This will give you the folder name that hosts the current user command:

{⎕IO←1 ⋄ ⍵↓⍨-⌊/'\/'⍳⍨⌽⍵} ##.SourceFile

Scripts

Sometimes a user command will not contain all the code itself but use one or more scripts to perform a certain task.

Note that you cannot save such files with the extension dyalog within the folder that hosts user commands because Dyalog assumes that everything that is saved in such a file is a user command.

The solution to the problem is to give the script(s) a different extension. For example code would be just fine. You can still load such a script with the SALT commands; you just have to specify the extension explicitly.

Author: -- KaiJaeger 2015-04-04 08:50:51

Last update: 2019-05-30.


UserCommands/WhereShouldTheyGo (last edited 2019-05-30 09:04:34 by KaiJaeger)