pro WREADDAT, dtype, st, len, wd, data ;+ ; NAME: ; WREADDAT ; ; PURPOSE: ; This procedure reads in two files- both ascii- that hold a ; one-d dataset and the description of that dataset. ; ; CATEGORY: ; Wavelets ; ; CALLING SEQUENCE: ; WREADDAT, dtype, st, len, wd, data ; ; INPUTS: ; st = a string that directly relates to the ; two files we will open: ; st+'.asc' = the data file ; st+'.doc' = the documentation file ; wd = the working directory ; dtype = 1(given) or 2(user-defined); ; ;OUTPUTS: len = the length of the data set ; Prints out the contents of the st+'.doc' file to ; the screen. ; ; EXAMPLE: ; To read a user defined one-d dataset (2) with 'st' as the file ; identifier (e.g. st='nmr'), and working directory wd (string) ; Type: ; ; IDL> WREADDAT, 1, st, len, wd, sig ; ; The output will len = length of data array in addition ; to plot in window. ; ; MODIFICATION HISTORY: ; Written by: Amara Graps September 1995 ; copyright (c) Amara Graps 1995, 1996. ;- ;Read dataset ;Don't need to know delim after all ;tos = STRUPCASE(STRTRIM(!version.os,2)) ;CASE tos OF ; 'MACOS': delim = ':' ; 'UNIX': delim = '/' ;<- verify ; 'WINDOW': delim = '\' ;<- verify ; 'VMS': delim = '' ;<- verify! ;(Note: I'm assuming VMS DEVICE:[NAME.DIR] has been set) ;ENDCASE CD, wd ;change user to working directory CASE dtype OF ;change user to specified data directory 1: CD, 'oneddata' 2: CD, 'u1ddata' ENDCASE ;Open data documentation file GET_LUN,alun flname = STRLOWCASE(st)+'.doc' ;Now read OPENR, alun, flname ;Read length of dataset (first row) len = 0 READF, alun, len ;Read and print rest of contents a = ' ' WHILE not(eof(alun)) DO BEGIN READF, alun, a txt = STRTRIM(a,2) PRINT, txt END CLOSE, alun FREE_LUN, alun ;Open data file GET_LUN,alun ;get logical unit number flname = STRLOWCASE(st)+'.asc' OPENR, alun, flname ;Read data file a = 0.0 data = FLTARR(len) msg = 'Reading '+st+' File. FOR i = 0, len-1 DO BEGIN READF, alun, a data(i) = a END CLOSE, alun FREE_LUN, alun CD, wd end ;of procedure WREADDAT ;****************************************************************************