User Command ListObjects

Overview

ListObjects is a utility useful to list all sorts of objects in a given namespace. Tired of looking up all the different 9.1, 9.2, 9.3, 9.4, 9.5, 9.6 and 9.8 in the help? Flabbergasted by a name class ¯8.6 or similar exotic values not mentioned in the documentation at all as of yet (2012)? Want to know what's an instance of an ordinary class and what's an instance of a form? Want to tell references from the "real thing"? 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'''
Hello2←{'Universe'}
⎕FX'r←(f Top)v' 'r←f v'
Dop←{⍺⍺ ⍵}
MyNS1←⎕NS''
MyNS1.⎕FX'r←Hello3' 'r←''World3'''
'MyNS2'⎕NS''
MyNS2.⎕FX'r←Hello4' 'r←''World4'''
⎕FIX':Class MyCl' '∇Make' ':Access Public Instance' ':Implements Constructor' '∇' ':EndClass'
ClInst←⎕NEW MyCl
'MyForm'⎕WC'Form'('KeepOnClose' 1)('Coord' 'Pixel')('Posn'(40 40))('Size'(200 300))
'MyForm.Label1'⎕WC'Label'('KeepOnClose' 1)('Posn'(15 15))
'MyForm.Label2'⎕WC'Label'('KeepOnClose' 0)('Posn'(55 15))
MyForm.Label1.onGotFocus←'{1}'
vars1←1 2 3
'WEBBROWSER'⎕WC'OCXClass' 'Microsoft Web Browser'
'MyForm.webbr'⎕WC'WEBBROWSER'('Coord' 'Prop')('Posn'(0 0))('Size'(100 100))
MyForm.webbr.onBeforeNavigate2←'OnNavigate'
RefToClassMyCl←MyCl

Example

Calling ListObjects without an argument and switch:

      ]ListObjects
⎕NC  Name            Type                 
 ===  ====            ====                 
 9.2  ClInst          Class Instance       
 4.2  Dop             Direct Operator      
 3.1  Hello           Traditional Function 
 3.2  Hello2          Direct Function      
 9.4  MyCl            Class                
 9.2  MyForm          Form (Instance)      
 9.1  MyNS1           Ref to Namespace     
 9.1  MyNS2           Namespace            
 9.4  RefToClassMyCl  Ref to Class         
 4.1  Top             Traditional Operator 
 9.2  WEBBROWSER      OCXClass (Instance)  
 2.1  vars1           Vars                 

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 #.MyNS1
Hello3

Note that if you don't qualify the name fully then ListObjects adds the name of the object it was called from. So this works as well:

      ]ListObjects MyNS1
Hello3

Note the missing #.

One can also list all objects in a GUI instance:

      ]ListObjects #.MyForm
 ⎕NC  Name    Type             
 ===  ====    ====             
 9.2  Label1  Label (Instance) 
 9.2  Label2  Label (Instance) 
 9.2  webbr   Class Instance   

Switches

There are two optional switches available:

Name class switch

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

      ]ListObjects -nc=3
 ⎕NC  Name    Type                 
 ===  ====    ====                 
 3.1  Hello   Traditional Function 
 3.2  Hello2  Direct Function      
 3.1  Test    Traditional Function 

      ]ListObjects -nc=3 4
Dop
Hello
Hello2
Test
Top

"Start with" switch

With the =s switch you can specify one or more characters. Note that the filter is case sensitive.

      ]ListObjects -s=H
Hello
Hello2

      ]ListObjects -s=HM
Hello
Hello2
MyCl
MyForm
MyNS1
MyNS2

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

Help

Help is available of course:

]?ListObjects
Command "ListObjects". Syntax: 1S arguments; accepts switches -nc= -s=

Returns information about all names found in the namespace the command
was called from OR in the namespace specified with the (optional) "s" switch.
With another optinal switch one can specify the name class one is interested in.
Examples:
]ListObjects
]ListObjects #.CertainNamespace
]ListObjects -nc=3.1
]ListObjects -s=St
]ListObjects #.CertainNamespace -nc=3.1 -s=St

Download

Download the script.

Version

The script is version 1.0.5 from 2014-09-09 Author: KaiJaeger


CategoryDyalogUserCommands

UserCommands/ListObjects (last edited 2017-04-27 11:20:53 by KaiJaeger)