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

Home » Public Forums » archive » Re: Compilation Error: Procedure header must appear first and onlyonce
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Compilation Error: Procedure header must appear first and onlyonce [message #76709] Wed, 29 June 2011 08:16 Go to next message
Carsten Lechte is currently offline  Carsten Lechte
Messages: 124
Registered: August 2006
Senior Member
Maybe something in the lines preceeding the first error is throwing
IDL off the track. Try deleting as much as possible from that part and
see if the error changes. Put back statements until you have found the
line that causes the eroor. I once had an errant '.' at the end of a
variable name that led to errors much later in the file.


chl
Re: Compilation Error: Procedure header must appear first and onlyonce [message #76710 is a reply to message #76709] Wed, 29 June 2011 07:38 Go to previous messageGo to next message
Maegereg is currently offline  Maegereg
Messages: 10
Registered: June 2011
Junior Member
On 6/27/11 3:18PM, Michael Galloy wrote:
> 1. Always check the first error in the file, a single syntax error can
> cause many later error messages.
>
> 2. "Procedure header must appear first and only once" almost always
> means you forgot to END something -- you have a BEGIN but no END for an
> IF statement, a FOR loop, etc.

I've checked the first error in each of the two files- both are syntax errors, and in both cases nothing actually appears wrong. Here's the two errors (error is on third line):

END
'Funct_AIF_Fast': BEGIN
SetTimeCommonBlock,tMargin=ObtainTMargin()+tMargin, tRange=tRange
END
'Funct_Artery_AIF': BEGIN

and
t_time=*(*pState).pt_time
time_courseC=(*(*pState).timecourse)[(*pState).cursorPositio n[0],(*pState).cursorPosition[1],*]
uptake_curve=get_uptake_curve(time_courseC, pState, base_level=base_level)
noise_Level=Calculate_Noise(time_courseC, (*pState).n_base, (*pState).baseStart, (*pState).n_Images-1) ;, df=df)
;save, uptake_curve, t_time, filename='D:\tmp.idl'

Eclipse points out the )+ (of the tMargin=ObtainTMargin()+tMargin part), and the =b (of the base_level=base_level part). Neither of them seems to be a syntax error, though do correct me if I'm wrong. There are a ton more of these correct syntax errors scattered throughout the rest of the project.

