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

Home » Public Forums » archive » How to get _overloadSize to return N_Dimensions=0?
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: How to get _overloadSize to return N_Dimensions=0? [message #94360 is a reply to message #94355] Wed, 19 April 2017 14:19 Go to previous messageGo to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 4/18/17 7:56 AM, Matthew Argall wrote:
> The problem with undefined variables was fixed, but there is another
> bug related to scalar values. I assume N_Elements is determined as
> Product(Size(input, /DIMENSIONS)). However, a scalar value has a
> dimension size of 0, so the result of 0 elements.
>
>
> function test_olSize::_OverloadSize
> return, size(*self.value, /DIMENSIONS)
> end
>
> function test_olSize::Init, value
> compile_opt strictarr
> self.value = Ptr_New(value, /NO_COPY)
> return, 1
> end
>
> pro test_olSize__define
> class = {test_olSize, $
> inherits IDL_Object, $
> value: ptr_new()}
> end
>
>
> IDL> myObj = Obj_New('Test_olSize', 1)
> IDL> Print, N_Elements(myObj)
> 0
>

I would use something like the following for your _overloadSize method:

function test_olsize::_overloadSize
return, size(*self.value, /n_dimensions) eq 0 $
? 1L $
: size(*self.value, /dimensions)
end

IDL> myObj = Obj_New('Test_olSize', 1)
IDL> Print, N_Elements(myObj)
1

Mike

--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: constant time cadence
Next Topic: alignment of y-axis tick labels

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

Current Time: Wed Oct 08 15:49:34 PDT 2025

Total time taken to generate the page: 0.00493 seconds