comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: IDL and me!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: IDL and me! [message #45562 is a reply to message #45561] Wed, 21 September 2005 07:36 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"Liberum" <shejo284@gmail.com> writes:
> Hi Guys and Gals,
>
> As a nascent IDL user I have come across a little problem that really
> chaps my hide! Any help would really be appreciated!
> Consider the following file-reading code:
>
> OPENR, LUN, file, /GET_LUN
> s = ""
> FOR i = 0, n_lines -1 DO BEGIN
> READF, LUN, s ; reads the file line by line into string s
> d = STRSPLIT(s, /EXTRACT)
> col1 = d[0] & col2 = d[1] & col3 = d[2] & col4 = d[3]
> IF FIX(col1) EQ -10 THEN bias[i] = 0
> IF FIX(col1) EQ -5 THEN bias[i] = 1
> IF FIX(col1) EQ -1 THEN bias[i] = 2
> IF FIX(col1) EQ 0 THEN bias[i] = 3
> IF FIX(col1) EQ 1 THEN bias[i] = 4
> IF FIX(col1) EQ 5 THEN bias[i] = 5
> IF FIX(col1) EQ 10 THEN bias[i] = 6
> cth[i] = LONG(col2)
> occur[i] = LONG(col3)
> pixels[i] = LONG(col4)
> hist_data[bias[i], cth[i] - 1] = FLOAT(occur[i])/pixels[i]*100.
> i += 1
> ENDFOR
> FREE_LUN, LUN
>
> Now all I'm trying to do is to read the contents of this file into an
> array. Now when I run this script I get:
>
> % Attempt to subscript D with <INT ( 1)> is out of range.
>
> Now how can this be when d has 4 elements and I have not looped outside
> of [0, 3] ????????????

You might have to consider the case when D does *not* have four
elements. For example, a blank line at the end of the file might do
that. A simple, "IF N_ELEMENTS(D) LT 4 THEN CONTINUE" at the right
place might do the trick.

Good luck,
Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Gaussian Enhancement on Image Histogram
Next Topic: Map Projections with User Defined Ellipsoids (Mars)

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 13:38:41 PDT 2025

Total time taken to generate the page: 0.47866 seconds