Differences between revisions 1 and 12 (spanning 11 versions)
Revision 1 as of 2012-07-16 13:56:59
Size: 4783
Editor: KaiJaeger
Comment:
Revision 12 as of 2019-05-30 07:55:01
Size: 4544
Editor: KaiJaeger
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
<<TableOfContenst>> <<TableOfContents>>
Line 7: Line 7:
`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`! `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`.
Line 30: Line 30:
RefToClassMyCl←MyCl
Line 32: Line 33:
== Examples == == Example ==
Line 38: Line 39:
 ⎕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    Namespace       
 9.1 MyNS2    Namespace
 3.1 Test Traditional Function
 4.1 T
op    Traditional Operator
 9.2 WEBBROWSER    OCXClass (Instance)
¯8.6 onBeforeNavigate2 External (inherited)
 2.
1 vars1 Vars
⎕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
Line 57: Line 57:
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: 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:
Line 61: Line 61:
 ⎕NC Name Type
 === ==== ====
 3.1 Hello3 Traditional Function
Hello3
Line 66: Line 64:
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 "'''#.'''"): 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:
Line 70: Line 68:
 ⎕NC Name Type
 === ==== ====
 3.1 Hello3 Traditional Function
Hello3
Line 74: Line 70:
works as well.
Note the missing `#.`
Line 93: Line 90:
By default all objects are listed. You can specify the nameclass(es) you are interested in by specifying the `-nc` switch: By default all objects are listed. You can specify the name class(es) you are interested in by specifying the `-nc` switch:
Line 104: Line 101:
 ⎕NC Name Type
 === ==== ====
 4.2 Dop Direct Operator
 3.1 Hello Traditional Function
 3.2 Hello2 Direct Function
 3.1 Test Traditional Function
 4.1 Top Traditional Operator
Dop
Hello
Hello2
Test
Top
Line 119: Line 114:
 ⎕NC Name Type
 === ==== ====
 3.1 Hello Traditional Function
 3.2 Hello2 Direct Function
Hello
Hello2
Line 125: Line 118:
 ⎕NC Name Type
 === ==== ====
 3.1 Hello Traditional Function
 3.2 Hello2 Direct Function
 9.4 MyCl Class
 9.2 MyForm Form (Instance)
 9.1 MyNS1 Namespace
 9.1 MyNS2 Namespace
Hello
Hello2
MyCl
MyForm
MyNS1
MyNS2
Line 137: Line 127:

== 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 ==

[[attachment:ListObjects.dyalog | Download]] the script.
Line 139: Line 155:
The script is version 1.0 from 2012-07-15 The script is version 1.1.0 from 2017-04-27

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.1.0 from 2017-04-27 Author: KaiJaeger


CategoryDyalogUserCommands

UserCommands/ListObjects (last edited 2019-05-30 07:55:01 by KaiJaeger)