home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1995 November
/
PCWK1195.iso
/
inne
/
podstawy
/
dos
/
4dos
/
4uzytki
/
4dtnt.exe
/
MISC.ZIP
/
WHERE.BTM
< prev
Wrap
Text File
|
1991-11-03
|
2KB
|
88 lines
rem Determine "WHERE" a particular command comes from -- internal,
rem alias, external, executable extension, etc.
rem None of the rems is necessary to proper operation and may be
rem deleted for ordinary use.
setlocal
rem See if a command to check was supplied.
iff "%1" == "" then ^ echo Syntax: where command ^ quit
else
rem
rem separate the name and the extension (if any)
rem
set targ=%@upper[%@name[%1]]
set ex=%@upper[%@ext[%1]]
endiff
rem Skip some stuff if no extension
if "%ex" == "" goto noext
rem See if the extension is one of the usual executables
if %ex == COM .or. %ex == EXE .or. %ex == BTM .or. %ex == BAT goto catext
rem There is an extension, but it's not a normal executable. See if there's
rem such an extension in the environment -- i.e., a user-defined executable
rem extension.
set ey=.%ex
iff "%[%ey]" ne "" then
rem It's a defined executable extension. Tell the user.
echo Executable extension = %@upper[%[%ey]]
rem Now find out whether the program which is supposed to be run
rem against the executable extension file is there!
iff "%@path[%[%ey]]" == "" then
where %@name[%[%ey]].%@ext[%[%ey]]
endiff
iff not exist %[%ey] then
echo Extension program not found
endiff
else
echo Executable extension .%ex definition not found
endiff
goto cleanup
rem Above was for executable extensions. What follows is the branch
rem label for normal executables (.BTM, .BAT, .COM, and .EXE)
:catext
rem Put the file name back together with its extension.
set targ=%targ.%ex
:noext
rem Check for alias or internal first, because they would be found first.
iff isalias %targ then
echo Alias
goto cleanup
elseiff isinternal %targ then
echo Internal
goto cleanup
endiff
rem It wasn't an alias or an internal, look down the PATH
set targ=%@search[%targ]
iff "%targ" ne "" then
echo %targ
else
echo Unknown command
endiff
goto cleanup
:cleanup
endlocal
rem The branches to "cleanup" and the "endlocal" are not strictly necesary.
rem They could all have been "quit", but I like programs to have a single
rem exit point and exit in a way which is obviously clean.