home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 5
/
ctrom5b.zip
/
ctrom5b
/
DOS
/
TEKST
/
AURORA2
/
WHERE.AML
< prev
next >
Wrap
Text File
|
1995-04-28
|
6KB
|
183 lines
/* ------------------------------------------------------------------ */
/* Macro: WHERE.AML */
/* Written by: nuText Systems */
/* */
/* Description: This macro searches all directories on one or more */
/* disk drives for a filename or filespec. When the */
/* search is completed, the located files are */
/* displayed in a popup menu. */
/* */
/* Usage: Select this macro from the Macro List (on the Macro */
/* menu), or run it from the macro picklist <shift f12> */
/* */
/* You will be prompted for the filespec and drives. */
/* The filespec and drives must be entered in */
/* multi-string format, e.g. 'filespec/drives'. If no */
/* drives are specified, then all drives on your */
/* computer will be searched (excluding A: and B:). */
/* */
/* Select a file from the popup menu to display it in */
/* an edit window. */
/* */
/* Select the first line of the popup menu to edit the */
/* contents of the menu (you can then use the */
/* 'openword' <ctrl ]> command to open each file). */
/* ------------------------------------------------------------------ */
// compile time macros and function definitions
include bootpath "define.aml"
// function to show progress while scanning directories
function onscanning (directory found filespec)
// create the progress window
if not window? 'scan' then
createwindow 'scan'
setwinobj
setframe ">b"
setcolor border_color color white on gray
setcolor text_color color black on gray
settitle "Where is '" + filespec + "'" 'c'
setborder "1i"
setshadow 2 1
// center the window
width = 60
height = 16
ox = (getvidcols - width) / 2
oy = (getvidrows - height) / 2
sizewindow ox oy ox + width oy + height "ad"
writestr directory
elseif found then
writestr " FOUND" (color brightgreen on gray) (getcoord 'x1') - 7
elseif directory then
writeline
writestr directory
else
destroywindow
end
display
end
// scan directories recursively for a filespec
function scandir (filespec directory resultbuf)
onscanning directory
// is filespec found in the directory?
if locatefile filespec (getpath directory) then
// wildcard filespec specified?
if poschar '*?' filespec then
filebuf = loadbuf (qualify filespec directory)
if filebuf then
repeat
addline (qualify (sendobject "fmgr" "getffile") directory)
'' '' resultbuf
until not down
destroybuf filebuf
end
// complete filename was specified
else
addline (qualify filespec directory) '' '' resultbuf
end
// notify progress window that filespec is found
onscanning directory 1
end
// get a directory listing
if loadbuf directory '' '' "dh1" then
ss = '^' + (char 0)
if find ss 'x*' then
// do recursively for all subdirectories
repeat
name = qualify (sendobject "fmgr" "getffile") directory
// don't go back to parent directory
if (sizeof name) > (sizeof directory) then
scandir filespec name resultbuf
end
until not (find ss 'x')
end
destroybuf
end
end
var filespec
var drives
var i
// get filespec to search for and drives to search through
file_and_drives = ask "[filespec/drives] Where is"
splitstr '' file_and_drives ref filespec ref drives
if not filespec then
return
end
// search all available drives (except floppies), if none specified
if not drives then
drives = sub 'A' '' (getdisk 'm')
drives = sub 'B' '' drives
end
// convert to upper case
filespec = upcase filespec
drives = upcase drives
// create buffer to hold located files
resultbuf = createbuf
if resultbuf then
// set first line in resultbuf
ovltext "≡≡≡≡≡≡ Select this line to edit file list ≡≡≡≡≡≡"
// setup progress window
onscanning '' '' filespec
// scan each drive
repeat
i = i + 1
directory = drives [i] + ":\\*.*"
scandir filespec directory resultbuf
until i >= (sizeof drives)
// destroy progress window
onscanning
currbuf resultbuf
if getlines > 1 then
// sort and display the located file list in a popup menu
sendobject "fmgr" "fsort" 'n'
file = popup resultbuf "Where is '" + filespec + "'" 60
if file then
if file [1] == '≡' then
// edit the file list
delline 1 1 resultbuf
setbufname (qualify "TEMP.TXT" (getbufname (getwinbuf))) resultbuf
openbuf resultbuf
return
else
// open the selected file
open file
end
end
else
display
say filespec + " not found" 'b'
end
destroybuf resultbuf
end