Terrasoft CRM 3.0 SDK > Examples > Files > IStringsListExample.js
ContentsIndex
IStringsListExample.js

 

Description

 

Body Source
//-----------------------------------------------------------------------------
// IStringsListExample.js file
//-----------------------------------------------------------------------------
// There is described the usage of the IStringsList object in the example. 
//-----------------------------------------------------------------------------
//@ Start Example

// Message displaying function 
function ShowMessage(Str) {
    for (var i = 1; i < arguments.length; i++ ) {
        Str = Str.replace(new RegExp('%' + i), arguments[i]);
    }
    WScript.Echo(Str);
}

// The StringsList text storage creation
var StringsList = new ActiveXObject('TSObjectLibrary.StringsList');

// Creating a variable for displaying the data in the message
var MessageString;

// Enabling the sorting mode
StringsList.IsSorted = true;

// Disabling the uniqueness mode for the string in the text
StringsList.IsUnique = false;

// Enabling case-sensitiveness of the string
StringsList.IsCaseSensitive = true;

// Adding the three strings to the storage (with the enabled sorting mode)
// String can be randomly added
StringsList.Add('aaaaaa');
StringsList.Add('AAAAAA');
StringsList.Add('AaAaAa');

// Displaying the storage content
// Strings storing order does not match the strings adding order 
MessageString = StringsList.Text;
ShowMessage(MessageString);

// Disabling the sorting mode
StringsList.IsSorted = false; 

// Adding strings to the storage (with the disabled sorting mode)
// Storing order matches the strings adding order 
StringsList.Add('1');
StringsList.Add('3');
StringsList.Add('2');

// Displaying the storage content
// Strings storing order matches the strings adding order
MessageString = StringsList.Text;
ShowMessage(MessageString);

// Adding the string using the item collection Items 	
StringsList.Items(3) = "String";

// The first and second string values replacement
StringsList.Exchange(0, 1);

// Adding a string by the Insert method 
StringsList.Insert(4, "The string that has been added by the Insert method");

// Displaying the storage content
MessageString = StringsList.Text;
ShowMessage(MessageString);

// The storage sorting
StringsList.IsSorted = true;

// Displaying the storage content
MessageString = StringsList.Text;
ShowMessage(MessageString);

// Enabling the uniqueness mode for the string in the text 
StringsList.IsUnique = true;

// Disabling the case-sensitiveness
StringsList.IsCaseSensitive = false;

// Displaying the storage content
MessageString = StringsList.Text;
ShowMessage(MessageString);

// The storage cleaning
StringsList.Clear();

// Adding the text by the CommaText property 
// (See the example of the text transformation by the property CommaText)
StringsList.CommaText="'Stri,ng 1', 'String 2' , String 3,String4";

// Displaying the storage content
MessageString = StringsList.Text;
ShowMessage(MessageString);

//@ End Example
Copyright (с) Terrasoft 2002-2007.