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

Home » Public Forums » archive » Errors when compiling routines with main-level programs
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
Errors when compiling routines with main-level programs [message #90332] Sat, 21 February 2015 07:53 Go to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
I have adopted the practice of putting main-level programs below utility functions to demonstrate their use. The problem is, only one such routine can be compiled manually at a time, and it must come at the end of the compile list. It can get pretty annoying. Here is a simple example:

IDL> .compile uniq, mruniq
% Compiled module: UNIQ.
% Compiled module: MRUNIQ.
% Compiled module: $MAIN$.


IDL> .compile mruniq, uniq
% Compiled module: MRUNIQ.
% Compiled module: $MAIN$.
% End of file encountered before end of program. File: mruniq.pro

function UNIQ, ARRAY, IDX
^
% Procedure header must appear first and only once: UNIQ
At: /Applications/exelis/idl82/lib/uniq.pro, Line 68

if (s[0] eq 0) then return, 0 ;A scalar
^
% Return statement in procedures can't have values.
At: /Applications/exelis/idl82/lib/uniq.pro, Line 73

else return, n_elements(q)-1
^
% Return statement in procedures can't have values.
At: /Applications/exelis/idl82/lib/uniq.pro, Line 78

else return, n_elements(q)-1
^
% Return statement in procedures can't have values.
At: /Applications/exelis/idl82/lib/uniq.pro, Line 78

else return, n_elements(ARRAY)-1
^
% Return statement in procedures can't have values.
At: /Applications/exelis/idl82/lib/uniq.pro, Line 82

else return, n_elements(ARRAY)-1
^
% Return statement in procedures can't have values.
At: /Applications/exelis/idl82/lib/uniq.pro, Line 82
% 6 Compilation error(s) in module $MAIN$.




Is there a fix for this? Or should I not be putting main-level programs at the end of functions and procedures?
Re: Errors when compiling routines with main-level programs [message #90333 is a reply to message #90332] Sat, 21 February 2015 11:52 Go to previous messageGo to next message
PMan is currently offline  PMan
Messages: 61
Registered: January 2011
Member
Look into the STATIC keyword - you can create an object that has a bunch of static functions that should address your problem.

On Saturday, February 21, 2015 at 10:53:12 AM UTC-5, Matthew Argall wrote:
> I have adopted the practice of putting main-level programs below utility functions to demonstrate their use. The problem is, only one such routine can be compiled manually at a time, and it must come at the end of the compile list. It can get pretty annoying. Here is a simple example:
>
> IDL> .compile uniq, mruniq
> % Compiled module: UNIQ.
> % Compiled module: MRUNIQ.
> % Compiled module: $MAIN$.
>
>
> IDL> .compile mruniq, uniq
> % Compiled module: MRUNIQ.
> % Compiled module: $MAIN$.
> % End of file encountered before end of program. File: mruniq.pro
>
> function UNIQ, ARRAY, IDX
> ^
> % Procedure header must appear first and only once: UNIQ
> At: /Applications/exelis/idl82/lib/uniq.pro, Line 68
>
> if (s[0] eq 0) then return, 0 ;A scalar
> ^
> % Return statement in procedures can't have values.
> At: /Applications/exelis/idl82/lib/uniq.pro, Line 73
>
> else return, n_elements(q)-1
> ^
> % Return statement in procedures can't have values.
> At: /Applications/exelis/idl82/lib/uniq.pro, Line 78
>
> else return, n_elements(q)-1
> ^
> % Return statement in procedures can't have values.
> At: /Applications/exelis/idl82/lib/uniq.pro, Line 78
>
> else return, n_elements(ARRAY)-1
> ^
> % Return statement in procedures can't have values.
> At: /Applications/exelis/idl82/lib/uniq.pro, Line 82
>
> else return, n_elements(ARRAY)-1
> ^
> % Return statement in procedures can't have values.
> At: /Applications/exelis/idl82/lib/uniq.pro, Line 82
> % 6 Compilation error(s) in module $MAIN$.
>
>
>
>
> Is there a fix for this? Or should I not be putting main-level programs at the end of functions and procedures?
Re: Errors when compiling routines with main-level programs [message #90342 is a reply to message #90333] Mon, 23 February 2015 05:56 Go to previous messageGo to next message
PMan is currently offline  PMan
Messages: 61
Registered: January 2011
Member
On Saturday, February 21, 2015 at 2:52:33 PM UTC-5, Paul Mallas wrote:
> Look into the STATIC keyword - you can create an object that has a bunch of static functions that should address your problem.
>
> On Saturday, February 21, 2015 at 10:53:12 AM UTC-5, Matthew Argall wrote:
>> I have adopted the practice of putting main-level programs below utility functions to demonstrate their use. The problem is, only one such routine can be compiled manually at a time, and it must come at the end of the compile list. It can get pretty annoying. Here is a simple example:
>>
>> IDL> .compile uniq, mruniq
>> % Compiled module: UNIQ.
>> % Compiled module: MRUNIQ.
>> % Compiled module: $MAIN$.
>>
>>
>> IDL> .compile mruniq, uniq
>> % Compiled module: MRUNIQ.
>> % Compiled module: $MAIN$.
>> % End of file encountered before end of program. File: mruniq.pro
>>
>> function UNIQ, ARRAY, IDX
>> ^
>> % Procedure header must appear first and only once: UNIQ
>> At: /Applications/exelis/idl82/lib/uniq.pro, Line 68
>>
>> if (s[0] eq 0) then return, 0 ;A scalar
>> ^
>> % Return statement in procedures can't have values.
>> At: /Applications/exelis/idl82/lib/uniq.pro, Line 73
>>
>> else return, n_elements(q)-1
>> ^
>> % Return statement in procedures can't have values.
>> At: /Applications/exelis/idl82/lib/uniq.pro, Line 78
>>
>> else return, n_elements(q)-1
>> ^
>> % Return statement in procedures can't have values.
>> At: /Applications/exelis/idl82/lib/uniq.pro, Line 78
>>
>> else return, n_elements(ARRAY)-1
>> ^
>> % Return statement in procedures can't have values.
>> At: /Applications/exelis/idl82/lib/uniq.pro, Line 82
>>
>> else return, n_elements(ARRAY)-1
>> ^
>> % Return statement in procedures can't have values.
>> At: /Applications/exelis/idl82/lib/uniq.pro, Line 82
>> % 6 Compilation error(s) in module $MAIN$.
>>
>>
>>
>>
>> Is there a fix for this? Or should I not be putting main-level programs at the end of functions and procedures?

I meant compiler options, not keyword for static.
http://www.exelisvis.com/docs/Static_Methods.html
Re: Errors when compiling routines with main-level programs [message #90344 is a reply to message #90342] Mon, 23 February 2015 08:44 Go to previous message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
> I meant compiler options, not keyword for static.
> http://www.exelisvis.com/docs/Static_Methods.html

Unfortunately, they were introduced in IDL 8.3 and I am stuck on IDL 8.2.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Direction of Wind Vectors: A bug?
Next Topic: Fortran Namelist Parser

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

Current Time: Wed Oct 08 15:37:56 PDT 2025

Total time taken to generate the page: 0.00510 seconds