Variants
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
If you, or people here, can figure out what you really need, then you might not need variants.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + all updates, PB3.51, Ed3.53)
What is it you need variants for (well, obviously something VB related)? But really, it may be possible that you do not need to give yourself such painsOriginally posted by dmoc
Any one tried reproducing in PB? As expected but what a whopper!
If you've had any luck let me know and save my sanity!

--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + all updates, PB3.51, Ed3.53)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
It certainly looked like a request of some sort ;p
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + all updates, PB3.51, Ed3.53)
Ah, OK. Well, if you really want to try to get variants, what about using a structure with a union containing all the basic data types? I don't know how well it would work because you would still need to manually choose what data type to access (if you were using VB then I think the interpreter would be able to choose it for you, but I don't know what types it can handle).Originally posted by dmoc
No, nothing VB related and yes I can figure out what I really need. I am converting an MS example c-prog to implement an Excel OLE automation controller. The comment was not really a request for help.
It certainly looked like a request of some sort ;p
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + all updates, PB3.51, Ed3.53)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by dmoc.
I've been converting a lot of types recently and late last night I
took a look at the structure for a variant just before going to bed.
I did a little work on it but the unions, to my tired brain, didn't
make sence. I *know* what a union is but suspect this particular
arrangement has something to do with identifying the variants type.
Anyway, below is as far as I got (which isn't very far) for anyone who may be interested. I'll return to it afresh in a few days time. I have not given any thought to "Decimal" assuming I may get away with float. Thanks for your input.
; From OAIDL.h
Structure VARIANT
StructureUnion
Structure __tagVARIANT {
vt.VARTYPE ;
wReserved1.w;
wReserved2.w;
wReserved3.w;
StructureUnion
lVal;
bVal.b;
iVal.w;
fltVal.f;
dblVal.f[2];
>> boolVal; VARIANT_BOOL
>> bool; _VARIANT_BOOL
ullVal.l; unsigned long long
scode.SCODE;
cyVal.CY;
date.DATE;
bstrVal.l; BSTR
punkVal.l; IUnknown*
pdispVal.l; IDispatch *
parray.l; SAFEARRAY *
pbVal.l; BYTE *
piVal.l; SHORT *
plVal.l; LONG *
pfltVal.l; FLOAT *
pdblVal.l; DOUBLE *
pboolVal.l; VARIANT_BOOL *
pbool.l; _VARIANT_BOOL *
pscode.l; SCODE *
pcyVal.l; CY *
pdate.l; DATE *
pbstrVal.l; BSTR *
ppunkVal.l; IUnknown **
ppdispVal.l; IDispatch **
pparray.l; SAFEARRAY **
pvarVal.l; VARIANT *
byref; PVOID
cVal.b; CHAR
uiVal.w; USHORT
ulVal.l; ULONG
intVal.w; INT
uintVal.w; UINT
>> pdecVal; DECIMAL *
pcVal.l; CHAR *
puiVal.l; USHORT *
pulVal.l; ULONG *
pintVal.l; INT *
puintVal.l; UINT *
EndStructureUnion; __VARIANT_NAME_3;
EndStructureUnion; __VARIANT_NAME_2;
decVal; DECIMAL
EndStructureUnion; } __VARIANT_NAME_1;
EndStructure
I've been converting a lot of types recently and late last night I
took a look at the structure for a variant just before going to bed.
I did a little work on it but the unions, to my tired brain, didn't
make sence. I *know* what a union is but suspect this particular
arrangement has something to do with identifying the variants type.
Anyway, below is as far as I got (which isn't very far) for anyone who may be interested. I'll return to it afresh in a few days time. I have not given any thought to "Decimal" assuming I may get away with float. Thanks for your input.
; From OAIDL.h
Structure VARIANT
StructureUnion
Structure __tagVARIANT {
vt.VARTYPE ;
wReserved1.w;
wReserved2.w;
wReserved3.w;
StructureUnion
lVal;
bVal.b;
iVal.w;
fltVal.f;
dblVal.f[2];
>> boolVal; VARIANT_BOOL
>> bool; _VARIANT_BOOL
ullVal.l; unsigned long long
scode.SCODE;
cyVal.CY;
date.DATE;
bstrVal.l; BSTR
punkVal.l; IUnknown*
pdispVal.l; IDispatch *
parray.l; SAFEARRAY *
pbVal.l; BYTE *
piVal.l; SHORT *
plVal.l; LONG *
pfltVal.l; FLOAT *
pdblVal.l; DOUBLE *
pboolVal.l; VARIANT_BOOL *
pbool.l; _VARIANT_BOOL *
pscode.l; SCODE *
pcyVal.l; CY *
pdate.l; DATE *
pbstrVal.l; BSTR *
ppunkVal.l; IUnknown **
ppdispVal.l; IDispatch **
pparray.l; SAFEARRAY **
pvarVal.l; VARIANT *
byref; PVOID
cVal.b; CHAR
uiVal.w; USHORT
ulVal.l; ULONG
intVal.w; INT
uintVal.w; UINT
>> pdecVal; DECIMAL *
pcVal.l; CHAR *
puiVal.l; USHORT *
pulVal.l; ULONG *
pintVal.l; INT *
puintVal.l; UINT *
EndStructureUnion; __VARIANT_NAME_3;
EndStructureUnion; __VARIANT_NAME_2;
decVal; DECIMAL
EndStructureUnion; } __VARIANT_NAME_1;
EndStructure
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by dmoc.
For a start it's wip so that's why it's strange looking. In principle it's very "simple"...a structure that can contain any other type. From VBA help...
"A Variant is a special data type that can contain any kind of data except fixed-length String
data and user-defined types. A Variant can also contain the special values Empty, Error,
Nothing, and Null. You can determine how the data in a Variant is treated using the VarType
function or TypeName function."
I use to think it was a lazy programmer's type but it does have it's uses, eg, to allow more
generic functions (and if you don't consider that necessary think about what most oop aims
to do). And of course it makes dealing with MSOffice apps easier, for creating add-in's etc.
If you take a closer look you'll see most of it converts to longs so it's not as bad as it
may look.

"A Variant is a special data type that can contain any kind of data except fixed-length String
data and user-defined types. A Variant can also contain the special values Empty, Error,
Nothing, and Null. You can determine how the data in a Variant is treated using the VarType
function or TypeName function."
I use to think it was a lazy programmer's type but it does have it's uses, eg, to allow more
generic functions (and if you don't consider that necessary think about what most oop aims
to do). And of course it makes dealing with MSOffice apps easier, for creating add-in's etc.
If you take a closer look you'll see most of it converts to longs so it's not as bad as it
may look.
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.51, Ed3.53)
Pointer to BCD coded string?Originally posted by El_Choni
DECIMAL * seems to be a pointer to DECIMAL, whatever it is, so it's .l
Pointer to void (i.e. non-specific) type.PVOID could also be a pointer, but this is indeed a guess.
--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.51, Ed3.53)