Spice in Dyalog V 1 02 Spice Utilities

  • Slides: 27
Download presentation
Spice in Dyalog V 1. 02

Spice in Dyalog V 1. 02

Spice Utilities Spice is a cover for SALT. It uses an input area at

Spice Utilities Spice is a cover for SALT. It uses an input area at the bottom of the screen to issue user defined commands using SALT. Spice can be initialized directly from SALT: Oct 2008 2

Initializing Spice can be started automatically when starting APL by setting the SALT registry

Initializing Spice can be started automatically when starting APL by setting the SALT registry key Add. SPICE to ‘ 1’ Oct 2008 3

Initializing Spice can also be started automatically by using the <enable. Spice> function in

Initializing Spice can also be started automatically by using the <enable. Spice> function in the SALT workspace: )LOAD SALT enable. Spice Oct 2008 4

Initializing Spice in V 12 The configuration menu: Oct 2008 5

Initializing Spice in V 12 The configuration menu: Oct 2008 5

Spice Help ? To get a list of all available commands you enter ‘?

Spice Help ? To get a list of all available commands you enter ‘? ’ in the input area: Oct 2008 6

Example of a custom Spice command: locate Use “locate string” to locate a regular

Example of a custom Spice command: locate Use “locate string” to locate a regular expression string in SALT folders , e. g. : locate babcb>0 Will find in SALT files where syntactic abc is greater than 0 Oct 2008 7

Using SALT commands in Spice All the SALT commands but New can be issued

Using SALT commands in Spice All the SALT commands but New can be issued here, e. g. : save myclass file 1 compare file 1 -ver=4 list mine settings load myfile removeversions filex -v=<9 Oct 2008 8

How does Spice work? - Spice commands are kept in script files, like SALT.

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 in folder [Dyalog]SALTspice Oct 2008 9

How does Spice work? Each script file contains a class with a number of

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 Oct 2008 10

How does Spice work? A script file MUST contain at least 3 public shared

How does Spice work? A script file MUST contain at least 3 public shared functions: 1. A <List> function 2. A <Run> function 3. A <Help> function It may contain other functions. Oct 2008 11

How does Spice work? The <List> function is niladic. It returns a list of

How does Spice work? The <List> 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. Oct 2008 12

How does Spice work? The <List> function Each namespace returned by <List> contains 4

How does Spice work? The <List> function Each namespace returned by <List> 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 Oct 2008 13

How does Spice work? The <List> function The 4 variables: 1. Name: a single

How does Spice work? The <List> 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= Oct 2008 14

How does Spice work? The <List> function (example with 2 cmds) ∇ r←List :

How does Spice work? The <List> 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' ∇ Oct 2008 15

How does Spice work? The <Help> function is monadic. It takes a string naming

How does Spice work? The <Help> 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. Oct 2008 16

How does Spice work? The <Help> function (example with 2 cmds) ∇ r←Help Cmd

How does Spice work? The <Help> 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 ∇ Oct 2008 17

How does Spice work? The <Run> function is monadic. It takes 2 arguments: 1.

How does Spice work? The <Run> 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 Oct 2008 18

How does Spice work? The <Run> function (example with 2 cmds) ∇ r←Run(Cmd ca);

How does Spice work? The <Run> function (example with 2 cmds) ∇ r←Run(Cmd ca); ct; w : Access Shared Public r← 0 0� '' ⋄ ct←� SE. SALT. Load'Utilsfile. Utils -noname' w←##. text. Utils. split. On�� SE. SALT. Settings'workdir' : Select Cmd : Case 1⊃Fns ⋄ w ct. show. Expr¨⊂ca. Argument : Case 2⊃Fns ⋄ w ct. repl. Expr¨⊂ca. Argument : End. Select ∇ Oct 2008 19

Example See script Spicea. Sample. dyalog It contains 2 examples of Spice commands: 1.

Example See script Spicea. Sample. dyalog It contains 2 examples of Spice commands: 1. no parsing rules 2. with specific parsing rules Oct 2008 20

Example The syntax is described in the help: Oct 2008 21

Example The syntax is described in the help: Oct 2008 21

Example If the syntax is wrong Spice will complain: No arguments! Oct 2008 22

Example If the syntax is wrong Spice will complain: No arguments! Oct 2008 22

Example If the syntax is right Spice will do it: Oct 2008 23

Example If the syntax is right Spice will do it: Oct 2008 23

Special Spice command When Spice starts a special command is run That command is

Special Spice command When Spice starts a special command is run That command is 'Setup' It is found in spiceSetup. dyalog It can be modified to suit your needs Oct 2008 24

Special Spice command Oct 2008 25

Special Spice command Oct 2008 25

Final SPICE is a development tool. It can be used to store frequently used

Final SPICE is a development tool. It can be used to store frequently used (and even less frequently used) user commands. Oct 2008 26

Short Final More information can be found in the Spice document. Dyalog 2008 Oct

Short Final More information can be found in the Spice document. Dyalog 2008 Oct 2008 27