× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 5/18/2015 2:22 PM, Dan wrote:
> I posted a similar message in Midrange-L, but then remembered iSphere's
> Source File Search, and wondered if the function I'm looking for (below)
> could be integrated into this.
> 
> I need to do a bulk search of source (ala FNDSTRPDM) but with the ability
> to ignore all comments.
> 
> I'm guessing this is custom-written app, but it seems to be that this would
> be a valuable tool for many programmers, especially for those in shops
> where code is never deleted outright, but is commented-out.

pullhairout.gif

> Specifically, I am looking for all usages of '*MDY' (and other formats
> utilizing 2-digit years).
> 
> Has someone already invented this wheel?

Wow, this turned out to be ugly.  I used to think I understood regular
expressions in RDi but I have been disabused of that notion.  I'm half
of a mind to call in a support ticket to try to figure out exactly what
regex engine RDi is using because the standard Java (?!) lookahead
doesn't seem to be working for me.  This finds comments:

findText regularExpression ^(.{6}\*.*|.*\/\/.*)$

I would have thought (ooooh, there's the problem!) that this would have
found anything but the comments:

findText regularExpression ^(?!.{6}\*.*|.*\/\/.*)$

Instead, I get a "" not found.

IBM i search does not appear to support regex.
Remote search looks like it should; I tried the regex that found
comments (the first one I posted) but it didn't find anything.
Different regex engine?
I don't know how File Search is supposed to work; it has a regular
expression box.




So, my mind turns to IBM i, where the source resides anyway.

I almost did it in Code, but who except me has that loaded anymore?  So
I went to Cygwin to try out sed/grep/awk and had a lovely go with sed -r
'/^......\*.*|^.*\/\/.*|nysut/d' greptest.rpgle which was great except
that the sed I have on my IBM i machine doesn't understand -e.  So I
just did some tinkering in QShell.

It turns out I have an egrep in /QOpenSys/usr/bin.  It may be part of
the YiPS stuff or it may be part of 5799-PTL; I can't remember.  Anyway,
this bit of arcana worked:

cat /qsys.lib/prodlib.lib/qrpglesrc.file/greptest.mbr | egrep -v
'^......\*.*|^.*\/\/.*' | grep -i '*mdy'

Wrap that in a for...do loop and you can scan an entire source file:

for file in /qsys.lib/prodlib.lib/qrpglesrc.file/*; do echo $file; cat
$file | egrep -v '^......\*.*|^.*\/\/.*' | grep -i '*mdy'; done




The for...do...done makes a list of files (members) and DOes the stuff
until the DONE.  The stuff in the middle is an

echo $file which prints the full member name

cat $file 'prints' the contents of the source member which gets piped into:

egrep which looks for
^ start of line
...... 6 characters
\* the literal *
.* any number of characters
| - or -
^ start of line
.* any number of characters
\/\/ the literal //
.* any number of characters

This filters out (-v) the comments.

That then gets piped into grep which does a case insensitive search (-i)
for *mdy.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.