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

Home » Public Forums » archive » Re: When Ptr_New doesn't work
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: When Ptr_New doesn't work [message #28950 is a reply to message #28949] Tue, 22 January 2002 09:36 Go to previous messageGo to previous message
Richard Younger is currently offline  Richard Younger
Messages: 43
Registered: November 2000
Member
Hi, Carles.

There's something very fishy here. Your code seems perfectly correct to
me. I found that when the outer set of parenthesis on the left hand
side of the offending line of code is omitted, your program snippet
seems to work fine. When I include the outer set of parenthesis, it
gives me an error on versions Win 5.3-5.5, and possibly earlier. My
test program is below. Either this is a bug or a very strange quirk of
the language with obscure origins. Perhaps it should be reported?

For anyone else out there running on different systems, do other
versions have this problem?

Best,
Rich

--

PRO test

nElems = 4
elems = intarr(nElems)+2
rCoefficients=PtrArr(nElems)

FOR i=0, nElems-1 DO BEGIN
rCoefficients[i]=Ptr_New(PtrArr(elems[i]))
ENDFOR

FOR j=0, nElems-1 DO BEGIN
FOR k=0, elems[j]-1 DO BEGIN
;Works:
(*rCoefficients[j])[k] = Ptr_New(FltArr(2), /NO_COPY)

;Causes Error:
;((*rCoefficients[j])[k]) = Ptr_New(FltArr(2), /NO_COPY)
ENDFOR
ENDFOR

;;--- Clean up ----
;; - as in "I don't do any".

END

--
Richard Younger


Carles Badenes wrote:
>
> I have the following problem:
>
> rCoefficients=PtrArr(nElems)
> FOR i=0, nElems-1 DO BEGIN
> rCoefficients[i]=Ptr_New(PtrArr(elems[i]))
> ENDFOR
>
> since elems is a vector of integers, each element i of
> rCoefficients is a pointer to an array of elems[i] pointers.
> But, for some reason,
>
> ((*rCoefficients[j])[k]) = Ptr_New(FltArr(2), /NO_COPY)
>
> doesn't work. k and j are within the allowed range, of course, and
> ((*rCoefficients[j])[k]) is a null pointer, as expected from the
> initialization above. Ptr_New is supposed to allocate memory for the
> specified pointer to store an array of 2 floats, but I get the message
>
> Expression must be named variable in this context: <POINTER
> (<NullPointer>)>.
>
> I must be doing something wrong. Can you help?
>
> Thanks,
> Carles
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: bug in curvefit?
Next Topic: When Ptr_New doesn't work

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

Current Time: Fri Oct 10 11:24:23 PDT 2025

Total time taken to generate the page: 1.12284 seconds