I don't care if Alan hates Tcl. Here is how we do it:
----------------------------------------------------------------
@proc p.which { myFilename } {
@ set myPathList [ split $::env(PATH) \; ]
@ ## the above creates a list with one path as each element
@
@ foreach dir $myPathList {
@ foreach extension { "" .exe .dll .com .bat } {
@ set myCTL [ file join $dir "$myFilename$extension" ]
@ ## the above joins: 'sed', '.exe', and makes sed.exe
@ ## with other extensions, so we can also find sed.bat
@ ## and sed.dll and sed.com etc.
@
@ if { [ file exists $myCTL ] && [ file readable $myCTL ] }
{
@ return $myCTL
@ }
@ }
@ }
@return ""
@}
@## note that this proc (function) has two opportunities to "return", and
only
@## one occurs, of course.
@
@Test:
@p.which sed
@D:/CYGWIN/BIN/sed.exe
@p.which xcopy
@C:/WINDOWS/COMMAND/xcopy.exe
@p.which doskey
@C:/WINDOWS/COMMAND/doskey.com
----------------------------------------------------------------
Now you just have to port it to PowerPro. [grin]
>If not: Bruce, any chance of either
> (b) isOnPath() function?
I would gladly exchange isOnPath() for a better list/array implementation.
But now that's too off-topic.
--
Luciano Espirito Santo
Santos, SP - Brasil
<-quote-> **************************************************
On 27/04/04 at 06:40, entropyreduction wrote in 4K:
>Hi,
>
>I have a script which includes
>
>do(<an exe>,...)
>
>and which I run on several machines. <an exe> may either be an
>absolute path to an app, or the name of an exe on the path.
>
>On some machines the exe in question doesn't exist, so I don't want
>to run the do(...).
>
>If <the exe> is absolute path, no problem, I can do
>validpath(<anexe>) and avoid execution if it fails.
>
>How about the <an exe> is the name of an exe on the path,
>e.g. "cmd.exe"? Anyone worked out how to test to see if such a file
>is indeed on the path?
>
>If not: Bruce, any chance of either
>
> (a) an isExecutable() function, which would test to see if an
> expression would work as first parameter of "do" or
>
> (b) isOnPath() function?
********* END OF ORIGINAL MESSAGE *********</-quote->
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/JV_rlB/TM
---------------------------------------------------------------------~->
**** EDIT YOUR POSTINGS !!!! ****
Please remove as much as possible from original messages before replying to them.
________________________________________________
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/power-pro/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/