DADiSP Worksheet Functions > Function Categories > ActiveX > Automation Server > GETVARIANTDATA

 

GETVARIANTDATA

Purpose:

Retrieves data from a command, Window or variable as a variant of a specified type from DADiSP’s ActiveX Automation Server.

Syntax:

[out] VARIANT result = GetVariantData(

[in] BSTR "command", [in, optional] INT type, [in optional] INT vtype)

"command"

-

A string, a command or Window or variable name.

type

-

Optional. An integer, the amplitude correction flag:

 

Type

Description

VARTYPE

nothing

VT_EMPTY

2 byte integer

VT_I2

4 byte integer

VT_I4

4 byte float

VT_R4

8 byte double

VT_R8

currency

VT_CY

date

VT_DATE

binary string

VT_BSTR

10

error

VT_ERROR

11

boolean

VT_BOOL

12

variant

VT_VARIANT

13

unknown

VT_UNKNOWN

16

char

VT_I1

17

unsigned char

VT_UI1

18

unsigned short

VT_UI2

19

unsigned int

VT_UI4

20

8 byte integer

VT_I8

21

8 byte unsigned

VT_UI8

22

machine int

VT_INT

23

unsigned machine int

VT_UINT

24

void

VT_VOID

28

C-style array

VT_CARRAY

30

null-terminated string

VT_LPSTR

31

wide null-terminated string

VT_LPWSTR

 

vtype

-

Optional. An integer. Specifies the type when converting to a Variant. Only valid if type is 12 (Variant). Defaults to 5 (double). Valid types are the same as above.

Returns:

A variant, either a string, scalar or array.

Example:

Visual Basic Example:

 

Dim DADiSP as Object

Dim Result1 as Variant

Dim Result2 as Variant

Dim Result3 as Variant

 

’’’ Connect to DADiSP

Set DADiSP = CreateObject("dadisp.application")

 

’’’ Create a 2 Window Worksheet without prompting

Call DADiSP.Execute("newworksheet(2, 0)")

 

’’’ Generate random data in W1

Call DADiSP.Execute("W1: grand(1000, 1)")

 

’’’ get version

Result1 = DADiSP.GetVariantData("version", 8)

 

’’’ get integral of W1

Result2 = DADiSP.GetVariantData("integ(W1)", 2)

 

’’’ get integral of W1

Result3 = DADiSP.GetVariantData("integ(W1)", 12, 2)

 

’’’ show it

DADiSP.Visible = 1

 

 

Starts DADiSP as an ActiveX Automation server, creates a 2 Window Worksheet and places 1000 random samples in W1. The variant Result1 is a string containing the current version number of DADiSP. The variant Result2 is an 1000x1 integer array containing the integration of the random data rounded to the nearest integer value. The variant Result3 is a 1000x1 variant array where each variant contains an integer.

Example:

Visual Basic Example:

 

Dim DADiSP as Object

Dim Result as Variant

 

’’’ Connect to DADiSP

Set DADiSP = CreateObject("dadisp.application")

 

’’’ Create a 2 Window Worksheet without prompting

Call DADiSP.Execute("newworksheet(2, 0)")

 

’’’ today’s date as a Julian integer

Call DADiSP.Execute("now = julstr(getdate)")

 

‘’’ Generate date data in W1

Call DADiSP.Execute("W1: now..1..(now+10);setvunits(‘daily’)")

 

’’’ get date data

Result = DADiSP.GetVariantData("W1")

 

 

Starts DADiSP as an ActiveX Automation server, creates a 2 Window Worksheet and places 10 date values in W1. The variant Result is a 10x1 variant array where each variant contains a date (VT_DATE) value.

 

Because the type parameter was not specified, the returned variant array defaults to the type of series, in this case an array of variants containing date values.

Remarks:

Any DADiSP command can be executed or the contents of any Window or variable can be retrieved.

Use GetVariantData when the data must be returned as a variant of a particular type. If the input is a series and the type is not specified, GetVariantData returns an array of variants. This is equivalent to GetVariantData(series, 12). As indicated in the second example, an array of variants is the best format to return series that contain time and/or date values.

See GETDATA to return variant data where the variant type is automatically determined by the data.

See GETSERIES to explicitly return a SafeArray.

See CASTVARIANTARRAY to explicitly return a series as an array of variants.

See Also:

CALCULATE

CASTVARIANTARRAY

EVALUATE

GETCHARARRAY

GETCOMPLEXDATA

GETCOMPLEXSERIES

PUTCHARARRAY

PUTCOMPLEXDATA

PUTCOMPLEXSERIES

PUTDATA

PUTFULLMATRIX

PUTSERIES