User Commands (UCMDs) in Dyalog APL A programmer's tool V1.04 Dan Baronet.

Slides:



Advertisements
Similar presentations
Module 3: Block 3 Call Management
Advertisements

2017/3/25 Test Case Upgrade from “Test Case-Training Material v1.4.ppt” of Testing basics Authors: NganVK Version: 1.4 Last Update: Dec-2005.
Advanced Piloting Cruise Plot.
1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 2 Getting Started.
Chapter 7 Constructors and Other Tools. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 7-2 Learning Objectives Constructors Definitions.
Chapter 6 Structures and Classes. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 6-2 Learning Objectives Structures Structure types Structures.
Chapter 1 The Study of Body Function Image PowerPoint
BASIC SKILLS AND TOOLS USING ACCESS
8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
6 Copyright © 2005, Oracle. All rights reserved. Building Applications with Oracle JDeveloper 10g.
Tutorial 10 – Managing Long Documents
Tutorial 9 – Creating On-Screen Forms Using Advanced Table Techniques
XP New Perspectives on Microsoft Office Word 2003 Tutorial 6 1 Microsoft Office Word 2003 Tutorial 6 – Creating Form Letters and Mailing Labels.
XP New Perspectives on Microsoft Office Word 2003 Tutorial 7 1 Microsoft Office Word 2003 Tutorial 7 – Collaborating With Others and Creating Web Pages.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Exit a Customer Chapter 8. Exit a Customer 8-2 Objectives Perform exit summary process consisting of the following steps: Review service records Close.
Child Health Reporting System (CHRS) How to Submit VHSS Data
Michigan Electronic Grants System Plus
Programming Language Concepts
Microsoft®.
Excel Functions. Part 1. Introduction 2 An Excel function is a formula or a procedure that is performed in the Visual Basic environment, outside the.
1 NatQuery 3/05 An End-User Perspective On Using NatQuery To Extract Data From ADABAS Presented by Treehouse Software, Inc.
Integrify 5.0 Tutorial : Creating a New Process
Course Objectives After completing this course, you should be able to:
1 2 In a computer system, a file is a collection of information with a single name, such as addresses.doc, or filebackup.ppt, or ftwr.exe, or guidebook.xls.
Meditech MOX (Magic Office)
Yavapai College Self Service Banner Training. Agenda Definition of Key Concepts Log Into Finance Self Service Budget Query Overview Budget Query Procedures.
Chapter 17 Linked Lists.
Modern Programming Languages, 2nd ed.
ABC Technology Project
MySQL Access Privilege System
Vanderbilt Business Objects Users Group 1 Reporting Techniques & Formatting Beginning & Advanced.
Chapter 10: Virtual Memory
“The Honeywell Web-based Corrective Action Solution”
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 24.1 Test-Driving the Ticket Information Application.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 12 – Security Panel Application Introducing.
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
VOORBLAD.
Benchmark Series Microsoft Excel 2013 Level 2
Renesas Technology America Inc. 1 SKP8CMINI-15,17 Tutorial 2 Creating A New Project Using HEW4.
1 Breadth First Search s s Undiscovered Discovered Finished Queue: s Top of queue 2 1 Shortest path from s.
1 Displaying Open Purchase Orders (F/Y 11). 2  At the end of this course, you should be able to: –Run a Location specific report of all Open Purchase.
4 Oracle Data Integrator First Project – Simple Transformations: One source, one target 3-1.
© 2012 National Heart Foundation of Australia. Slide 2.
INTRODUCTORY MICROSOFT WORD Lesson 7 – Working With Documents
25 seconds left…...
Januar MDMDFSSMDMDFSSS
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
PSSA Preparation.
Abstract Class, Packages and interface from Chapter 9
© Paradigm Publishing, Inc Access 2010 Level 2 Unit 2Advanced Reports, Access Tools, and Customizing Access Chapter 8Integrating Access Data.
1 Abstract Class and Packages from Chapter 9 Lecture.
CMPT 100 : INTRODUCTION TO COMPUTING TUTORIAL #5 : JAVASCRIPT 2 GUESSING GAME By Wendy Sharpe 1.
Know About E-CTLT Teachers Panel and working area.
South Dakota Library Network MetaLib User Interface South Dakota Library Network 1200 University, Unit 9672 Spearfish, SD © South Dakota.
User Friendly Item Relationship Maintenance A Family of Enhancements For iSeries 400 DMAS from  Copyright I/O International, 2006, 2007, 2008, 2010 Skip.
12-CRS-0106 REVISED 8 FEB 2013 PRESENTS Payment Functionality.
Benchmark Series Microsoft Excel 2013 Level 2
Spice Spice in Dyalog V1.03. Sep Spice Utilities Spice is a user command handler. Under V11 & V12 it uses an input area at the bottom of the screen.
New User commands in Dyalog APL Dan Baronet 2013 *
Utilities in Dyalog APL Dan Baronet Boston 2011 V1.00 0Dyalog’11 - BostonUtilities.
Spice Spice in Dyalog Document V1.06. Oct 2011 Spice Utilities Spice is a user command handler. Under V11 & V12 it uses an input area at the bottom of.
20081 Converting workspaces and using SALT & subversion to maintain them. V1.02.
Oct SALT in Dyalog Doc v1.18. Oct Introduction SALT is a Simple APL Library Toolkit It is a source code management system for objects with.
User Commands in Dyalog APL By Dan Baronet A programmer's tool - V1.03.
Spice Spice in Dyalog V1.02. Oct Spice Utilities Spice is a cover for SALT. It uses an input area at the bottom of the screen to issue user defined.
Presentation transcript:

