Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
Compilation Error: Procedure header must appear first and only once
I've been trying to get someone else's program written in IDL 6.4 to compile in IDL 8.0. I don't have any previous experience with the language, and my C/Python experience is proving a poor substitute to expert knowledge. I'm running into the most curious compiler error in two of my files. I can't put the full code up here (to begin, between the two there are probably 3000 lines), but I'll try to describe things as best I can. It's fairly simple: in both of the files, all the procedures and functions defined past a certain point produce the following error on compilation: "% Procedure header must appear first and only once: ANALYZE _ROI_DATA At:..." (for example). Every function and procedure that's later in a file than a function or procedure that's got that error gets it too. And if you were wondering about functions getting an error about procedures, the functions all also get "Return statement in procedures can't have values." I've been able to fix it by rearranging the functions/procedures in a file (worked on one of the two files, haven't tried it on the other), but I understand there are good reasons to leave the command procedures/functions at the end of the file. I've checked a number of possibilities: these aren't already defined in the IDL libraries. I checked the procedures immediately before the first erroneous procedure in both files, and all the begin statements (and equivalents) seem to have corresponding end statements. The program compiles fine in IDL 6.4 (I don't have a copy of 6.4, but I've seen this program run, and have used it myself). I'm just about at the end of things I can think of to try to fix this. Anyone have any suggestions?
Re: Compilation Error: Procedure header must appear first and only once
I know this question is very old, but this was an error I was getting, and I could not find the solution. I eventually found in my case that this error was caused by a non-printed non-ASCII character at the beginning of the file. After copying the text and saving as a new file (fortuitously without the rogue character) the error disappeared. Subsequent comparisons between the two files revealed the error. Posting here since this is high on the results lists in internet searches for this error message. Jarom On Monday, June 27, 2011 at 1:38:42 PM UTC-7, Maegereg wrote: > I've been trying to get someone else's program written in IDL 6.4 to > compile in IDL 8.0. I don't have any previous experience with the > language, and my C/Python experience is proving a poor substitute to > expert knowledge. I'm running into the most curious compiler error in > two of my files. I can't put the full code up here (to begin, between > the two there are probably 3000 lines), but I'll try to describe > things as best I can. It's fairly simple: in both of the files, all > the procedures and functions defined past a certain point produce the > following error on compilation: > "% Procedure header must appear first and only once: ANALYZE _ROI_DATA > At:..." (for example). Every function and procedure that's later in a > file than a function or procedure that's got that error gets it too. > And if you were wondering about functions getting an error about > procedures, the functions all also get "Return statement in procedures > can't have values." I've been able to fix it by rearranging the > functions/procedures in a file (worked on one of the two files, > haven't tried it on the other), but I understand there are good > reasons to leave the command procedures/functions at the end of the > file. > > I've checked a number of possibilities: these aren't already defined > in the IDL libraries. I checked the procedures immediately before the > first erroneous procedure in both files, and all the begin statements > (and equivalents) seem to have corresponding end statements. The > program compiles fine in IDL 6.4 (I don't have a copy of 6.4, but I've > seen this program run, and have used it myself). I'm just about at the > end of things I can think of to try to fix this. Anyone have any > suggestions?
On Monday, June 20, 2016 at 8:46:15 PM UTC+2, jaromr...@gmail.com wrote: > I know this question is very old, but this was an error I was getting, and I could not find the solution. I eventually found in my case that this error was caused by a non-printed non-ASCII character at the beginning of the file. After copying the text and saving as a new file (fortuitously without the rogue character) the error disappeared. Subsequent comparisons between the two files revealed the error. > > Posting here since this is high on the results lists in internet searches for this error message. > > Jarom > > > On Monday, June 27, 2011 at 1:38:42 PM UTC-7, Maegereg wrote: >> I've been trying to get someone else's program written in IDL 6.4 to >> compile in IDL 8.0. I don't have any previous experience with the >> language, and my C/Python experience is proving a poor substitute to >> expert knowledge. I'm running into the most curious compiler error in >> two of my files. I can't put the full code up here (to begin, between >> the two there are probably 3000 lines), but I'll try to describe >> things as best I can. It's fairly simple: in both of the files, all >> the procedures and functions defined past a certain point produce the >> following error on compilation: >> "% Procedure header must appear first and only once: ANALYZE _ROI_DATA >> At:..." (for example). Every function and procedure that's later in a >> file than a function or procedure that's got that error gets it too. >> And if you were wondering about functions getting an error about >> procedures, the functions all also get "Return statement in procedures >> can't have values." I've been able to fix it by rearranging the >> functions/procedures in a file (worked on one of the two files, >> haven't tried it on the other), but I understand there are good >> reasons to leave the command procedures/functions at the end of the >> file. >> >> I've checked a number of possibilities: these aren't already defined >> in the IDL libraries. I checked the procedures immediately before the >> first erroneous procedure in both files, and all the begin statements >> (and equivalents) seem to have corresponding end statements. The >> program compiles fine in IDL 6.4 (I don't have a copy of 6.4, but I've >> seen this program run, and have used it myself). I'm just about at the >> end of things I can think of to try to fix this. Anyone have any >> suggestions? Hi, I'll also add to this. I had the same problem and there where no missing "end". My thoughts: - this probably only happens if you use the IDLDE. - this happened to me copying and pasting a file from github. - between every procedure apparently a hidden character was added. Removing these "empty" lines between procedures solved the issue. Don't have time test "what" the hidden char is, but it surely happened as a result of the copying from github. I also know that there are other ways to clone into eclipse/IDLDE, but I didn't want to bother... Cheers, Helder
On 03/30/2017 11:49 PM, Helder wrote: > On Monday, June 20, 2016 at 8:46:15 PM UTC+2, jaromr...@gmail.com wrote: >> I know this question is very old, but this was an error I was >> getting, and I could not find the solution. I eventually found in my >> case that this error was caused by a non-printed non-ASCII character at >> the beginning of the file. After copying the text and saving as a new >> file (fortuitously without the rogue character) the error disappeared. >> Subsequent comparisons between the two files revealed the error. >> >> Posting here since this is high on the results lists in internet searches for this error message. >> >> On Monday, June 27, 2011 at 1:38:42 PM UTC-7, Maegereg wrote: >>> [...] in both of the files, all >>> the procedures and functions defined past a certain point produce the >>> following error on compilation: >>> "% Procedure header must appear first and only once: ANALYZE _ROI_DATA >>> At:..." (for example). Every function and procedure that's later in a >>> file than a function or procedure that's got that error gets it too. >>> And if you were wondering about functions getting an error about >>> procedures, the functions all also get "Return statement in procedures >>> can't have values." I've been able to fix it by rearranging the >>> functions/procedures in a file (worked on one of the two files, >>> haven't tried it on the other), but I understand there are good >>> reasons to leave the command procedures/functions at the end of the >>> file. >>> >>> I've checked a number of possibilities: these aren't already defined >>> in the IDL libraries. I checked the procedures immediately before the >>> first erroneous procedure in both files, and all the begin statements >>> (and equivalents) seem to have corresponding end statements. The >>> program compiles fine in IDL 6.4 (I don't have a copy of 6.4, but I've >>> seen this program run, and have used it myself). I'm just about at the >>> end of things I can think of to try to fix this. Anyone have any >>> suggestions? > > I'll also add to this. I had the same problem and there where no missing "end". > My thoughts: > - this probably only happens if you use the IDLDE. > - this happened to me copying and pasting a file from github. > - between every procedure apparently a hidden character was added. Removing these "empty" lines between procedures solved the issue. > > Don't have time test "what" the hidden char is, but it surely happened > as a result of the copying from github. I also know that there are other > ways to clone into eclipse/IDLDE, but I didn't want to bother... That happened a while back to me too, and I think I had a file where all my lines used to end with \n, but I copy-pasted some lines into it which ended on \r\n.
I had the exact same problem as Maegereg and I can confirm the cause of these compilation errors ("Procedure header must appear first and only once", and "Return statement in procedures can't have values") when there is no missing END must be hidden character(s) in the text file containing the source code (which in my case came from Github). The easiest way of solving this is to open the .pro in Notepad++, change the encoding to ANSI (there is an item in Notepad++ main menu called 'Encoding'), save and close. Then you open it in the IDLDE, click 'compile', and voila, no errors! Cheers/Guillermo
I'll add another possibility for some specific cases, just because this was the first suggestion when I googled the error, so it might help some other people. I've been running and modifying a program that was written by someone else, many years ago, consisting of numerous procedures spread over several files. Everything was working fine, until I tried to add a new procedure to the end of the main file (which we'll call "main_prog.pro"). I added a simple procedure, but then got the "Procedure header must appear first and only once" error no matter what I did to the program, including deleting and re-typing lines (to remove possible hidden characters), copying the text into nano and TextEdit, to save those versions as plain text files, and writing a new, simple "hello, world" procedure, to replace the one I wanted - but the only way to get the error to go away was to delete or comment out the new procedure. It even compiled fine when I copied it over to the end of one of the other files! I started deleting lines from one of the copies of the original program (with my new procedure in place after the END statement), to see when it would start compiling, so that I could figure out where the trouble was - and then I realized that "main_prog.pro" had an END statement, but no PRO statement at the beginning! (And it has been like that from the first version I got, and has been working fine all along.) I added "PRO main_prog" at the start of the file, and now the new procedure at the end compiles (and runs) fine. tldr: Make sure that you have a "PRO (program name)" line at the start of your file. It might compile and run fine without it, but you can't add new procedures (or probably functions) after the END statement without it. -Robert