1 / 27

Spice in Dyalog

Spice is a cover for SALT that allows users to issue commands using an input area. It can be initialized directly from SALT or started automatically when starting APL.

kyleallen
Download Presentation

Spice in Dyalog

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Spicein Dyalog V1.02

  2. 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:

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

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

  5. Initializing Spice in V12 The configuration menu:

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

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

  8. 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

  9. 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]\SALT\spice

  10. How does Spice work? Each script file contains a class with a number of presumably related commands. For example a script/class could contain • a command to search text • a command to replace text

  11. How does Spice work? A script file MUST contain at least 3 public sharedfunctions: • A <List> function • A <Run> function • A <Help> function It may contain other functions.

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

  13. How does Spice work? The <List> function Each namespace returned by <List> contains 4 variables; each one is a string: • Name: the name of the command • Group: the group the command belongs to • Desc: a short description • Parse: the parsing rules

  14. How does Spice work? The <List> function The 4 variables: • Name: a single word, e.g. locate • Group: a single word, e.g. files • Desc: a sentence, e.g. Find string in files • Parse: a string describing the command syntax, e.g. 2 –exclude=

  15. 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' ∇

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

  17. 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 ∇

  18. How does Spice work? The <Run> function The <Run> function is monadic. It takes 2 arguments: • a string naming the command to deal with, e.g. locate • either a string or a namespace which is the argument to the command

  19. 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'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 ∇

  20. Example See script Spice\aSample.dyalog It contains 2 examples of Spice commands: • no parsing rules • with specific parsing rules

  21. Example The syntax is described in the help:

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

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

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

  25. Special Spice command

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

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

More Related