AnsweredAssumed Answered

vrf What's up with Arrays?

Question asked by VRFuser on Nov 3, 2004
Shawn,

Try this:

ary = Array.CreateInstance(Type.GetType("System.Int32"), 0)

> Set typ = asClrType(0, System.Int32);
The purpose of asClrType() is to provide a hint to VEE when marshalling
data from VEE to .NET.  In the case above, you get back a boxed
System.Int32 so it is a reference type but it is of type System.Int32
not System.Type.

BTW, I'm a little baffled as to why a "Set" is required on a constructor
call yet "Set" can't be used to assign the result of a static method
call.  Both return a reference type that would be assigned into a VEE
Object type.   Hmmm.

--
Keith

> -----Original Message-----
> From: Shawn Fessenden [mailto:shawn@testech-ltd.com]
> Sent: Wednesday, November 03, 2004 1:27 AM
> To: VRF
> Subject: [vrf] What's up with Arrays?
>
> Ok, I got a problem. System.Array is an abstract class. So far so
good.
> There's a static method CreateInstance that creates an array of a
given
> type
> and size. Fine. Now, watch carefully. This works:
>
> Set ary = Array.CreateInstance(System.Object, 0);
>
> ary is an object of type System.Object[] with 0 elements (or actually
> maybe
> one element - I can't figure that one out either). The problem is that
> this
> doesn't work for intrinsic types:
>
> Set ary = Array.CreateInstance(System.Int32, 0);
>
> Fails with "'SET x=a' is not supported for 'a' not an Object, don't
use
> SET". Now, here's the problem. Ok you argue, a value type is different
> from
> a reference type so that's why it doesn't work. Fine. Now how about
this:
>
> Set ary = Array.CreateInstance(Type.GetType("System.Int32"), 0);
>
> This fails too! Why? GetType returns an object of type Type (a
reference
> type) that describes a value type. What's the story? It doesn't matter
if
> you try to increase the number of elements either. It simply doesn't
work
> and it ought to.
>
> I think VEE is automatically converting Type to it's own intrinsic
types
> as
> soon as it sees them! This doesn't work either:
>
> Set typ = asClrType(0, System.Int32);
> Set ary = Array.CreateInstance(typ.GetType(), 0);
>
> So the challenge is to create an empty array of any CLR intrinsic
type.
> -SHAWN-



---
You are currently subscribed to vrf as: rsb@soco.agilent.com
To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list,  email "vrf@agilent.com". 
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".

Outcomes