| 1 |
/* |
| 2 |
* @progname search_source.ll |
| 3 |
* @version 1.0 |
| 4 |
* @author Stephen Dum |
| 5 |
* @category |
| 6 |
* @output text |
| 7 |
* @description |
| 8 |
|
| 9 |
Search source records for a particular string. |
| 10 |
Program prompts for the type of sub record to search |
| 11 |
and then for string to search for. If no sub record type is |
| 12 |
entered, all records are searched. Case is ignored in searches. |
| 13 |
|
| 14 |
by Stephen Dum ([email protected]) |
| 15 |
Version 1 July 2006 |
| 16 |
*/ |
| 17 |
|
| 18 |
option("explicitvars") |
| 19 |
|
| 20 |
proc main() |
| 21 |
{ |
| 22 |
getstr(search,"Enter type of SOUR sub records searched(e.g. TITL, AUTH) <return> for all") |
| 23 |
set(search,upper(search)) |
| 24 |
getstr(match,"Enter string to search for") |
| 25 |
set(match,lower(match)) |
| 26 |
|
| 27 |
forsour(n,i){ |
| 28 |
if (strlen(search)) { |
| 29 |
/* only search children of this source where tag is search */ |
| 30 |
fornodes(n,ch) { |
| 31 |
if (eqstr(tag(ch),search)) { |
| 32 |
set(v,value(ch)) |
| 33 |
if (i,index(lower(v),match,1)) { |
| 34 |
/* |
| 35 |
print ("Found in ",xref(n)," ",v,"\n") |
| 36 |
*/ |
| 37 |
print ("Found in ",xref(n),": ") |
| 38 |
print (d(level(ch))," ") |
| 39 |
if (strlen(xref(ch))) { |
| 40 |
print (xref(ch)," ") |
| 41 |
} |
| 42 |
print(tag(ch)," ",lower(v),"\n") |
| 43 |
} |
| 44 |
} |
| 45 |
} |
| 46 |
} else { |
| 47 |
traverse(n,ch,i) { |
| 48 |
set(v,value(ch)) |
| 49 |
if (i,index(lower(v),match,1)) { |
| 50 |
/* |
| 51 |
print ("Found in ",xref(n)," ",v,"\n") |
| 52 |
*/ |
| 53 |
print ("Found in ",xref(n),": ") |
| 54 |
print (d(level(ch))," ") |
| 55 |
if (strlen(xref(ch))) { |
| 56 |
print (xref(ch)," ") |
| 57 |
} |
| 58 |
print(tag(ch)," ",lower(v),"\n") |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
} |