pro SetRotations, Prompt, WildCard, LoRot, HiRot @compile_opt.pro ; On error, return to caller ;+ ; NAME: ; SetRotations ; PURPOSE: ; Use specified wildcard to locate directory with data files for the ; Carrington programs. If located, define a logical pointing to ; data directory. ; Also return first and last Carrington rotations numbers for which files ; are available. ; CALLING SEQUENCE: ; SetRotations, Prompt, WildCard, LoRot, HiRot ; INPUTS: ; Prompt = 0/1 ; 0 : check directory assigned to logical only. ; 1 : check directory assigned to logical. If unsuccessful, prompt ; for directories until data files are located ; WildCard string wildcard used to search for data files; ; see RESTRICTIONS ; OUTPUTS: ; LoRot integer First and .. ; HiRot integer last Carrington rotation located ; CALLS: ; SetLog2Dir, SetFileSpec, GetFileSpec ; RESTRICTIONS: ; WildCard must contain only the wildcard specifier '%%%%' and must ; consist only of filename+filetype (i.e. do NOT specify device or ; directory) ; PROCEDURE: ; > The wildcard is used to search for data files; %%%% is the Carrington ; rotation number. ; > The file type (extension) is used to construct the name of the logical ; assigned to the data directory. ; > If the logical is already assigned to a directory, that directory is ; searched first. If data files are found, the value is retained. If not, ; the logical is deassigned. ; > If no files are found in the previous step, then ; - if Prompt = 0 then return LoRot = HiRot = 0 ; - if Prompt = 1 continue to prompt for a directory until one is specified ; which contains data files or until program is aborted. ; MODIFICATION HISTORY: ; JUL-1993, Paul Hick (UCSD), translation of F77 subroutine SETROTATIONS ;- I = strpos(WildCard,'.') if I eq -1 then message, 'Wildcard must include valid file type xName = strmid(WildCard,I+1,999) Iper = strpos(WildCard,'%%%%') if Iper eq -1 then message, 'Wildcard must include substring %%%% ; Check for existence of directory logical xData = getenv(xName) if xData ne '' then begin SetLog2Dir, 0, xName, WildCard, Found if Found eq '' then dellog, xName endif else begin message, /info, 'no translation for logical name '+xName Found = '' endelse ; Check for requested file type, if it has not been located yet ; Set the logical xName to the proper directory. ; SetLog_Dir will prompt for a directory until a file is found. if Found eq '' then begin if not Prompt then begin LoRot = 0 HiRot = 0 message, /info, 'No rotations located in '+xName return endif SetLogDir, 1, xName, WildCard, Found endif ; Extract the Carrington rotation number from the file name. ; Then keep searching for more rotations until the last is located SetFileSpec, Found Found = GetFileSpec(upto='DIRECTORY') LoRot = strmid(Found,Iper,4) Found = file_search(filepath(root=xName,WildCard)) Found = Found[n_elements(Found)-1] SetFileSpec, Found Found = GetFileSpec(upto='DIRECTORY') HiRot = strmid(Found,Iper,4) message, /info, 'Available rotation(s) are '+strcompress(LoRot,/rem)+' to '+strcompress(HiRot,/rem) return & end