[comp.os.msdos.misc] My version of WHICH.BTM for 4DOS

ggurman@cory.Berkeley.EDU (Gail Gurman) (04/10/91)

Somebody recently posted WHICH.BTM for 4DOS.  It was really great
but I thought it should allow you to say WHICH *NAME to skip over
the check for aliases.  My version sacrifices the ability to
use more than one name on the command line however.  It's that nasty
FOR command.  It only works on file names.

I also tried to make a version that would check if the argument
was an internal command.  Again, I tried the FOR command
(e.g. for %NAME in (BREAK CLS COPY DEL DIR) echo Internal command.)
but, again, it only works on file names.  If anyone has any ideas,
please tell me.  I'd really like this to work for every possibility.

Anyway, here's my version.  It is basically the other one, edited.

Gail

8<---------------------------------------------------------------------

@echo off
REM WHICH.BTM -- usage is WHICH name
setlocal

if #==1 then goto error

set NAME = %@upper[%1]
REM Is it an aliased command that we don't want expanded?
iff "%@substr[%1,0,1]" == "*" then
	set NAME = %@substr[%NAME,1,12]
	gosub search
else
REM Is it an alias?
	iff isalias %NAME then
		alias %NAME | input %%AL
		echo "%NAME" is an alias for "%AL"
	else
		gosub search
	endiff
endiff
quit

:error
REM Oops!  No argument!
echo Syntax is "WHICH [filename][.ext]"
quit

:search
REM Here's where we check if it is a program or file.
set FILE=%@search[%NAME]
iff "%FILE" == "" then
	echo "%NAME" not found in PATH
else
	echo %FILE
endiff
return
Send mail to:	ggurman@cory.Berkeley.EDU