Re: Please help me pass an array from VBA to Perl and populate it. Newbie at wits' end!
- From: robic0
- Date: Mon, 02 Oct 2006 19:25:03 -0700
On Mon, 02 Oct 2006 19:15:17 -0700, robic0 wrote:
On 2 Oct 2006 18:49:12 -0700, david.f.jenkins@xxxxxxx wrote:
Well, I went and looked at the PDK Samples I got with the distribution,
and found nothing that would help me.
Here's what I want - surely this is child's play to experienced
Perlers:
I want to pass an empty container for a set of strings from VBA into
Perl, do some stuff in Perl, and populate the Collection with a set of
strings. I've stolen most of the PDK Perlctrl regex sample and made
some small mods to it to meet my requirements.
In general, the VBA side is easy, but I do have these VBA questions:
should the array be typed in VBA as a Collection? Variant? Object?
Something else? And why? Where is that documented?
I'm at a complete loss as to what to do on the Perl side:
1. How do I specify the parameter to the method? My intuition tells me
that it ought to be a scalar that contains a pointer (reference?) to
the Collection. If I type the parameter in VBA as a Variant, say, can
I operatoe on it in Perl as an array? Should I show it as $something?
@something? Something else?
2. In the TypeLib, how do I show the parameter? VT_ARRAY? VT_VARIANT?
VT_BSTR? VT_something else?
3. Someplace I saw, while crashing thorugh endless Google references,
the notation "VT_VARIANT|VT_ARRAY" What does that mean? Where is that
documented? Is that what I should use?
4. Do I have to populate my own Perl array and then do something
special to get it into the VBA array? Or can I process directly into
it? If so, what would be the pointer/reference/dereference notation I'd
be most likely to use?
5. What notation do I use in Perl if the parameter is defined as
$something? Do I populate it by using @$something?
5. Would it be possible to populate an array in Perl and then allow the
VBA code to access the array using a get_xxx() function? If so, would
the name of that function be "get_arrayname()" where "arrayname" is the
name of the Perl array? Do all classes created by Perlctrl have such
methods created for them? Where is that documented?
Isn't there a simple example someplace that would show me how to do
this? I understand that it's not "Hello, world" but it ought to be a
common enough requirement that the problem's been solved over and over
again.
Do I sound extremely frustrated? Well, I am...
Here this should help you.....
enum VARENUM
{ VT_EMPTY = 0,
VT_NULL = 1,
VT_I2 = 2,
VT_I4 = 3,
VT_R4 = 4,
VT_R8 = 5,
VT_CY = 6,
VT_DATE = 7,
VT_BSTR = 8,
VT_DISPATCH = 9,
VT_ERROR = 10,
VT_BOOL = 11,
VT_VARIANT = 12,
VT_UNKNOWN = 13,
VT_DECIMAL = 14,
VT_I1 = 16,
VT_UI1 = 17,
VT_UI2 = 18,
VT_UI4 = 19,
VT_I8 = 20,
VT_UI8 = 21,
VT_INT = 22,
VT_UINT = 23,
VT_VOID = 24,
VT_HRESULT = 25,
VT_PTR = 26,
VT_SAFEARRAY = 27,
VT_CARRAY = 28,
VT_USERDEFINED = 29,
VT_LPSTR = 30,
VT_LPWSTR = 31,
VT_RECORD = 36,
VT_FILETIME = 64,
VT_BLOB = 65,
VT_STREAM = 66,
VT_STORAGE = 67,
VT_STREAMED_OBJECT = 68,
VT_STORED_OBJECT = 69,
VT_BLOB_OBJECT = 70,
VT_CF = 71,
VT_CLSID = 72,
VT_BSTR_BLOB = 0xfff,
VT_VECTOR = 0x1000,
VT_ARRAY = 0x2000,
VT_BYREF = 0x4000,
VT_RESERVED = 0x8000,
VT_ILLEGAL = 0xffff,
VT_ILLEGALMASKED = 0xfff,
VT_TYPEMASK = 0xfff
};
Oh, this might help too .....
There's no getting around it. We'll have to look at the VARIANT structure before we can talk about what to do with it.
struct tagVARIANT {
VARTYPE vt;
WORD wReserved1;
WORD wReserved2;
WORD wReserved3;
union {
// C++ Type Union Name Type Tag Basic Type
// -------- ---------- -------- ----------
long lVal; // VT_I4 ByVal Long
unsigned char bVal; // VT_UI1 ByVal Byte
short iVal; // VT_I2 ByVal Integer
float fltVal; // VT_R4 ByVal Single
double dblVal; // VT_R8 ByVal Double
VARIANT_BOOL boolVal; // VT_BOOL ByVal Boolean
SCODE scode; // VT_ERROR
CY cyVal; // VT_CY ByVal Currency
DATE date; // VT_DATE ByVal Date
BSTR bstrVal; // VT_BSTR ByVal String
IUnknown *punkVal; // VT_UNKNOWN
IDispatch *pdispVal; // VT_DISPATCH ByVal Object
SAFEARRAY *parray; // VT_ARRAY|* ByVal array
// A bunch of other types that don't matter here...
VARIANT *pvarVal; // VT_BYREF|VT_VARIANT ByRef Variant
void * byref; // Generic ByRef
};
};
.
- Follow-Ups:
- References:
- Prev by Date: Re: Please help me pass an array from VBA to Perl and populate it. Newbie at wits' end!
- Next by Date: Re: Modifying a one-liner
- Previous by thread: Re: Please help me pass an array from VBA to Perl and populate it. Newbie at wits' end!
- Next by thread: Re: Please help me pass an array from VBA to Perl and populate it. Newbie at wits' end!
- Index(es):
Relevant Pages
|