Skip to main content
Question

Uniface COM interop: Uniface and VARIANT datatype

  • March 11, 2026
  • 3 replies
  • 26 views

Gianni Sandigliano
Forum|alt.badge.img+3

Hi Unifacers,

I would like to understand how to deal with VARIANT datatype in a COM interface with Uniface.

VARIANT datatype as far as I’ve understood from Microsoft documentation is accepting either strings or numeric or any other datatypes and based on the datatype received it is reacting accordingly.
Giving an easy understandable example (but the problem is generic):
an Excel workbook could be composed from one or more worksheet; when more worksheets are available the program should select the one it wants to work into.
After loading the Excel type library in Uniface and opening the workbook the operation to be called to move to a specific worksheet is:
    sheets->get_item(handle out, variant in)
- First param is an output parameter and it is the handle/pointer to the requested sheet
- Second param is a VARIANT and it could be either a number or a string; when number it means the ordinal number identifying the requested worksheet or when string it means the name assigned to the worksheet.
Trying to call the operation with second parameter as string it works!

Unfortunately when an Excel file is opened the program does not (yet) know worksheets names, it should discovered them before using them!
Trying to call the operation with second parameter as number give back $status -1 and $procerror -150 !!!

I made various tests and my current gotfeel is that Uniface COM driver is NOT able to deal correctly with VARIANT datatype.

Am I missing anything?

Any suggestion is welcome!

Regards
Gianni
 

3 replies

Gianni Sandigliano
Forum|alt.badge.img+3

Hi there,

I’ve solved with a workaround, duplicating the original operation and changing Uniface datatype:
    get_item(handle, string)
to:
    get_item_num(handle, numeric)
The second parameter has maintained datatype VT_VARIANT to COM interface.

It works!

IMHO this datatype input switch should be implemented directly into COM driver without being forced to duplicate original operation.

Best regards,
Gianni
 


Ingo Stiller
Forum|alt.badge.img+3
  • Participating Frequently
  • March 12, 2026

Hi  Gianni
Your are quicker then I can answer :-)
Yes, define the parameter with the type you specifically expect. Also pay attention to the specific interface in the parameter details.
It only becomes problematic if you expect different types. In this case, you must create a new signature for all possibilities (combinations).
$signaturepropertie only works for SOAP interfaces.
Regards
Ingo


Gianni Sandigliano
Forum|alt.badge.img+3

Hi Ingo,

IMHO the official acceptance of VARIANT datatype into world external to Uniface would enable ULab to extend implementation of $signatureproperties() outside SOAP and to properly manage VARIANT directly within COM (and other) driver(s): basically when it receives a numeric it passes a number and when it receives a string it passes a string.
However this will require an extension to Urepo to properly support the specific packing codes each number / date / datetime / others datatypes request to clarify their physical interface.
From the implementation perspective this would be the Nth case where Uniface structure is managing things hiding physical details to the programmer.

It’s a wish…

Gianni