User Commands (UCMDs) in Dyalog APL A programmer's tool V1.04 Dan Baronet

Agenda This tutorial is divided into 4 steps: -Why UCMDs -Dyalog's UCMDs -Implementation of the UCMD framework -Your UCMDs: how to write them

Why The idea is to provide a mechanism for accessing tools anywhere by -separating utilities from the workspace -make them available at any time

History The concept of user commands (UCMDs) is not new. APL/PC had them in the 90s. Their implementation was different but the idea was the same

User Commands A user command (UCMD) is similar to a system command like )LOAD or )WSID. It is a call to an independent routine written by a user, not a routine provided by the system. It can be used anytime.

User Commands System commands start with a ), e.g. ) SAVE User commands start with a ], e.g. ] WSLOC

User Commands - syntax Like their system commands counterpart, user commands may take arguments, e.g. )WSID [newname] And ]FNSLIKE [pattern] Just like system commands they are not case sensitive.

User Commands - syntax Unlike system commands, in the actual implementation, they can also take modifiers, e.g. ]FNSLIKE [Pattern] –format Modifiers are preceded by a specific character (here –) Modifiers ARE case sensitive.

User Commands - syntax This is Dyalog's implementation. UCMDs could take any format. WE decide what is acceptable.

User Commands - syntax UCMDs are based on SALT.

SALT SALT is basically a pair of programs to write and read Unicode text files UCMDs make use of these 2 functions to write out and read back their code SALT has many other features that are irrelevant with UCMDs (but nonetheless useful) WPF and APLDyalog’11 - Boston11

SALT When an object is saved using SALT it is tagged That tag is used afterwards when resaving the object, e.g. after editing it That tag remains with the object unless removed, even when the workspace is saved WPF and APLDyalog’11 - Boston12

User Commands Dyalog comes pre-packaged with a set of user commands divided into groups. Groups exist for SALT, workspace utilities, code utilities, user commands management, etc.

User Commands For example the command ]SAVE, which saves an OBJECT (not a workspace), takes up to 2 arguments, saving the object named in the 1 st argument to, if present, the location named in the 2 nd argument. Ex: ]save myfn \my\location\myfn To bring the object back use the command ]LOAD: ]load my\location\myfn

User Commands - Help General help can be obtained with ]?? Or ]help The list of all commands can be obtained with ]? And ]?+ Specific help for a command can be obtained with ]?cmdx Or more detailed help, if any, with ]??cmdx Or ]?\path\to\file\containing\a\user\cmd

User Commands available Dyalog comes pre-packaged with some already defined UCMDs They are divided into groups: -SALTSamples -Spice (UCMD)svn -SysmonSystem -ToolsTransfer -wsutils

