Subject: | Re: Searching for text inside libraries, form, scripts and reports
| Date: | 8 Sep 2020 11:49:31 -0400
| From: | "Thies Grimm" <thies.grimm@t-online.de>
| Newsgroups: | pnews.paradox-development
|
wonderfull idea
you might do the samething using windows powershell
try this script:
==================================
method run(var eventInfo Event)
var
dynAliase,
dynType dynArray[] String
stMatch String
ts TextStream
ar Array[] String
fs FileSystem
stline String
dyn dynArray[] String
endVar
; // Default Match
stMatch = "cmgetuserInfos"
; // Match abfragen
stMatch.view("what are we looking for?")
; // Aliase
dynAliase["work"] = getAliasPath("work")
dynAliase["priv"] = getAliasPath("priv")
; // fileTypes
dynType["Form"] = "fsl"
dynType["Script"] = "ssl"
dynType["Library"] = "lsl"
; // PowerShell-Script erstellen
ts.open(":priv:__FindStringInFiles.ps1", "nw")
ts.writeLine("$priv = \"" + privDir() + "\"")
si = 1
ar.empty()
forEach element in dynAliase
forEach fileType in dynType
ts.writeLine("Get-ChildItem " + dynAliase[element] + "\\*." + dynType[fileType]
+
" | SELECT-STRING -Pattern \"" + stMatch + "\"" +
" | SELECT FileName" +
" | Out-File -encoding default $priv\\__" + format("W4.0,EZ",
si) + ".txt")
ar.addLast(element)
si = si + 1
endForEach
endForEach
ts.close()
; // execute PowerShell-Script
if not execute("Powershell -file " + privDir() + "\\__FindStringInFiles.ps1",
True, exehidden) then
errorshow()
return
endIf
; // read powershell Resultfiles
for si from 1 to ar.size()
if not ts.open(privDir() + "\\__" + format("W4.0,EZ", si) + ".txt",
"r") then
errorshow()
quitLoop
endIf
while not ts.eof()
ts.readLine(stLine)
if fs.findFirst(":" + ar[si] + ":" + stline) then
dyn[fs.FullName()] = format("DY3O(%D.%M.%Y),TO(%D %H:%M:%S)",
fs.Time())
endIf
endWhile
endFor
; // create Resultfile
ts.open(":priv:__Result.txt", "nw")
ts.writeLine(stMatch)
ts.writeLine(fill("=", stMatch.size()))
ts.writeLine("")
si = 0
forEach element in dyn
si = max(si, smallInt(element.size()))
endforEach
forEach element in dyn
ts.writeLine(element + fill(" ", si - element.size()) + "\t" + dyn[element])
endforEach
ts.close()
; // showResultfile
fs.findFirst(":priv:__Result.txt")
execute(windowsDir() + "\\explorer.exe" + " /e /select, " + fs.FullName(),
yes, exeshownormal)
endMethod
=====================
Mark Bannister <markRemove@THISinjection-moldings.com> wrote:
>I've posted this before but I use this many times a week when
>developing. If you have access to a Linux system (virtual machine will
>work with access to your pdox data) or you run a Linux server then you
>can use this command:
>
>find . -type f -name '*.*sl' -exec grep -li "TextToSearchFor" {} +
>
>It searches inside files using regular expressions. In the above case
>I'm searching in the current directory recursively, for all files ending
>in .*sl; so all scripts, libraries, forms and reports.
>
>This is really handy when you are trying to find all code that
>references a specific method name, etc. Since pdox objects are mostly
>text, it can also find every place you reference a table or alias in a
>data model.
>
>--
>Mark B
|