|
Re: Global Variable [message #26893 is a reply to message #26838] |
Wed, 03 October 2001 03:45  |
Martin Downing
Messages: 136 Registered: September 1998
|
Senior Member |
|
|
> Dear Martin,
>
> your type function could be replaced by size() with it's keyword /type.
>
> I will include this into my routine, thanks.
>
> regards
> Reimar
>
Reimar,
You are right! Cant think how I never saw that when I first wrote the
routine, I wonder whether those keywords were introduced in IDL 5. Some day
I shall put time aside to reread more of the help files!
Anyway it just shows how posting messages to this group is truely symbiotic!
thanks,
Martin
|
|
|
Re: Global Variable [message #26917 is a reply to message #26838] |
Tue, 02 October 2001 08:47  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Martin Downing wrote:
>
> "Reimar Bauer" <r.bauer@fz-juelich.de> wrote in message
> news:3BB85BEB.45BD9C5D@fz-juelich.de...
>> Martin Downing wrote:
>>>
>>> "Reimar Bauer" <r.bauer@fz-juelich.de> wrote in message
>>> news:3BB83D11.5A58FC00@fz-juelich.de...
>>>>
>>>> The fourth way is to use Pointers
>>>>
>>>>
>>>> value=10
>>>> ptr=ptr_new(value)
>>>>
>>>> help, *ptr
>>>>
>>>> Reimar
>>>>
>>>
>>> Reimar,
>>>
>>> If this is to be a global variable, do you have a cunning method of
> locating
>>> and identifying this variable off the heap?
>>>
>>> Martin
>>
>> - locating is be done by ptr_valid()
>>
>> - identifing is a bit more complicated.
>>
>> At the moment I am only able to identify named structures as pointers.
>> We are using them as global variable in some of our widgets with
>> external communication
>> between some of our widgets.
>>
>>
> http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/downl
> oad/get_pointer.tar.gz
>>
>
> Thanks Reimar, thats really very useful. I have added the line
> to the function so that it can still work if there are non-structure
> pointers on the heap.
> cheers
>
> Martin
>
> FUNCTION get_pointer,name
> ...
> ...
> FOR i=0,N_ELEMENTS(c)-1 DO BEGIN
> if type(*c[i]) ne 8 then continue ; only test structure pointers
> s_name=TAG_NAMES(*c[i],/STRUCTURE_NAME)
> IF STRUPCASE(name) EQ s_name THEN RETURN,c[i]
> ENDFOR
> ...
> ...
> END
>
Dear Martin,
your type function could be replaced by size() with it's keyword /type.
I will include this into my routine, thanks.
regards
Reimar
>>
>> Reimar
>>
>>
>> --
>> Reimar Bauer
>>
>> Institut fuer Stratosphaerische Chemie (ICG-1)
>> Forschungszentrum Juelich
>> email: R.Bauer@fz-juelich.de
>> http://www.fz-juelich.de/icg/icg1/
>> ============================================================ ======
>> a IDL library at ForschungsZentrum Juelich
>> http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
>>
>> http://www.fz-juelich.de/zb/text/publikation/juel3786.html
>> ============================================================ ======
>>
>> read something about linux / windows
>> http://www.suse.de/de/news/hotnews/MS.html
>
> ; FUNCTION: TYPE
> ;
> ; Purpose: Returns the data type of a variable as defined in the size() function
> ; May be used on undefined varfiables also (data type = 0)
> ;
> ; Example:
> ; IDL> print, type(s)
> ; 0
> ; IDL> s = { a:1, b:2}
> ; IDL> print, type(s)
> ; 8
> ;
> ; Author: Martin R Dowining 1996
> FUNCTION Type , x
>
> var_info = size(x)
>
> RETURN, var_info( N_ELEMENTS( var_info ) - 2)
>
> END
>
> ; Copyright (c) 1999, Forschungszentrum Juelich GmbH ICG-1
> ; All rights reserved.
> ; Unauthorized reproduction prohibited.
> ; This software may be used, copied, or redistributed as long as it is not
> ; sold and this copyright notice is reproduced on each copy made. This
> ; routine is provided as is without any express or implied warranties
> ; whatsoever.
> ;+
> ; NAME:
> ; get_pointer
> ;
> ; PURPOSE:
> ; This routine gets a defined pointer over the structure name
> ;
> ; CATEGORY:
> ; PROG_TOOLS
> ;
> ; CALLING SEQUENCE:
> ; a=get_pointer(name)
> ;
> ; INPUTS:
> ; name : the name of the pointer
> ;
> ; OUTPUTS:
> ; the pointer or -1 if it is not defined
> ;
> ; EXAMPLE:
> ; a=PTR_NEW(CREATE_STRUCT(name='dd','name','a','value',24))
> ; b=get_pointer('dd')
> ; HELP,*b,/str
> ; ** Structure DD, 2 tags, length=12:
> ; NAME STRING 'a'
> ; VALUE INT 24
> ;
> ;
> ; MODIFICATION HISTORY:
> ; Idea was given by F.Rohrer ICG-3
> ; Written by: R.Bauer (ICG-1), 1999-03-15
> ;-
>
> FUNCTION get_pointer,name
> c=PTR_VALID()
>
> errvar=0
> catch,errvar
> if errvar ne 0 then return,-1
>
> FOR i=0,N_ELEMENTS(c)-1 DO BEGIN
> ; only test structure pointers
> if type(*c[i]) ne 8 then continue
> s_name=TAG_NAMES(*c[i],/STRUCTURE_NAME)
> IF STRUPCASE(name) EQ s_name THEN RETURN,c[i]
> ENDFOR
>
> RETURN,-1
> END
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======
read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
|
|
|