Group SALT These are the same as their SALT functions: -Saveobject[tolocation] -Loadlocation -Comparefile1[file2] -Settings[type[value]] -List[folder] -Snaptolocation -Removeversionsfile

Group Spice These are commands used to manage the User commands system: -Uloadcommand -Udebug [ON|OFF] -Uclean -Unew [name] -Ureset -Uupdate [SALT] -Uversion [wsname] -Umonitor

Group svn This group contains commands to mimic SubVersion's commands: -svnci: commit changes -Svnco: check out -Svnadd/delete: add/delete new files -Svnstatus/resolve -Svndiff: show changes to a file -Svnimport/export -Svnupdate: bring in most recent changes

Group SysMon This group is used to monitor the system: -APLMON: used to monitor expressions by primitive, ex: ]aplmon {+/1= ⍵∨⍳⍵ }¨ ⍳ 1000 –file=\tmp\data -CPUtime: used to find CPU used for expressions, ex: ]cputime {+/1= ⍵∨⍳⍵ }¨ ⍳ Monitor:used to find lines consuming the most CPU -Profile:used to profile an application

Group Transfer This group is used to move code in and out of ATF files with -in/out And move code in and out of "extended" files with code translation with -inx/outx

Groups Tools & WSutils These 2 groups contain various utilities e.g. to show a subset of names following a specific pattern or do function call analysis or search the workspace for strings of code/text: ]fnslike GUI* -date=> ]fncalls MainProgram -details -treeview ]wsloc abc -exclude=ct -recursive

UCMDs - implementation The code to run a UCMD is contained in a class or namespace in a SALT (text, Unicode)file. That file may be host to several UCMDs Command names are case insensitive, e.g. ‘find’ and ‘FIND’ call the same code Switches names are case sensitive UCMDs are grouped together, e.g. utilities can be grouped under the group ‘wsutils’ The class or namespace must contain at least 3 public functions: ‘List’, ‘Run’ and ‘Help’

UCMDs - implementation The ‘List’ function is used to gather basic info displayed when using ]?+ The ‘Help’ function is used to display more complete info when using ]?cmdx or ]??cmdx The ‘Run’ function is the one doing the work.

UCMDs - implementation The whole framework is based on 2 things: -SALT: used to read/write Unicode text files -Spice: used to implement the rules of UCMDs

UCMDs – an example Let’s assume we have a simple function we wish to call once in a while without having to copy/call/erase it each time: calendar 3 March S M T W T F S

UCMDs – an example Let’s create a user command named CAL that we will call with a single argument like this: ]cal 3

UCMDs – an example We need to create a class with the 3 basic functions, the function: :Namespace dates ⎕ IO←1 ⋄ ⎕ ML←1 ∇ r←List r← ⎕ NS ⍬ ⍝ Name, group, short description and parsing rules r.Name← ' cal ' r.Group←'dates' r.Desc← 'returns the calendar for a given month' r.Parse←'' ∇

UCMDs – an example The HELP function: ∇ r←Help dummy r←'Enter a month as argument' ∇

UCMDs – an example The RUN function: ∇ r←Run(a1 a2) 'calendar' ⎕ CY 'myutils' r←calendar ⍎ a2 ∇ :endnamespace

UCMDs – an example Because each class may contain more than one UCMD the HELP and RUN functions should really account for that.

UCMDs – an example HELP function for more than one command: ∇ r←Help Cmd :Select Cmd :Case 'cal' r← 'Enter a month as argument' :Case 'other' … :EndSelect ∇

UCMDs – an example The RUN function for more than one command: ∇ r←Run(Cmd Args) :Select Cmd :Case 'cal' 'calendar' ⎕ CY 'myutils' r←calendar ⍎ Args :Case 'other' … :EndSelect ∇

UCMDs – Parsing If automatic parsing of the arguments is desired the system will look at the line given as argument, split the tokens on spaces and put the resulting vector of text vectors in variable 'Arguments’ in a namespace. That namespace will be given as the 2 nd argument to the function. To request parsing simply put in 'Parse' (in function ) the rules to follow, e.g. '3' to ensure 3 arguments. If no parsing is desired simply leave 'Parse' empty.