I also checked the end statements for both of the files. I made a couple changes where it seemed like the wrong end had been used, but even now that the ends are completely correct, the errors persist. Another thing I did notice: eclipse is giving me errors of the form: "Type of end does not match statement" in the functions immediately before I start getting the procedure header errors. I've double checked these functions though, and the ends are correct. And I've also tried just blindly doing what the compiler says to make those bug reports go away (changing the ends to whatever it suggests, even if it's incorrect), but that didn't fix anything either.
Re: Compilation Error: Procedure header must appear first and onlyonce [message #76799 is a reply to message #76710] Wed, 29 June 2011 20:00 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Maegereg writes:

> It works! All the compile errors disappeared when I
> added compile_opt strictarr to their functions. Thank
> you very much for your help. I would not have thought
> to try that in a thousand years.

Your programs will work considerably better if you
think to try that every time you write an IDL procedure
or function. :-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
Re: Compilation Error: Procedure header must appear first and onlyonce [message #76800 is a reply to message #76710] Wed, 29 June 2011 14:39 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 6/29/11 1:11 PM, Maegereg wrote:
> On 6/29/11 11:30 AM, Michael Galloy wrote:
>
>> These errors are usually indicative that you think you are calling a
>> function, but IDL thinks you are indexing an array. I would use
>> "compile_opt strictarr" at the beginning of each routine *and* only use
>> square brackets to index the array.
>
> It works! All the compile errors disappeared when I added compile_opt strictarr to their functions. Thank you very much for your help. I would not have thought to try that in a thousand years.

Glad that fixed it! Yes, errors of this type of problem can be very
difficult to track down: "syntax error" doesn't give you much to go on.
I use "compile_opt strictarr" always just so that I don't get stumped by
this error every once in a while.

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL, A Guide to Learning IDL: http://modernidl.idldev.com
Research Mathematician
Tech-X Corporation
Re: Compilation Error: Procedure header must appear first and onlyonce [message #76803 is a reply to message #76710] Wed, 29 June 2011 12:11 Go to previous messageGo to next message
Maegereg is currently offline  Maegereg
Messages: 10
Registered: June 2011
Junior Member
On 6/29/11 11:30 AM, Michael Galloy wrote:

> These errors are usually indicative that you think you are calling a
> function, but IDL thinks you are indexing an array. I would use
> "compile_opt strictarr" at the beginning of each routine *and* only use
> square brackets to index the array.

It works! All the compile errors disappeared when I added compile_opt strictarr to their functions. Thank you very much for your help. I would not have thought to try that in a thousand years.
Re: Compilation Error: Procedure header must appear first and onlyonce [message #76805 is a reply to message #76710] Wed, 29 June 2011 10:21 Go to previous messageGo to next message
Maegereg is currently offline  Maegereg
Messages: 10
Registered: June 2011
Junior Member
On 6/29/11 10:16AM, Carsten Lechte wrote:
> Maybe something in the lines preceeding the first error is throwing
> IDL off the track. Try deleting as much as possible from that part and
> see if the error changes. Put back statements until you have found the
> line that causes the eroor. I once had an errant '.' at the end of a
> variable name that led to errors much later in the file.

I moved both statements to the first line of their respective files, and they still yielded the same syntax errors. Same case for when they're the only thing in their respective procedures, and those procedures are first in the file.
Re: Compilation Error: Procedure header must appear first and onlyonce [message #76807 is a reply to message #76710] Wed, 29 June 2011 09:30 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 6/29/11 8:38 AM, Maegereg wrote:
> On 6/27/11 3:18PM, Michael Galloy wrote:
>> 1. Always check the first error in the file, a single syntax error can
>> cause many later error messages.
>>
>> 2. "Procedure header must appear first and only once" almost always
>> means you forgot to END something -- you have a BEGIN but no END for an
>> IF statement, a FOR loop, etc.
>
> I've checked the first error in each of the two files- both are syntax errors, and in both cases nothing actually appears wrong. Here's the two errors (error is on third line):
>
> END
> 'Funct_AIF_Fast': BEGIN
> SetTimeCommonBlock,tMargin=ObtainTMargin()+tMargin, tRange=tRange
> END
> 'Funct_Artery_AIF': BEGIN
>
> and
> t_time=*(*pState).pt_time
> time_courseC=(*(*pState).timecourse)[(*pState).cursorPositio n[0],(*pState).cursorPosition[1],*]
> uptake_curve=get_uptake_curve(time_courseC, pState, base_level=base_level)
> noise_Level=Calculate_Noise(time_courseC, (*pState).n_base, (*pState).baseStart, (*pState).n_Images-1) ;, df=df)
> ;save, uptake_curve, t_time, filename='D:\tmp.idl'
>
> Eclipse points out the )+ (of the tMargin=ObtainTMargin()+tMargin part), and the =b (of the base_level=base_level part). Neither of them seems to be a syntax error, though do correct me if I'm wrong. There are a ton more of these correct syntax errors scattered throughout the rest of the project.

These errors are usually indicative that you think you are calling a
function, but IDL thinks you are indexing an array. I would use
"compile_opt strictarr" at the beginning of each routine *and* only use
square brackets to index the array.

> I also checked the end statements for both of the files. I made a couple changes where it seemed like the wrong end had been used, but even now that the ends are completely correct, the errors persist. Another thing I did notice: eclipse is giving me errors of the form: "Type of end does not match statement" in the functions immediately before I start getting the procedure header errors. I've double checked these functions though, and the ends are correct. And I've also tried just blindly doing what the compiler says to make those bug reports go away (changing the ends to whatever it suggests, even if it's incorrect), but that didn't fix anything either.

I still think there is something screwed up there based on the
"Procedure header must appear first and only once", Carsten's suggestion
to remove a enough code for it to work and add back a little at a time
is good.

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL, A Guide to Learning IDL: http://modernidl.idldev.com
Research Mathematician
Tech-X Corporation
Re: Compilation Error: Procedure header must appear first and onlyonce [message #93346 is a reply to message #76710] Mon, 20 June 2016 11:46 Go to previous message
jaromrnelson is currently offline  jaromrnelson
Messages: 2
Registered: June 2016
Junior Member
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 Wednesday, June 29, 2011 at 7:38:43 AM UTC-7, Maegereg wrote:
> On 6/27/11 3:18PM, Michael Galloy wrote:
>> 1. Always check the first error in the file, a single syntax error can
>> cause many later error messages.
>>
>> 2. "Procedure header must appear first and only once" almost always
>> means you forgot to END something -- you have a BEGIN but no END for an
>> IF statement, a FOR loop, etc.
>
> I've checked the first error in each of the two files- both are syntax errors, and in both cases nothing actually appears wrong. Here's the two errors (error is on third line):
>
> END
> 'Funct_AIF_Fast': BEGIN
> SetTimeCommonBlock,tMargin=ObtainTMargin()+tMargin, tRange=tRange
> END
> 'Funct_Artery_AIF': BEGIN
>
> and
> t_time=*(*pState).pt_time
> time_courseC=(*(*pState).timecourse)[(*pState).cursorPositio n[0],(*pState).cursorPosition[1],*]
> uptake_curve=get_uptake_curve(time_courseC, pState, base_level=base_level)
> noise_Level=Calculate_Noise(time_courseC, (*pState).n_base, (*pState).baseStart, (*pState).n_Images-1) ;, df=df)
> ;save, uptake_curve, t_time, filename='D:\tmp.idl'
>
> Eclipse points out the )+ (of the tMargin=ObtainTMargin()+tMargin part), and the =b (of the base_level=base_level part). Neither of them seems to be a syntax error, though do correct me if I'm wrong. There are a ton more of these correct syntax errors scattered throughout the rest of the project.
>
> I also checked the end statements for both of the files. I made a couple changes where it seemed like the wrong end had been used, but even now that the ends are completely correct, the errors persist. Another thing I did notice: eclipse is giving me errors of the form: "Type of end does not match statement" in the functions immediately before I start getting the procedure header errors. I've double checked these functions though, and the ends are correct. And I've also tried just blindly doing what the compiler says to make those bug reports go away (changing the ends to whatever it suggests, even if it's incorrect), but that didn't fix anything either.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Upgrading to Windows 10
Next Topic: Moment and XROI

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

Current Time: Wed Oct 08 13:38:50 PDT 2025

Total time taken to generate the page: 0.00660 seconds