PRO CONCAT4DOS
;+
; NAME:
; CONCAT4DOS
; PURPOSE:
; Concatenates IDL procedure files together into a form suitable for
; copying to a DOS machine.
; CALLING SEQUENCE:
; CD, directory ;(go to desired directory)
; CONCAT4DOS
; PARAMETERS:
; None.
; OPTIONAL KEYWORD PARAMETERS:
; None.
; COMMON BLOCKS:
; None.
; SIDE EFFECTS:
; A "dos" subdirectory is created. On VMS machines, a temporary command
; file called "CONCAT4DOS.COM" is created and then destroyed.
; RESTRICTIONS:
; None.
; PROCEDURE:
; All the .PRO files in the current directory are copied into a special
; "dos" subdirectory, with the following changes made:
;
; 1. All filenames are truncated to eight characters.
; 2. All procedure files with names beginning with the same
; first eight characters are concatenated together into a
; single file.
;
; MODIFICATION HISTORY:
; William Thompson, August 1992.
;-
;
ON_ERROR,2
;
; First make sure there are procedure files in the current directory.
;
FILES = FINDFILE('*.pro',COUNT=N_FILES)
IF N_FILES EQ 0 THEN MESSAGE,'No procedure files found'
;
; Next, look for an existing "dos" directory. On VMS machines, open up a
; command file to store all subsequent commands. All the commands will then
; be executed at the end with a single spawn.
;
IF !VERSION.OS EQ 'vms' THEN BEGIN
OPENW,UNIT,'CONCAT4DOS.COM',/GET_LUN
PRINTF,UNIT,'$ SET VERIFY'
DOSDIR = 'DOS.DIR'
END ELSE DOSDIR = 'dos'
DOSDIRFILE = FINDFILE(DOSDIR,COUNT=N_FOUND)
;
; If an existing directory was found, then warn the user that all the ".pro"
; files in that subdirectory will be deleted, and ask if the user wants to
; continue. If yes, then delete the files.
;
IF N_FOUND NE 0 THEN BEGIN
PRINT,'DOS directory already found'
PRINT,'All .PRO files in the DOS directory will be deleted.'
ASK,'Continue? ',ANSWER,'YN'
IF ANSWER EQ 'Y' THEN BEGIN
IF !VERSION.OS EQ 'vms' THEN BEGIN
PRINTF,UNIT,'$ DELETE/NOLOG/NOCONFIRM ' + $
'[.DOS]*.PRO;*'
END ELSE BEGIN
COMMAND = 'rm dos/*.pro'
PRINT,'$ ' + COMMAND
SPAWN,COMMAND
ENDELSE
END ELSE RETURN
;
; Otherwise, create the subdirectory.
;
END ELSE BEGIN
IF !VERSION.OS EQ 'vms' THEN BEGIN
PRINTF,UNIT,'$ CREATE/DIRECTORY [.DOS]'
END ELSE BEGIN
COMMAND = 'mkdir dos'
PRINT,'$ '+COMMAND
SPAWN,COMMAND
ENDELSE
ENDELSE
;
; For each file, determine the eight character equivalent, and copy all files
; beginning with those eight characters into a single file.
;
LAST = ''
FOR I=0,N_FILES-1 DO BEGIN
FDECOMP,FILES(I),DISK,DIR,NAME,EXT,VER
NAME8 = STRMID(NAME,0,8)
IF NAME8 NE LAST THEN BEGIN
IF STRLEN(NAME8) EQ 8 THEN NAME9 = NAME8 + '*' ELSE $
NAME9 = NAME8
IF !VERSION.OS EQ 'vms' THEN BEGIN
PRINTF,UNIT,'$ COPY ' + NAME9 + $
'.PRO [.DOS]' + NAME8 + '.PRO'
END ELSE BEGIN
COMMAND = 'cat ' + NAME9 + '.pro > dos/' + $
NAME8 + '.pro'
PRINT,'$ ' + COMMAND
SPAWN,COMMAND
ENDELSE
ENDIF
LAST = NAME8
ENDFOR
;
; On VMS machines, tell the command file to delete itself after processing,
; and execute it.
;
IF !VERSION.OS EQ 'vms' THEN BEGIN
PRINTF,UNIT,'$ DELETE/NOLOG/NOCONFIRM CONCAT4DOS.COM;*'
FREE_LUN,UNIT
SPAWN,'@CONCAT4DOS.COM'
ENDIF
;
RETURN
END
|