Download presentation
Presentation is loading. Please wait.
Published byOscar Morgan Modified over 9 years ago
1
Spice Spice in Dyalog V1.03
2
Sep 2009 2 Spice Utilities Spice is a user command handler. Under V11 & V12 it uses an input area at the bottom of the screen to issue user defined commands using SALT. It can be initialized directly from SALT:
3
Sep 2009 3 Initializing Spice Spice can be started automatically when starting APL by setting the SALT registry key AddSPICE to ‘1’
4
Sep 2009 4 Initializing Spice The Spice input area can also be started automatically by using the function in the SALT workspace: )LOAD SALT enableSpice
5
Sep 2009 5 Initializing the Spice area in V12 The configuration menu:
6
Sep 2009 6 Initializing Spice in V12.1 There is no need to initialize the Spice input area in 12.1. The Spice user command handler is always available directly through the ] with 12.1. Simply use ] where you would use the input area, e.g. ]mycmd
7
Sep 2009 7 Spice Help To get a list of all available commands you enter ]? or ‘?’ in the input area: ?
8
Sep 2009 8 Example of a custom Spice command: locate Use “locate string” to locate a regular expression string in SALT folders, e.g.: ]locate \babc>0$ Will find in SALT files where syntactic abc is greater than 0 at the end of a line.
9
Sep 2009 9 Using SALT commands in Spice All the SALT commands but New can be issued here, e.g.: ]save myclass file1 ]compare file1 -ver=4 ]list mine ]settings ]load myfile ]removeversions filex -v=<9
10
Sep 2009 10 How does Spice work? -Spice commands are kept in script files, like SALT. -Spice files have a.dyalog extension. -All Spice script files are kept by default in folder [Dyalog]\SALT\spice
11
Sep 2009 11 How does Spice work? Each script file contains a class with a number of (presumably) related commands. For example a script/class could contain 1.a command to search text 2.a command to replace text
12
Sep 2009 12 How does Spice work? A script file MUST contain at least 3 public shared functions for the Spice handler: 1.A function 2.A function 3.A function It may contain other functions.
13
Sep 2009 13 How does Spice work? The function The function is niladic. It returns a list of as many namespaces as there are commands in the script file. E.g.: if there are 2 commands in the script file it returns 2 namespaces.
14
Sep 2009 14 How does Spice work? The function Each namespace returned by contains 4 variables; each one is a string: 1.Name: the name of the command 2.Group: the group the command belongs to 3.Desc: a short description 4.Parse: the parsing rules
15
Sep 2009 15 How does Spice work? The function The 4 variables: 1.Name: a single word, e.g. locate 2.Group: a single word, e.g. files 3.Desc: a sentence, e.g. Find string in files 4.Parse: a string describing the command syntax, e.g. 2 –exclude=
16
Sep 2009 16 How does Spice work? The function (example with 2 cmds) ∇ r←List :Access Shared Public r← ⎕ NS¨2 ⍴⊂ '' r.Name←'Locate' 'Replace' r.Group← ⊂ 'Files' r.Parse←'1' '2' r[1].Desc←'Find a string in files' r[2].Desc←'Replace a string by another' ∇
17
Sep 2009 17 How does Spice work? The function The function is monadic. It takes a string naming the command to return detailed help for, e.g. locate It returns a string describing help for that command.
18
Sep 2009 18 How does Spice work? The function (example with 2 cmds) ∇ r←Help Cmd :Access Shared Public r←'' r,← ⊂ 'Arg: string; shows where the string is found' r,← ⊂ 'Arg: 2 strings; replace the first one by the other' r←r ⊃⍨ 'Locate' 'Replace' ⍳⊂ Cmd ∇
19
Sep 2009 19 How does Spice work? The function The function is monadic. It takes 2 arguments: 1.a string naming the command to deal with, e.g. locate 2.either a string or a namespace which is the argument to the command
20
Sep 2009 20 How does Spice work? The function (example with 2 cmds) ∇ r←Run(Cmd ca);ct;w :Access Shared Public r←0 0 ⍴ '' ⋄ ct← ⎕ SE.SALT.Load'Utils\fileUtils -noname' w←##.textUtils.splitOn ⍨⎕ SE.SALT.Settings'workdir' :Select Cmd :Case 1 ⊃ Fns ⋄ w ct.showExpr¨ ⊂ ca.Argument :Case 2 ⊃ Fns ⋄ w ct.replExpr¨ ⊂ ca.Argument :EndSelect ∇
21
Sep 2009 21 Example See script Spice\aSample.dyalog It contains 2 examples of Spice commands: 1.no parsing rules 2.with specific parsing rules
22
Sep 2009 22 Example The syntax is described in the help:
23
Sep 2009 23 Example If the syntax is wrong Spice will complain: No arguments!
24
Sep 2009 24 Example If the syntax is right Spice will do it:
25
Sep 2009 25 Spice command location When APL is installed Spice commands location is [Dyalog]\SALT\spice but you can change it. The SALT settings contain Spice’s commands location in cmddir: ]setting cmddir \my\own\user\cmds Will change the Spice/user commands folder to \my\own\user\cmds
26
Sep 2009 26 Special Spice command
27
Sep 2009 27 Final SPICE is a development tool. It can be used to store frequently used (and even less frequently used) user commands.
28
Sep 2009 28 Short Final More information can be found in the Spice document. Dyalog 2008
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.