CkStringArray ActiveX Reference

CkStringArray

* This is a freeware class/component/library.

Component for managing and manipulating collections of strings.

Object Creation

(Visual Basic 6.0)
Dim obj As New CkStringArray
(ASP)
set obj = Server.CreateObject("Chilkat.StringArray")
(VBScript)
set obj = CreateObject("Chilkat.StringArray")
(Delphi)
obj := TCkStringArray.Create(Self);
(FoxPro)
loObject = CreateObject('Chilkat.StringArray')
(SQL Server)
EXEC @hr = sp_OACreate 'Chilkat.StringArray', @obj OUT
(Javascript)
var obj = new ActiveXObject("Chilkat.StringArray");

Properties

Count As Long (read-only)

The number of strings in the array.

Crlf As Long

If 1, strings are always automatically converted to use CRLF line endings. If 0, strings are automatically converted to use bare LF line endings.

Trim As Long

If 1, whitespace, including carriage-returns and linefeeds, are automatically removed from the beginning and end of a string when added to the array.

Unique As Long

If 1, the array does not allow duplicates. When an attempt is made to insert a string that already exists in the array, the insertion simply doesn't happen and no error is returned.

Methods

Append(str As String)

Appends a string to the end of the array.

AppendSerialized(encodedStr As String)

Appends multiple strings to the end of the array. The encodedStrings argument is what is returned from the Serialize method (see below).

Clear()

Remove all strings from the array.

Contains(str As String) As Long

Returns 1 if the string is present in the array. The string comparisons are case sensitive.

Find(str As String, beginIndex As Long) As Long

Finds the index of the first string equal to the string passed. The search begins at beginIndex. If the string is not found, -1 is returned. The first string in the array is at index 0.

FindFirstMatch(str As String, beginIndex As Long) As Long

To be documented soon...

GetString(index As Long) As String

Returns the string at a location in the array. The first string is at index 0.

Returns a null on failure

InsertAt(index As Long, str As String)

Insert a string into the array at a particular index. Using index 0 will insert at the beginning.

Intersect(array As CkStringArray)

The caller will contain the intersection of both string arrays. (In other words, all strings that are present in both the calling object and the argument object.)

LastString() As String

Returns the last string in the array.

Returns a null on failure

LoadFromFile(filename As String) As Long

Adds strings from a file (one per line) into the string array.

Returns 1 for success, 0 for failure.

LoadFromText(txt As String)

Adds strings from an in-memory string (one per line) into the string array.

Pop() As String

Returns the last string and removes it from the array.

Returns a null on failure

Prepend(str As String)

Adds a string to the beginning of the array.

Remove(str As String)

Removes all strings equal to the string argument from the array.

RemoveAt(index As Long)

Removes the string at a particular index.

SaveNthToFile(index As Long, filename As String) As Long

Saves the Nth string in the StringArray object to a file.

Returns 1 for success, 0 for failure.

SaveToFile(filename As String) As Long

Saves the array of strings to a file, one string per line.

Returns 1 for success, 0 for failure.

SaveToText() As String

Saves the array of strings to a single string, one string per line (separated by CRLF line endings).

Serialize() As String

Returns an string which is an encoded representation of all the strings in the array. The StringArray can be re-created by calling the AppendSerialized method. One reason this method exists is to make it easy to pass entire string arrays as a form parameter in a Web page.

Returns a null on failure

Sort(ascending As Long)

Sorts the string array in ascending or descending order.

SplitAndAppend(str As String, boundary As String)

Splits a string at a character or substring boundary and adds each resulting string to the StringArray object.

Subtract(array As CkStringArray)

Subtracts the strings in the argument object from the calling object's set.

Union(array As CkStringArray)

Performs the union set-operator. The caller will contain the union of two string arrays.