Halcon算子翻译——assign_at
名称
assign_at - 将一个或多个值分配给一个或多个元组(tuple)元素。
用法
assign_at( : : Index, Value : Result)
描述
assign_at为元组中的一个或多个元素赋值单个值,或者将元素赋值给输出元组的指定元素。 输出元组的所有其他元素保持其值。 如果传递的索引超出了输出元组的当前范围,则元组将增加,新值将被初始化为默认值。
在全文编辑器中,assign_at操作只需在赋值运算符:=和输出变量之后的索引访问运算符[]的帮助下输入即可。 Index可以是任何表达式,其计算结果为任意数量的正整数值。 Value参数必须求值为恰好一个值或通过Index参数提供的相同数量的索引,例如:Areas [Radius-1]:=Area,Area [0,4,|Rad| -1]:= 0,FileNames [0,2,4]:= ['f1','f2','f3']。
算子assign_at是替换并扩展旧insert算子的修改版本。
assign_at assigns a single value to one or several elements of a tuple, or it assigns a number of values elementwise to the specified elements of the output tuple. All other elements of the output tuple keep their values. If the passed indices are out of the current range of the output tuple, the tuple is increased and the new values are initialized to a default value.
In the full text editor an assign_at operation is simply entered with the help of the assignment operator symbol := and the index access operator symbol [ ] following the output variable. The Index parameter can be any expression that evaluates to any number of positive integer values. The Value parameter must evaluate to exactly one value or to the same number of indices that are provided via the Index parameter, e.g.: Areas[Radius-1] := Area Areas[0,4,|Rad|-1] := 0 FileNames[0,2,4] := ['f1','f2','f3']
The operator assign_at replaces and extends the modifying version of the old insert operator.
参数
Index (input_control) integer(-array) → (integer)
要赋新值的元素的索引
默认值:0
推荐值:0, 1, 2, 3, 4, 5, 6
最小增量:1
Value (input_control) tuple(-array) → (integer / real / string)
分配的值
默认值:1
Result (output_control) tuple(-array) → (real / integer / string)
结果元组
结果
如果表达式正确assign_at返回2(H_MSG_TRUE)。 否则会引发异常并返回错误代码。
备选方案
assign, tuple_replace
模块
Foundation