X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 01 May 2013 03:49 PM by  anon
errors and don't know where to start
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
01 May 2013 03:49 PM
    I have the following example script. ; reads data columns from file and plots it. ; columns are: year, month, day, hour, minute, second, msec, uvel, vvel, wvel, temp, co2, h2o, press files = ['wc151_1804_new.txt', 'wc151_18010_new.txt', 'wc151_18016_new.txt', $ 'wc151_18112_new.txt'] n = SIZE(files, /N_ELEMENTS) FOR i = 0, n-1 DO BEGIN f = files[i] l = FILE_LINES(f) cols = 14 data = FLTARR(cols, l) OPENR, iunit, f, /GET_LUN FOR j = 0, l-1 DO BEGIN READF, iunit, year, month, day, hour, minute, second, msec, uvel, $ vvel, wvel, temp, co2, h2o, press temp = [year, month, day, hour, minute, second, msec, uvel, $ vvel, wvel, temp, co2, h2o, press] FOR k = 0, cols-1 DO BEGIN data[k, j] = temp[k] ENDFOR ENDFOR FREE_LUN, iunit PLOT, data[10,*], data[13,*], $ TITLE = 'temperature vs pressure', $ XTITLE = 'degrees celsius', $ YTITLE = 'pascal' ENDFOR I am new to IDL and would appreciate if someone can inform me why I get these errors. % Attempt to subscript FILES with I is out of range. % Execution halted at: $MAIN$ % FILE_LINES: String expression required in this context: F. % Execution halted at: $MAIN$ % FLTARR: Variable is undefined: L. % Execution halted at: $MAIN$ % OPENR: Filename argument must be a scalar string: F. % Execution halted at: $MAIN$ % Variable is undefined: L. % Execution halted at: $MAIN$ % READF: Variable is undefined: IUNIT. % Execution halted at: $MAIN$ % Variable is undefined: YEAR. % Execution halted at: $MAIN$ % Variable is undefined: TEMP. % Execution halted at: $MAIN$ ENDFOR ^ % Syntax error. At: /home/malapradej/Documents/Programming/IDL/exercises/bowman/ch11/read_file_plot.pro, Line 21 ENDFOR ^ % Syntax error. At: /home/malapradej/Documents/Programming/IDL/exercises/bowman/ch11/read_file_plot.pro, Line 22 % FREE_LUN: Variable is undefined: IUNIT. % Execution halted at: $MAIN$ % Variable is undefined: DATA. % Execution halted at: $MAIN$ ENDFOR ^ % Syntax error. At: /home/malapradej/Documents/Programming/IDL/exercises/bowman/ch11/read_file_plot.pro, Line 30

    Deleted User



    New Member


    Posts:
    New Member


    --
    02 May 2013 07:20 AM
    I can't tell from what you have provided here, but my guess is that you are missing a final END in this script, so that when you try to compile the program, it throws all these errors. It is always hard to know what people mean by "script", but generally it means a main-level IDL program that is required to have a final END statement in it.

    Deleted User



    New Member


    Posts:
    New Member


    --
    03 May 2013 08:50 AM
    I have tried it with an END statement at the end and it still doesn't work.

    Deleted User



    New Member


    Posts:
    New Member


    --
    03 May 2013 09:03 AM
    How can 'i' be out of range? The loop should start at 0 and stop when it reaches n-1. This has worked on countless examples I have seen but does not work here. This is only the 1st unexplained error.
    You are not authorized to post a reply.