ZmeY soft ActiveX objects installation

  1. Create a new folder or choose an existing folder (e.g., the one that already contains ZmeY soft ActiveX components).
  2. Copy all *.dll and/or *.ocx files to the selected folder.
  3. For each *.dll or *.ocx file from the command prompt execute
    regsvr32 <full path of the file>
    You shoud get a message box stating that "DllRegisterServer in <full path of the file> succeeded."

To uninstall selected ActiveX objects:

  1. For each *.dll or *.ocx file you want to uninstall from the command prompt execute
    regsvr32 /u <full path of the file>
    You shoud get a message box stating that "DllUnregisterServer in <full path of the file> succeeded."
  2. Delete all .dll and/or .ocx files that have been successfully unregistered.
  3. If there are no files left in the folder, you may delete the folder.


ZmeY soft utility ActiveX objects

This is a collection of three ActiveX objects for managing data types not natively supported by JScript/VBScript.

Array Object
Allows manipulation of existing and creation of new arrays of any automation-compatible type. VBScript can handle only arrays of variants and JScript is limited to read-only access to arrays of variants.
The array can be sorted using a default or user-defined sort function.

BinaryData Object
Allows manipulation of existing and creation of new arrays of bytes from JScript/VBScript. Can read binary files.
Record Object
Allows JScript/VBScript to communicate with ActiveX objects which have properties and/or methods that accept or return user-defined types.

A note for ASP programmers: All objects are thread-safe and are marked with ThreadingModel = "Both". However due to the nature of the Array and Record objects, which may hold references to other ActiveX objects, creation of instances of these objects with application scope will result in slower access from scripts and objects with page or session scope (IIS 4).


ZmeYsoft.Util.Array Object

Allows manipulation of existing and creation of new arrays of any automation-compatible type. VBScript can handle only arrays of variants and JScript is limited to read-only access to arrays of variants (we are talking about the VBArray object, the Array object in JScript does not correspond to an Automation-compatible data type). Using a specific data type instead of a variant can dramatically reduce memory requirements for large arrays. For example, each element of an array of type vbInteger takes 8 times less memory than an element of a variant array.

The array can be sorted using a default or user-defined sort function.

Note: If you need to manipulate one-dimensional arrays of bytes, such as the ones required by the BinaryWrite method of the ASP Response object, you should consider using the BinaryData object, which offers better performance and simpler syntax.

Method or Property | Type | Description
Property | Element(lngIndex1 [, lngIndex2 [,...]]) | Variant | An individual array element. The number of indices must be equal to the number of Dimensions. This is the default property of the Array object.
Read-only property | Dimensions | Integer | The number of array dimensions.
Property | LBound([intDimension = 1]) | Long | The smallest available subscript for the indicated dimension. Changing the value of this property will also change the value of UBound(intDimension) to preserve the number of elements in the dimension. To change the number of elements in the last dimension use the ReDim method.
Read-only property | UBound([intDimension = 1]) | Long | The largest available subscript for the indicated dimension.
Property | Value | Variant | The whole array as a variant.
Read-only property | VariantArray | Variant | The whole array as an array of variants. The value of this property is compatible with the native JScript/VBScript array support.
Read-only property | VarType | Integer | A value indicating the type of the array elements. Possible values are the same as returned by the VarType function in VB/VBScript.
Method Dim intVarType, lngUBound1 [, lngUBound2 [,...]] - Creates a new array of the specified type (use the VarType constants), which replaces the current Value of the object. Only the upper bound can be specified for each dimension. The lower bounds are initially 0 and may be modified by assigning to the LBound property.
Method ReDim lngUBoundOfLastDimension - Changes the number of elements in the last dimension. Elements which exist in both the old and the new array are preserved. To change the number of elements in any dimension without preserving the old data, use the Dim method.
Method Clear - Sets all elements of the array to their default values: 0 for numbers, empty for strings, etc.
Method Empty - Destroys the array currently associated with the object.
Method Reverse - Reverses the elements of the array. Multi-dimensional arrays are treated as one-dimensional with the first index being least significant and the last index being most significant.
Method Sort [intOrder = 1 [, funSortFunction]] -

