Search .p .wfiles within directory

tej

New Member
Hi

Not sure if this is possible but i want to search a folder which contains a loads of progress programs .w's and .p's.

What i want to do is search this directory and find the text view-as text.

If found i want the name of the program.

can this be done in progress?

im on version 9.1c if that helps

cheers

TJ
 

rusguy

Member
This surely can be done in progress but this would require to read line by line from every file. Progress is not that fast with doing that, so your best bet is to use os functions - grep, find. If you don't have this option, then something like this will work for you:
def var cFile as char.
def var cPath as char.
def var cType as char.
def var str as char.
def stream in-str.
input from os-dir("path to your directory").
repeat:
import cFile cPath cType.
if cType = "F" and num-entries(cFile, ".") > 1 and
lookup(entry(num-entries(cFile, "."), cFile, "."), "p,w") > 0 then
do:
input stream in-str from value(cPath).
repeat:
import stream in-str unformatted str.
if index(str, "view-as text") > 0 then
do:
message cPath view-as alert-box.
leave.
end.
end.
input stream in-str close.
end.
end.
input close.
 

doreynie

Member
I don't use it often enough to shake a good example out of my hat, but ever heard of PERL? That's a good tool to do such things.
 

Casper

ProgressTalk.com Moderator
Staff member
Or on Unix, use OS search:

something like:
Code:
find . -type f -exec grep -il "View-as text" {} ;\ > /tmp/listfile.tmp

You can issue this in Progress with an OS-command statement and import from the generated file to display the filenames in Progress.....

Regards,

Casper.
 
In Windows XP, you can use the findstr command.

def var this_command as char no-undo.
this_command = 'findstr /C:"view-as text" ' +
" c:\whateverdrive\*.w c:\whateverdrive\*.p > c:\temp\findstr.tmp".

os-command silent value (this_command).

Then you can input the information from c:\temp\findstr.tmp

If you just want a list of filenames, without the lines containing the text, add the /M switch.
 

Casper

ProgressTalk.com Moderator
Staff member
Just interested, but this this also work with non registered filename extension. I remember there was an issue with persistenthandler....

Regards,

Casper.
 
Top