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!
Logo. www.xtramaina.com  
Home Search E-mail
ActiveCompanion Usage/Wrappers/Binary

ActiveCompanionSet xtras for Macromedia Director

Binary Data Wrapper

Binary data wrapper is provided by VbScriptXtra for handling binary data. It is a kind of array of bytes that could be handled by Lingo. Binary wrapper is created automatically by typecasting routines when BLOB value is detected. If the object is set to handle Unicode as Binary then Binary wrapper is created to represent the Unicode text string in Lingo.

Binary data wrapper is free. You may download ActiveCompanionSet and use the Binary wrapper. Read the License agreement for more details.

To explicitly create this wrapper use xtra-level CreateWrapper method:

binaryWrapper = xtra("VbScriptXtra").CreateWrapper( #Binary )
unicodeWrapper = xtra("VbScriptXtra").CreateWrapper( #UnicodeString )

Newly created binary wrapper is initialized as an empty array.

Use Interface() method to get the short description of methods and properties provided by this object.
put binaryWrapper.Interface()

Use ContentsType property to define what is contained in the object: binary data or Unicode string. See more details about handling Unicode text in Director here.

Use Allocate( nSize ) or Resize( nSize ) methods to set the wrapped data to the requested amount of bytes. Clear() method releases all allocated memory. Use Count or Size properties or methods to get the allocated size of the wrapped data.

Binary wrapper supports list-like element access via GetAt( nIndex ) and SetAt( nIndex, nValue ) methods. They are implicitly called by using square brackets objBinary[ nIndex ].

To initialize the binary data from a file use ReadFromFile(...) method. It allows reading either whole file or the portion of it.

WriteToFile(...) and AppendToFile(...) methods allow creating or modifying existing files with the contents of the binary wrapper.

Use UnsignedByte[ nIndex ] or SignedByte[ nIndex ] operators to get the numeric value of the specified element of the wrapped data either as unsigned or as signed value.

Use Byte[ nStartIndex .. nEndIndex ] to get the new binary wrapper object initialized with the specified portion of wrapped data.

Use String property to use wrapped data as a String. If the ContentsType of the object is set to #UnicodeString then MBCS to Unicode conversion occurs between Lingo string and wrapped data. Using together with CodePage property allows easy conversion between Unicode and MBCS encoded for the specific code page or other encodings like UTF8.

HexString allows working with wrapper contents as with hex encoded data.

Picture and Media properties allow working with cast members media to store them in a file or in a database.

Use MakeImageFromRGB(...) and GetRGBFromImage(...) to operate directly on raw image data and create Lingo Image objects from it.

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