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

Home » Public Forums » archive » Re: Attempt to store into an expression: Structure reference
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: Attempt to store into an expression: Structure reference [message #63275] Tue, 04 November 2008 10:54 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Reimar Bauer writes:

> I think it should be only
>
> (*s.tab)[0].img=ptr_new(dist(100))

Yeah, that, too. ;-)

Cheers,

David
--
David Fanning, Ph.D.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Attempt to store into an expression: Structure reference [message #63276 is a reply to message #63275] Tue, 04 November 2008 09:40 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
David Fanning schrieb:
> =?ISO-8859-2?Q?F=D6LDY_Lajos?= writes:
>
>> On Tue, 4 Nov 2008, greg.addr@googlemail.com wrote:
>>
>>> I'm doing something wrong here, but what - I'm not sure...
>>>
>>> IDL> help,s.tab
>>> <Expression> POINTER = <PtrHeapVar26>
>>>
>>> IDL> help,*(s.tab)
>>> <PtrHeapVar26> STRUCT = -> TAB Array[2]
>>>
>>> IDL> help,(*(s.tab))[0]
>>> <Expression> STRUCT = -> TAB Array[1]
>>>
>>> IDL> help,((*(s.tab))[0]).img
>>> <Expression> POINTER = <NullPointer>
>>>
>>> IDL> ((*(s.tab))[0]).img=ptr_new(image)
>>> % Attempt to store into an expression: Structure reference.
>>>
>> Seems to be an IDL bug. This works in FL:
>>
>> s={s, tab:ptr_new()}
>> tab={tab, img:ptr_new()}
>> s.tab=ptr_new(replicate(tab, 2))
>> ((*(s.tab))[0]).img=ptr_new(dist(100))
>
> This is what I had in mind:
>
> s={s, tab:ptr_new()}
> tab={tab, img:ptr_new()}
> s.tab=ptr_new(replicate(tab, 2))
> (*(s.tab))[0].img=ptr_new(dist(100))
>
> Cheers,
>
> David

I think it should be only

(*s.tab)[0].img=ptr_new(dist(100))


cheers
Reimar
Re: Attempt to store into an expression: Structure reference [message #63277 is a reply to message #63276] Tue, 04 November 2008 09:12 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
=?ISO-8859-2?Q?F=D6LDY_Lajos?= writes:

>
> On Tue, 4 Nov 2008, greg.addr@googlemail.com wrote:
>
>>
>> I'm doing something wrong here, but what - I'm not sure...
>>
>> IDL> help,s.tab
>> <Expression> POINTER = <PtrHeapVar26>
>>
>> IDL> help,*(s.tab)
>> <PtrHeapVar26> STRUCT = -> TAB Array[2]
>>
>> IDL> help,(*(s.tab))[0]
>> <Expression> STRUCT = -> TAB Array[1]
>>
>> IDL> help,((*(s.tab))[0]).img
>> <Expression> POINTER = <NullPointer>
>>
>> IDL> ((*(s.tab))[0]).img=ptr_new(image)
>> % Attempt to store into an expression: Structure reference.
>>
>
> Seems to be an IDL bug. This works in FL:
>
> s={s, tab:ptr_new()}
> tab={tab, img:ptr_new()}
> s.tab=ptr_new(replicate(tab, 2))
> ((*(s.tab))[0]).img=ptr_new(dist(100))

This is what I had in mind:

s={s, tab:ptr_new()}
tab={tab, img:ptr_new()}
s.tab=ptr_new(replicate(tab, 2))
(*(s.tab))[0].img=ptr_new(dist(100))

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.")
Re: Attempt to store into an expression: Structure reference [message #63278 is a reply to message #63277] Tue, 04 November 2008 08:58 Go to previous messageGo to next message
greg.addr is currently offline  greg.addr
Messages: 160
Registered: May 2007
Senior Member
Initialised with /heap_allocate:

IDL> help,((*(s.tab))[i]).img
<Expression> POINTER = <PtrHeapVar8>

IDL> ((*(s.tab))[i]).img=ptr_new(image)
% Attempt to store into an expression: Structure reference.

...still get the same. But this does work...

IDL> (*(s.tab))[i].img=ptr_new(image)

Thanks for the quick answers! And I was thinking you could never have
too many brackets when there's a pointer around! Still, I would like
to know about /heap_allocate - when do you need that?

regards,
Greg
Re: Attempt to store into an expression: Structure reference [message #63279 is a reply to message #63278] Tue, 04 November 2008 08:57 Go to previous messageGo to next message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Tue, 4 Nov 2008, greg.addr@googlemail.com wrote:

>
> I'm doing something wrong here, but what - I'm not sure...
>
> IDL> help,s.tab
> <Expression> POINTER = <PtrHeapVar26>
>
> IDL> help,*(s.tab)
> <PtrHeapVar26> STRUCT = -> TAB Array[2]
>
> IDL> help,(*(s.tab))[0]
> <Expression> STRUCT = -> TAB Array[1]
>
> IDL> help,((*(s.tab))[0]).img
> <Expression> POINTER = <NullPointer>
>
> IDL> ((*(s.tab))[0]).img=ptr_new(image)
> % Attempt to store into an expression: Structure reference.
>

Seems to be an IDL bug. This works in FL:

s={s, tab:ptr_new()}
tab={tab, img:ptr_new()}
s.tab=ptr_new(replicate(tab, 2))
((*(s.tab))[0]).img=ptr_new(dist(100))


regards,
lajos
Re: Attempt to store into an expression: Structure reference [message #63281 is a reply to message #63279] Tue, 04 November 2008 08:44 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Vince Hradil writes:

> Because it's a null pointer. How was it created? When a pointer is
> created without know what it's going to contain, you need to us /
> ALLOCATE_HEAP.

I don't think so. I think there are one too many sets
of parentheses.

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.")
Re: Attempt to store into an expression: Structure reference [message #63282 is a reply to message #63281] Tue, 04 November 2008 08:44 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
greg.addr@googlemail.com writes:

> I'm doing something wrong here, but what - I'm not sure...
>
> IDL> help,s.tab
> <Expression> POINTER = <PtrHeapVar26>
>
> IDL> help,*(s.tab)
> <PtrHeapVar26> STRUCT = -> TAB Array[2]
>
> IDL> help,(*(s.tab))[0]
> <Expression> STRUCT = -> TAB Array[1]
>
> IDL> help,((*(s.tab))[0]).img
> <Expression> POINTER = <NullPointer>
>
> IDL> ((*(s.tab))[0]).img=ptr_new(image)
> % Attempt to store into an expression: Structure reference.
>
> Any ideas why I can't assign something to this pointer?

Too much work to test this, but I think you have an
extra set of parentheses. I think it should be like
this:

((*(s.tab))[0].img=ptr_new(image)

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.")
Re: Attempt to store into an expression: Structure reference [message #63283 is a reply to message #63282] Tue, 04 November 2008 08:39 Go to previous messageGo to next message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Nov 4, 10:21 am, greg.a...@googlemail.com wrote:
> I'm doing something wrong here, but what - I'm not sure...
>
> IDL> help,s.tab
> <Expression>    POINTER   = <PtrHeapVar26>
>
> IDL> help,*(s.tab)
> <PtrHeapVar26>  STRUCT    = -> TAB Array[2]
>
> IDL> help,(*(s.tab))[0]
> <Expression>    STRUCT    = -> TAB Array[1]
>
> IDL> help,((*(s.tab))[0]).img
> <Expression>    POINTER   = <NullPointer>
>
> IDL> ((*(s.tab))[0]).img=ptr_new(image)
> % Attempt to store into an expression: Structure reference.
>
> Any ideas why I can't assign something to this pointer?
>
> Greg

Because it's a null pointer. How was it created? When a pointer is
created without know what it's going to contain, you need to us /
ALLOCATE_HEAP.
Re: Attempt to store into an expression: Structure reference [message #63352 is a reply to message #63276] Wed, 05 November 2008 00:31 Go to previous message
greg.addr is currently offline  greg.addr
Messages: 160
Registered: May 2007
Senior Member
> I think it should be only
>
> (*s.tab)[0].img=ptr_new(dist(100))

Ha! Can't believe that! All those brackets have been annoying me for
years - now I realise I must have written kilobytes of them
unnecessarily...

many thanks,
Greg
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Read_grib under IDL 7.0
Next Topic: array subtraction

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

Current Time: Wed Oct 08 13:51:58 PDT 2025

Total time taken to generate the page: 0.00736 seconds