Sorts the elements of the array. Treats multi-dimensional arrays in the same way as the Reverse method.

The value of intOrder has the following meaning:

  • > 0 - sort in ascending order
  • < 0 - sort in descending order
  • ±1 - case-insensitive
  • ±2 - case-sensitive
  • ±3 - case-insensitive, use an alternative sorting algorithm
  • ±4 - case-sensitive, use an alternative sorting algorithm

The case-insensitive/case-sensitive constants have no effect if a user-defined sort function is used.

The alternative sorting algorithm preserves the order of the elements which are considered equal by the sort function at the expense of creating a temporary copy of the array.

The user-defined sort function funSortFunction must take two arguments and return:

  • a negative value if the first argument is less than the second argument
  • zero if the two arguments are equal
  • a positive value if the first argument is greater than the second argument

If funSortFunction is not specified, a default sort function is used.

Sample code

...
Option Explicit

' Output the text
Sub print(strText)
    ' Uncomment the next line for .vbs files
    ' WScript.Echo strText
    ' Uncomment the next line for .asp files
    ' Response.Write strText & "<BR>"
End Sub

' Returns -1 if a is even and b is odd (a < b),
' +1 if a is odd and b is even (a > b),
' and 0 otherwise (a = b)
Function ByEvenOdd(a, b)
    ByEvenOdd = (a Mod 2 = 0) - (b Mod 2 = 0)
End Function

Dim objArr
Set objArr = CreateObject("ZmeYsoft.Util.Array")

' Create a 4 x 5 array of integers
objArr.Dim vbInteger, 3, 4
objArr.LBound(2) = -2

Dim i, j

' Initialize array elements
For j = objArr.LBound(2) To objArr.UBound(2)
    For i = objArr.LBound(1) To objArr.UBound(1)
        objArr(i, j) = i * 7 - j * 5
        print "objArr(" & i & ", " & j & ") = " & objArr(i, j)
    Next
Next

' Sort the array using a user-defined sort function
' and an algorithm that preserves the order of "equal" elements
print "Sorting..."
objArr.Sort +3, GetRef("ByEvenOdd")

' Display the sorted array
For j = objArr.LBound(2) To objArr.UBound(2)
    For i = objArr.LBound(1) To objArr.UBound(1)
        print "objArr(" & i & ", " & j & ") = " & objArr(i, j)
    Next
Next
...


ZmeYsoft.Util.BinaryData Object

Allows manipulation of existing and creation of new arrays of bytes. This data type is required, for example, by the BinaryWrite method of the ASP Response object. Can read binary files.

Method or Property |  | Type | Description
Property | Byte(lngIndex) | Byte | An individual byte, lngIndex must be between 0 and Size - 1. This is the default property of the BinaryData object.
Property | Size | Long | The size of the data, in bytes. Assigning a smaller/bigger value to this property will truncate/zero pad the data.
Property | Value | Byte() | The data as an one-dimensional array of bytes.
Method | Clear | - | Sets all bytes to 0.
Method | Empty | - | Destroys the data currently associated with the object. This is the same as setting the Size to 0.
Method | ReadFromFile strFileName [, lngStart = 0 [, lngEnd = -1]] | - | Reads an entire file, or a portion of it. The data read replaces the current contents of the object. Negative values for lngStart and/or lngEnd indicate offset(s) relative to the end of file, -1 is the last byte of the file.
Method | WriteToResponse | - | Writes the data to the ASP Response object. Using this method is slightly faster than Response.BinaryWrite(object.Value). This mehtod will fail unless the object have been created with page scope.

Sample code
ASP / VBScript fragment

...
Option Explicit

Dim objBin
Set objBin = Server.CreateObject("ZmeYsoft.Util.BinaryData")

