A list of products available on this site
Documentation for XtraMania's xtras
Prices and links to the online store
Xtras, PDFs, samples
Have a question? Ask us!
Contacts
Logo. www.xtramaina.com  
Home Search E-mail
ADOxtra Reference/Automatic Type Casting

ADOxtra for Macromedia Director

ADOxtra object wrapper - automatic type casting

ADOxtra performs automatic type casting to correctly transfer data between Lingo and ADO object and vice versa. ADOxtra implicitly performs typecasting operations during processing Lingo method arguments, returning values, and property values.
Automation and Visual Basic supports rather large amount of data types. Lingo has its own Director specific data types. So, ADOxtra may not find suitable conversion in all cases, although it provides conversion in the most cases. If ADOxtra does not know how to convert the value it will report an error.
See Mapping Lingo types to ADO types and Mapping ADO types to Lingo types topics below for further details.

Mapping Lingo types to ADO types

This conversion is taking place when ADOxtra wrapper object passes any arguments to the wrapped ADO object. This includes assigning property values of the wrapped ADO object.
The table below describes Lingo types that are recognized by ADOxtra wrapper and into which types they are converted.

Lingo type Lingo Value (if any) Automation type
Symbol #Null NULL
Symbol other symbols String
Integer   signed integer 4 bytes
Float   Float 8 bytes
String   String
Date   Float
VOID VOID Missing value
ADOxtra wrapper   ADO object reference
BinaryXtra wrapper   SafeArray (Vector) of Bytes


The Symbol type is native to Director, ADO knows nothing about it, and the actual integer value of any Director symbol is guaranteed to be the same only during current Director session. So, the special symbol value #Null is treated as ADO Null value. It is often used in databases and in VB to mark empty references to objects. Other Symbol values are converted to the corresponding String. So value #SomeSymbol will be converted to string "SomeSymbol".

Special note about Date values. The Date/Time value in ADO is actually represented as a float number where the whole part is the number of days since the 1st of January 1901, and the fraction part represents the time. Director uses special Date/Time values. ADOxtra provides a conversion of these values into ADO date/time values, but due to a bug in Director 8, the conversion gets the wrong results if the date value is outside this range: date(1901,12,14) to date(2038,1,19). Conversion of date values inside this range works correctly. Director 7.02 and Director 8.5 work correctly over all time period available to ADO.
ADOxtra provides a couple of routines for conversion float date representation into "human readable" form and vice versa: DateTimeListToFloat and FloatToDateTimeList

VOID Lingo values are usually treated as missing argument, therefore it is converted into corresponding COM Automation value which indicates missing argument.

Other ADOxtra wrapper as an argument is converted to the corresponding wrapped automation object reference. So you can safely use ADOxtra wrappers with corresponding object where other object expect it.

ADOxtra can handle large binary data contained in BinaryXtra wrapper. If such wrapper is passed as an argument, its data is converted to the SafeArray of unsigned chars. For more information about BinaryXtra see its documentation.

Mapping ADO types to Lingo types

This conversion is taking place when ADOxtra wrapper returns any value returned by the wrapped ADO object. This includes getting property values of the wrapped ADO object.
The table below describes ADO types that are recognized by ADOxtra wrapper and into which Lingo types they are converted.

Automation type Lingo type Value (if any)
EMPTY VOID VOID
NULL Symbol #Null
Integer (signed/unsigned), 1,2,4 bytes Integer  
Float 4,8 bytes Float  
Numeric Float  
Date Float  
String String  
Boolean Integer 1 or 0
Currency Float  
GUID String  
ADO object reference ADOxtra wrapper  
SafeArray of Bytes (BLOB, OLE, Image) BinaryXtra wrapper  


Empty COM Automation values are converted to the VOID Lingo values.

Null value, which is often used in databases and in VB to mark empty references to objects, is converted to Lingo symbol #Null.

Any integer values are converted to 4 byte signed Integer value native to Director.

Any float or numeric or currency values are converted to 8-byte float value native to Director.

Boolean value in COM Automation usually represented as -1 for true and 0 for false. It is converted to integer values 1 and 0 accordingly.

GUID values are converted in string representation and then are converted into Lingo string values.

Date values are converted to the corresponding float values. Advanced date/time conversion routines will be available soon. ADOxtra provides a couple of routines for conversion float date representation into "human readable" form and vice versa: DateTimeListToFloat and FloatToDateTimeList

SafeArrays of Bytes (BLOB, OLE or Image database fields) are converted to the BinaryXtra wrappers containing those binary data. This conversion works if BinaryXtra is detected, otherwise 'Cannot convert ADO value to Lingo value' error is reported. BinaryXtra is free. It is available in Downloads section. For more information about BinaryXtra see its documentation.

Site homeSearchContact author © Eugene Shoustrov. www.xtramania.com