Example No 2

This is a read-only page

r←{parms}Find what;Seek;noComments;noText;list;this;body;between;buffer;bool;namesOnly;verboseMode;drop;b;⎕ML
⍝⍝ Try to find "what" in ⎕nl 3 4; by default, comments and text is ignored, the report is detailed
⍝⍝ Note that the search is case sensitive!
⍝⍝ "what" = simple string to be searched
⍝⍝ left argument is optional ⋄ may be:
⍝⍝ '-c -t -v -h'
⍝⍝ -c = ignore all comments
⍝⍝ -h = search in headers only; useful to find a name in several namespaces
⍝⍝ -v = verbose mode; reports line details
⍝⍝ -t = ignore text
⍝⍝ default is:   -c -t -v
⍝⍝ To suppress the defaults:
⍝⍝ '' Find 'Foo'
⍝⍝ Copyright: APL Team Ltd ⋄ Kai Jaeger ⋄ www.aplteam.com
 ⎕ML←3
 parms←{2=⎕NC ⍵:' ',' ',⍨⍎⍵ ⋄ ' -c -t -v '}'parms'
 noComments←0<+/' -c '⍷parms
 noText←0<+/' -t '⍷parms
 namesOnly←0<+/' -h '⍷parms
 verboseMode←0<+/' -v '⍷parms
 Seek←{
     l←(⊂'.',⍨⍕⍵),¨⍕¨' '~¨⍨↓⍵.⎕NL 3 4
     0∊⍴a←⍵.⎕NL 9:l
     a←('.',⍨⍕⍵)∘,¨↓a
     0∊⍴a←(~'['∊¨⍕¨⍎¨a)/a:l
     0∊⍴a←(⍵∘{16::1 ⋄ ⍺≢¨⍎⍵}¨a)/a:l
     l,↑,/∇¨⍎¨a
 }
 between←{⍺←'''' ⋄ {⍵∨≠\⍵}⍵∊⍺}
 drop←{(⎕PW-2){(⍺⌊⍴,⍵)↑⍵}⍵/⍨~'  '⍷⍵}
 list←Seek #
 r←''
 :For this :In list
     :If ~0∊⍴body←⎕NR this
     :AndIf 2=≡body
         :If 0<+/∨/¨bool←what∘⍷¨buffer←body
             :If noText
                 bool←bool{⍵\⍵/⍺}∘~∘between¨body
             :EndIf
             :If 0<+/∊bool
                 :If noComments
                     :If ~noText
                         buffer←{w←⍵
                             b←between w
                             (b/w)←' '
                             w
                         }¨body
                     :EndIf
                     bool←bool{~'⍝'∊⍵:⍺
                         ⍺↑⍨¯1+⍵⍳'⍝'
                     }¨buffer
                 :EndIf
             :AndIf 0<+/∊bool
                 bool←∨/¨bool
                 :If namesOnly
                     :If 1=1⍴bool
                         :If verboseMode
                             r,←⊂' ',1⊃body
                         :Else
                             r,←⊂' ',this
                         :EndIf
                     :EndIf
                 :Else
                     r,←⊂b←this,'[',(⍕{⍵/⍳⍴⍵}bool),']'
                     :If verboseMode
                         r,←' ',¨{⍵↓⍨+/∧\' '=⍵}¨bool/body
                     :EndIf
                 :EndIf
             :EndIf
         :EndIf
     :EndIf
 :EndFor
 r←,[1.5]r