Wow, good stuff. I am absolutely deficient in the ways of qshell and
regex, so thank you for breaking down and explaining this, Buck!

Should have tried this on a smaller source file first. It appears a job
log for job QP0ZSPWP was created for every single member. Need to turn off
job logging.

Is there a way to redirect the output on the screen to a file?

On Mon, May 18, 2015 at 6:06 PM, Buck Calabro <kc2hiz@xxxxxxxxx> wrote:

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.

--
--buck

--
This is the Rational Developer for IBM i / Websphere Development Studio
Client for System i & iSeries (WDSCI-L) mailing list
To post a message email: WDSCI-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/wdsci-l
or email: WDSCI-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/wdsci-l.


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-2019 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].