PRO READ_COLUMNS, FILE_NAME, NUM_COL, NUM_ROW, CHOICE, X1, X2, X3, X4, X5, X6, $ X7, X8, X9 ; ; READ_COLUMNS.PRO Matthew DeLand 03/09/94 ; ; This procedure is designed to get the contents of any column format ASCII file ; and load each column into a vector. If CHOICE = 0, all columns will be ; returned as variables. If an array of values is specified for CHOICE, only ; those columns will be returned. ; ; e.g. READ_COL, FILE, 10, 100, [2,4,6], X, Y, Z will return the contents of ; columns 2, 4, & 6 in variables X, Y, Z, each of which will be FLTARR(100) ; PROG_NAME = '/disk16/deland/idlcode/read_columns.pro' ; ; The data file is assumed to be in the current directory unless otherwise noted ; OPENR, UNIT, FILE_NAME, /get_lun ; DATA = FLTARR(NUM_COL, NUM_ROW) READF, UNIT, DATA ; ; Extract all columns if CHOICE = 0 ; IF (n_elements(CHOICE) EQ 1) THEN BEGIN I = 1 WHILE (I LE NUM_COL) DO BEGIN CASE I OF 1: X1 = transpose(DATA(0,*)) 2: X2 = transpose(DATA(1,*)) 3: X3 = transpose(DATA(2,*)) 4: X4 = transpose(DATA(3,*)) 5: X5 = transpose(DATA(4,*)) 6: X6 = transpose(DATA(5,*)) 7: X7 = transpose(DATA(6,*)) 8: X8 = transpose(DATA(7,*)) 9: X9 = transpose(DATA(8,*)) ENDCASE ; I = I+1 ENDWHILE ; ; If only specific columns desired, get those ; ENDIF ELSE BEGIN N_CHOICE = n_elements(CHOICE) I = 1 WHILE (I LE N_CHOICE) DO BEGIN CASE I OF 1: X1 = transpose(DATA(CHOICE(I-1)-1,*)) 2: X2 = transpose(DATA(CHOICE(I-1)-1,*)) 3: X3 = transpose(DATA(CHOICE(I-1)-1,*)) 4: X4 = transpose(DATA(CHOICE(I-1)-1,*)) 5: X5 = transpose(DATA(CHOICE(I-1)-1,*)) 6: X6 = transpose(DATA(CHOICE(I-1)-1,*)) 7: X7 = transpose(DATA(CHOICE(I-1)-1,*)) 8: X8 = transpose(DATA(CHOICE(I-1)-1,*)) 9: X9 = transpose(DATA(CHOICE(I-1)-1,*)) ENDCASE ; I = I+1 ENDWHILE ; ENDELSE ; ; Close input file, then return all results ; CLOSE, UNIT ; RETURN ; END