Class wwNameValueCollection

A special collection that allows key and value pairs to be stored and retrieved by the key name or index.

This class manages the Collection in a two dimensional array aItems which contains key and value in the first and second columns respectively.

loCol = CREATEOBJECT("wwNameValueCollection")
loCol.Add("Item1","This is Item1")
loCol.Add("Item2","This is Item2")

? loCol.Count              && 2
? loCol.Item("Item2")      && This is Item2
? loCol.Item("Item1")      && This is Item1

? loCol.aItems["Item2",2]      && This is Item1
? loCol.aItems["Item1",2]      && This is Item2


? loCol.Item("ItemBOGUS")  && .NULL.

? loCol.GetIndex("Item2")  && 2
? loCol.GetKey(2)          && Item2

loCol.Remove("Item1")
? loCol.Count              && 1
Custom
  wwCollection

Class Members

MemberDescription

Add

Adds an item to the collection. The value can be added either just by adding the value, or by adding a key and value combination.

o.Add(Key,Value)

Clear

Clears the collection of all items.

o.Clear()

FastAdd

Similar to the Add method this method allows adding an item to the collection. Unlike Add() though this method will not check if a key of the same name exists and simply add it. This means it's possible to insert duplicate keys.

o.FastAdd(Key,Value)

Get

Retrieves an item from the collection and returns the item as an Key and Value pair object that has Key and Value properties.

o.Get(lvKey)

GetIndex

Retrieves an index value from a key.

o.GetIndex(Key)

GetKey

Returns the key for a specified index into the collection.

o.GetKey(Index)

InsertAt

Inserts an item at the specified index position. Items are inserted before the item specified.

o.InsertAt(Position,Key,Value)

Item

Returns an item's value out of the collection either by index or by string key.

o.Item(Key)

Remove

Removes an item out of the collection by index or key.

o.Remove(Key)

ToAttributeString

Creates an Attribute string of key value pairs like that can be used for HTML elements.

o.ToAttributeString(lcSeparator)

UpdateItem

Updates an item in the collection with a new value.

o.UpdateItem(lvKey, lvValue)

aItems[]

The internally maintained two-dimensional array of items added. This array is two dimensional and contains the Key in the first column and the Value in the second.

Count

The count of items in this collection.


© West Wind Technologies, 2024 • Updated: 12/17/18
Comment or report problem with topic