Part of the Samples Website. 8/16/97.


«Searches all text files in a folder for a string of characters
«looking for files that contain a string of characters
«when it finds one, it adds it to the outline it builds
«using file.creator, you could customize it to only look in files created by one app
if dialog.ask ("String to search for?", @scratchpad.searchString)
local (folder)
if file.getFolderDialog ("Choose a folder to search", @folder)
local (adrOutline = @scratchpad.fileList)
new (outlineType, adrOutline)
target.set (adrOutline)
editMenu.setFont ("Palatino")
editMenu.setFontSize (12)
window.setTitle (adrOutline, "Search Results" ) «set title before opening (adrOutline)
op.setLineText ("Files that contain "" + scratchpad.searchString + "":");
local (matches = 0, dir = right)
fileloop (f in folder, infinity) «loop over all files and subfolders
if file.type (f) == 'TEXT' «it's a text file
msg (file.fileFromPath (f)) «show that we're searching this file
if file.findInFile (f, scratchpad.searchString) «found it!
target.set (adrOutline) «make sure heading goes into the right outline
op.insert (f, dir) «insert the full path to the file
dir = down
matches++ «add 1 to the counter
window.msg (matches + " matches")
if matches == 0
dialog.alert (""" + scratchpad.searchString + "" wasn't found.")

This page was last built on Sat, Aug 16, 1997 at 6:40:54 PM. You can download the current set of sample scripts from our FTP site. Dave