Re: IDL V4 and Windows 95 [message #6052] |
Thu, 04 April 1996 00:00 |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
Mirko Vukovic wrote:
> Yes, can you please post that (concat4dos) utility.
CONCAT4DOS is included below. It is a modification of the routine of the same name in
the CDS library (http://sohowww.nascom.nasa.gov/solarsoft/gen/idl/) and it calls
FDECOMP from the CDS library, plus OS_FAMILY, which is in the IDL Astronomy Library
(http://idlastro.gsfc.nasa.gov/homepage.html) but may also be in the CDS library.
> Can you please be more specific
> on adding a space to file names. Where? In the idl call or to the file name
> itself?
Either, eg, create a file called alongname.txt and try to open it:
IDL> name='c:\temp\alongname.txt'
IDL> openr,1,name
% OPENR: Error opening file: c:\temp\alongnam.txt.
No such file or directory
% Execution halted at: $MAIN$
That doesn't work but this does:
IDL> openr,1,name+' '
IDL> text='' & readf,1,text & print,text
some text
IDL> close,1
However use this workaround at your own risk. I've had strange results from FINDFILE
when used with long file names--seems to corrupt the file name.
> How do people like the imbedded editor? I usually kill those windows as they pop and
> do most of the editing via emacs. The idl editor, I use for debugging.
Me too. I stopped using the IDL editor when, in an earlier version, it used to erase
the files it was editing!
============================================================ ==
Mark Hadfield NIWA (Taihoro Nukurangi)
PO Box 14-901
m.hadfield@niwa.cri.nz Wellington, New Zealand
************************************************************ **
PRO CONCAT4DOS, SUBDIRECTORIES=SUBDIRECTORIES
;+
; Project : SOHO - CDS
;
; Name :
; CONCAT4DOS
; Purpose :
; Concatenates IDL procedure files for copying to DOS machine.
; Explanation :
; Concatenates IDL procedure files together into a form suitable for
; copying to a DOS machine.
;
; 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.
;
; Use :
; CD, directory ;(go to desired directory)
; CONCAT4DOS ;or CONCAT4DOS, /SUBDIRECTORIES
; Inputs :
; None.
; Opt. Inputs :
; None.
; Outputs :
; None.
; Opt. Outputs:
; None.
; Keywords :
; SUBDIRECTORIES = If set, then subdirectories are also recursively
; processed. This does not work under Windows.
; Calls :
; FDECOMP
; Common :
; None.
; Restrictions:
; None.
; Side effects:
; A "dos" subdirectory is created. A temporary command file is created
; and then destroyed. On VMS machines, the file is called "CONCAT4DOS.COM",
; on UNIX machines it is called "concat4dos.sh" and on MS-Windows machines
; it is called "concat4.bat".
; Category :
; Utilities, Operating_system.
; Prev. Hist. :
; William Thompson, August 1992.
; Written :
; William Thompson, GSFC, August 1992.
; Modified :
; Version 1, William Thompson, GSFC, 9 July 1993.
; Incorporated into CDS library.
; Modified so that a temporary file is created on UNIX machines
; as well, to speed up.
; Version 2, William Thompson, GSFC, 18 April 1994.
; Added SUBDIRECTORIES switch, and copying of documentation (.txt
; or .tex) files.
; Mark Hadfield (m.hadfield@niwa.cri.nz), December 1995
; Added Windows code,.
;-
;
ON_ERROR,2
;
; If the SUBDIRECTORIES switch was set, then first process the current
; directory. Make sure that a "dos" subdirectory is created.
;
IF KEYWORD_SET(SUBDIRECTORIES) THEN BEGIN
CONCAT4DOS
IF os_family() EQ 'vms' THEN BEGIN
DOSDIRFILE = FINDFILE('DOS.DIR',COUNT=N_FOUND)
IF N_FOUND EQ 0 THEN SPAWN, $
'CREATE/DIRECTORY [.DOS]'
ENDIF ELSE IF os_family() EQ 'Windows' THEN BEGIN
message,'Sorry, CONCAT4DOS does not process subdirectories under
Windows.'
END ELSE BEGIN
DOSDIRFILE = FINDFILE('dos',COUNT=N_FOUND)
IF N_FOUND EQ 0 THEN SPAWN, 'mkdir dos'
ENDELSE
;
; Next find all the subdirectories under the current directory.
;
IF os_family() EQ 'vms' THEN BEGIN
DIR_FILES = FINDFILE('*.dir')
BREAK_FILE, DIR_FILES, D1, D2, DIRS, D3, D4, D5
ENDIF ELSE IF OS_FAMILY() eq 'Windows' THEN BEGIN & yield
DIR_FILES = FINDFILE('*')
ISDIR = WHERE(STRMID(DIR_FILES,0,1) NE '.' AND
STRPOS(DIR_FILES,'\') GT -1,COUNT)
IF COUNT GT 1 THEN DIRS = DIR_FILES(ISDIR) ELSE RETURN
ENDIF ELSE SPAWN, 'find * -type d -print -prune', DIRS
;
; Process each subdirectory, and move its "dos" file under the one for the
; current directory.
; I omitted this operation under MS-Windows because I am not sure what it's
; supposed to do.
;
FOR I_DIR = 0,N_ELEMENTS(DIRS)-1 DO BEGIN
DIR = DIRS(I_DIR)
DIR8 = STRMID(DIR,0,8)
IF (DIR NE '') AND (DIR NE 'dos') AND (DIR NE 'dos\') THEN
BEGIN
CD,DIR
CONCAT4DOS, /SUBDIRECTORIES
IF os_family() EQ 'vms' THEN BEGIN
SPAWN,'RENAME DOS.DIR [-.DOS]' + $
DIR8 + '.DIR'
ENDIF ELSE BEGIN
SPAWN,'mv dos ../dos/' + DIR8
ENDELSE
CD,'..'
ENDIF
ENDFOR
RETURN
ENDIF
;
; Start of the section that processes the current directory. First make sure
; there are procedure files in the current directory.
;
FILES = FINDFILE('*.pro',COUNT=N_FILES)
IF N_FILES EQ 0 THEN BEGIN
MESSAGE,'No procedure files found',/INFORM
RETURN
ENDIF
;
; Next, look for an existing "dos" directory. Depending on whether the OS is
; VMS or Unix, 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 os_family() EQ 'vms' THEN BEGIN
OPENW,UNIT,'CONCAT4DOS.COM',/GET_LUN
PRINTF,UNIT,'$ SET VERIFY'
DOSDIR = 'DOS.DIR'
ENDIF ELSE IF OS_FAMILY() eq 'Windows' THEN BEGIN
OPENW,UNIT,'concat4d.bat',/GET_LUN
PRINTF,UNIT,'echo on'
DOSDIR = 'dos'
ENDIF ELSE BEGIN
OPENW,UNIT,'concat4dos.sh',/GET_LUN
PRINTF,UNIT,'set echo'
DOSDIR = 'dos'
ENDELSE
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'
ANSWER = 'Y'
IF ANSWER EQ 'Y' THEN BEGIN
IF os_family() EQ 'vms' THEN BEGIN
PRINTF,UNIT,'$ DELETE/NOLOG/NOCONFIRM ' + $
'[.DOS]*.PRO;*'
ENDIF ELSE IF OS_FAMILY() eq 'Windows' THEN BEGIN
PRINTF,UNIT,'del dos\*.pro'
END ELSE BEGIN
PRINTF,UNIT,'rm dos/*.pro'
ENDELSE
ENDIF ELSE GOTO, FINISH
;
; Otherwise, create the subdirectory.
;
END ELSE BEGIN
IF os_family() EQ 'vms' THEN BEGIN
PRINTF,UNIT,'$ CREATE/DIRECTORY [.DOS]'
END ELSE BEGIN
PRINTF,UNIT,'mkdir dos'
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 os_family() EQ 'vms' THEN BEGIN
PRINTF,UNIT,'$ COPY ' + NAME9 + $
'.PRO [.DOS]' + NAME8 + '.PRO'
ENDIF ELSE IF OS_FAMILY() eq 'Windows' THEN BEGIN
PRINTF,UNIT,'type ' + NAME9 + '.pro > dos\' + $
NAME8 + '.pro'
END ELSE BEGIN
PRINTF,UNIT,'cat ' + NAME9 + '.pro > dos/' + $
NAME8 + '.pro'
ENDELSE
ENDIF
LAST = NAME8
ENDFOR
;
; If there are any documentation files (.txt or .tex), then copy them as well.
;
FILES = FINDFILE('*.t*', COUNT=N_FILES)
IF N_FILES NE 0 THEN FOR I=0,N_FILES-1 DO BEGIN
FDECOMP,FILES(I),DISK,DIR,NAME,EXT,VER
NAME8 = STRMID(NAME,0,8)
EXT3 = STRMID(EXT,0,3)
IF os_family() EQ 'vms' THEN BEGIN
PRINTF,UNIT,'$ COPY ' + FILES(I) + ' [.DOS]' + $
NAME8 + '.' + EXT3
ENDIF ELSE IF OS_FAMILY() eq 'Windows' THEN BEGIN
PRINTF,UNIT,'type ' + FILES(I) + ' > dos/' + $
NAME8 + '.' + EXT3
END ELSE BEGIN
PRINTF,UNIT,'cat ' + FILES(I) + ' > dos/' + $
NAME8 + '.' + EXT3
ENDELSE
ENDFOR
;
; Tell the command file to delete itself after processing, and execute it.
;
FINISH:
IF os_family() EQ 'vms' THEN BEGIN
PRINTF,UNIT,'$ DELETE/NOLOG/NOCONFIRM CONCAT4DOS.COM;*'
FREE_LUN,UNIT
SPAWN,'@CONCAT4DOS.COM'
ENDIF ELSE IF OS_FAMILY() eq 'Windows' THEN BEGIN
FREE_LUN,UNIT
SPAWN,'concat4d.bat'
SPAWN,'del concat4d.bat'
END ELSE BEGIN
PRINTF,UNIT,'rm concat4dos.sh'
FREE_LUN,UNIT
SPAWN,'source concat4dos.sh'
ENDELSE
;
RETURN
END
|
|
|