(view source code of which.kix as plain text)
; Check command line argument
If $search = "" OR InStr( $search, "?" )
? "Which.kix, Version 1.00"
? "Locate the specified program file"
? "Port of Unix' WHICH command" ?
? "Usage: KIX32 WHICH.KIX $$SEARCH=filename[.ext]" ?
? "Where: " + Chr(34) + "filename" + Chr(34)
" is a file name only: no path, no wildcards" ?
? "Written by Rob van der Woude"
? "http://www.robvanderwoude.com" ?
Exit 2
EndIf
; Store PATH and PATHEXT in arrays
$pathArray = Split( "@CurDir;%PATH%", ";", -1 )
$pathExtArray = Split( "%PATHEXT%;.DLL;.SYS;.OCX", ";", -1 )
; Reset search result variable
$found = 0
; Search each directory until one match is found
For Each $i In $pathArray
If $found = 0
$pathDir = $i
; Strip trailing backslash and/or dot
If Right( $i, 2 ) = "\."
$pathDir = SubStr( $i, 1, Len( $i ) - 2 )
Else
If Right( $i, 1 ) = "\"
$pathDir = SubStr( $i, 1, Len( $i ) -1 )
EndIf
EndIf
; Try without appending extension first
If InStr( $search, "." )
If Exist( $pathDir + "\" + $search )
$result = $pathDir + "\" + $search
$found = 1
EndIf
Else
; Then try all the extensions from PATHEXT
For Each $j In $pathExtArray
If Exist( $pathDir + "\" + $search + $j )
$result = $pathDir + "\" + $search + $j
$found = 1
EndIf
Next
EndIf
EndIf
Next
; Display the result
If $found = 0
? "-None-" ?
$ret = 1
Else
? $result ?
$ret = 0
EndIf
; Exit with return code
Exit $ret
page last modified: 2024-04-16; loaded in 0.0067 seconds