Size: 4783
Comment:
|
Size: 4860
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 137: | Line 137: |
== Download == [[attachment:ListObjects.zip | Download]] the script. |
User Command ListObjects
Contents
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''' 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'
Examples
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 Namespace 9.1 MyNS2 Namespace 3.1 Test Traditional Function 4.1 Top Traditional Operator 9.2 WEBBROWSER OCXClass (Instance) ¯8.6 onBeforeNavigate2 External (inherited) 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 ⎕NC Name Type === ==== ==== 3.1 Hello3 Traditional Function
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 MyNS1 ⎕NC Name Type === ==== ==== 3.1 Hello3 Traditional Function
works as well.
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 nameclass(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 ⎕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
"Start with" switch
With the =s switch you can specify one or more characters. Note that the filter is case sensitive.
]ListObjects -s=H ⎕NC Name Type === ==== ==== 3.1 Hello Traditional Function 3.2 Hello2 Direct Function ]ListObjects -s=HM ⎕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
Note that this switch works in the same way as the (optional) left argument to ⎕NL.
Download
Download the script.
Version
The script is version 1.0 from 2012-07-15 Author: KaiJaeger