When you use Visual FoxPro as an early binding client and want to reference a variant data type in a COM object, you must first create an instance of the variable with the type you expect to retrieve. For example:
| В | Copy Code |
|---|---|
DEFINE CLASS varianttest AS SESSION OLEPUBLIC
FUNCTION varret(outVal AS VARIANT@, inVal AS VARIANT) AS VOID
OutVal = inVal
ENDFUNC
ENDDEFINE | |
After building this class into a DLL named myServer, you can reference the data as shown in the following code:
| В | Copy Code |
|---|---|
x = CREATEOBJECT("myServer.varianttest","","")
ov = ""
tt.varret(@ov, "string") && Sets string value.
ov = 0
tt.varret(@ov, 123) && Sets ov to an integer value.
ov = 0.0
tt.varret(@ov, 44.44) && Sets ov to a real numeric value.
ov = l
tt.varret(@ov, f) && Sets ov to a Boolean value. | |
js editor
Web development