PhantomScript v1.7 Reference - Copyright © 2006 P1 Systems Incorporated. All Rights Reserved.

Prev | Next | Users Guide | PhantomScript Reference | P1 Systems


Keyed Value Lists

KeyList

Syntax

KeyList <keyedlistvar>

Description

This function returns the list of keys present in a keyed value list

Parameters

<keyedlist>

A variable containing the list to be accessed.

Remarks

The list of keys is returned in unsorted order.

Keyed value lists are created by executing the InsertKeyedValue statement to store keys and associated values into a specified variable. Keyed value lists use a hashing algorithm to provide very rapid access to the keyed values when the key is provided.

Keyed value lists perform best when the hash table size is equal to or greater than the number of associations that are stored in the keyed value list. The intrinsic variable KeyedValueHashTableSize determines the size of the hash table used. The default value is 1000 but this may be overridden by assigning a new value to KeyedValueHashTableSize before creating the keyed value list.

Keyed values may be strings, variables, or composite variables. Keyed value lists may passed to procedures and may also be stored in files using SaveFile and read back from such files with the LoadFile statement.

Example

          Local h 

KeyedValueHashTableSize = 3000

For i = 1 To 2000 Loop
InsertKeyedValue h "key" & i "value" & i
EndLoop

Log ItemCount KeyList h

The example script fragment stores 2000 associations in a table sized for 3000 entries, retrieves the list of keys and displays the count of keys (which is 2000).



Prev | Next | Users Guide | PhantomScript Reference | P1 Systems

PhantomScript v1.7 Reference - Copyright © 2006 P1 Systems Incorporated. All Rights Reserved.