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