comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Which routine (was: Re: Seeing Source w/ Debugger)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Which routine (was: Re: Seeing Source w/ Debugger) [message #2390] Fri, 24 June 1994 06:04
robijn is currently offline  robijn
Messages: 18
Registered: June 1994
Junior Member
;+
; NAME:
; WHICH
;
; PURPOSE:
; Searches the !PATH for a given file.
;
; CATEGORY:
; Programming.
;
; CALLING SEQUENCE:
;
; Result = WHICH (FileName)
;
; INPUTS:
; FileName The name of the file to look for. The '.pro'
; extension can be omitted.
;
; KEYWORD PARAMETERS:
; PATH A string containing an alternative path to search.
; If this keyword is omitted, !PATH is used.
;
; OUTPUTS:
; The function returns the path to the file name. If the file is
; not found, an empty string '' is returned.
;
; COMMON BLOCKS:
; None.
;
; SIDE EFFECTS:
; None.
;
; RESTRICTIONS:
; Should work on DOS and Unix platforms.
;
; MODIFICATION HISTORY:
;
; Jun 13, 1994 (Frank Robijn, Robijn@Strw.LeidenUniv.NL)
; Written.
;-
FUNCTION Which, File, PATH=Path

if (NOT Keyword_Set (File)) then return, ''
if (NOT Keyword_Set (Path)) then Path = !PATH

case !VERSION.OS of
'windows': begin SepDir = '\' & SepPath = ';' & end
else: begin SepDir = '/' & SepPath = ':' & end
endcase

SearchDir = ['.']
Pos = -1
repeat begin
NewPos = StrPos (Path, SepPath, Pos + 1)
if (NewPos LT 0) then Len = StrLen (Path) else Len = NewPos-Pos-1
SearchDir = [Temporary (SearchDir), StrMid (Path, Pos+1, Len)]
Pos = NewPos
endrep until (NewPos LT 0)

FileName = ''
On_IOError, Continue
Get_LUn, Unit
for i = 0, N_Elements (SearchDir) - 1 do begin
OpenR, Unit, SearchDir(i) + SepDir + File
Close, Unit
FileName = SearchDir(i) + SepDir + File
GoTo, FileFound
Continue:
endfor

On_IOError, GoOn
Get_LUn, Unit
for i = 0, N_Elements (SearchDir) - 1 do begin
OpenR, Unit, SearchDir(i) + SepDir + File + '.pro'
Close, Unit
FileName = SearchDir(i) + SepDir + File + '.pro'
GoTo, FileFound
GoOn:
endfor

FileFound:
On_IOError, NULL
return, FileName
END
--
_____ ____
/ / / Frank Robijn Internet: Robijn@Strw.LeidenUniv.NL
/___ /___/ Sterrewacht Leiden Bitnet: Robijn@HLERUL51
/ / \ Phone (31) 71 275841 Local: Robijn@HL628
/ / \ Fax : (31) 71 275819 Snail: P.O.Box 9513, 2300 RA Leiden,
The Netherlands
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Adding Devices to PV~Wave/IDL
Next Topic: Re: Seeing Source w/ Debugger

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 13:22:26 PDT 2025

Total time taken to generate the page: 1.59947 seconds