;+ ; NAME: ; KIEXPAND ; PURPOSE: ; Expansion of compressed Polar Camera image files. ; CATEGORY: ; ; CALLING SEQUENCE: ; KIEXPAND, COMPRESSED_FILE_NAME, RM = RM, SCRIPT = SCRIPT ; INPUTS: ; COMPRESSED_FILE_NAME: The full pathname of the file to ; be expanded. ; OPTIONAL INPUTS: ; None. ; KEYWORD PARAMETERS: ; /RM: Set this keyword to delete the compressed file ; after it's expanded. ; SCRIPT: This keyword returns an operating system command ; sequence to expand the specified file, and ; optionally delete the compressed file. It is used ; to generate expansion scripts that can be ; executed by SPAWNing, thus avoiding the overhead ; of a SPAWN for each compressed file. ; OUTPUTS: ; None. ; OPTIONAL OUTPUTS: ; None. ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; An expanded image file is created. If /RM is set, the ; compressed version is removed. ; RESTRICTIONS: ; The compressed file must exist. It must be named according ; to the standard Polar Camera file name convention, where ; expanded files can begin with one of [abcdfg] and the ; compressed version of a given file begins with the ; corresponding character of [nopqst]. ; PROCEDURE: ; The file name part of the full path name is isolated, and ; the first character is checked to see that it is one of ; [nopqrst]. If not, an error message is printed and nothing ; else happens. Otherwise, the expanded file name is ; generated, and an operating system command is created to ; perform the expansion. If the SCRIPT keyword is ; supplied, the command output is redirected to a file. If ; the RM keyword is set, a further command is supplied to ; remove the compressed file after the expansion has ; taken place. If the SCRIPT keyword is not supplied, the ; command is then SPAWNed, otherwise it is returned to the ; calling routine via the SCRIPT keyword. ; EXAMPLE: ; kiexpand,'/jasper/cnsr3_data1/dk/c0/q0200060.012',/rm $ ; ,script=myscript ; SEE ALSO: ; UNCOMPRESS.PRO, DUCALL.PRO, UCALL.PRO ; MODIFICATION HISTORY: ; Written by: D P Steele, November 1993. ; Documented by: D P Steele, April 1995. ;- PRO kiexpand,compressed_file_name,rm=rm,script=script ; Set up OS-specific items @isitdos cpfn=STRTRIM(compressed_file_name,2) fc=STRMID(cpfn,STRLEN(cpfn)-12,1) bfc=BYTE(fc) bc=bfc(0) ; Is the first character of the file name between 'n' and 't'? IF ((078B LE bc) AND (bc LE 084B)) OR $ ((110B LE bc) AND (bc LE 116B)) THEN BEGIN ucfn=cpfn STRPUT,ucfn,STRING(bc-13B),STRLEN(ucfn)-12 cmd=kiexpcmd+cpfn+' '+ucfn IF KEYWORD_SET(script) THEN BEGIN ; Return a line to be added to a script to expand all files IF dos $ THEN cmd=cmd+' > devnull' $ ELSE cmd=cmd+' > /dev/null' IF KEYWORD_SET(rm) THEN cmd=[cmd,rmcmd+cpfn] script=cmd ENDIF ELSE BEGIN ; spawn a shell command to expand this particular file SPAWN,cmd IF KEYWORD_SET(rm) THEN BEGIN ; spawn another command to remove the compressed file SPAWN,rmcmd+cpfn ENDIF ENDELSE ENDIF ELSE BEGIN MESSAGE,'Bad file name :'+cpfn MESSAGE,'Expansion not attempted' ENDELSE END