set_dict_tuple — 将键/元组对添加到字典中。
set_dict_tuple( : : DictHandle, Key, Tuple : )
set_dict_tuple stores a tuple associated with a key in the
dictionary.
The dictionary is denoted by the DictHandle parameter.
Tuple including strings is copied by the operation, and can
thus be immediately reused.
An empty tuple is considered as a valid value that can be associated with
the key.
If any data (tuple or object) was already associated with given key
(Key), the old data is destroyed by set_dict_tuple
and replaced by Tuple。
The Key has to be a string or an integer.
Strings are treated case sensitive.
The tuple data for the given key can be retrieved again from the dictionary
using get_dict_tuple。
set_dict_tuple allows setting the values of multiple keys with a
single call.
In this case, the length of Tuple must either be equal to the
number of keys or 1.
In the first case, Tuple is split into
segments of length 1, one for each key.
In the second case, if Tuple has length 1, that one
value is associated with each key.
If no keys are passed, the values in Tuple are ignored.
The following table summarizes the possible combinations of
number of keys and values, where N is an arbitrary
non-negative integer:
Length of Key |
Length of Tuple |
Effect |
|---|---|---|
| N | 1 | Value in Tuple is associated with all keys |
| 1 | N | Associate Tuple with Key |
| N | N | Associate tuples of length 1 with each passed key |
If the tuple contains any handles only the handle values are copied by the operation, not the resources behind those handles (no deep copy is created).
此算子修改后续输入参数的状态:
在执行此算子时,若该参数值需在多个线程间使用,则必须对其访问进行同步。
DictHandle (输入控制,状态被修改) dict → (handle)
Dictionary handle.
元素数量: DictHandle == 1
Key (输入控制) string(-array) → (string / integer)
Key string.
Tuple (输入控制) tuple-array → (string / integer / real / handle)
Tuple value to be associated with the key.
create_dict (Dict) set_dict_tuple (Dict, 'simple_integer', 27) set_dict_tuple (Dict, 'simple_string', 'Hello world') set_dict_tuple (Dict, 'mixed_tuple', ['The answer', 42]) set_dict_tuple (Dict, 0, 'This is zero')
If the operation succeeds, set_dict_tuple 返回 2 ( H_MSG_TRUE )。否则将抛出异常。 Possible error conditions include
invalid parameters (handle or key) or resource allocation error.
set_dict_tuple,
set_dict_object
set_dict_object,
set_dict_tuple_at
create_dict,
set_dict_tuple_at,
get_dict_tuple,
set_dict_object,
get_dict_object,
get_dict_param,
remove_dict_key
基础