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

 

Description

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

// Creating the INamedValues object
var NamedValues = new ActiveXObject('TSObjectLibrary.NamedValues');

// 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);
}

// Function of the set of named values formation 
function SetSomeValues(NamedValues) {

	// The set of values cleaning
	NamedValues.Clear();

	// Adding the 'Stringlist' item to the set and 
	// StringsList value
	var StringsList = new ActiveXObject('TSObjectLibrary.StringsList')
	StringsList.Add("The first string of the StringsList object");
	StringsList.Add("The second string of the StringsList object");
	NamedValues.Values('Stringslist') = StringsList;

	// Adding the simple type values to the set
	NamedValues.Values('Integer')  = 123;
	NamedValues.Values('String') = "String in the dataset";

	// Adding the included INamedValues object with the simple type values  
	SecondaryNamedValues = new ActiveXObject('TSObjectLibrary.NamedValues');
	SecondaryNamedValues.Values('Value1') = 1;
	SecondaryNamedValues.Values('Value2') = "Value";
	NamedValues.Values('NamedValues') = SecondaryNamedValues;

}

// Set of the named values displaying function
function GetSomeValues(NamedValues) {
	
	// Displaying the item value with the name 'StringsList'
	// The value existence check on the value's name is case sensitive
	if (NamedValues.IsValueExists('stringsList')) {
		ShowMessage(NamedValues.Values('stringsList').Text);
	}
	
	// Displaying the item value with the name 'Integer' 
	// and removing from the dataset
	if (NamedValues.IsValueExists('Integer')) {
		ShowMessage(NamedValues.Values('Integer'));
		NamedValues.Delete('Integer');
	}
	
	// Displaying the value of the 'String' item
	ShowMessage(NamedValues.Values('String'));
	
	// Displaying the null item value of the 'Value' set
	ShowMessage(NamedValues.Values('Value'));
	
}

// The set of named values formation
SetSomeValues(NamedValues);

// Displaying the dataset values 
GetSomeValues(NamedValues);

//@ End Example

Copyright (с) Terrasoft 2002-2007.