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

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


Keyed Value Lists

InsertKeyedValue

Syntax

InsertKeyedValue <keyedlistvar> <key> <value>

Description

This function deleted the specified association from the a keyed value list.

Parameters

<keyedlist>

A variable containing the list to be accessed.

<key>

The key that is to be inserted.

<value>

The value to be associated with the key.

Remarks

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. Values associated with keys in a keyed value list are retrieved using FindKeyedValue.

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 "Key169: " & FindKeyedValue h "key169"
Log "Key270: " & FindKeyedValue h "key270"
Log "Key1671: " & FindKeyedValue h "key1671"

DeleteKeyedValue h "key69"

The example script fragment stores 2000 associations in a table sized for 3000 entries, retrieves three values and then deletes one of the stored values.



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

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