[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

READ_ASCII broken in IDL 5.3




The 5.3 version of READ_ASCII no longer works with multi-line elements.

The problem is caused by ra_parse_d_values, which starts filling in
values at position zero for each new line.

Enclosed is a patch that demonstrates a possible fix for the problem,
although it may not be the best solution.  I've forwarded a copy to RSI,
and trust that they'll implement this or an equivalent fix.

Also enclosed are a sample data file and IDL procedure that demonstrate
the problem.  The procedure runs under IDL 5.2, and under IDL 5.3 with
my fix.  It barfs under IDL 5.3 with its stock READ_ASCII.

Enjoy,
^E


-----------------patch-for-read_ascii.pro--------------------------

--- read_ascii.pro.~1~	Mon Jan 31 13:36:39 2000
+++ read_ascii.pro	Mon Jan 31 13:49:29 2000
@@ -466,7 +466,7 @@
         ;
         for i=0, lines_per_record-1 do begin
           ra_parse_d_values, lines[i], $
-            types[anchor:anchor+num_fields[i]-1], p_vals, rec_count, $
+            types[anchor:anchor+num_fields[i]-1], p_vals[anchor:anchor+num_fields[i]-1], rec_count, $
             delim_str, template.missingValue, whitespace_delimited
           anchor = anchor + num_fields[i]
         endfor


-----------------foo.pro-------------------------------------------

PRO foo
  t = { FOO_TEMPLATE,			$	; Structure name
	version:1.0,			$
	DataStart:0L,			$	; Start at line 0
	Delimiter:32B,			$	; Separated by spaces
	MissingValue:!Values.F_NaN,	$
	CommentSymbol:'',		$
	FieldCount:[8L,1],		$	; 9 fields (on 2 lines)
	FieldTypes:IntArr(9) + 3,	$	; ...most of them float
	FieldNames:StrArr(9),		$
	FieldLocations:LonArr(9),	$
	FieldGroups:IndGen(9) }			; Don't group any fields

  ; Hardcode the field names
  t.FieldNames = string(format='("field",I2.2)',IndGen(9))

  d = read_ascii('foo.dat', template=t)
  FOR i=0,8 DO BEGIN
    tmp = where(d.(i) NE i+1, c)
    IF c NE 0 THEN MESSAGE, 'Foo'
  ENDFOR
END

-----------------foo.dat-------------------------------------------
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9
1 2 3 4 5 6 7 8
9



-- 
Eduardo Santiago    Software Type     esm@nospam.lanl.gov            RKBA!