UCMDs – Parsing If we wish the system to check the number of arguments (here 1) for us we say it in : ∇ r←List :Access Shared Public r← ⎕ NS¨1 ⍴⊂⍬ ⍝ Name, group, short description and parsing rules r.Name← ⊂ 'cal' r.Group← ⊂ 'dates' r.Desc← ⊂ 'returns the calendar for a given month' r.Parse← '1' ∇ In that case the 2nd argument of will contain a namespace but only AFTER the framework has ensured only ONE argument has been supplied.

UCMDs – Parsing ∇ r←Run(Cmd a2) :Select Cmd :Case 'cal' 'calendar' ⎕ CY 'myutils' r←calendar ⍎ 1 ⊃ a2.Arguments :EndSelect ∇ Function can also/should be defined in the class instead of being copied in.

UCMDs – an example. ]cal 3 March S M T W T F S

UCMDs – an example If Parsing is enabled, entering the wrong number of arguments will be refused: ]cal Command Execution Failed: too few arguments ]cal 2 3 Command Execution Failed: too many arguments

UCMDs location The location of user commands is preset to Dyalog's folder SALT\spice under APL's location, e.g. C:\program files\Dyalog\V121\SALT\spice

UCMDs location The location of UCMDs is one of SALT's settings. To know what they are: []SE.SALT.Settings 'cmddir' Or, as a UCMD: ]settings cmddir

UCMDs location You can reset it too. It follows the same rule as SALT's workdir setting, i.e. it is a series of paths separated by semicolons, e.g. \my\own\path ; C:\program files\Dyalog\V121\SALT\Spice For example, to add "\my\own\path" to the existing path: (note the comma) ]settings cmddir, \my\own\path

UCMDs location You can set them manually or in Options/Configure…

UCMDs location

Some commands are always there: Spice's and SALT's Doing (note NO comma) ]settings cmddir \my\own\path Will keep Spice and SALT's commands even though they have not been specified.

UCMDs – Advanced Topics Debugging code ]udebug ON|OFF When debugging is OFF errors are reported in the calling environment: Command Execution Failed: DOMAIN ERROR When debugging is ON errors are reported in the class: DOMAIN ERROR calendar[4] r←n÷month ∧

UCMDs – Advanced Topics Switches Those can be specified in the Parse variable: They come in different forms: -Without a value: /sw -With a value: /sw= -Possibly with a value: /sw[=] The specification for each includes the (same) switch delimiter (here /)

UCMDs – Advanced Topics Switches A set of possible values may be specified, e.g. /animal=cat monkey giraffe A set of possible characters can also be specified: /vowel ∊ aeiou Or /vowel [ ∊ ] aeiou If the switch can be specified without a value

UCMDs – Advanced Topics Switches – Examples 1. Switch time takes a value, switch PM does not, switch delimiter is /: Parse ← '/time= /PM' 2. Switch Prime may accept values 2, 3, 5 and 7, switch Octal accepts values made out of ' ', delimiter is +: Parse ←'+Prime[=] Octal ∊ '

UCMDs – Advanced Topics Switches – Examples Switches and number of arguments are specified together. A command accepting 2 arguments and a switch -offset with a value would be specified as: Parse ←'2 -offset='

UCMDs – Advanced Topics Arguments Arguments are delimited by spaces. If an argument must contain spaces, or the switch delimiter character or a quote, it should be surrounded by quotes. For example, if the switch delimiter is /, the following call will contain 4 arguments: ]mycmd 'arg 1' '2001/4/5' OK "I'm" /lights=on

UCMDs – Advanced Topics Long Arguments If a command accepts N arguments and the last argument may contain spaces then it may be unnecessary to quote the last argument simply by stating the command as "long". For ex, if command addrec accepts 3 arguments it could accept ]addrec Joe Blow 42 main str With Parse ←'3L' The arguments will be 'Joe' 'Blow' '42 main str'

UCMDs – Advanced Topics Short Arguments If a command accepts a maximum of N arguments it can be specified as "short". For ex, With Parse ←'3S' Any number of argument less than or equal to 3 will be accepted.

UCMDs – Exercices 1.Write a UCMD to display the time, formatted 2.Write a UCMD to display the time in another city

]END