home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1994 February
/
psl_9403.zip
/
psl_9403
/
DOS
/
UT_SYSTM
/
CENVI2.ZIP
/
PATHADD.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-06-14
|
1KB
|
48 lines
@echo off
REM **********************************************************************
REM *** PathAdd.cmd - add a directory to the current path, if it's not ***
REM *** already there ***
REM **********************************************************************
if "%1"=="" GOTO SHOW_HOW
if not "%2"=="" GOTO SHOW_HOW
CALL CEnviSet %0.cmd %1
GOTO FINI
:SHOW_HOW
ECHO PathAdd.cmd - Add a directory to the PATH if it's not already there
ECHO USAGE: PathCmd DirSpec
GOTO FINI
GOTO CENVI_EXIT
main(argc,argv)
{
NewDir = argv[1]
if ( AlreadyInPath(NewDir) ) {
printf("The Directory \"%s\" is already in PATH.\n",NewDir)
} else {
// File is not already in the path, and so append to the end of PATH.
// If there isn't a semi-colon at the end of PATH already, then add one.
if ( PATH[strlen(PATH)-1] != ';' )
strcat(PATH,";")
// Append this new directory to the end of the path statement
strcat(PATH,NewDir)
}
}
AlreadyInPath(Dir) // search through path for this Dir, return True if found, else False
{
len = strlen(Dir)
p = PATH
do {
if ( 0 == strnicmp(p,Dir,len) && (p[len]==0 || p[len]==';') )
return(True)
p = strchr(p,';')
} while( p++ != NULL )
return(False)
}
:CENVI_EXIT
:FINI