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

Home » Public Forums » archive » Re: Pass Pointer through procedures
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: Pass Pointer through procedures [message #55254] Thu, 09 August 2007 07:19
payon is currently offline  payon
Messages: 11
Registered: July 2007
Junior Member
Oh sorry, sorry, i made a small mistake, even if i didn't define the
variable before i call my procedure,

i also have to call it like
IDL> imageopen, image

So now it works.. Ok, this was the most important thing. I think, when
i could pass variables, it's also the same with pointers. I will try

So thanks a lot!!

greetings

martin
Re: Pass Pointer through procedures [message #55255 is a reply to message #55254] Thu, 09 August 2007 07:11 Go to previous message
payon is currently offline  payon
Messages: 11
Registered: July 2007
Junior Member
Oh thanks Mr. Fanning for your answer.
Well maybe I really read the wrong sources.
But now i tried a look in your book. and i found how to pass
variables through procedures.
But I have a small problem, lke you described it with the examlpe of
the image which is resized.
Of course, this works, but only if the image variable was defined
before the procedure was started. So After the procedure was executed,
the image variable wes changed by through the procedure and could be
read by other procedures.

But my problem is, just again a small example

i start a procedure like

pro imageopen, image
image=fltarr(300,300)
image=openfunction()
end

So here in this small procedure the variable is first defined in the
procedure itself. So it just should have the function as a output
variable, not as input variable-

but the problem is, when i execute the procedure with
IDL> imageopen

and then try to open the image
IDL> tvscl, image

He can't find the variable. So my question is. Can i just pass
variables, when I used them also as input variables, so when i defined
them before i called the procedure?
Like
IDL>image=fltarr(300,300)
IDL>imageopen, image
IDL>tvscl, image

?

greetings

martin
Re: Pass Pointer through procedures [message #55256 is a reply to message #55255] Thu, 09 August 2007 06:04 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
payon@gmx.de writes:

> what is the simpliest way to pass pointers through procedures? I
> couldn't find anything which exlpain it well. Ok, I read some
> different things a bout pointers and they weren't helpful.

You are reading the wrong things. Try this:

http://www.dfanning.com/misc_tips/pointers.html

Pointers are nothing more or less than IDL variables. While
it is true that the thing the pointer points to is stored
in a global memory location, the pointer itself is a local
variable and must be treated as such.

And you are also correct that if you are going to use Common
blocks, there is no advantage to pointers, unless the
thing you are pointing to will be changing in the course
of the IDL session.

The usual way to pass variables among procedures and functions
is via positional or keyword parameters.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Pass Pointer through procedures
Next Topic: Structure Containing Structure: question about parentheses

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

Current Time: Wed Oct 08 15:07:13 PDT 2025

Total time taken to generate the page: 0.00594 seconds