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

Home » Public Forums » archive » Re: Problem Compiling and Using Functions
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: Problem Compiling and Using Functions [message #46804] Wed, 04 January 2006 16:13 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
someone@someplace.com writes:

> DOH!... Doh!... doh!... (echoing off into the distance) :)
>
> Thanks for your fast response. It works now.
>
> I'm new to IDL and I'm not used there being this difference between
> functions and procedures.
>
> So, procedures don't return anything and functions *always* have to
> return something and the calling function/procedure has handle them
> correctly.

Yes, this is correct. But if you are going to write your
functions to return 0s, you have surmised correctly that
you could just as well use a procedure. All arguments
to procedures and function alike (including keyword
arguments) can be passed by reference, so getting things
into and out of procedure (as well as functions) is
reasonably trivial.

Just keep chanting to yourself "IDL is NOT C, IDL is NOT C."

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Problem Compiling and Using Functions [message #46805 is a reply to message #46804] Wed, 04 January 2006 15:51 Go to previous messageGo to next message
someone[1] is currently offline  someone[1]
Messages: 2
Registered: January 2006
Junior Member
On Wed, 04 Jan 2006 17:48:28 -0500, Paul Van Delst
<Paul.vanDelst@noaa.gov> wrote:

> David Fanning wrote:
>> someone@someplace.com writes:
>>
>>
>>> I'm having trouble getting simple functions to work.
>>>
>>> It's probably a simple error, but I can't figure it out. I'm using IDL
>>> 5.6 and ENVI 3.6.
>>>
>> Functions return a value. Try writing the function call like this:
>>
>> void = extract_tiles_get_tile(fid)
>
> Man, I heard the "D'OH!" all the way over here!
>
> :o)

DOH!... Doh!... doh!... (echoing off into the distance) :)

Thanks for your fast response. It works now.

I'm new to IDL and I'm not used there being this difference between
functions and procedures.

So, procedures don't return anything and functions *always* have to
return something and the calling function/procedure has handle them
correctly.

Thanks,
Mike
Re: Problem Compiling and Using Functions [message #46806 is a reply to message #46805] Wed, 04 January 2006 14:48 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
David Fanning wrote:
> someone@someplace.com writes:
>
>
>> I'm having trouble getting simple functions to work. I have the code
>> below in a single file named extract_tiles.pro. When I try and compile
>> it gives me a syntax error on the line containing
>> "extract_tiles_get_tile(fid)" in the extract_tiles procedure. If I
>> change the function to a procedure, comment out the return statement
>> and change the function call to a procedure call it works perfectly.
>>
>> It's probably a simple error, but I can't figure it out. I'm using IDL
>> 5.6 and ENVI 3.6.
>>
>> FUNCTION extract_tiles_get_tile, fImg
>> ENVI_FILE_QUERY, fImg, ns=ns, nl=nl
>> print, 'Samples: ', ns
>> print, 'Lines: ', nl
>> RETURN, 0
>> END
>>
>> PRO extract_tiles
>> ENVI_OPEN_FILE, 'image.dat', r_fid=fid
>> extract_tiles_get_tile(fid)
>> END
>
>
> Functions return a value. Try writing the function call like this:
>
> void = extract_tiles_get_tile(fid)

Man, I heard the "D'OH!" all the way over here!

:o)


--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
Re: Problem Compiling and Using Functions [message #46807 is a reply to message #46806] Wed, 04 January 2006 14:09 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
someone@someplace.com writes:

> I'm having trouble getting simple functions to work. I have the code
> below in a single file named extract_tiles.pro. When I try and compile
> it gives me a syntax error on the line containing
> "extract_tiles_get_tile(fid)" in the extract_tiles procedure. If I
> change the function to a procedure, comment out the return statement
> and change the function call to a procedure call it works perfectly.
>
> It's probably a simple error, but I can't figure it out. I'm using IDL
> 5.6 and ENVI 3.6.
>
> FUNCTION extract_tiles_get_tile, fImg
> ENVI_FILE_QUERY, fImg, ns=ns, nl=nl
> print, 'Samples: ', ns
> print, 'Lines: ', nl
> RETURN, 0
> END
>
> PRO extract_tiles
> ENVI_OPEN_FILE, 'image.dat', r_fid=fid
> extract_tiles_get_tile(fid)
> END

Functions return a value. Try writing the function call like this:

void = extract_tiles_get_tile(fid)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Problem Compiling and Using Functions [message #46875 is a reply to message #46804] Sat, 07 January 2006 15:04 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
David Fanning wrote:

> someone@someplace.com writes:
>
>> DOH!... Doh!... doh!... (echoing off into the distance) :)
>>
>> Thanks for your fast response. It works now.
>>
>> I'm new to IDL and I'm not used there being this difference between
>> functions and procedures.
>>
>> So, procedures don't return anything and functions *always* have to
>> return something and the calling function/procedure has handle them
>> correctly.
>
> Yes, this is correct. But if you are going to write your
> functions to return 0s, you have surmised correctly that
> you could just as well use a procedure. All arguments
> to procedures and function alike (including keyword
> arguments) can be passed by reference, so getting things
> into and out of procedure (as well as functions) is
> reasonably trivial.
>
> Just keep chanting to yourself "IDL is NOT C, IDL is NOT C."
>
> Cheers,
>
> David

Hmm I think there was a change you could write a function which does not
need a return inside. It's not that's I like this. I like a clear
definition as above.

IDL> $more test.pro
function test

end

IDL> a=test()
IDL> help,a
A INT = 0


cheers

Reimar
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: archivos
Next Topic: Re: Unicode Question

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

Current Time: Sat Oct 11 15:00:13 PDT 2025

Total time taken to generate the page: 1.12215 seconds