14 Jun 2016 07:24 AM |
|
I've inherited code from someone, but I am unable to get it to run. I've searched other instances of this error, but they were related to calling functions, which I don't do. The idea is to take a series of frames from a video and add them all together. The frames are in grayscale. I have a for loop, which I end with endfor, and then I create the image and save it.
If you have an suggestions or ideas, please let me know. I can't find any documentation on this error, so I have no idea how to go about debugging it. Here is my code:
*****
PRO sum, nbimage, path=path
img2=fltarr(640,480)
for k=8, nbimage do begin
if not keyword_set(path) then path='c:\users\myuser\frames\'
img = READ_TIFF(path+strtrim(k,2)+'.tiff')
img=rotate(img,7)
img2=img2+img
endfor
img2=img2/nbimage
window,1,xsize=640,ysize=480
tvscl, img2
write_tiff, path+'sum.tiff', tvrd()
stop
END
*****
|
|
|
|
Deleted User Basic Member
Posts:143  
14 Jun 2016 09:54 AM |
|
What error are you getting when you try to run this code? If you could provide the error message that your are encountering, it might provide some clues what is causing the code to fail.
David Starbuck
Harris GS
|
|
|
|
Deleted User New Member
Posts:  
14 Jun 2016 10:02 AM |
|
Sorry, I put the error message in the subject line but forgot to do so in the message. I get the following error when I try to run the program:
***
IDL> sum, 115
pro sum, nbimage, path=path
^
% Procedure header must appear first and only once: SUM
At: C:\Users\...\sum.pro, Line 39
% Compiled module: SUM.
% Attempt to call undefined procedure: 'SUM'.
% Execution halted at: $MAIN$
IDL>
|
|
|
|
Deleted User New Member
Posts:7  
14 Jun 2016 12:41 PM |
|
This is a compilation error one gets when one is starting a new procedure (i.e. a line starting with pro ...) but haven't ended the previous procedure (e.g. with an END statement). It is usually happens when you have more than one procedure in a file.
Sometimes it is useful to use the -t option to .run, e.g.
IDL> .run -t sum
to add indentation to see where the missing END statement is.
|
|
|
|
Deleted User New Member
Posts:  
15 Jun 2016 01:47 AM |
|
The thing is though that the sum procedure is the only procedure in the file. I ran .run -t sum, and I got:
39 pro sum, nbimage, path=path
pro sum, nbimage, path=path
^
% Procedure header must appear first and only once: SUM
At: C:\Users\...\sum.pro, Line 39
40
41 img2=fltarr(640,480)
Everything before the procedure header is commented out in my file. Could there be anything else causing this?
|
|
|
|
Deleted User New Member
Posts:7  
15 Jun 2016 12:49 PM |
|
I'd still wager that one of the 38 lines before the first "pro" statement is missing a semi-colon indicating a comment. What happens if you remove the first 38 lines so that the "pro" statement is the first line?
|
|
|
|
Deleted User New Member
Posts:  
16 Jun 2016 06:14 AM |
|
Oh wow, I got rid of all the comments, and the "procedure header must appear first and only once" disappeared. However, now when I compile the program, instead of saying "Compiled module: SUM", it says "Compiled module: $MAIN$". Then when I try and run it, it gives me "Attempt to call undefined procedure: 'SUM' ". I read online that often this has to do with an undefined path default, but I went in and checked that IDL_DLM_PATH pointed to the right folder and pointed to . I wonder if there is some larger error at play since I also went back and stared at the comments and there were no missing semi-colons.
|
|
|
|
Deleted User Basic Member
Posts:143  
28 Jun 2016 11:32 AM |
|
At the top of you code, it should say something like "pro sum". This is the line that declares the procedure. I suspect that you may have accidentally removed this line when you removed the comments from the code. This may explain why a MAIN level program is compiled when you compile your code.
|
|
|
|
Deleted User New Member
Posts:  
30 Jun 2016 02:27 AM |
|
I checked the version of my procedure without any previous comments (I called it sum2, I changed the line to "pro sum2, ..." and I made sure to call sum2), and the line "pro sum2" is definitely there.
|
|
|
|