' Read binary data from file
objBin.ReadFromFile Server.MapPath("/img/template.gif")

' Modify the color of the 8th palette entry with the values
' specified in the query sting. Note: byte offsets may differ
' depending on the software used to produce the image file.
' In a real-world code some error-checking must be added.
objBin(37) = CByte(Request.QueryString("red"))
objBin(38) = CByte(Request.QueryString("green"))
objBin(39) = CByte(Request.QueryString("blue"))

' Send the image to the client
Response.ContentType = "image/gif"
Response.BinaryWrite(objBin.Value) ' or objBin.WriteToResponse
...


ZmeYsoft.Util.Record Object

Contrary to what you may have believed, ActiveX objects are not limited to exchanging only simple data types, references to other ActiveX objects, and arrays. It is possible to create ActiveX objects with properties and methods that accept and/or return records, also known as user-defined data types in Visual Basic (see part 1 of the sample code) and structures in C/C++. Unfortunately, JScript and VBScript have no native support for such data types.

Using ActiveX objects that utilize user-defined data types can increase performance and reduce network load in distributed environments. Consider an object that runs on a remote server and a script on the local server that must read four related fields from this object. If each of the fields is exposed as a separate property, four expensive remote calls will be required to get the values of the four fields. On the other hand, if the object exposes a single property, which returns a record containing all four fields, a single remote call and five fast in-process calls will be required to obtain the same information.

Method or Property |  | Type | Description
Property | Field(strFieldName) | Variant | An individual field. This is the default property of the Record object.
Read-only property | Size | Long | The size of the record, in bytes.
Read-only property | TypeName | String | The name of the user-defined type, as specified in the type declaration.
Read-only property | TypeUuid | String | The UUID (universally unique identifier) of the user-defined type, as specified in the type declaration or generated by the development tool.
Property | Value | Variant | The record as a variant of user-defined type.
Method | As strTypeNameOrUuid, objObject | - | Associates the object with a new record of the specified user-defined type. The second argument must be a reference to an ActiveX object that accepts and/or returns values of this type. Or, to get a little more technical, the type library associated with the objObject must contain a definition of a record named "strTypeNameOrUuid". Alternatively, as the name suggests, strTypeNameOrUuid may specify the UUID of the type enclosed in braces. If the words "type library" make you feel nervous, please ignore the last two sentences.
Method | Clear | - | Sets all fields to their default values: 0 for numbers, empty for strings, etc.
Method | Empty | - | Destroys the record currently associated with the object.

Sample code

Part 1 - ActiveX component written in Visual Basic

' Class module Test in project VBActiveX
Option Explicit

Public Type Record1
    x As Integer
    y As Integer
End Type

Public Type Record2
    FirstName As String
    LastName As String
End Type

Public Property Get Location() As Record1
    Location.x = 10
    Location.y = -5
End Property

Public Function Format(rec As Record2) As String
    Format = rec.LastName & ", " & rec.FirstName
End Function
...

Part 2 - VBScript

Option Explicit

' Output the text
Sub print(strText)
    ' Uncomment the next line for .vbs files
    ' WScript.Echo strText
    ' Uncomment the next line for .asp files
    ' Response.Write strText & "<BR>"
End Sub

Dim objTest
Set objTest = CreateObject("VBActiveX.Test")

Dim objRec
Set objRec = CreateObject("ZmeYsoft.Util.Record")

' First we demonstrate how to access data in an existing record
objRec.Value = objTest.Location
print "TypeName = " & objRec.TypeName ' TypeName = Record1
print "Size = " & objRec.Size         ' Size = 4
print ".x = "  & objRec.Field("x")    ' .x = 10
' Or using a shorthand syntax
print ".y = "  & objRec("y")          ' .y = -5

' Now let's create and initialize a record of a different type
objRec.As "Record2", objTest
objRec("FirstName") = "John"
objRec("LastName") = "Doe"
print objTest.Format(objRec.Value) ' Doe, John
...