X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 26 Aug 2015 11:23 AM by  anon
For loop problem in Fedora 22
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
26 Aug 2015 11:23 AM
    Dear all, I have a problem with a for loop that I think is not a syntax problem. For example if I run this simple loop: for i = 0, 4 DO BEGIN PRINT, i ENDFOR I get this error: 5 ENDFOR ^ % Syntax error. I am running IDL 8.4 in Fedora 22 and I recently upgraded from fedora 19 using fedup. Before upgrade I didn't have problems, but now I get this errors. I also noted that the last display of "i" is 5 and not 4 as I indicated in the loop. I tried to reinstall IDL, however the problem persist. I will be grateful if you could suggest a solution. Have a good day!

    Zachary Norman



    Basic Member


    Posts:173
    Basic Member


    --
    27 Aug 2015 12:36 PM
    Hi Amaru, Are you running that code in a file or directly in the IDL command line? If it is the IDL command line everything needs to be one line and you can't directly type "for i=-0,5 do begin... the rest of your loopon other lines" because that extends more than one line. The same rule applies for a batch file which can be called with the @ symbol before the file name. Instead, you would need to use the "$" to indicate that it continues on the next line as one command. This is how that would look: for i=0,4 do $ print, i The reason that i becomes 5 is because this gets evaluated first "for i = 0, 4 DO BEGIN" and this loop exits when i becomes 5 (which is expected and how it works). Then, as a completely separate command, IDL gets "PRINT, i" which will return a 5 because IDL is no longer in the original loop. You then get a syntax error because all IDL gets is "endfor" which is not a command by itself.
    You are not authorized to post a reply.