Differences between revisions 6 and 7
Revision 6 as of 2012-07-15 13:35:50
Size: 1050
Editor: KaiJaeger
Comment:
Revision 7 as of 2012-07-15 14:18:01
Size: 3560
Editor: KaiJaeger
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
#If you want to "own" this page you MUST ask one of the admins to do this for you = User Command ListObjects =
Line 3: Line 3:
= User Command {whatever} = <<TableOfContenst>>
Line 7: Line 7:
{whatever} is a utility useful to .... `ListObjects` is a utility useful to list all sorts of objects in a given namespace. Tired of looking up all the different 2.1, 3.2 and 9.4 in the help? Want to know what's an instance of an ordinary class and what's an instance of a form? Then you will love `ListObjects`!
Line 9: Line 9:
Obviously it makes sense to make {whatever} available as a User Command.

This page offers a small class script `{whatever}` which is designed to do exactly that.

== 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 `{whatever}` attached to this page must go into this directory. Only then the User Commd "{whatever}" is recognized.

That script, which represents the ADOC User Command, assumes that it can find the "real" script at ....

== Samples ==
Let's assume that you are in a clear workspace. Let's create a couple of objects in this workspace:
Line 22: Line 12:
{whatever} in action ....       ⎕FX 'r←Hello' 'r←''World'''
      sum←{+/⍵}
      ⎕FX 'r←(fns MyOp) array' 'r←fns array'
      myNamespace←⎕ns ''
      myNamespace.⎕FX 'r←Hello' 'r←''World'''
      'myNamespace2' ⎕ns ''
      ⎕FIX ':Class MyClass' '∇ Make' ':Access Public Instance' ':Implements Constructor' '∇' ':EndClass'
      myInstance1←⎕new ⊂MyClass
      'myInstance2' ⎕WC 'Form' ('KeepOnClose' 1)
Line 25: Line 23:
== Examples ==

Calling `ListObjects` without an argument and switch:

{{{
]ListObjects
 ⎕NC Name Type
 === ==== ====
 3.1 Hello Traditional function
 9.4 MyClass Class
 4.1 MyOp Traditional Operator
 9.2 myInstance1 Instance
 9.2 myInstance2 Form (Instance)
 9.1 myNamespace Namespace
 9.1 myNamespace2 Namespace
 3.2 sum Direct function
 3.1 test Traditional function
}}}

== Argument ==
`
By default `ListObjects` looks "into" the namespace it was called from; in our example this is `#`. If you want to list the contents of a different namespace or instance you can specify the name of that object as an argument:

{{{
]ListObjects #.myNamespace_defau
 ⎕NC Name Type
 === ==== ====
 3.1 Hello Traditional function
}}}

In our case this is empty, of course.

Note that if you don't qualify the name fully then `ListObjects` adds the name of the object it was called from. So this (note the missing "'''#.'''"):

{{{
]ListObjects #.myNamespace
 ⎕NC Name Type
 === ==== ====
 3.1 Hello Traditional function
}}}
works as well.

== Switches ==

There are two optional switches available:

=== Name class switch ===

By default all objects are listed. You can specify the nameclass(es) you are interested in by specifying the `-nc` switch:

{{{
]ListObjects -nc=9.1
 ⎕NC Name Type
 === ==== ====
 9.1 myNamespace Namespace
 9.1 myNamespace2 Namespace

]ListObjects -nc=3 4
 ⎕NC Name Type
 === ==== ====
 3.1 Hello Traditional function
 4.1 MyOp Traditional Operator
 3.2 sum Direct function
 3.1 test Traditional function

}}}

=== "Start with" switch ===

With the `=s` switch you can specify one or more characters

{{{
]listob -s=Mm
 ⎕NC Name Type
 === ==== ====
 9.4 MyClass Class
 4.1 MyOp Traditional Operator
 9.2 myInstance1 Instance
 9.2 myInstance2 Form (Instance)
 9.1 myNamespace Namespace
 9.1 myNamespace2 Namespace
}}}

Note that this switch works in the same way as the (optional) left argument to `⎕NL`.
Line 27: Line 109:
The script is version 1.0 from 2009-mm-dd

Author: {you}
The script is version 1.0 from 2012-07-15
Author: KaiJaeger
Line 32: Line 113:
''Remove the "C" in front of one of the following lines and delete the other one:''

CCategoryDyalogUserCommands
CategoryDyalogUserCommands

User Command ListObjects

<<TableOfContenst>>

Overview

ListObjects is a utility useful to list all sorts of objects in a given namespace. Tired of looking up all the different 2.1, 3.2 and 9.4 in the help? Want to know what's an instance of an ordinary class and what's an instance of a form? Then you will love ListObjects!

Let's assume that you are in a clear workspace. Let's create a couple of objects in this workspace:

      ⎕FX 'r←Hello'  'r←''World'''
      sum←{+/⍵}
      ⎕FX 'r←(fns MyOp) array' 'r←fns array'
      myNamespace←⎕ns ''
      myNamespace.⎕FX 'r←Hello'  'r←''World'''
      'myNamespace2' ⎕ns ''
      ⎕FIX ':Class MyClass' '∇ Make' ':Access Public Instance' ':Implements Constructor' '∇' ':EndClass'
      myInstance1←⎕new ⊂MyClass
      'myInstance2' ⎕WC 'Form' ('KeepOnClose' 1)

Examples

Calling ListObjects without an argument and switch:

]ListObjects
 ⎕NC  Name          Type                 
 ===  ====          ====                 
 3.1  Hello         Traditional function 
 9.4  MyClass       Class                
 4.1  MyOp          Traditional Operator 
 9.2  myInstance1   Instance             
 9.2  myInstance2   Form (Instance)      
 9.1  myNamespace   Namespace            
 9.1  myNamespace2  Namespace            
 3.2  sum           Direct function      
 3.1  test          Traditional function 

Argument

` By default ListObjects looks "into" the namespace it was called from; in our example this is #. If you want to list the contents of a different namespace or instance you can specify the name of that object as an argument:

]ListObjects #.myNamespace_defau
 ⎕NC  Name   Type                 
 ===  ====   ====                 
 3.1  Hello  Traditional function 

In our case this is empty, of course.

Note that if you don't qualify the name fully then ListObjects adds the name of the object it was called from. So this (note the missing "#."):

]ListObjects #.myNamespace
 ⎕NC  Name   Type                 
 ===  ====   ====                 
 3.1  Hello  Traditional function 

works as well.

Switches

There are two optional switches available:

Name class switch

By default all objects are listed. You can specify the nameclass(es) you are interested in by specifying the -nc switch:

]ListObjects -nc=9.1
 ⎕NC  Name          Type                 
 ===  ====          ====                 
 9.1  myNamespace   Namespace 
 9.1  myNamespace2  Namespace 

]ListObjects -nc=3 4
 ⎕NC  Name   Type                 
 ===  ====   ====                 
 3.1  Hello  Traditional function 
 4.1  MyOp   Traditional Operator 
 3.2  sum    Direct function      
 3.1  test   Traditional function 

"Start with" switch

With the =s switch you can specify one or more characters

]listob -s=Mm
 ⎕NC  Name          Type                 
 ===  ====          ====                 
 9.4  MyClass       Class                
 4.1  MyOp          Traditional Operator 
 9.2  myInstance1   Instance             
 9.2  myInstance2   Form (Instance)      
 9.1  myNamespace   Namespace            
 9.1  myNamespace2  Namespace            

Note that this switch works in the same way as the (optional) left argument to ⎕NL.

Version

The script is version 1.0 from 2012-07-15 Author: KaiJaeger


CategoryDyalogUserCommands

UserCommandTemplate (last edited 2012-07-16 14:01:26 by KaiJaeger)